Skip to content

Instantly share code, notes, and snippets.

@dsueiro
dsueiro / gist:4136028
Created November 23, 2012 15:02
Rails 3.2.0 Capistrano
require "bundler/capistrano"
# General
set :application, "application_name"
set :domain, "www.your_domain.com"
set :user, "deploy"
set :runner, "deploy"
set :use_sudo, false
set :deploy_to, "/var/www/#{application}"
set :repository_cache, "#{application}_cache"
@dsueiro
dsueiro / 2500 config products
Created November 8, 2012 18:25 — forked from magento-team/2500 config products
Create 2500 configurable products, Magento CE 1.7.0.1
<?php
/**
* Error reporting
*/
error_reporting(E_ALL | E_STRICT);
/**
* Compilation includes configuration file
*/
define('MAGENTO_ROOT', getcwd());
@dsueiro
dsueiro / createObject.js
Created October 27, 2012 21:00 — forked from mxriverlynn/createObject.js
An Object.create wrapper / shim for MarionetteJS
// Helpers
// -------
// For slicing `arguments` in functions
var slice = Array.prototype.slice;
// Borrow the Backbone `extend` method so we can use it as needed
Marionette.extend = Backbone.Model.extend;
// A wrapper / shim for `Object.create`. Uses native `Object.create`
@dsueiro
dsueiro / createObject.js
Created October 27, 2012 12:11 — forked from mxriverlynn/createObject.js
An Object.create wrapper / shim for MarionetteJS
// Helpers
// -------
// For slicing `arguments` in functions
var slice = Array.prototype.slice;
// Borrow the Backbone `extend` method so we can use it as needed
Marionette.extend = Backbone.Model.extend;
// A wrapper / shim for `Object.create`. Uses native `Object.create`
@dsueiro
dsueiro / promises.md
Created October 22, 2012 15:45 — forked from domenic/promises.md
You're Missing the Point of Promises

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.
});
@dsueiro
dsueiro / gist:3756542
Created September 20, 2012 15:17 — forked from astorm/gist:1188644
Moving a Magento Block Object
<layout>
<catalog_category_default>
<!-- block gets added -->
<reference name="content">
<block type="core/text" name="are_you_sure"></block>
</reference>
</catalog_category_default>
<catalog_category_default>
<!-- later, a different handle gets a reference and sets block state -->
@dsueiro
dsueiro / 0_README.md
Created September 20, 2012 13:53 — forked from josevalim/0_README.md
Sinatra like routes in Rails controllers

Sinatra like routes in Rails controllers

A proof of concept of having Sinatra like routes inside your controllers.

How to use

Since the router is gone, feel free to remove config/routes.rb. Then add the file below to lib/action_controller/inline_routes.rb inside your app.

@dsueiro
dsueiro / latency.txt
Created August 17, 2012 01:47 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
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
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms
@dsueiro
dsueiro / gist:3265393
Created August 5, 2012 15:26 — forked from swannodette/gist:3217582
sudoku_compact.clj
;; based on core.logic 0.8-alpha2 or core.logic master branch
(ns sudoku
(:refer-clojure :exclude [==])
(:use clojure.core.logic))
(defn get-square [rows x y]
(for [x (range x (+ x 3))
y (range y (+ y 3))]
(get-in rows [x y])))
@dsueiro
dsueiro / gist:3262021
Created August 5, 2012 05:31 — forked from anonymous/gist:3260973
Dump all Session Related PHP ini Values
<?php
$paths = array('session.save_path',
'session.name',
'session.save_handler',
'session.auto_start',
'session.gc_probability',
'session.gc_divisor',
'session.gc_maxlifetime',
'session.serialize_handler',