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 | |
# | |
# Identifies the predominant color in an image. | |
# You can specify certain colors to discard from the result. | |
# | |
# Usage: $0 <image> [colors to discard] | |
[ -z "$1" ] && exit 1 | |
file="$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
def Object.method_added(method) | |
return super(method) unless method == :helper | |
helper.instance_variable_set("@controller", app) | |
def helper.method_missing(method, *args, &block) | |
helper.send(method, *args, &block) if helper.instance_variable_get('@controller') && method.to_s =~ /_path$|_url$/ | |
end | |
end if ENV['RAILS_ENV'] |
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
# | |
# "grep"s through Rails views searching for a specific Route. | |
# | |
# You can think of it as a "which views links to this route" finder, | |
# good in refactoring scenarios. | |
# | |
# Actually the search is done using "ack" [http://betterthangrep.com], | |
# you must have it in your PATH. | |
# | |
# Also, this ack usage requires a definition of the Haml filetype for |
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
--type-set | |
haml=.haml |
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 'rexml/parsers/pullparser' | |
require 'htmlentities' | |
class String | |
# Truncate strings containing HTML code | |
# Usage example: "string".truncate_html(50, :word_cut => false, :tail => '[+]') | |
def truncate_html(len = 30, opts = {}) | |
opts = {:word_cut => true, :tail => ' ...'}.merge(opts) | |
p = REXML::Parsers::PullParser.new(self) | |
tags = [] |
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
" | |
" CSS 1-line comment helpers | |
" | |
" Comments the current line | |
fun CssComment() | |
:s@^\(\s*\)\(.*\)$@\1/*\2*/@ | |
endfun | |
" Un-comment from current line |
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
<?php | |
require_once 'util.php'; | |
class Application_Model_Abstract | |
{ | |
public function __construct(array $options = null) | |
{ | |
if (is_array($options)) { | |
$this->setFromArray($options); |
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
<?php | |
/*** | |
* Helper functions to convert strings: | |
* - from CamelCase to camel_case and; | |
* - from under_score to UnderScore | |
* | |
* These are very probably not fast (or the fastest version). | |
***/ |
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 python | |
# If Win32, MSYS/cygwin with sed is required | |
import sys | |
if __name__ != '__main__': | |
print "This script must be run, not imported" | |
sys.exit(1) | |
try: |
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
= Christian Neukirchen's Ruby Style Guide | |
[ http://github.com/chneukirchen/styleguide/blob/master/RUBY-STYLE ] | |
You may not like all rules presented here, but they work very well for | |
me and have helped producing high quality code. Everyone is free to | |
code however they want, write and follow their own style guides, but | |
when you contribute to my code, please follow these rules: | |
== Formatting: |