Skip to content

Instantly share code, notes, and snippets.

View Machx's full-sized avatar

Colin Wheeler Machx

View GitHub Profile

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
function fish_prompt --description 'Write out the prompt'
# Just calculate these once, to save a few cycles when displaying the prompt
if not set -q __fish_prompt_hostname
set -g __fish_prompt_hostname (hostname|cut -d . -f 1)
end
if not set -q __fish_prompt_normal
set -g __fish_prompt_normal (set_color normal)
end
# Mac OS X
*.DS_Store
# Xcode
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
*.xcuserstate
project.xcworkspace/
#include "copyfile.h"
typedef enum {
_NotStarted = 0,
_InProgress,
_Finished,
} _State;
@implementation BAVAppDelegate
{
@Machx
Machx / gist:4392987
Last active December 10, 2015 06:08 — forked from anonymous/gist:4392908
import Cocoa;
export MyFramework.DataStructures;
//Objective-C Modules
@class Queue : NSObject
//implicitly because we are exporting group names we have a "namespace" of sorts
//which is why this class doesn't have a prefix. Since we have modules now @class
//can serve a different purpose than it currently serves
#import <Foundation/Foundation.h>
// Adapted from http://stackoverflow.com/a/11068850
/**
* @brief convert a hexidecimal string to a signed long
* will not produce or process negative numbers except
* to signal error.
*
* @param hex without decoration, case insensative.
*
self.startButton.rac_command = [RACCommand command];
self.stopButton.rac_command = [RACCommand command];
__unsafe_unretained id weakSelf = self;
id<RACSignal> tick = [[[[self.startButton.rac_command
map:^(id _) {
RTAFirstView *strongSelf = weakSelf;
// Map each start button click to a new signal that fires every second
// and stops when the stop button is clicked.
return [[RACSignal interval:1] takeUntil:strongSelf.stopButton.rac_command];
@Machx
Machx / gist:4179161
Created November 30, 2012 22:29
Objc Blocks & C++ auto
// Creating a lambda in C++ with variable type inferred automatically
auto someLambda = [](float w, int x, int y) { return(x); };
// Creating a block in C/ObjC without the use of a typedef -- UGLY
int (^someBlock)(float, int, int) = ^(float w, int x, int y) { return(x); };
// Creating a block in CPP/ObjCPP with variable type inferred automatically -- NOT TOO BAD
auto someBlock = ^(float w, int x, int y) { return(x); };
@Machx
Machx / app_scanner.py
Created October 7, 2012 16:38
Look for iPhone apps that you have in iTunes on your Mac but not installed on any device...
#!/usr/bin/python
import zipfile
import glob
import fnmatch
import sys
import json
import os
import Foundation
@Machx
Machx / gist:1950460
Created March 1, 2012 15:19 — forked from ddribin/gist:1946836
Animating with Autolayout
// Find out where the frames will be with the "after" layout
1. Remove the "before" constraints
2. Add the "after" constraints
3. Call [window layoutIfNeeded], to force the frames to update
4. Grab the frames of all the views I want to animate and save them off
// Go back to what the user sees
5. Remove the "after" constraints
6. Add the "before" constraints
7. Call [window layoutIfNeeded], to force the frames to update