Skip to content

Instantly share code, notes, and snippets.

r53 = AWS::Route53.new(
:access_key_id => 'aws-key-id',
:secret_access_key => 'aws-secret-key')
response = r53.client.list_resource_record_sets(
:hosted_zone_id => "zone-id",
:start_record_name => 'xxx.example.com',
:start_record_type => 'CNAME'
)
puts response[:resource_record_sets].map{|r| r[:name]}
@ches
ches / follow_observer_spec.rb
Last active April 9, 2025 10:36
Example of testing Rails observers in isolation for cross-cutting concerns
require 'spec_helper'
# Bustle is a pubsub system used for activity streams:
# https://github.com/fredwu/bustle
#
# Here when a person follows another (or a discussion, for instance), the observer wires
# up pubsub between them for future activity notifications. The Follow model knows nothing
# about the implementation choices for the pubsub system.
describe FollowObserver do
subject { FollowObserver.instance }
@tmm1
tmm1 / ruby19_date_marshal.rb
Created February 6, 2013 06:07
Fix marshal incompatibility between Date/DateTime on 1.8 and 1.9
require 'date'
class Date
if RUBY_VERSION < '1.9'
## accept 1.9 marshaled data on 1.8
## based on ext/date/date_core.c d_lite_marshal_dump_old
def marshal_load(data)
nth, jd, df, sf, of, @sg = data
real_jd =
$('form#new_task').submit(function() {
$.ajax({
type: "POST",
url: $(this).attr('action'), //sumbits it to the given url of the form
data: {
data_1: value_1,
data_2: value_2
}, //input gui di
dataType: "HTML",
success(function(result){
@adamcooke
adamcooke / cloudapp-export.rb
Created January 11, 2013 15:45
Export all your drops from CloudApp using this quick Ruby script
#!/usr/bin/env ruby
# A quick script to download all your files from CloudApp.
# To run this just run the script passing your e-mail & password
# to the script, for example:
#
# gem install cloudapp_api
# ruby cloudapp-export.rb [email protected] mypassword
#
@lucasdavila
lucasdavila / dynamic_form_for_hstore_attributes_in_rails.html.erb
Created September 13, 2012 15:54
Dynamic form for hstore attributes in rails
<%= simple_form_for @product do |f| %>
<%= f.simple_fields_for :attributes do |d| %>
<% f.object.attributes.try(:each) do |key, value| %>
<%= d.input key, :input_html => {:value => value } %>
<% end %>
<% end %>
<% end %>
@Mithrandir0x
Mithrandir0x / gist:3639232
Created September 5, 2012 16:15
Difference between Service, Factory and Provider in AngularJS
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
@jboner
jboner / latency.txt
Last active May 13, 2025 17:54
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@marktabler
marktabler / pretty_hash.rb
Created May 22, 2012 22:43
A quick and dirty hash beautifier
def self.pretty_hash(hash)
results = []
hash.keys.each do |key|
results << key
if hash[key].respond_to?(:keys)
results << pretty_hash(hash[key]).split("\n").map do | line |
" -- " + line
end
end
end
@douglas
douglas / install_swig_mac.sh
Created July 6, 2011 01:47
Install swig on a mac with homebrew
brew install https://raw.github.com/cobrateam/formulae/master/swig.rb