Skip to content

Instantly share code, notes, and snippets.

@clee704
clee704 / convert_css_uri.rb
Created May 14, 2013 00:41
Convert CSS URI values
# Parse CSS URI values according to http://www.w3.org/TR/CSS21/syndata.html#uri
URI_PATTERN = /
url\( # 'url('
[ \t\n\r\f]* # optional white space
(
# double quoted URI
(
(?<quote>") # an optional double quote
(?<str>([^"\\]|\\.)*?) # URI
"
// Stolen from http://stackoverflow.com/a/841121/332370
// Modified so that:
// 1. `end' can be omitted (defaults to the same value as `start').
// 2. -1 means the end of the range.
$.fn.selectRange = function(start, end) {
return this.each(function() {
if (typeof end == "undefined") {
end = start;
}
@clee704
clee704 / korean_error_messages.rb
Created October 31, 2012 17:26
Display proper Korean particles in error messages
# encoding: UTF-8
# Original article: http://dailyupgrade.me/post/6806676778/rubyonrails-full-messages-for-korean
# Modified to support more postpositions and client_side_validations gem.
#
# Add Korean translations like this:
# ko:
# errors:
# format: "%{message}"
# messages:
# blank: "%{attribute}((이)) 입력되지 않았습니다"
@clee704
clee704 / rename-field.py
Created December 31, 2011 17:05
Rename Drupal 7 fields
#! /usr/bin/env python
from datetime import datetime
from StringIO import StringIO
import getpass, os, re, subprocess, sys
import MySQLdb
def main():
if len(sys.argv) != 3: