Does every Android phone support SHA-256

All Android devices support SHA-256. The NoSuchAlgorithmException indicates that a requested algorithm could not be found and is necessary because the method takes a String argument for the algorithm name. If you passed in “foo-256”, the method’s only recourse is to throw a NoSuchAlgorithmException because, for reasons beyond my understanding, there’s no algorithm called “foo-256”. … Read more

Base64 Encoding safe for filenames?

Modified Base64 (when /,= and + are replaced) is safe to create names but does not guarantee reverse transformation due to case insensitivity of many file systems and urls. Base64 is case sensitive, so it will not guarantee 1-to-1 mapping in cases of case insensitive file systems (all Windows files systems, ignoring POSIX subsystem cases). … Read more

How can I filter an array of hashes to get only the keys in another array?

This should do what you want: events.map do |hash| hash.select do |key, value| [:id, :start].include? key end end Potentially faster (but somewhat less pretty) solution: events.map do |hash| { id: hash[:id], start: hash[:start] } end If you need return_keys to be dynamic: return_keys = [:id, :start] events.map do |hash| {}.tap do |new_hash| return_keys.each do |key| … Read more

Is there a java hash structure with keys only and no values?

You need Java’s HashSet (Java 8). The description from the official documentation is: This class implements the Set interface, backed by a hash table (actually a HashMap instance). It makes no guarantees as to the iteration order of the set; in particular, it does not guarantee that the order will remain constant over time. This … Read more

Ruby .reject! vs .delete_if

reject – create a new array without elements that match and return the new array delete_if – delete elements that match from current array and return the array reject! – delete elements that match from current array. Return the array if something was rejected, or nil when none.

Converting nested hash keys from CamelCase to snake_case in Ruby

If you use Rails: Example with hash: camelCase to snake_case: hash = { camelCase: ‘value1’, changeMe: ‘value2’ } hash.transform_keys { |key| key.to_s.underscore } # => { “camel_case” => “value1”, “change_me” => “value2” } source: http://apidock.com/rails/v4.0.2/Hash/transform_keys For nested attributes use deep_transform_keys instead of transform_keys, example: hash = { camelCase: ‘value1’, changeMe: { hereToo: { andMe: ‘thanks’ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)