Skip to content

Instantly share code, notes, and snippets.


Jordan Hollinger jhollinger

View GitHub Profile
jhollinger / csp-strict-dynamic.js
Last active Aug 18, 2020
Rewrites index.html to with CSP strict-dynamic enabled
View csp-strict-dynamic.js
* Usage: node csp-strict-dynamic.js dist/
* Replaces all external script tags in index.html with dynamic loaders, calculates their SHA 256 hashes, and adds those
* hashes as allowed script sources + strict dynamic.
* Your index.html should contain a meta tag with a CSP policy, and the script-src section should look like this:
* script-src $csp-strict-dynamic;
jhollinger / Gemfile
Created Apr 9, 2019
DatabaseTasks Green Example
View Gemfile
source ''
gem 'activerecord', '~> 5.2', require: 'active_record'
gem 'sqlite3'
gem 'rake'
View fizzbuzz.rb
def fizzbuzz(input) do |n|
fizz = n % 3 == 0 ? 'Fizz' : nil
buzz = n % 5 == 0 ? 'Buzz' : nil
if fizz or buzz
jhollinger / loc
Created Apr 7, 2016
Lines of Code
View loc
find $@ -type f -print0 | wc -l --files0-from=-
jhollinger / sidekiq_csrf_token_fix.rb
Created Nov 23, 2015
Fix for Sidkiq::Web's lack of CSRF token
View sidekiq_csrf_token_fix.rb
require 'securerandom'
module Sidekiq
class CsrfTokenFix
def initialize(app)
@app = app
def call(env)
request =
# Clone the consolo-release app. It, instead of core, will now hold all our release version info,
# as well as all capistrano tasks.
git clone http://git.consolo.lan/consolo/consolo-release
cd consolo-release
# ONLY use this when deploying to sigma until you hear otherwise
# Deploy core to sigma
bundle exec cap core:sigma deploy
jhollinger / fax.rb
Last active Aug 29, 2015
Fun with Enumerator
View fax.rb
require_relative 'libfax'
puts "Sending fax..."
attempts = mock_fax('555-555-5555', "Here's a fax!")
attempts.each_with_index do |status, i|
case status
when :sent
puts "Fax sent!"
when :busy
jhollinger /
Created Nov 12, 2014
Sample Grape/Swagger Cat API
require './main'
run API::Root
jhollinger / managed_web_socket.js
Last active Apr 6, 2017
ManagedWebSocket - WebSocket wrapper to handle auto reconnecting and event re-binding
View managed_web_socket.js
* ManagedWebSocket is a thin wrapper around WebSocket that handles automatic reconnecting and re-binding.
* If the server/network drops the connection, it will keep trying to reconnect. However, you may call
* "kill" to permanently disconnect on the client side. The native WebSocket object is available as "ws".
* Use "on" to bind to normal WebSocket events (open, message, error, close), and to the following custom events:
* - connecting: Fired when it is attempting to connect or reconnect.
* - drop: Fired when the connection has been dropped by the server or network. (fired before "close")
* - kill: Fired when you call "kill" on the MWS. (fired before "close")
jhollinger / rspec_database_cleaner.rb
Created Dec 21, 2012
Optimal RSpec Database Cleaner config
View rspec_database_cleaner.rb
Capybara.javascript_driver = :webkit # Selenium works, but not as well
RSpec.configure do |config|
config.use_transactional_fixtures = false
# Use transactions by default
config.before :each do
DatabaseCleaner.strategy = :transaction