Skip to content

Instantly share code, notes, and snippets.

View johnthethird's full-sized avatar

John Lynch johnthethird

View GitHub Profile
#!/usr/bin/env python
# Quick and dirty demonstration of CVE-2014-0160 by
# Jared Stafford (jspenguin@jspenguin.org)
# Modified so that it finds cookies
import sys
import struct
import socket
import time
import select
@johnthethird
johnthethird / ReactRenderer.rb
Created February 2, 2014 19:01
React Server-Side Rendering for Rails
require 'connection_pool'
class ReactRenderer
mattr_accessor :pool
def self.setup!
size = ::Rails.configuration.react.max_renderers || 10
timeout = ::Rails.configuration.react.renderer_timeout || 20 #seconds
@@pool ||= ConnectionPool.new(:size => size, :timeout => timeout) { ReactRenderer.new }
@johnthethird
johnthethird / my_controller.rb
Created April 16, 2013 17:53
Compile an arbitrary string of SCSS code in Rails controller
# widget#custom_css is a string containing CSS or SCSS code
def custom_css
respond_to do |format|
format.css {
# I cant believe there isnt a better way to just compile a sass string. Sheesh.
sprockets_env = Rails.application.assets
opts = sprockets_env.context_class.sass_config
ctx = sprockets_env.context_class.new(sprockets_env, "inmemory", Pathname(sprockets_env.root+"/app/assets/stylesheets"))
opts = opts.merge( :syntax => :scss,
:load_paths => [Rails.root.join("app/assets/stylesheets")],
@johnthethird
johnthethird / Validator.java
Created March 26, 2013 01:16
Validate a SAML XML response using JSR-105 API via xmlsec jar
import javax.xml.crypto.*;
import javax.xml.crypto.dsig.*;
import javax.xml.crypto.dom.*;
import javax.xml.crypto.dsig.dom.DOMValidateContext;
import javax.xml.crypto.dsig.keyinfo.*;
import java.io.FileInputStream;
import java.security.*;
import java.security.cert.*;
import java.util.Collections;
import java.util.Iterator;
@johnthethird
johnthethird / 00_torquebox.rb
Last active December 11, 2015 21:19
Shim for running Torquebox apps under MRI Ruby
# Shim for running Torquebox apps under MRI Ruby
# http://www.rigelgroupllc.com/blog/2013/01/28/torquebox-shims-for-mri/
if ENV["INSIDE_TORQUEBOX"] == "true"
Rails.logger.info "[TorqueBoxInitializer] Inside TorqueBox"
else
Rails.logger.info "[TorqueBoxInitializer] NOT inside Torquebox, shimming TB functions..."
module TorqueBox
module Messaging
class MessageProcessor
attr_accessor :message
@johnthethird
johnthethird / server.log
Created January 15, 2013 03:37
sso log
server.log.2012-12-13:09:11:48,360 sso_token:$6$uZVjf/PkecNFitqhPF+8yVaam9WQI9vanwSCSpFAeX4h/BHaQ=;$6$ZOrZJ/DHoZBC3gyX7QnLI1hxn6bsRydMH3TsNKotAEHxEPYycR5Hnk4mkJul/X8Y0VWUHNlmIKaMN2Xw2WogsxcLSUVg==
server.log.2012-12-13:09:11:50,315 sso_token:$6$uZVjf/PkecNFitqhPF+8yVaam9WQI9vanwSCSpFAeX4h/BHaQ=;$6$ZOrZJ/DHoZBC3gyX7QnLI1hxn6bsRydMH3TsNKotAEHxEPYycR5Hnk4mkJul/X8Y0VWUHNlmIKaMN2Xw2WogsxcLSUVg==
server.log.2012-12-13:09:11:50,942 sso_token:$6$uZVjf/PkecNFitqhPF+8yVaam9WQI9vanwSCSpFAeX4h/BHaQ=;$6$ZOrZJ/DHoZBC3gyX7QnLI1hxn6bsRydMH3TsNKotAEHxEPYycR5Hnk4mkJul/X8Y0VWUHNlmIKaMN2Xw2WogsxcLSUVg==
server.log.2012-12-13:09:11:51,560 sso_token:$6$uZVjf/PkecNFitqhPF+8yVaam9WQI9vanwSCSpFAeX4h/BHaQ=;$6$ZOrZJ/DHoZBC3gyX7QnLI1hxn6bsRydMH3TsNKotAEHxEPYycR5Hnk4mkJul/X8Y0VWUHNlmIKaMN2Xw2WogsxcLSUVg==
server.log.2012-12-13:09:11:52,388 sso_token:$6$uZVjf/PkecNFitqhPF+8yVaam9WQI9vanwSCSpFAeX4h/BHaQ=;$6$ZOrZJ/DHoZBC3gyX7QnLI1hxn6bsRydMH3TsNKotAEHxEPYycR5Hnk4mkJul/X8Y0VWUHNlmIKaMN2Xw2WogsxcLSUVg==
server.log.2012-12-13:09:11:53,748
@johnthethird
johnthethird / fiddle.cs
Created November 21, 2012 22:22
Batman jsFiddle Scaffold in a Gist
console.log "Working"
def after_create(model)
orig_tenant = (Tenant.current rescue Kexception::TenantNotFoundError)
Tenant.current = model.tenant
...
ensure
Tenant.current = orig_tenant
end
@johnthethird
johnthethird / new_bashrc.sh
Created August 11, 2012 14:09 — forked from josephwecker/new_bashrc.sh
Replace .bashrc, .bash_profile, .profile, etc. with something much more clean, consistent, and meaningful.
#!/bin/bash
# License: Public Domain.
# Author: Joseph Wecker, 2012
#
# Are you tired of trying to remember what .bashrc does vs .bash_profile vs .profile?
# Are you tired of trying to remember how darwin/mac-osx treat them differently from linux?
# Are you tired of not having your ~/.bash* stuff work the way you expect?
#
# Symlink all of the following to this file:
# * ~/.bashrc
@johnthethird
johnthethird / parallel_asset_compiler.rb
Created August 3, 2012 16:05 — forked from brentd/parallel_asset_compiler.rb
Parallelize assets:precompile
require 'parallel' # gem install parallel (https://github.com/grosser/parallel)
# Monkey patch to Sprockets::StaticCompiler, a class provided by actionpack
# that's used by the assets:precompile task. This patch uses the Parallel gem
# to parallelize asset compilation in the simplest way possible.
#
# Parallel wraps Process.fork to handle things like inter-process communication
# via pipes and determining the maximum number of processes to run based on
# your system's total logical processors. So far only tested on MRI 1.9.3 on OS X.
module Sprockets