Skip to content

Instantly share code, notes, and snippets.

View markembling's full-sized avatar

Mark Embling markembling

View GitHub Profile
@markembling
markembling / index.php
Created May 5, 2012 16:01
Allow the PHP 5.4 built-in web server to serve a Zend Framework application.
cd path/to/project/public
php -S localhost:8080 index.php
# 'git status' alias function
function gs {
git status $args
}
@markembling
markembling / gist:1104836
Created July 25, 2011 18:42
A small ruby script which basically spams an MQTT broker.
require 'mqtt/client'
mqtt = MQTT::Client.new('10.25.2.4')
loop do
mqtt.connect do |c|
c.publish('test/foo/bar','this is a test message #{Time.now}')
puts "published a msg"
@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 */
@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: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 / .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 / 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
// 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 / gist:207757
Created October 11, 2009 17:10
Symlink your Powershell profile to a folder within your dropbox
mklink /D ".\WindowsPowershell" ".\My Dropbox\PowershellProfile"