Skip to content

Instantly share code, notes, and snippets.

@j-mcnally
j-mcnally / gist:8329642
Created January 9, 2014 05:06
When your presentation has a public demo where users can post messages.... this is what happens.
Sup dawg
I heard you like ember
Hey
Larry rules
Sup
heyo
Seems to work pretty well
This works
mkay
Yo yo yo
@j-mcnally
j-mcnally / gist:8511557
Created January 19, 2014 22:00
Stubbing charge creation in stripe
@charges = []
Stripe::Charge.stub(:create) { |hash| @charges << hash }
<input type="text" />
@j-mcnally
j-mcnally / HeartAttack.md
Last active August 29, 2015 13:59
In The Wake of Heartbleed: Certificate Revocation & Re-issue / CRL List checking

Heartbleed

By now everyone has likely heard of heartbleed. It is a dangerous exploit that reveals the contents of a server's memory to the web on any server running an unpatched or pre 1.0.1 version of OpenSSL. The fear by most is that the private key of a servers SSL Certificate may have been compromised since servers keep that information in RAM at some point.

  • Disclaimer: Facebook and other sites used in this article are used mearly as a familiar example and are not known at this time to be vulnerable of anything *

Man In The Middle

When an attacker gets your SSL Private key it enables them to sign SSL traffic as your site. This mean if the attacker has facebook.com's private key, they can impersonate facebook.com and have you send traffic to facebook.com and through various ARP and DNS poisoning have you really be sending data to them. Historically SSL has mitigated this type of attack because if you expect to send traffic to https://www.facebook.com the attacker won't have a valid cert and pri

@j-mcnally
j-mcnally / README.md
Last active January 24, 2017 10:45
Sample ElasticBeanstalk Config for Rails 3 on Puma and Using a bundle / gems cached on s3 for faster scaling.

Quick / Cached Bundles on ElasticBeanstalk

Bonus, support Rack 1.4.5 with puma for Rails 3 apps

Basically we bundle install on one box, upload the result to a dedicated s3 bucked and then other servers/nodes can download the gems and save a ton of time compiling them.

I can not stress enough how the bucked should be dedicated as it will often remove all the files in the bucket to clear the cache / do a new gem build each month incase changes are made to backing ami / software, you can adjust the prefix to clear the bundle "cache key" more frequently by appending more date modifiers such as day or hour if you run into issues.

Note: You can remove 14downgradepuma if your app runs on Rails 4

def self.activate
Dir.glob(File.join(File.dirname(__FILE__), '../../app/reward_cards/*.rb')) do |c|
Rails.configuration.cache_classes ? require(c) : load(c)
end
end
require_dependency 'spree/address'
module AddressExtension
def self.included(base)
base.extend(ClassMethods)
base.send(:include, InstanceMethods)
base.class_eval do
unloadable
attr_accessible :residential
require 'reward/starbucks'
require 'reward/united'
class Card
def initialize(params)
@type = params[:type]
@username = params[:username]
@password = params[:password]
end
<form onsubmit="grabMarkdownHtml()">
<textarea id='md_html' name="md_html"></textarea>
</form>
<script>
var editor = new EpicEditor().load();
grabMarkdownHtml = function() {
document.getElementById('md_html').value = editor.getElement('previewer').body
}
2.0.0 (main):0 > d = DateTime.now
=> Tue, 29 Apr 2014 15:16:04 -0500
2.0.0 (main):0 > d.in_time_zone("Berlin")
=> Tue, 29 Apr 2014 22:16:04 CEST +02:00