Skip to content

Instantly share code, notes, and snippets.

View walski's full-sized avatar

Thorben Starsy walski

View GitHub Profile

Generate keys

# Generate THE key
$ openssl genrsa -out mykey.pem 2048
# Generate the private key for the backend
$ openssl pkcs8 -topk8 -inform PEM -outform PEM -in mykey.pem -out private_key.pem -nocrypt
# Generate the public key for iOS
$ openssl rsa -in mykey.pem -pubout -outform DER -out public_key.der
@walski
walski / config.as-is.rb
Created June 29, 2014 04:33
That would be nice
# what if…
class Config
def initialize(path)
@data = YAML.parse_file(path)
end
protected
def root_path
@root_path ||= @data['app']['root_path']
@walski
walski / full_key_from_rails_i18n_yaml.rb
Created August 31, 2016 10:29
Outputs the full key of the current line in a Rails I18n YAML file and copies it to the clipboard. 🎉
#!/usr/bin/env ruby18 -wKU
def key_part(line)
match = line.match(/^\s*([^:]+)/)
return unless match
match.captures.first
end
def leading_spaces(line)
line.match(/^(\s*)\S?/).captures.first.length
@walski
walski / mapper.rb
Last active July 31, 2017 13:40
Mapping without the curly braces ;)
class MethodChainer < BasicObject
def initialize(obj, deep_chain = false)
@obj = obj
@deep_chain = deep_chain
end
def __
@obj.map { |e| e }
end

[0.72.2]

  • Initial version