Skip to content

Instantly share code, notes, and snippets.

View josepjaume's full-sized avatar

Josep Jaume Rey josepjaume

View GitHub Profile
@josepjaume
josepjaume / ember-batch-find.js
Created April 9, 2014 17:23
Batch find for ember data - it waits for multiple calls on the same run loop and performs a single request on the API
// Batch find for Ember Data. It will coerce all the finds on the same run loop
// and execute a single batch find for all the records. It mimics the find
// semantics.
//
// Example usage:
//
// var user1 = store.find('user', 1);
// var user2 = store.find('user', 2);
//
// user1.then(function(user){
<link rel="import" href="../components/polymer/polymer.html">
<polymer-element name="my-element">
<template>
<style>
</style>
</template>
<script>
@josepjaume
josepjaume / Gemfile
Created September 22, 2014 09:43
CORS with Rails
gem 'rack-cors'
source 'http://rubygems.org'
gem 'rails', :git=>'git://github.com/rails/rails.git', :branch=>'3-0-stable'
gem 'arel', :git=>'git://github.com/rails/arel.git'
gem "compass", ">= 0.10.5"
gem "haml"
gem "will_paginate", "3.0.pre2"
gem "devise"#, :git=>'git://github.com/plataformatec/devise.git'
gem "devise_invitable", :git=>"git://github.com/scambra/devise_invitable.git"
gem "high_voltage"
@josepjaume
josepjaume / button.rb
Created January 25, 2011 09:14
Replaces input type="submit" form elements with button
module ActionView
module Helpers
def submit_tag(value = "Save changes", options = {})
options.stringify_keys!
if disable_with = options.delete("disable_with")
options["data-disable-with"] = disable_with
end
if confirm = options.delete("confirm")
@josepjaume
josepjaume / vim.rb
Created February 7, 2011 15:20 — forked from uasi/vim.rb
require 'formula'
class Vim <Formula
url 'ftp://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2'
homepage 'http://www.vim.org/'
md5 '5b9510a17074e2b37d8bb38ae09edbf2'
version '7.3.112'
def patchlevel; 112 end
def features; %w(tiny small normal big huge) end
@josepjaume
josepjaume / qt.rb
Created May 17, 2011 13:06
QT Head Formula
require 'formula'
require 'hardware'
class Qt < Formula
url 'http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.7.3.tar.gz'
md5 '49b96eefb1224cc529af6fe5608654fe'
homepage 'http://qt.nokia.com/'
head 'git://gitorious.org/qt/qt.git', :branch => 'master-stable'
def options
@josepjaume
josepjaume / gist:1188097
Created September 2, 2011 07:32
Install patched ruby 1.9.2-p290
rvm uninstall 1.9.2
wget https://gist.github.com/raw/1156873/6343983e3ac418b3f0f59e9b3c38a5a5e5b0915a/gistfile1.sh -O - | sh
rvm gemset use global
gem install bundler
rvm reload
@josepjaume
josepjaume / gist:1206106
Created September 9, 2011 12:40
Time comparison inconsistency with SQLite, PostgreSQL and MySQL with ActiveRecord
def pending_notifications
notifications = self.notifications
if last_notification_read_at
# Sqlite doesn't properly compare dates because doesn't have a dedicated
# type for it.
# TODO: Investigate further and find a better solution for this.
#
time_restriction = if connection.class.name.demodulize =~ /SQLite/
@josepjaume
josepjaume / backbone-form-builder-interface.js
Created January 5, 2012 17:13
backbone-form-builder idea
var model = new Backbone.Model.extend();
// The form would bind to the model's "error" event.
// Any error retrieved from the JSON response or js
// validations would be captured.
//
// Sending the form would simply call the model's
// 'save' function with its serialized attributes
// and therefore would either render the errors or
// fire up the 'success' callback.