Skip to content

Instantly share code, notes, and snippets.

View stan's full-sized avatar
💭
¯\_(ツ)_/¯

stan

💭
¯\_(ツ)_/¯
View GitHub Profile
javascript:
if( !window.goviasGrid ){
window.goviasGrid = document.createElement("div");
document.getElementsByTagName("body")[0].appendChild(window.goviasGrid);
window.goviasGrid.style.background = "url(http://tomlea.co.uk/assets/the-grid.png) repeat-y 50% 0";
window.goviasGrid.style.width = "100%";
window.goviasGrid.style.height = "100%";
window.goviasGrid.style.position = "fixed";
window.goviasGrid.style.top = "0";
window.goviasGrid.style.bottom = "0";
module Rankable
extend ActiveSupport::Concern
included do
field :ratings_value_sum, :type => Integer, :default => 0
field :ratings_count, :type => Integer, :default => 0
embeds_many :ratings
end
/*!
* jQuery TextChange Plugin
* http://www.zurb.com/playground/jquery-text-change-custom-event
*
* Copyright 2010, ZURB
* Released under the MIT License
*/
(function ($) {
$.event.special.textchange = {
# checkout: http://github.com/igrigorik/async-rails/
From bb2a78858cffa7c6937642986e9aca1a4f862c0d Mon Sep 17 00:00:00 2001
From: Ilya Grigorik <[email protected]>
Date: Thu, 10 Jun 2010 00:46:48 -0400
Subject: [PATCH] async rails3
---
Gemfile | 6 ++++++
app/controllers/widgets_controller.rb | 6 ++++++
@bru
bru / texmate_dot_filter
Created June 12, 2010 09:14
TextMate dotfiles filter
# TextMate dotfiles filter
# use this filter in Preferences -> Advanced -> Folder References -> File Pattern
# to show .gitignore, .gems (useful for Heroku), .bundle in your project
!(/\.(?!(htaccess|gitignore|gems|bundle))[^/]*|\.(tmproj|o|pyc)|/Icon\r|/svn-commit(\.[2-9])?\.tmp)$
class User < ActiveRecord::Base
state_machine :initial => :pending do
# Event to call each time user proceeds to the next step
event :proceed do
transition :pending => :personal_info_registered
transition :personal_info_registered => :payment_info_registered
transition :payment_info_registered => :activated
end
# Attributes that must be present in at least Step 1
$$('a[data-remote=true]').each(function(a){
a.onclick = function(){
href = a.getAttribute('href');
url = href.split('?')[0];
params = href.split('?')[1];
newParam = encodeURI(eval(a.getAttribute('data-with')));
if(params){
params = params.split('&');
require 'fiddle'
module FFI
module Library
def ffi_lib *libs
libs.each { |lib| Fiddle.dlopen lib }
end
def attach_function name, arg_types, return_type
f = Fiddle::Function.new(
@Arcath
Arcath / gist:481321
Created July 19, 2010 12:19
gravatar avatar url generating helper method, simply pass an email to it
def gravatar_url(email,options = {})
require 'digest/md5'
hash = Digest::MD5.hexdigest(email)
url = "http://www.gravatar.com/avatar/#{hash}"
options.each do |option|
option == options.first ? url+="?" : url+="&"
key = option[0].to_s
value = option[1].to_s
url+=key + "=" + value
end
@hagenburger
hagenburger / javascript_loader.js
Created July 30, 2010 15:28
Dynamically load JavaScript files with callback when finished
// Example:
JavaScript.load("/javascripts/something.js");
// With callback (that’s the good thing):
JavaScript.load("http://www.someawesomedomain.com/api.js", function() {
API.use(); // or whatever api.js provides ...
});