- Twitter: @matiaskorhonen.fi
- GitHub: matiaskorhonen
- Email: me@matiaskorhonen.fi
- Web: matiaskorhonen.fi
- Blog: randomerrata.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class AuthenticationToken | |
| # Encode a hash | |
| def self.encode(payload, ttl: 14.days.to_i) | |
| keygen = ActiveSupport::KeyGenerator.new(Rails.application.secrets.token_secret) | |
| key = keygen.generate_key(Rails.application.secrets.token_salt, 32) | |
| crypt = ActiveSupport::MessageEncryptor.new(key) | |
| payload[:expires] = ttl.seconds.from_now.to_i | |
| crypt.encrypt_and_sign(JSON.dump(payload.deep_stringify_keys)) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // matches polyfill | |
| this.Element && function(ElementPrototype) { | |
| ElementPrototype.matches = ElementPrototype.matches || | |
| ElementPrototype.matchesSelector || | |
| ElementPrototype.webkitMatchesSelector || | |
| ElementPrototype.msMatchesSelector || | |
| function(selector) { | |
| var node = this, nodes = (node.parentNode || node.document).querySelectorAll(selector), i = -1; | |
| while (nodes[++i] && nodes[i] != node); | |
| return !!nodes[i]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # config/initializers/active_record_uuid_ids.rb | |
| Rails.application.config.generators do |generator| | |
| # Always use UUIDs for primary keys (when generating migrations) | |
| generator.orm :active_record, primary_key_type: :uuid | |
| end |
These are instructions to setup Postgres.app to allow connections over unix sockets. These instructions were written for macOS Sierra (10.12) and Postgres.app 9.6.0
- Run Postgres.app once so that the configuration is initialized in
~/Library/Application Support/Postgres/var-9.6/ - Quit Postgres.app
- Open
~/Library/Application Support/Postgres/var-9.6/postgresql.confin your favorite text editor - Uncomment the line
unix_socket_directories = '/tmp'and change it tounix_socket_directories = '/var/pgsql_socket,/tmp' - Run
sudo mkdir -p /var/pgsql_socket - Run
sudo chmod 770 /var/pgsql_socket - Run
sudo chown root:staff /var/pgsql_socket
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Underscore.js | |
| // http://underscorejs.org | |
| // (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | |
| // Underscore may be freely distributed under the MIT license. | |
| // | |
| // Returns a function, that, as long as it continues to be invoked, will not | |
| // be triggered. The function will be called after it stops being called for | |
| // N milliseconds. If `immediate` is passed, trigger the function on the | |
| // leading edge, instead of the trailing. | |
| function debounce(func, wait, immediate) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require "tumblr_client" | |
| require "time" | |
| require "yaml" | |
| require "fileutils" | |
| require "open-uri" | |
| require "nokogiri" | |
| require "loofah" | |
| require "reverse_markdown" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| wget https://launchpad.net/~canonical-chromium-builds/+archive/ubuntu/stage/+build/8883797/+files/chromium-browser_48.0.2564.82-0ubuntu0.15.04.1.1193_armhf.deb && \ | |
| wget https://launchpad.net/~canonical-chromium-builds/+archive/ubuntu/stage/+build/8883797/+files/chromium-codecs-ffmpeg-extra_48.0.2564.82-0ubuntu0.15.04.1.1193_armhf.deb && \ | |
| sudo dpkg -i chromium-codecs-ffmpeg-extra_48.0.2564.82-0ubuntu0.15.04.1.1193_armhf.deb chromium-browser_48.0.2564.82-0ubuntu0.15.04.1.1193_armhf.deb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require "openssl" | |
| require "time" | |
| begin | |
| require "origami" | |
| rescue LoadError | |
| abort "origami not installed: gem install origami" | |
| end |