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 the UNIX timestamp from the ASP.NET JSON-serialised DateTime | |
* | |
* @param d - a string in the format /Date(1331127585489)/ | |
* @return UNIX timestamp extracted from d, or zero | |
* @see http://www.hanselman.com/blog/OnTheNightmareThatIsJSONDatesPlusJSONNETAndASPNETWebAPI.aspx | |
* for possible changes to the way DateTime objects are serialised to JSON | |
* | |
* Example usage: | |
* var jsonDateTime = '/Date(1331127585489)/'; |
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
# From https://github.com/tpope/vim-pathogen with .vim replaced with vimfiles | |
mkdir -p ~/vimfiles/autoload ~/vimfiles/bundle; \ | |
curl -so ~/vimfiles/autoload/pathogen.vim \ | |
https://raw.github.com/tpope/vim-pathogen/HEAD/autoload/pathogen.vim | |
# Install some plugins | |
cd ~/vimfiles/bundle | |
git clone git://github.com/scrooloose/nerdtree.git | |
git clone git://github.com/msanders/snipmate.vim.git |
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
""" proxy.py | |
Wires up a proxy server so you can access URL's via Python. | |
Based on this answer from Stack Overflow: http://stackoverflow.com/a/35443 | |
TODO: | |
1. use proper command line args via optparse / OptionParser | |
""" | |
import urllib2 |
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
!!! 5 | |
%html | |
%head | |
%title Example HAML | |
/[if IE] | |
%link{ :rel => "stylesheet", :href => "/css/ie.css" } | |
%body | |
#container | |
%header | |
%h1 Our Awesome HTML5 Template |
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
// Edited / adapted from http://forum.jquery.com/topic/jquery-validate-comma-seperated-multiple-emails-validation#14737000002179275 | |
jQuery.validator.addMethod("multiemail", function (value, element) { | |
if (this.optional(element)) { | |
return true; | |
} | |
var emails = value.split(','), | |
valid = true; | |
for (var i = 0, limit = emails.length; i < limit; i++) { |
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
""" base58 encoding / decoding functions """ | |
import unittest | |
alphabet = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ' | |
base_count = len(alphabet) | |
def encode(num): | |
""" Returns num in a base58-encoded string """ | |
encode = '' | |
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
SELECT 'ALTER TABLE [' + TABLE_SCHEMA + '].[' + TABLE_NAME + '] ALTER COLUMN [' + COLUMN_NAME + '] nvarchar(' + CAST(CHARACTER_MAXIMUM_LENGTH As NVARCHAR) + ');' | |
FROM INFORMATION_SCHEMA.COLUMNS | |
WHERE DATA_TYPE = 'VARCHAR'; |
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
function formutils_form_alter(&$form, &$form_state, $form_id) { | |
if (is_array($form['submitted'])) { | |
foreach ($form['submitted'] as $field) { | |
if (!$field['#required']) { | |
$currentTitle = $field['#title']; | |
$field['#title'] = $currentTitle . ' (optional)'; | |
} | |
} | |
} | |
} |
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
# Copy a file's contents to the clipboard | |
cat filename | xclip -sel clip | |
# Generate a random password | |
date | md5sum |
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
if (self != top) { | |
document.documentElement.style.visibility = 'hidden'; | |
top.location = self.location; | |
} |