Skip to content

Instantly share code, notes, and snippets.

View boof's full-sized avatar

Florian Aßmann boof

  • YNI
  • Hamburg, Germany
View GitHub Profile
@boof
boof / mardown.rb
Created December 14, 2008 00:23
Textile to Markdown formatter
module RedCloth::Formatters::Markdown
include RedCloth::Formatters::Base
# escapement for regular HTML (not in PRE tag)
def escape(text)
html_esc(text)
end
# escapement for HTML in a PRE tag
def escape_pre(text)
@boof
boof / git_hub.rb
Created December 14, 2008 08:06
Browse GitHub from IRB
require 'rubygems'
require 'active_support/memoizable'
require 'httparty'
module GitHub
class User
extend ActiveSupport::Memoizable
attr_reader :name
@boof
boof / polymorphism.rb
Created December 14, 2008 08:07
Polymorphisms for polymorphic resource controllers
class Polymorphism
attr_reader :base, :ctrl, :path
@@polymorph = ''
@@polymorphs = ''
cattr_reader :polymorph, :polymorphs
def self.set_polymorph(polymorph)
@@polymorph = "#{ polymorph }"
@@polymorphs = "#{ polymorph }".pluralize
@boof
boof / gist:64634
Created February 15, 2009 07:20 — forked from kiko/gist:63801
require 'rubygems'
require 'not_naughty'
# Load the validations you want to use.
NotNaughty::Validation.load 'length', 'presence'
Person = Struct.new(:name) do
extend NotNaughty
validates(:name) { presence and length :minimum => 4 }
end
@boof
boof / pages_controller.rb
Created October 29, 2009 16:47
Make controller code more readable...
class PagesController < Protected::Base
before_filter :authorized?, :except => [:index, :show]
before_filter :assign_searcher, :except => :index
before_filter :assign_navigation, :except => [:show, :new, :edit]
def index
@pages = Page.find :all
end
require 'rubygems'
require 'mq'
#require 'yajl'
#require 'sequel'
require 'em-websocket'
require 'uuid'
AMQP.start(:host => 'localhost') do
uuid = UUID.new # drop UUID in favour of 1
chat = MQ.new.fanout 'chat'
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Page Title</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
$(function() {
$('.card').draggable()
@boof
boof / README.md
Created August 29, 2010 15:27
Client-Side Server-Side-Includes

jquery.bcome.js

Client-Side Server-Side-Includes

$(document).bcome({
  done: function() { alert('Done...'); }
});

Supports only <!--# include file=... for now.

@boof
boof / gist:712673
Created November 23, 2010 22:38
brew install postgresql
make -C compatlib install
/usr/bin/cc -O3 -march=core2 -msse4.1 -w -pipe -I/usr/include/libxml2 -I/Users/boof/local/Cellar/ossp-uuid/1.6.2/include -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing -fwrapv -Kthread -kthread -pthread -pthreads -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -I../include -I../../../../src/interfaces/ecpg/include -I../../../../src/interfaces/libpq -I../../../../src/include/utils -I../../../../src/include -I/Users/boof/local/Cellar/readline/6.1/include -isystem /Users/boof/local/include -I/usr/include/libxml2 -DSO_MAJOR_VERSION=3 -c -o informix.o informix.c
awk '/^[^#]/ {printf "_%s\n",$1}' exports.txt >exports.list
/bin/sh ../../../../config/install-sh -c -d '/Users/boof/local/Cellar/postgresql/9.0.1/lib'
/usr/bin/cc -O3 -march=core2 -msse4.1 -w -pipe -I/usr/include/libxml2 -I/Users/boof/local/Cellar/ossp-uuid/1.6.2/include -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-label
http://jsfiddle.net/yBLNX/1/