Skip to content

Instantly share code, notes, and snippets.

View tmdvs's full-sized avatar
🔆
making cool stuff with cool people

Tim Davies tmdvs

🔆
making cool stuff with cool people
View GitHub Profile
alias ls='ls -gFh'
# MacPorts Installer addition on 2010-10-11_at_11:46:41: adding an appropriate $
export PATH=/usr/local/bin:/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
export GREP_OPTIONS='--color=auto'
export CLICOLOR=1;
function git-branch() {
@tmdvs
tmdvs / gist:3603700
Created September 2, 2012 19:34
Help my broken brains
The following doesnt work for some reason and it's really hurting my brains.
The variables contents are:
===========================
myString = <script src="/mint/?js" type="text/javascript">
matchedString = ?js"
I'm finding the range:
======================
NSRange matchRange = [[myString string] rangeOfString:matchedString options:NSLiteralSearch];
[[self layer] setMasksToBounds:YES];
[[self layer] setShadowColor:[[UIColor blackColor] CGColor]];
[[self layer] setShadowOffset:CGSizeMake(0, 0)];
[[self layer] setShadowOpacity:1];
[[self layer] setShadowRadius:4.0];
[[self layer] setBackgroundColor:[[UIColor clearColor] CGColor]];
/**
* Live updating API JS client side class
* @author Tim Davies
*/
function liveupdatingClient (container)
{
/**
* Set up, include handlebars and setup template
*/
var endpoint = 'liveupdating.php';
@tmdvs
tmdvs / null
Created September 26, 2012 16:11
<?PHP
function sortPins (&$array, $key) {
$sorterArray = array();
$ret=array();
reset($array);
foreach ($array as $ii => $va)
$sorterArray[$ii]=$va[$key];
int64_t delayInSeconds = 2.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
<#code to be executed on the main queue after delay#>
});
// Do something in the background and then when done call something on the main thread
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
Handlebars.registerHelper('set', function(name, value) {
Handlebars.registerHelper(name, function() {
return value;
});
});
/* usage */
{{ set "foo" "bar" }}
class User extends Base
{
public static $table = 'users';
public static $rules = array('email' => 'required|email|unique:users','password' => 'required',);
}
/**
* Handle the dynamic retrieval of attributes and associations.
*
* @param string $key
* @return mixed
*/
public function __get($key)
{
// Lets check if the model has a function for this first
if(method_exists($this, $key))