Skip to content

Instantly share code, notes, and snippets.

@dmdeller
dmdeller / 1_before.m
Last active August 29, 2015 13:57
Trying to avoid having ugly weakBlah variables all over the place to avoid retain cycles (or at least having to look at them)
__weak __typeof__(foo) weakFoo = foo;
foo.block = ^
{
[weakFoo doSomething];
};
@dmdeller
dmdeller / gist:ad8a1d76bb00e3784820
Last active August 29, 2015 14:04
Import seeds into Core Data
#pragma mark - Core Data
- (void)setupCoreData
{
[MagicalRecord setupAutoMigratingCoreDataStack];
if (SearchEngine.MR_countOfEntities == 0)
{
[self importSeeds];
}
@dmdeller
dmdeller / gulpfile.js
Created August 8, 2014 21:02
My Gulpfile, based on generator-gulp-webapp, with added Coffee and options.
'use strict';
// generated on 2014-08-08 using generator-gulp-webapp 0.1.0
var gulp = require('gulp');
// load plugins
var $ = require('gulp-load-plugins')();
var mainBowerFiles = require('main-bower-files');
// config
@dmdeller
dmdeller / gist:4c71027faf8a0f45db30
Created August 15, 2014 17:25
Uninstall all ruby gems
for gem in $(gem list | cut -d" " -f1); do gem uninstall -aIx $gem; done
<?php
preg_match_all('/<img src="([^"]+)_SM.jpg"/i', file_get_contents($argv[1]), $matches);
foreach ($matches[1] as $key => $match)
{
$infile = $match.'_BG.jpg';
if ($data = file_get_contents($infile))
{
#!/usr/bin/env php
<?php
# execute as nightly cronjob
# redirect to /dev/null if you don't want get mailed errors because WoW is running
# use with Elephant (or similar) addon that automatically enables writing to WoWChatLog.txt
$source_path = "/Applications/Games/World of Warcraft/Logs";
$dest_path = '/Users/david/Documents/Logs/WoW';
<?php
/**
* reorders an array based on the specified order of keys.
*
* @param array $array the array that should be reordered
* @param array $order the order that the keys in the first array should be in. each value should be a key from the first array. any elements from the first array that are not specified in the order will be inserted at the end of the returned array, in their original order.
*
* @return array
*/
#!/usr/bin/env bash
# config
date=`date "+%Y-%m-%d"`
git_binary=/usr/local/bin/git
# repositories in /git, space-separated.
repos="foo.git bar.git"
<?php
/**
* get current git revision
*/
if (sfConfig::get('sf_environment') != 'prod' && file_exists(sfConfig::get('sf_root_dir').'/../.git/logs/HEAD'))
{
$fp = fopen(sfConfig::get('sf_root_dir').'/../.git/logs/HEAD', 'r');
$pos = -2; $line = ''; $c = '';
#!/bin/bash
# Apple has informed me that you should not use Time Machine for backing up a server.
# (Why it remains an option in System Preferences, despite not working correctly, is a mystery to me.)
# For further information, see Advanced_Server_Admin_v10.6.pdf, page 36.
# If you still want this script for some reason, see past revisions.