Skip to content

Instantly share code, notes, and snippets.

@toulouse
toulouse / User.scala
Created May 7, 2011 09:11
How to parse JSON into a case class in Scala
package models
import controllers.FacebookApp
import dispatch.json._
import helpers.LogHelper
import org.joda.time._
import org.joda.time.format._
import play.db.anorm._
import play.db.anorm.defaults._
import play.libs.WS
@toulouse
toulouse / LICENSE.md
Created May 11, 2012 04:13
Hack around collapsed tab dropdown selection bug in ICS and ActionBarSherlock

Boilerplate

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

TL;DR

Assume this code is public domain or something similarly permissive.

@toulouse
toulouse / sshtutorial.md
Created October 25, 2012 17:17
SSH Tutorial

I noticed some people were typing a lot just to ssh. This can be a pain, so for those who don't already know, here's how you use SSH fast and effectively. These instructions primarily apply to *nix systems. Specifically, I saw Angie was typing more than she needed and I offered to email helpful instructions.

Part 1: Getting Started

In your home directory, there will be a .ssh directory. This directory is where most of our magic will happen.

If you don't have one, go to your home directory and make the directory. Go ahead and cd into it.

[toulouse@myhomecomputer:~]% cd ~
[toulouse@myhomecomputer:~]% mkdir .ssh

[toulouse@myhomecomputer:~]% cd ~/.ssh

@toulouse
toulouse / ATScrollDirectionProxy.h
Created May 7, 2013 07:07
Augments a UITableViewDelegate to let you detect which direction a UITableView has been scrolled.
// Created by Andrew Toulouse on 5/6/13.
// Copyright (c) 2013 Andrew Toulouse. All rights reserved.
#import <Foundation/Foundation.h>
typedef NS_ENUM(NSUInteger, ATScrollDirection) {
ATScrollDirectionUp,
ATScrollDirectionDown
};
@toulouse
toulouse / gist:6836071
Created October 5, 2013 02:47
That's because you're doing it wrong
@class X
@interface Y : NSObject
@property (nonatomic, assign) int z;
- (int)times:(int)other;
- (int)timesX:(X *)xObject;
@end
@implementation Y
class action_disabler {
BOOL previousValue;
action_disabler(){
previousValue = [CATransaction disableActions];
[CATransaction setDisableActions:YES];
}
~action_disabler() {
[CATransaction setDisableActions:previousValue];
@toulouse
toulouse / main.cpp
Last active December 27, 2015 17:59
#include <iostream>
class BlahClass {
public:
BlahClass() {
std::cout << "BlahClass()" << std::endl;
}
~BlahClass() {
std::cout << "~BlahClass()" << std::endl;
}
@toulouse
toulouse / .vimrc
Created April 15, 2014 18:33
Some useful vimrc settings
""" Settings
imap \ymd <C-R>=strftime("%Y.%m.%d")
imap \date <C-R>=strftime("%c")
imap \vimss :s/\s\+$//<CR>i
set nocompatible " Don't care about vi compatibility
set backupdir=~/.vim/backup " Backup - specify directory
set directory=~/.vim/backup
set backup
//
// Foo.h
// InternCheck
//
// Created by Andrew Toulouse on 5/23/14.
// Copyright (c) 2014 Andrew Toulouse. All rights reserved.
//
#import <Foundation/Foundation.h>
@toulouse
toulouse / xcptool.py
Created August 23, 2014 06:22
Messing around with Xcode functions in PyObjC
#!/usr/bin/env python -i
import objc
import os
DVTFoundation = objc.loadBundle('DVTFoundation', globals(), "/Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework")
CSServiceClient = objc.loadBundle("CSServiceClient", globals(), "/Applications/Xcode.app/Contents/SharedFrameworks/CSServiceClient.framework")
IDEFoundation = objc.loadBundle("IDEFoundation", globals(), "/Applications/Xcode.app/Contents/Frameworks/IDEFoundation.framework")
Xcode3Core = objc.loadBundle('Xcode3Core', globals(), "/Applications/Xcode.app/Contents/PlugIns/Xcode3Core.ideplugin")