Skip to content

Instantly share code, notes, and snippets.

View dariocravero's full-sized avatar

Darío Javier Cravero dariocravero

View GitHub Profile
Sequel.migration do
up do
run 'CREATE EXTENSION "uuid-ossp"'
create_table :products do
primary_key :id, {type: :uuid, default: Sequel.function(:uuid_generate_v4)}
end
end
end
require 'rubygems'
require 'rake'
require 'rake/testtask'
Rake::TestTask.new do |t|
t.pattern = "test/test_*.rb"
t.verbose = true
end
@dariocravero
dariocravero / libuv-compilation-error
Last active August 29, 2015 13:56
Error while trying to build libuv in Ubuntu both the latest release and the git repo, here's the output of autogen/configure/make/make check. uname -a: Linux uxtemple 3.8.0-29-generic #42~precise1-Ubuntu SMP Wed Aug 14 16:19:23 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
root@uxtemple:~/tmp/libuv# sh autogen.sh
+ libtoolize
libtoolize: putting auxiliary files in `.'.
libtoolize: linking file `./ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIR, `m4'.
libtoolize: linking file `m4/libtool.m4'
libtoolize: linking file `m4/ltoptions.m4'
libtoolize: linking file `m4/ltsugar.m4'
libtoolize: linking file `m4/ltversion.m4'
libtoolize: linking file `m4/lt~obsolete.m4'
App.controllers do
get :images, map: '/images/:id/*', provides: ['.jpeg', '.jpg', '.png', '.gif'] do
# params[:splat] still contains whatever is entered at the end
artwork = Artwork[params[:id]]
send_file artwork.picture.tempfile, type: artwork.type
end
error Mongoid::Errors::MongoidError do
halt 404, 'File not found'
end
@dariocravero
dariocravero / retarget-links.js
Last active August 29, 2015 14:03
Retarget GitHub gist links to open in a new tab instead of taking over the current one.
def date_field_tag(name, options={})
input_tag(:date, { :name => name }.update(options))
end
# config/boot.rb
# Add
# load File.expand_path('../bundler-mem.rb', __FILE__)
# before Bundler.require(:default, RACK_ENV)
# Defines our constants
RACK_ENV = ENV['RACK_ENV'] ||= 'development' unless defined?(RACK_ENV)
PADRINO_ROOT = File.expand_path('../..', __FILE__) unless defined?(PADRINO_ROOT)
# Load our dependencies
@dariocravero
dariocravero / bower.json
Created November 2, 2014 11:08
gulpfile.js and public/bower.json
{
"name": "my-app",
"version": "0.0.1",
"dependencies": {
"normalize-css": "latest",
"angular": "latest"
}
}
@dariocravero
dariocravero / package.json
Created January 29, 2015 15:48
build process demo
{
"name": "rce",
"version": "0.0.1",
"description": "HMH's RCE",
"main": "js/rce.js",
"readme": "README.md",
"dependencies": {
"http-server": "^0.7.4",
"react": "^0.12.2"
},
@dariocravero
dariocravero / expand-a-titles.js
Created January 30, 2015 14:40
Expand MDN's a tag titles into text nodes
Array.prototype.forEach.apply(
document.querySelectorAll('#wikiArticle ul li'),
function(li) {
var title = document.createElement('div');
title.innerText = li.querySelector('a').title;
li.appendChild(title);
});