Skip to content

Instantly share code, notes, and snippets.

View fabiode's full-sized avatar
🏠
sono a casa mia.

Fabio Daguer Esposito fabiode

🏠
sono a casa mia.
  • Italy
View GitHub Profile
@viglioni
viglioni / string-bin.hs
Last active July 2, 2022 21:54
Encode/Decode strings into strings of binaries
--
-- Encodes/Decodes string in a string of binaries
--
-- Each char is converted to a string with eight 0s or 1s
-- λ> encode "The darkside of the force is a pathway to many abilities some consider to be unnatural"
-- "0101010001101000011001010010000001100100011000010111001001101011011100110110100101100100011001010
-- 01000000110111101100110001000000111010001101000011001010010000001100110011011110111001001100011011
-- 00101001000000110100101110011001000000110000100100000011100000110000101110100011010000111011101100
@rubenmoya
rubenmoya / middleware.rb
Created April 22, 2019 14:41
Rails middleware to convert request params and response data from camelCase to snake_case
module CaseConverter
class Transformations
class << self
def transform(value)
case value
when Array then value.map { |item| transform(item) }
when Hash then value.deep_transform_keys! { |key| transform(key) }
when String then camelize(value)
else value
end