Skip to content

Instantly share code, notes, and snippets.

View azisaka's full-sized avatar

Zisa azisaka

View GitHub Profile
RSpec.configure do |config|
config.filter_run :focus => true
end
describe "something" :focus => true do
...
end
describe "another thing" do
it "should be testable" do
@azisaka
azisaka / template.rb
Created October 18, 2010 04:01
My Rails 3 template for basic projects
gem 'autotest', :group => :test
gem 'capybara', :group => :test
gem 'cucumber', :group => :test
gem 'cucumber-rails', :group => :test
gem 'database_cleaner', :group => :test
gem 'factory_girl', :group => :test
gem 'haml'
gem 'haml-rails'
gem 'jammit'
gem 'jquery-rails'
➜ base git:(master) ✗ RAILS_ENV=test rake spec --trace
(in /Users/Bruno/Projects/Personal/base)
DEPRECATION WARNING: require "activesupport" is deprecated and will be removed in Rails 3. Use require "active_support" instead.. (called from <top (required)> at /Users/Bruno/.rvm/gems/ruby-1.9.2-rc1/gems/activesupport-2.3.5/lib/activesupport.rb:2)
** Invoke spec (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:abort_if_pending_migrations
** Execute db:test:prepare
@azisaka
azisaka / gist:455505
Created June 28, 2010 06:18
A SQL (MySQL) function that returns the number of the quadrimester based on the date
DELIMITER //
CREATE FUNCTION QUADRIMESTER (date_and_time DATETIME)
RETURNS INT(1)
BEGIN
DECLARE month_of_the_year INT(1);
SET month_of_the_year = MONTH(date_and_time);
IF month_of_the_year >= 1 AND month_of_the_year <= 4 THEN RETURN 1;
#include <stdlib.h>
#include <stdio.h>
struct node {
int value;
struct node *next;
};
typedef struct node node;
class Page
include Mongoid::Document
field :title
field :body
field :permalink
validates_presence_of :title, :body
before_validation :generate_permalink
#!/bin/sh
# Install ImageMagick on Snow Leopard: by kain, improved by mislav and samsoffes
# http://www.icoretech.org/2009/08/install-imagemagick-in-leopard-snow-leopard/
# Work with 64bit kernel mode
set -e
PREFIX=/usr/local
# Passenger users: amend your Apache global configuration with the following directive
# SetEnv PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
class Campaign
include Mongoid::Document
field :name
index :name, :unique => true
validates_presence_of :name
end
describe Campaign do
db.collection.group([fields], { conditions }, { :initial => value }, Mongo::Code.new("function (obj, prev) { prev.count++; }"))
# Clear chains
iptables -F
# Allow outgoing traffic and disallow any passthroughs
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP
# Allow traffic already established to continue
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT