Skip to content

Instantly share code, notes, and snippets.

@PaulChana
PaulChana / ResartPrefsServer.sh
Last active June 6, 2017 08:42
Restart OSX preferences server (forces reload of prefs on app start)
killall cfprefsd
@PaulChana
PaulChana / TerminalTextColour.sh
Last active August 29, 2015 14:23
Colourize text in terminal
function printError
{
# Number after setaf is the colour...
# 0 - black
# 1 - red
# 2 - green
# 3 - yellow
# 4 - blue
# 5 - magenta
# 6 - cyan
@PaulChana
PaulChana / NM.sh
Last active August 29, 2015 14:23
Print binary symbols
nm "PATH TO EXE" > "OUTFILE.txt"
@PaulChana
PaulChana / LastTag.sh
Last active August 29, 2015 14:23
Last tag on git branch
git describe --abbrev=0 --tag
@PaulChana
PaulChana / GitCommitMessages.sh
Last active August 29, 2015 14:23
Git commit messages since tag
git log --pretty=format:%s <LAST_RELEASE>..HEAD
@PaulChana
PaulChana / LineStartsWith.sh
Last active August 29, 2015 14:23
Get lines starting with a string in bash
grep "^String_to_find" "myfile.txt"
# example:
# grep "^Bugfix:" "~/myfile.txt"
# Finds and returns all lines that start with Bugfix:
@PaulChana
PaulChana / NormalDistribution.cpp
Last active August 29, 2015 14:23
C++11 Normal distribution random numbers
#include <random>
std::mt19937 generator;
double mean = 0.0;
double std = 1.0;
std::normal_distribution<double> normal(mean, std);
const double normalNumber = normal(generator);
@PaulChana
PaulChana / OpenURL.m
Last active August 29, 2015 14:23
Open URL
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.google.com"]];
@PaulChana
PaulChana / NSWindowControl.m
Last active August 29, 2015 14:23
Put a control in NSWindow titlebar
NSView *themeFrame = [[mainWindow contentView] superview];
NSRect c = [themeFrame frame];
NSRect aV = [accessoryView frame];
NSRect newFrame = NSMakeRect(c.size.width - aV.size.width,
c.size.height - aV.size.height,
aV.size.width,
aV.size.height);
[accessoryView setFrame:newFrame];
[themeFrame addSubview:accessoryView];
@PaulChana
PaulChana / YosemiteTitlebar.m
Last active August 29, 2015 14:23
Yosemite title bar
window.titleVisibility = NSWindowTitleHidden;