Skip to content

Instantly share code, notes, and snippets.

Avatar

Tadas Tamošauskas tadast

View GitHub Profile
@tadast
tadast / with_active_support.rb
Last active Dec 10, 2018 — forked from mbyczkowski/with_active_support.rb
session cookie decrypter for Rails 5.1
View with_active_support.rb
require 'cgi'
require 'json'
require 'active_support'
def verify_and_decrypt_session_cookie(cookie, secret_key_base = Rails.application.secrets.secret_key_base)
cookie = CGI::unescape(cookie)
salt = 'encrypted cookie'
signed_salt = 'signed encrypted cookie'
key_generator = ActiveSupport::KeyGenerator.new(secret_key_base, iterations: 1000)
secret = key_generator.generate_key(salt)[0, ActiveSupport::MessageEncryptor.key_len]
@tadast
tadast / README.md
Last active Aug 29, 2015 — forked from chrisroos/README.md
Spike into ways of visualising Smart Answers
View README.md

The print_graph method displays the Smart Answer as a tree.

The print_questions_and_possible_next_nodes method displays the questions and their possible next nodes.

The extraction of possible next nodes is horrible in the case where the Smart Answer uses the block syntax of next_node. I'm getting the source of the block and extracting things that look like symbols.

@tadast
tadast / ssl_puma.sh
Last active Aug 13, 2020 — forked from trcarden/gist:3295935
localhost SSL with puma
View ssl_puma.sh
# 1) Create your private key (any password will do, we remove it below)
$ cd ~/.ssh
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@tadast
tadast / syntax_highlighting.py
Created Nov 28, 2012 — forked from JeanMertz/syntax_highlighting.py
Ruby on Rails syntax highlight switcher for Sublime Text 2
View syntax_highlighting.py
# Forked from https://gist.github.com/925008
# Makes it work with Ruby on Rails snippets
# https://github.com/tadast/sublime-rails-snippets#sublime-text-2-rails-snippets
import sublime, sublime_plugin
import os
class DetectFileTypeCommand(sublime_plugin.EventListener):
""" Detects current file type if the file's extension isn't conclusive """
""" Modified for Ruby on Rails and Sublime Text 2 """
You can’t perform that action at this time.