This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
require 'haml' | |
configure do | |
set :reload_templates, true | |
end | |
get '/' do | |
haml :index, :layout => false | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Rack::Auth::Basic, "Nope" do |u, p| | |
[u, p] == ['user', 'password'] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> | |
<script> | |
$(document).ready(function() { | |
console.log($('#new_patent')); | |
$('#new_patent').css('background','blue'); | |
}); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def method_missing(meth, *args) | |
meth_s = meth.to_s | |
key = meth_s.sub(/=$/,'') | |
aattr = self.account_attributes.find_by_key key | |
if aattr | |
case meth_s | |
when aattr.key | |
aattr.value | |
when "#{aattr.key}=" | |
if args[0].nil? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# actually, fuck rvm... | |
OPT_RUBY_CURRENT=/opt/ruby/current | |
function opt_ruby_clear_current { | |
rm ${OPT_RUBY_CURRENT} | |
} | |
function opt_ruby_187 { | |
opt_ruby_clear_current | |
ln -s /opt/ruby/1.8.7-p358 ${OPT_RUBY_CURRENT} | |
hash -r | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" delete buffer, keep window | |
function Kwbd(kwbdStage) | |
if(a:kwbdStage == 1) | |
let g:kwbdBufNum = bufnr("%") | |
let g:kwbdWinNum = winnr() | |
windo call Kwbd(2) | |
execute "bd! " . g:kwbdBufNum | |
execute "normal " . g:kwbdWinNum . "" | |
else | |
if(bufnr("%") == g:kwbdBufNum) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class String | |
def base60_decode | |
n = 0 | |
self.each_byte do |c| | |
case | |
when c >= 48 && c <= 57 | |
c -= 48 | |
when c >= 65 && c <= 72 | |
c -= 55 | |
when c == 73 || c == 108 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'sinatra' | |
require 'sinatra/namespace' | |
configure do | |
disable :raise_errors | |
disable :show_exceptions | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation | |
{ | |
NSMutableArray *locations = [NSMutableArray arrayWithObject:newLocation]; | |
if (oldLocation) [locations insertObject:oldLocation atIndex:0]; | |
[self locationManager:locationManager didUpdateLocations:locations]; | |
} | |
// --- or the other way around | |
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# RFC822 Email Address Regex | |
# Originally written by Cal Henderson | |
# c.f. http://iamcal.com/publish/articles/php/parsing_email/ | |
# Translated to Ruby by Tim Fletcher, with changes suggested by Dan Kubb. | |
# Licensed under a Creative Commons Attribution-ShareAlike 2.5 License | |
# http://creativecommons.org/licenses/by-sa/2.5/ | |
module RFC822 | |
EmailAddress = begin | |
qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]' |
OlderNewer