View offscreen_preload.js
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
window.onload = function(){ | |
var doc = document | |
, img = doc.createElement('img') | |
, div = doc.createElement('div') | |
, body = doc.getElementsByTagName('body')[0]; | |
img.className = 'preload'; | |
img.style.cssText = ';position:absolute;top:-999em;left:-999em;width:0;height:0;visibility:hidden;'; | |
// ajax loaded or predefined img list | |
var arr = imgList | |
, str |
View append-css-link-or-rule.js
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
// create a <link> with specific URL | |
var addLink = function(url){ | |
var link = document.createElement('link'); | |
link.src = url; | |
link.rel = 'stylesheet'; | |
link.type = 'text/css'; // no need for HTML5 | |
document.getElementsByTagName('head')[0].appendChild(link); // for IE6 | |
}; | |
// create a style that can append CSS rules to <head> |
View Monokai.tmTheme
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>name</key> | |
<string>Monokai</string> | |
<key>settings</key> | |
<array> | |
<dict> | |
<key>settings</key> |
View clone_anythings.js
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
// http://davidwalsh.name/javascript-clone | |
function clone(src) { | |
function mixin(dest, source, copyFunc) { | |
var name, s, i, empty = {}; | |
for(name in source){ | |
// the (!(name in empty) || empty[name] !== s) condition avoids copying properties in "source" | |
// inherited from Object.prototype. For example, if dest has a custom toString() method, | |
// don't overwrite it with the toString() method that source inherited from Object.prototype | |
s = source[name]; | |
if(!(name in dest) || (dest[name] !== s && (!(name in empty) || empty[name] !== s))){ |
View Date Validation Expression.js
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
var re = /^(\d{4})[-\/\.]{0,1}(?:(?:(11|0?[469])[-\/\.]?([12]\d|30|0?[1-9]))|(?:(1[02]|0?[13578])[-\/\.]{0,1}([1-2]\d|3[01]|0?[1-9]))|(?:(0?2)[-\/\.]{0,1}(2[1-9]|1\d|0?[1-9])))$/; | |
// test | |
[ | |
// valid dates | |
'2012-4-21', | |
'2012-04-21', | |
'2012-5-1', | |
'2012-05-31', | |
'2012-11-21', |
View copy_iPhoto.rb
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 | |
# encoding: utf-8 | |
require 'optparse' | |
require 'fileutils' | |
def get_photo (path) | |
photos = [] | |
if File.directory?(path) then | |
Dir[path + '/*'].each { |path| |
View vagrant-lamp.sh
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 bash | |
apt-get update | |
echo mysql-server-5.5 mysql-server/root_password password PASSWORD | debconf-set-selections | |
echo mysql-server-5.5 mysql-server/root_password_again password PASSWORD | debconf-set-selections | |
apt-get install -y mysql-common mysql-server mysql-client | |
apt-get install -y apache2 |
View base64.js
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
/* | |
* Base64 Encoder and Decoder shims for client-side. | |
* Based on: https://github.com/dankogai/js-base64/ | |
* | |
* Licensed under the MIT license. | |
* http://opensource.org/licenses/mit-license | |
* | |
* References: | |
* http://en.wikipedia.org/wiki/Base64 | |
*/ |
View http_request_interceptor.coffee
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
# http://docs.angularjs.org/api/ng.$http | |
# | |
# - display loading effect | |
# - do other jobs before request start | |
# - ... | |
angular | |
.module('httpRequestServices', []) | |
.config(['$httpProvider', ($httpProvider) -> |
View hosts.rb
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 | |
# encoding: utf-8 | |
require 'optparse' | |
require 'fileutils' | |
@options = {} | |
@hosts_path = '/private/etc/hosts' | |
OptionParser.new { |opts| |
OlderNewer