Skip to content

Instantly share code, notes, and snippets.

View adamcaron's full-sized avatar

Adam Caron adamcaron

View GitHub Profile
...
##
# Until this commit is merged and released by rack
#
gem 'rack', git: 'https://github.com/rack/rack.git', ref: 'c859bbf7b53cb59df1837612a8c330dfb4147392'
...
require 'cgi'
require 'active_support'
def verify_and_decrypt_session_cookie(cookie, secret_key_base = Rails.application.secret_key_base)
config = Rails.application.config
cookie = CGI::unescape(cookie)
salt = config.action_dispatch.authenticated_encrypted_cookie_salt
encrypted_cookie_cipher = config.action_dispatch.encrypted_cookie_cipher || 'aes-256-gcm'
# serializer = ActiveSupport::MessageEncryptor::NullSerializer # use this line if you don't know your serializer
serializer = ActionDispatch::Cookies::JsonSerializer
const validChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let array = new Uint8Array(40);
window.crypto.getRandomValues(array);
array = array.map(x => validChars.charCodeAt(x % validChars.length));
const randomState = String.fromCharCode.apply(null, array);
console.log(randomState);
#!/usr/bin/env ruby
require 'optparse'
require 'erb'
class GeneratesConfig
attr_accessor :repo_dir, :output_file, :host, :port
def initialize
@host = "localhost"
@fokusferit
fokusferit / enzyme_render_diffs.md
Last active June 18, 2024 11:27
Difference between Shallow, Mount and render of Enzyme

Shallow

Real unit test (isolation, no children render)

Simple shallow

Calls:

  • constructor
  • render
@Thatgirlcancode16
Thatgirlcancode16 / Denali Lord - prework.md
Last active March 23, 2016 17:53 — forked from mbburch/prework.md
An example template for your Turing pre-work Gist

Turing School Prework- Denali Lord

Task A- Practice Typing: Completed. 27 wpm.

  • screenshots of scores will be posted in comments

Task B- Algorithmic Thinking & Logic:

  • screenshots of completed sections will be posted in comments

Task C- Create your Gist:

var person = {
firstName: 'Steve',
lastName: 'Kinney',
updateName: function () {
$.getJson('/api/vi/person', function () {
this.firstName = 'Wes'
}.bind(this));
}
};
@gaearon
gaearon / slim-redux.js
Last active May 5, 2024 15:14
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
@chinshr
chinshr / Jenkinsfile
Last active October 16, 2023 09:25
Best of Jenkinsfile, a collection of useful workflow scripts ready to be copied into your Jenkinsfile on a per use basis.
#!groovy
# Best of Jenkinsfile
# `Jenkinsfile` is a groovy script DSL for defining CI/CD workflows for Jenkins
node {
}
@mdorrance
mdorrance / Bootstrap Basics.md
Last active August 29, 2015 14:26
Intro to Bootstrap

#Bootstrap Basics

Gain an understanding of what Bootstrap is Introduce "Mobile First" design, the grid and components of Bootstrap Workshop: Importing Bootstrap into a Rails Project Workshop: Transferring a wireframe to html and css using Bootstrap

Frameworks