Skip to content

Instantly share code, notes, and snippets.

@jon
jon / BPGeometry.h
Created February 2, 2010 03:22
A collection of 2D vector-geometry functions for dealing with CGPoints in Cocoa/Cocoa Touch
/*
* BPGeometry.h
*
* Created by Jon Olson on 11/30/09.
* Copyright 2009 Ballistic Pigeon, LLC. All rights reserved.
*
*/
#import <Foundation/Foundation.h>
@pasviegas
pasviegas / mongodb
Created March 27, 2010 01:26
Simple monit script for mongodb
check host mongodb with address localhost
start program = "/usr/bin/sudo /opt/database/mongo/bin/mongod"
stop program = "/usr/bin/sudo /usr/bin/pkill -f mongod"
if failed port 28017 protocol HTTP
request /
with timeout 10 seconds
then start
@defunkt
defunkt / clients.md
Created April 18, 2010 14:09
A list of Gist clients.

Gist Clients

Want to create a Gist from your editor, the command line, or the Services menu? Here's how.

Editor Support

@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>SoundCloud OAuth 2 User Agent Authentication Flow Demo</title>
<script type="text/javascript" charset="utf-8" src="javascript/jquery-1.4.2.js"></script>
<script type="text/javascript" charset="utf-8">
$(function () {
var extractToken = function(hash) {
@torus
torus / command-key-on-nodoka.md
Created October 3, 2010 06:52
のどかで、Mac みたいなキーバインドを実現する。

のどかで、Mac みたいなキーバインドを実現する。

Ctrl キーは、Emacs 的なキーバインド。

Windows キーは、オリジナルの Windows での Ctrl キーのように振舞う。

Windows キーと Ctrl キーを区別するために、 Ctrl キーについては mod0 という新しいモディファイアとして扱うようにして、 emacsedit.nodoka ファイルを修正して、C- となっている部分をすべて M0- に置き換えた。

require 'sinatra/base'
class MyApp < Sinatra::Base
@@my_app = {}
def self.new(*) self < MyApp ? super : Rack::URLMap.new(@@my_app) end
def self.map(url) @@my_app[url] = self end
class FooController < MyApp
map '/foo'
@moro
moro / gist:1028677
Created June 16, 2011 04:35
samp.ru
require 'rack'
class App
def call(env)
to = Rack::Request.new(env).params["to"] || "World"
body = Rack::Utils.escape_html(to)
[200, {"Content-Type" => "text/html"}, [body]]
end
end
@agnellvj
agnellvj / friendly_urls.markdown
Created September 11, 2011 15:52 — forked from jcasimir/friendly_urls.markdown
Friendly URLs in Rails

Friendly URLs

By default, Rails applications build URLs based on the primary key -- the id column from the database. Imagine we have a Person model and associated controller. We have a person record for Bob Martin that has id number 6. The URL for his show page would be:

/people/6

But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6 here, is called the "slug". Let's look at a few ways to implement better slugs.