Skip to content

Instantly share code, notes, and snippets.

@simme
simme / gcd.m
Created April 20, 2011 12:21
Loading images async with GCD
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
NSString *tweetText = [_tweet valueForKey:@"text"];
NSString *userName = [_tweet valueForKeyPath:@"user.name"];
NSString *userDescription = [_tweet valueForKeyPath:@"user.description"];
NSNumber *friends = [_tweet valueForKeyPath:@"user.friends_count"];
NSNumber *followers = [_tweet valueForKeyPath:@"user.followers_count"];
@simme
simme / async_loading.m
Created April 20, 2011 12:59
Loading with NSOperation instead
- (id)initWithCoder:(NSCoder *)aDecoder
{
if ((self = [super initWithCoder:aDecoder])) {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
// Load the data
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
NSOperationQueue *main = [NSOperationQueue mainQueue];
NSBlockOperation *fetchStreamOperation = [[NSBlockOperation alloc] init];
[fetchStreamOperation addExecutionBlock:^{
NSLog(@"Getting data");
@simme
simme / _mixins.sass
Created May 25, 2011 12:20
SASS Mixins
// Rounds all the corners of a box
@mixin border-radius($radius, $clip: padding-box)
-webkit-border-radius: $radius
-moz-border-radius: $radius
-o-border-radius: $radius
border-radius: $radius
-webkit-background-clip: $clip
-mox-background-clip: $clip
-o-background-clip: $clip
background-clip: $clip
@simme
simme / l.aliases.drushrc.php
Created October 3, 2011 13:18
Drush automagic site aliases
<?php
/**
* @file
* Setup site aliases for local sites.
*
* Expects the following setup:
* SITES_DIR/
* site.local/public_html
* site2.local/public_html
*
@simme
simme / Install_tmux
Created October 19, 2011 07:55
Install and configure tmux on Mac OS X
# First install tmux
brew install tmux
# For mouse support (for switching panes and windows)
# Only needed if you are using Terminal.app (iTerm has mouse support)
Install http://www.culater.net/software/SIMBL/SIMBL.php
Then install https://bitheap.org/mouseterm/
# More on mouse support http://floriancrouzat.net/2010/07/run-tmux-with-mouse-support-in-mac-os-x-terminal-app/
@simme
simme / install-drupal.sh
Created October 27, 2011 14:11
Download and install Drupal 'n stuff
#!/bin/bash
SITES_DOMAIN="simme"
# # # # # # # # # # # # # # # # # # # # # # #
E_BADARGS=65
if [ ! -n "$1" ]
then
echo "Usage: `basename $0` sitename"
@simme
simme / module.js
Created May 15, 2012 10:06
Module pattern thingy
var ModuleName = (function ($) {
// Constructor
var module = function () {
// to stuff when "new" is called on us
};
// Say hello
module.prototype.say = function (name) {
alert('Hello ' + name);
};
@simme
simme / module.js
Created May 15, 2012 10:06
Module pattern thingy
var ModuleName = (function ($) {
// Constructor
var module = function () {
// to stuff when "new" is called on us
};
// Say hello
module.prototype.say = function (name) {
alert('Hello ' + name);
};
@simme
simme / drupal_table_pager.php
Created August 23, 2012 11:51
Drupal table with pager from db_select()
<?php
/**
* Display point award report.
*
* Generates a list of awarded points.
*
* @return array $content
*/
function game_report_page_points() {
// For some mysterious reason only parts of the db_select API is chainable.
@simme
simme / .vimrc
Created September 3, 2012 13:30
Find TODOs in custom Drupal modules
" use <leader>df to find all TODO's in custom Drupal modules
noremap <leader>df :noautocmd vimgrep /TODO/j sites/all/modules/custom/**/*.{php,inc,install,module,js,sass,scss,css,coffee}<CR>:cw<CR>