Skip to content

Instantly share code, notes, and snippets.

View jimmycuadra's full-sized avatar
☠️
GitHub profits from the separation of families and the deaths of children.

jimmycuadra

☠️
GitHub profits from the separation of families and the deaths of children.
View GitHub Profile
@domenic
domenic / promises.md
Last active April 1, 2025 01:54
You're Missing the Point of Promises

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.
@jimmycuadra
jimmycuadra / debounce.js
Created September 13, 2012 00:55
Debounce question
/*
Fill in the body of the `debounce` function, such that running
the following code will output "fn was called with 10!" only once.
*/
(function () {
var debounce, fn, i;
debounce = function (func, wait) {
// ...
};
@jimmycuadra
jimmycuadra / beget.js
Created September 6, 2012 19:33 — forked from ClayShentrup/beget.js
Beget question (prototypal inheritance)
function beget(parent, child) {
// Add code here to make test() return true.
}
function test(){
var c;
function Parent() {
throw 'exception';
}
@abeluck
abeluck / gpg-offline-master.md
Last active October 22, 2023 02:59 — forked from KenMacD/cmd.md
GPG Offline Master Key w/ smartcard
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@ClayShentrup
ClayShentrup / beget.js
Created July 20, 2012 06:59
beget question
function beget(parent, child){
// put code here to make test() return true
};
function test(){
function Parent(){
throw 'exception';
};
Parent.prototype = {code: Math.random()};
@ClayShentrup
ClayShentrup / whale_test.rb
Created July 20, 2012 05:12
Whale question
require 'test/unit'
class Whale
def self.attr_validated(method_name, &validation)
# Enter code here to make all tests pass.
end
attr_validated :num_teeth do |v|
v <= 4
end
@wzdf1982
wzdf1982 / rails engine setup
Created June 24, 2012 05:19
Rails: Engine setup
generate
rails plugin new importable --dummy-path=spec/dummy --full --mountable -T
add to gemspec
s.add_dependency 'jquery-rails'
s.add_dependency 'sass-rails'
s.add_dependency 'bootstrap-sass', '~> 2.0.3'
@matschaffer
matschaffer / create_data_bag.rb
Created June 8, 2012 15:30
Creating local encrypted data bags
require 'rubygems'
require 'chef/encrypted_data_bag_item'
secret = Chef::EncryptedDataBagItem.load_secret('data_bag_key')
data = {"id" => "mysql", "root" => "some secret password"}
encrypted_data = Chef::EncryptedDataBagItem.encrypt_data_bag_item(data, secret)
FileUtils.mkpath('data_bags/passwords')
File.open('data_bags/passwords/mysql.json', 'w') do |f|
f.print encrypted_data.to_json