Skip to content

Instantly share code, notes, and snippets.

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

stan

💭
¯\_(ツ)_/¯
View GitHub Profile
require 'active_support/basic_object'
ActiveRecord::Base.class_eval do
class WithoutCallbacks < ActiveSupport::BasicObject
def initialize(target, types)
@target = target
@types = types
end
def respond_to?(method, include_private = false)
<!DOCTYPE html>
<!-- Helpful things to keep in your <head/>
// Brian Blakely, 360i
// http://twitter.com/brianblakely/
-->
<head>
<!-- Disable automatic DNS prefetching.
@gawin
gawin / userstamp
Created September 16, 2010 08:17
# encoding: utf-8
module Mongoid #:nodoc:
# Include this module to set the creator of documents.
# This will add a created_at and updated_at field to the +Document+, managed automatically.
#
# To use:
#
# class Person
# include Mongoid::Document
# include Mongoid::Userstamps
# encoding: utf-8
module Mongoid #:nodoc:
# Include this module to set the creator of documents.
# This will add a created_at and updated_at field to the +Document+, managed automatically.
#
# To use:
#
# class Person
# include Mongoid::Document
# include Mongoid::Userstamps
@seangaffney
seangaffney / TextMate SASS Save to CSS
Created September 16, 2010 22:26
This TextMate command will export your SCSS files to CSS on save. Hotness. Requires HAML gem to be installed. It's really just a modified version of the LESS Save to CSS command. Be sure to check the screenshot in the comments for the rest of the config
#!/usr/bin/env ruby
file = STDIN.read[/sass: ([^*]+\.scss)/, 1] || ENV["TM_FILEPATH"]
file2 = file.sub(/\.scss/,'.css')
system("sass \"#{file}\":\"#{file2}\"")
// Add Modernizr test for font-smoothing
// A designer may wish to darken the colour of a given font when antialiasing is applied
// Examples of font-smoothing in action: http://bit.ly/bLeUg1
/*
Usage:
Add to your page
Use html.fontsmoothing h1 { color: xxx; } to make your colours darker
*/
@jlecour
jlecour / gist:591321
Created September 22, 2010 07:49
Geokit-rails and Rails 3

In my effort for porting the geokit-rails plugin to Rails 3, I've found that it would really benefit a full rewrite of the query composition parts.

My work can be followed here : http://github.com/jlecour/geokit-rails/ (make sure to look at the gem branch until it is merged into master) Any help is welcome.

The current version, compatible with Rails 2, has 2 main methods (find and count) and some utility methods, that are making some changes to the select/conditions/limit/order/… parts of the options hash passed to ActiveRecord and then call the super related method on the model's class.

With ActiveRecord 3 and its scope approche, I think we don't need to mess with the hash anymore if we use the power of scopes. I would be cleaner, more chainable and reusable, …

That said, we have to consider the kind of additions Geokit makes to a typical query. As a brief summary, here is how it works.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <hiredis/libevent.h>
void getCallback(redisContext *c, redisReply *reply, const void *privdata) {
printf("argv[%s]: %s\n", (const char*)privdata, reply->reply);
/* Disconnect after receiving the reply to GET */
redisDisconnect(c);
@sublee
sublee / README.rst
Created September 28, 2010 08:03
Finger Binary ASCII art generator for Python

Finger Binary

What's Finger Binary?

Here is a description of `Finger Binary in Wikipedia`_.

Finger binary is a system for counting and displaying binary numbers on the
require 'openid/store/interface'
module OpenID::Store
class Association
include Mongoid::Document
field :secret, :type => Binary
def from_record
OpenID::Association.new(handle, secret.to_s, issued, lifetime, assoc_type)
end