Skip to content

Instantly share code, notes, and snippets.

View markembling's full-sized avatar

Mark Embling markembling

View GitHub Profile
mark@silicon:~$ sudo pip install blinkstick
Downloading/unpacking blinkstick
Downloading BlinkStick-0.7.0.tar.gz
Running setup.py egg_info for package blinkstick
Downloading/unpacking grapefruit==0.1a3 (from blinkstick)
You are installing an externally hosted file. Future versions of pip will default to disallowing externally hosted files.
You are installing a potentially insecure and unverifiable file. Future versions of pip will default to disallowing insecure files.
Downloading grapefruit-0.1a3.tar.gz (194kB): 194kB downloaded
Running setup.py egg_info for package grapefruit
@markembling
markembling / .bash_profile
Created September 6, 2009 15:03
My preferred prompt for Bash (inc. Git info)
# Function for determining current git branch (if any)
# Gracefully fails if not in a git repo and returns nothing.
__gitBranch() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo ${ref#refs/heads/}
}
# Retrieves status information for git and places into predefined variables.
__gitStatus() {
# Initialise git status variables
@markembling
markembling / gist:207757
Created October 11, 2009 17:10
Symlink your Powershell profile to a folder within your dropbox
mklink /D ".\WindowsPowershell" ".\My Dropbox\PowershellProfile"
// Gets all items more expensive than £5.
var q = mongoContext.Query<Item>()
.Where(x => x.Price)
.IsGreaterThan(5);
// Gets all Smiths in the given cities.
var q2 = mongoContext.Query<Customer>()
.Where(x => x.Name).IsEqualTo("Smith")
.Where(x => x.City).IsIn("Bournemouth","Farnborough","London");
@markembling
markembling / MongoUtils.ps1
Created April 9, 2010 18:02
Utility functions for MongoDB
# Start the MongoDB server running (foreground)
function Start-MongoD {
$dropBox = (Resolve-Path '~\Documents\My Dropbox').Path
$mongoConfig = "$dropBox\Software\MongoDB\mongo.conf"
$mongoData = "$dropBox\Software\MongoDB\data\"
& $dropBox\Software\MongoDB\bin\mongod.exe --config "'$mongoConfig'" --dbpath "'$mongoData'"
}
# Start the MongoDB client app
@markembling
markembling / .gitignore
Created November 8, 2010 11:00
.gitignore file for .NET projects
[Bb]in
[Oo]bj
*.suo
TestResult.xml
*.sln.cache
*.[Rr]e[Ss]harper.user
_ReSharper*
*.csproj.user
@markembling
markembling / gist:769462
Created January 7, 2011 13:43
Dynamically create and submit a form.
// This would (does) work in proper browsers.
jQuery(createElement('form'))
.attr({'method':'post','action':/*some url*/})
.submit();
// IE needs it to be attached to the document somewhere first before submission will work. :(
var f = jQuery(createElement('form'))
.attr({'method':'post','action':/*some url*/});
jQuery('body').append(f);
f.submit();
@markembling
markembling / gist:1080247
Created July 13, 2011 12:56
Date/time JSON serialisation in Ruby
irb(main):004:0> require 'json'
=> true
irb(main):005:0> data = { "timestamp" => Time.new }
=> {"timestamp"=>2011-07-13 13:55:29 +0100}
irb(main):006:0> json = data.to_json
=> "{\"timestamp\":\"2011-07-13 13:55:29 +0100\"}"
irb(main):007:0> deserialised = JSON.parse json
=> {"timestamp"=>"2011-07-13 13:55:29 +0100"}
irb(main):008:0> deserialised["timestamp"].class
=> String
@markembling
markembling / gist:1101174
Created July 23, 2011 08:09
Tweaked version of jsgauge to use requestAnimationFrame
/*
* Jsgauge 0.4.1
* http://code.google.com/p/jsgauge/
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
* Tweaked by Mark Embling (http://markembling.info/) to use requestAnimationFrame instead of setTimeout.
*/
/*jslint browser: true */
# 'git status' alias function
function gs {
git status $args
}