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/local/bin/php | |
<?php | |
$replacements = array( | |
"/:([^ ])/" => ": \$1", | |
"/(\\w)\\{/" => "\$1 {", | |
"/\\}\n([^\n])/" => "}\n\n\$1", | |
); | |
if ($argc < 2) { |
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
# environment variables for scripts and the like | |
export RAILS_ENV=production | |
# If not running interactively, don't do anything | |
[ -z "$PS1" ] && return | |
# don't put duplicate lines in the history. See bash(1) for more options | |
export HISTCONTROL=ignoredups | |
# ... and ignore same sucessive entries. | |
export HISTCONTROL=ignoreboth |
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/php | |
<? | |
if ($argc < 3) { | |
error_log("Usage:\n\t" . __FILE__ . " newer-than-date path [path [path...]]"); | |
exit(1); | |
} | |
$accumulated_size_in_bytes = 0; | |
$newer_than_timestamp = strtotime($argv[1]); |
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 I18n | |
def self.with_locale(locale) | |
old_locale, result = I18n.locale, nil | |
I18n.locale = locale | |
result = yield | |
I18n.locale = old_locale | |
result | |
end | |
def self.each_locale |
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
# lib/forgery_protection_helpers.rb | |
module ForgeryProtectionHelpers | |
def without_forgery_protection | |
return unless block_given? && respond_to?(:controller) | |
original_value = controller.allow_forgery_protection | |
controller.allow_forgery_protection = false | |
result = yield | |
controller.allow_forgery_protection = original_value | |
result | |
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
// Returns a hash with the query parameters, parsed from the query string given | |
// (or the current location's query string, if no arguments given) | |
// Based on code found here: | |
// http://stackoverflow.com/questions/901115/get-querystring-values-in-javascript/2880929#2880929 | |
function getQueryParams(queryString) { | |
var queryParams = {}, | |
e, | |
r = /([^&=]+)=?([^&]*)/g, | |
d = function (s) { return decodeURIComponent(s.replace(/\+/g, ' ')); }, | |
q = queryString || window.location.search.substring(1); |
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
#!/bin/sh | |
dir="$1" | |
identation="$2" | |
self="$0" | |
if test "$dir" = "" | |
then | |
dir="." | |
fi |
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
# Nginx | |
server { | |
# (...server definition skipped...) | |
location ~ "/\.svn" { | |
return 403; | |
} | |
} | |
# Apache's .htaccess | |
RewriteEngine On |
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
Dir['app/models/*.rb'].each do |m| | |
m = File.basename(m).split('.').first | |
m = m.camelcase.constantize | |
next unless m.respond_to?(:all) | |
m.all.each do |i| | |
m.columns.each do |c| | |
if [:string, :text].include?(c.type) | |
v = i.send(c.name) | |
i.send("#{c.name}=", v.gsub(/\\r\\n/, "\n")) if v && v.kind_of?(String) | |
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
# hack to auto compile sass when Jammit runs in development mode | |
# you can place this in an initializer | |
unless Rails.env.production? | |
require 'sass/engine' | |
module Jammit | |
module Helper | |
SASS_TIMESTAMPS = {} |
OlderNewer