Skip to content

Instantly share code, notes, and snippets.

@ssherar
ssherar / gist:1920814
Created February 27, 2012 02:14
Curl command to debug Jetpack
curl -i -L --data "test" 'https://jetpack.wordpress.com/jetpack.register/1' > ~/curlError.txt
Simulator run Thu May 02 23:00:19 BST 2013
uk.ac.aber.rcs.cs211.schedulersim.scheduler.FirstComeFirstServed
DataFile name: /Users/sam/repos/cs211/schedulers/code/bin/Test.jobs
CPU2:1 13
CPU1:2 37
CPU3:2 56
MIXED1:2 63
IO1:3 75
Mean elapsed duration 48
Total CPU time 75
@ssherar
ssherar / item.php
Last active December 20, 2015 07:49 — forked from anonymous/gist:6096170
<?php
//retrieve the id from the GET variable
$ref = $_GET['ref'];
//Why do all the work if $ref is empty?!
// I think a redirect to index should be good enough
if($ref == NULL || count($ref) == 0) {
"<meta http-equiv='refresh' content='0; url=index.php' />";
}
@ssherar
ssherar / json.vbs
Created August 23, 2013 14:19 — forked from atifaziz/json.vbs
'==========================================================================
' JSON Encoder for VBScript
' Copyright (c) 2013 Atif Aziz. All rights reserved.
'
' Licensed under the Apache License, Version 2.0 (the "License");
' you may not use this file except in compliance with the License.
' You may obtain a copy of the License at
'
' http://www.apache.org/licenses/LICENSE-2.0
'
/**
* A generic javascript validator, which uses html elements such as
* a data-set or classes.
*
* Author: Sam Sherar <sbs1@aber.ac.uk>
*
* Class selectors:
* - required
* Make sure that the field not empty
* - numeric
(00) Emergency treatment of poisoning
(01) GASTRO-INTESTINAL SYSTEM
(01.01) Dyspepsia and gastro-oesophageal reflux disease
(01.01.01) Antacids and Simeticone
(01.01.01) -- magnesium trisilicate (Firstline - green)
(01.01.01) -- aluminium&magnesium hydroxide (Firstline - green)
(01.01.02) Compound alginates and proprietary indigestion preparations
(01.01.02) -- Gastrocote (Firstline - green)
(01.01.02) -- Gaviscon Advance (Firstline - green)
(01.01.02) -- Gaviscon Infant (Firstline - green)
/Users/sambuca/Documents/diss/formulary/Vendor/Nimble/Nimble/Matchers/BeLessThan.swift:32:53: error: expected type after 'as'
let expr = actualExpression.cast { $0 as! NMBComparable? }
^
/Users/sambuca/Documents/diss/formulary/Vendor/Nimble/Nimble/Matchers/Contain.swift:64:43: error: expected type after 'as'
return contain(expected as! String).matches(expr, failureMessage: failureMessage)
^
/Users/sambuca/Documents/diss/formulary/Vendor/Nimble/Nimble/Matchers/Contain.swift:64:43: error: expected ',' separator
return contain(expected as! String).matches(expr, failureMessage: failureMessage)
^
,
@ssherar
ssherar / UIColorFromRGB.swift
Last active April 18, 2017 21:05
UIColorFromRGB - adapted from http://stackoverflow.com/a/12397366 for Swift
/**
Returns a UIColor object from a Hexadecimal string with a solid colour
i.e.
UIColorFromRGB("#FF0000") == UIColor.redColor()
UIColorFromRGB("#0000FF") == UIColor.blueColor()
UIColorFromRGB("#GGGGGG") == UIColor.blackColor()
UIColorFromRGB("#Hello") == UIColor.blackColor()
@ssherar
ssherar / fade.swift
Created March 6, 2015 15:31
Swift - fading the navigationBar to a colour
import UIKit
/// Won't work - will expand the colour from Left hand corner out
self.navigationController?.navigationBar.barTintColor = nil
UIView.animateWithDuration(1.0) {
self.navigationController?.navigationBar.barTintColor = UIColor.blueColor()
}
///Works
self.navigationController?.navigationBar.barTintColor = UIColor.whiteColor()
def logs(self):
log_path = git.refs.RefLog.path(self.repo.head)
logs = git.refs.RefLog.from_file(log_path)[-5:]
for log in logs:
yield log.time[0], log.message