Skip to content

Instantly share code, notes, and snippets.

@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 / base58.py
Created March 11, 2011 14:00
base58 encoding in Python
""" base58 encoding / decoding functions """
import unittest
alphabet = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'
base_count = len(alphabet)
def encode(num):
""" Returns num in a base58-encoded string """
encode = ''
@ianoxley
ianoxley / smokeonthewater.py
Created August 21, 2012 17:56
Smoke on the Water for Lego Mindstorms
#!/usr/bin/env python
#
# Smoke on the water by Deep Purple, for the Lego Mindstorms
#
# Note frequencies worked out as follows:
# A = 440
# Notes above A = A * (1.059463)^ no. of steps above A
# Notes below A = A * (1.059463)^ -no. of steps below A
#
@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 / ctags definitions for Javascript
Last active June 9, 2017 12:59 — forked from tim-smart/ctags definitions for Javascript
CTags Definitions for Javascript
--langdef=js
--langmap=js:.js
--regex-js=/(,|(;|^)[ \t]*(var|let|const|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*\{/\5/,object/
--regex-js=/(,|(;|^)[ \t]*(var|let|const|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*function[ \t]*\(/\5/,function/
--regex-js=/(,|(;|^)[ \t]*(var|let|const|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*\[/\5/,array/
--regex-js=/(,|(;|^)[ \t]*(var|let|const|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*[^"]'[^']*/\5/,string/
--regex-js=/(,|(;|^)[ \t]*(var|let|const|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*(true|false)/\5/,boolean/
--regex-js=/(,|(;|^)[ \t]*(var|let|const|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*[0-9]+/\5/,number/
--regex-js=/(,|(;|^)[ \t]*(var|let|const|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Za-z0-9_$]+)[ \t]*=[ \t]*.+([,;=]|$)/\5/,variable/
--regex-js=/(,|(;|^)[ \t]*(var|let|const|([A-Za-z_$][A-Za-z0-9_$.]+\.)*))[ \t]*([A-Z
#!/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
using System;
using System.Data;
using System.IO;
using System.Text;
using System.Web;
using System.Web.Mvc;
public sealed class CsvActionResult : FileResult
{
private readonly DataTable _dataTable;
#!/usr/bin/bash
# Favicon and Apple Touch Icon Generator
#
# This bash script takes an image as a parameter, and uses ImageMagick to convert it to several
# other formats used on modern websites. The following copies are generated:
#
# * apple-touch-icon-144x144-precomposed.png
# * apple-touch-icon-114x114-precomposed.png
# * apple-touch-icon-57x57-precomposed.png
:-webkit-full-screen .gist {
overflow-y:auto;
}
@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>