This is now an actual repo:
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
module DateTimeHelper | |
def format_date_range(date_range) | |
first = date_range.first | |
last = date_range.last | |
if same_day?(first, last) | |
"#{first.to_s(:month_day)}, #{first.year}" | |
elsif same_month?(first, last) | |
"#{first.to_s(:month_day)}-#{last.day}, #{last.year}" | |
else | |
"#{first.to_s(:month_day)}-#{last.to_s(:month_day)}, #{last.year}" |
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/base' | |
class CacheHelper | |
module Sinatra | |
module Helpers | |
def cache(name, options = {}, &block) | |
if cache = read_fragment(name, options) | |
@_out_buf << cache | |
else | |
pos = @_out_buf.length |
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
// Provides a device_scale class on iOS devices for scaling user | |
// interface elements relative to the current zoom factor. | |
// | |
// http://37signals.com/svn/posts/2407-device-scale-user-interface-elements-in-ios-mobile-safari | |
// Copyright (c) 2010 37signals. | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
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 'iconv' | |
require 'open-uri' | |
class String | |
COLORS = [:black, :red, :green, :yellow, :blue, :magenta, :cyan, :white] | |
def colorize(color) | |
value = case color | |
when Symbol |
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
/* traditional way */ | |
(function($) { | |
$(document).ready(function() { | |
$('#searchForm').submit(function(e) { | |
var term = $.trim($(this).find('input[name="q"]').val()); | |
if (!term) { return; } | |
$.getJSON( |
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> | |
<head> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script> | |
<script type="text/javascript" src="http://ajax.cdnjs.com/ajax/libs/underscore.js/1.1.4/underscore-min.js"></script> | |
</head> | |
<body> | |
<p id="loading_msg">Loading...</p> | |
<script type="text/javascript"> | |
/* To being with, just in case the "$" is already taken in the global scope |
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/base' | |
require 'memcached' | |
module Sinatra | |
module Memcacher | |
module Helpers | |
def cache(key, &block) | |
return block.call unless options.memcacher_enabled | |
begin |
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
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
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
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 Jed Schmidt <http://jed.is> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
OlderNewer