Skip to content

Instantly share code, notes, and snippets.

View kenzie's full-sized avatar

Kenzie Campbell kenzie

View GitHub Profile
require 'net/dns/resolver'
# Custom Domain
#
# Require net-dns gem
#
# A Rack middleware to to resolve the custom domain to original subdomain
# for your multi telent application.
#
# It's all transperant to your application, it performs cname lookup and
@tswicegood
tswicegood / sync_things.rb
Created October 1, 2009 20:13
Simple Ruby script to sync Basecamp and Things to-dos.
#!/usr/bin/env ruby
#
# Biggest problem with this is that it checks everything. Needs
# to be adjusted to only check N days and/or N tasks on Basecamp.
#
# Also has a problem in that Completed always wins. If you have a
# task marked at completed, then mark it as open again on just one
# side, it'll mark the other as completed if you run the sync again.
#
# All that said, it provides a basic, very rudimentary sync.
# From Bryan Liles on the Practicing Ruby Discussion List
1. TDD is a great tool. As a tool, you'll use it when appropriate.
TATFT mostly means that you should be thinking about how you can put
whatever you are creating under test at all times. Writing tests for
the sake of writing tests is silly.
2. Like Gregory stated, brittle tests aren't helping anyone. Think
about the ingress/egress points of your objects at all times.
@comfuture
comfuture / gist:827368
Created February 15, 2011 10:29
amazon s3 policy by referrer example
{
"Version":"2011-02-15",
"Id":"only allowed referers",
"Statement":[
{
"Sid":"Allow get requests referred by maroo.info and apps.facebook.com",
"Effect":"Allow",
"Principal":"*",
"Action":"s3:GetObject",
"Resource":"arn:aws:s3:::static.maroo.info/*",
@unixmonkey
unixmonkey / Cucumber Plain Text Feature.tmLanguage
Created March 10, 2011 20:15
Cucumber Language definition file for TextMate; modified to work with Sublime Text 2
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>fileTypes</key>
<array>
<string>feature</string>
</array>
<key>firstLineMatch</key>
<string>기능|機能|功能|フィーチャ|خاصية|תכונה|Функціонал|Функционалност|Функционал|Особина|Могућност|Özellik|Właściwość|Tính năng|Savybė|Požiadavka|Požadavek|Osobina|Ominaisuus|Omadus|OH HAI|Mogućnost|Mogucnost|Jellemző|Fīča|Funzionalità|Funktionalität|Funkcionalnost|Funkcionalitāte|Funcționalitate|Functionaliteit|Functionalitate|Funcionalitat|Funcionalidade|Fonctionnalité|Fitur|Feature|Egenskap|Egenskab|Crikey|Característica|Arwedd(.*)</string>
@dhh
dhh / gist:1014971
Created June 8, 2011 18:09
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end
@jswanner
jswanner / Gemfile.diff
Created October 7, 2011 19:30
Differences between Rails 3.1.0 & Rails 3.1.1 generated apps
diff -U 0 -r rails-3.1.0/Gemfile rails-3.1.1/Gemfile
--- rails-3.1.0/Gemfile 2011-10-07 12:07:06.000000000 -0400
+++ rails-3.1.1/Gemfile 2011-10-07 12:59:13.000000000 -0400
@@ -3 +3 @@
-gem 'rails', '3.1.0'
+gem 'rails', '3.1.1'
@@ -14,3 +14,3 @@
- gem 'sass-rails', " ~> 3.1.0"
- gem 'coffee-rails', "~> 3.1.0"
- gem 'uglifier'
@henrydjacob
henrydjacob / users.yml
Created November 7, 2011 08:26
devise fixtures users.yml
user1:
email: user1@mysite.com
encrypted_password: <%= User.new.send(:password_digest, "user123") %>
confirmed_at: <%= Time.now %>
@ehoch
ehoch / gist:1761304
Created February 7, 2012 19:12
Spam Action on the Fly
config.actions do
member :spam do
link_icon 'icon-ban-circle'
bulkable? { true }
controller do
Proc.new do
if params[:bulk_ids]
params[:bulk_ids].each {|id| @abstract_model.model.find(id).spam }
flash[:success] = "#{params[:bulk_ids].size} Spammed"
else
class PostsController < ActionController::Base
def create
Post.create(post_params)
end
def update
Post.find(params[:id]).update_attributes!(post_params)
end
private