Skip to content

Instantly share code, notes, and snippets.

@ianoxley
ianoxley / multiemail.js
Created August 1, 2011 14:35
jQuery Validation Plugin: Multiple Email Address Validation
// 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++) {
@ianoxley
ianoxley / example.html.haml
Created August 15, 2011 20:06
Example code for my Introduction to Haml article on RubySource.com
!!! 5
%html
%head
%title Example HAML
/[if IE]
%link{ :rel => "stylesheet", :href => "/css/ie.css" }
%body
#container
%header
%h1 Our Awesome HTML5 Template
@ianoxley
ianoxley / proxy.py
Created December 7, 2011 16:24
Access URL's from behind a proxy in Python
""" 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
@ianoxley
ianoxley / install_pathogen.sh
Created December 19, 2011 10:35
Install pathogen.vim on Windows
# 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
@ianoxley
ianoxley / dateutils.js
Created March 7, 2012 13:41
JavaScript function to parse an ASP.NET JSON-serialised DateTime and extract the UNIX timestamp
/**
* 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)/';
@ianoxley
ianoxley / Config.cs
Created March 7, 2012 17:38
A dynamic config object to access <appSettings>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Dynamic;
using System.Collections.Specialized;
namespace Ox.Models
{
@ianoxley
ianoxley / console.xml
Created March 16, 2012 16:15
Console2 settings file
<?xml version="1.0"?>
<settings>
<console change_refresh="10" refresh="100" rows="25" columns="80" buffer_rows="500" buffer_columns="0" shell="" init_dir="" start_hidden="0" save_size="0">
<colors>
<color id="0" r="0" g="0" b="0"/>
<color id="1" r="0" g="0" b="128"/>
<color id="2" r="0" g="150" b="0"/>
<color id="3" r="0" g="150" b="150"/>
<color id="4" r="170" g="25" b="25"/>
<color id="5" r="128" g="0" b="128"/>
@ianoxley
ianoxley / AssemblyInfo.cs
Created May 21, 2012 08:11
Code snippets for the Albacore article
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyCompany("ACME")]
[assembly: AssemblyProduct("AlbacoreDemo")]
[assembly: AssemblyCopyright("Wile E. Coyote")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@ianoxley
ianoxley / canvas_transform.html
Created June 28, 2012 15:38
Canvas transformations demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Canvas Transforms</title>
<style>
canvas {
border:1px solid #ccc;
}
</style>
#!/usr/bin/env python
""" Script that prints out tomorrow's weather forecast, using the Yahoo Weather API.
You'll need to get your location's WOEID, which you can get from entering your
location in the form on http://weather.yahoo.com/ - currently where it says
'Enter city of zip code'.
The WOEID numerical id will be in the URL of the page you get redirected to
after submitting the form e.g. in the URL
http://weather.yahoo.com/united-kingdom/england/newcastle-upon-tyne-30079/ the