Skip to content

Instantly share code, notes, and snippets.

@lambdajitsu
lambdajitsu / rewrite_git_commit
Created July 23, 2008 12:32
Forgot something in your last commit?
git reset --soft HEAD^
git commit --amend
@ldenman
ldenman / gist:1718
Created July 23, 2008 13:09
Center a Div
/* Centering a DIV */
body {
text-align: center;
min-width: 600px;
}
#wrapper {
margin:0 auto;
width:600px;
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="router" class="your.domain.routing.FirstAvailableMatchRouter">
<property name="routes">
<list>
<bean
def merge_options(options, extra_options)
(options.keys + extra_options.keys).uniq.each do |key|
merge = options[key] && extra_options[key]
if key == :conditions && merge
options[key] = merge_conditions(extra_options[key], options[key])
elsif key == :include && merge
options[key] = merge_includes(options[key], extra_options[key]).uniq
else
options[key] = options[key] || extra_options[key]
end
@yugui
yugui / gist:1724
Created July 23, 2008 13:39
Decorator for Ruby, inspired by Python
class Module
def declare(decorator, *args)
orig_method_added = method(:method_added)
metaclass = (class << self; self end)
defined_methods = []
metaclass.send(:define_method, :method_added) do |name|
orig_method_added.call(name)
defined_methods << name
end
begin
gem 'dm-core'
require 'dm-core'
APP_ROOT = File.expand_path(File.dirname(__FILE__))
# Database stuff
DataMapper.setup(:default, "sqlite3:#{APP_ROOT}/tezeta.db")
class User
include DataMapper::Resource
property :id, Integer, :serial => true
privat {
# Do we know that extension?
hangup unless @user = User.first(:extension => extension)
# Add to call log
@user.call_logs << CallLog.new(:type => 'incoming', :caller_id => callerid, :created_at => Time.now)
dial(@user.node)
@user.save
}
<?php
$name = 'Joe';
echo 'Hello ' . $name;
?>
DROP TABLE IF EXISTS `community_conditions`;
CREATE TABLE `community_conditions` (
`id` char(36) NOT NULL,
`condition_id` char(36) NOT NULL,
`community_id` char(36) NOT NULL,
PRIMARY KEY (`id`),
KEY `doc` (`condition_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;