Skip to content

Instantly share code, notes, and snippets.

View nikreiman's full-sized avatar

Nik Reiman nikreiman

  • Stockholm, Sweden
View GitHub Profile
@nikreiman
nikreiman / YourProjectName.cpp
Created December 10, 2010 08:52
Code snippits for a VST plugin written for Windows
#include "YourProjectName.h"
AudioEffect* createEffectInstance(audioMasterCallback audioMaster) {
return new YourProjectName(audioMaster);
}
YourProjectName::YourProjectName(audioMasterCallback audioMaster) : AudioEffectX(audioMaster, 0, NUM_PARAMS) {
}
YourProjectName::~YourProjectName() {
@nikreiman
nikreiman / CallSuspendResume.cpp
Last active September 12, 2019 15:26
Code snippits for creating a VST 2.x plugin host
void resumePlugin(AEffect *plugin) {
dispatcher(plugin, effMainsChanged, 0, 1, NULL, 0.0f);
}
void suspendPlugin(AEffect *plugin) {
dispatcher(plugin, effMainsChanged, 0, 0, NULL, 0.0f);
}
@nikreiman
nikreiman / gen-button-states.sh
Created July 6, 2011 12:05
Generate XML state resources for all graphics in an Android project
#!/bin/sh
# Script to generate XML state files for button images in a project
# This script assumes that you have named your graphics like: button_normal.png, button_pressed.png
function help() {
printf "Usage: %s [Android Sources]\n" $0
exit 1
}
androidSourceRoot=$1
@nikreiman
nikreiman / android-screenshot.sh
Created July 7, 2011 12:38
Take a screenshot of a currently connected Android device to the desktop
#!/bin/bash
# This is a simple script which will take a screenshot from a currently
# connected Android device and dump it to the user's desktop.
# Written by Nik Reiman: nikreiman@shortmail.com
# INSTALLATION:
# For this tool, you will need the Android SDK installed, and you will also
# need to build the Android "screenshot" tool.
#
# To build the screeshot tool, you must download the source by running:
@nikreiman
nikreiman / WithInterfaceAbuse.java
Created August 17, 2011 10:11
Java interface abuse
// Fun trick I've been playing with to replace abstract classes with empty java interfaces.
public class BaseClass {
// stuff ...
}
public class PurpleClass extends BaseClass implements Controller.IsPurple {
// methods ...
}
@nikreiman
nikreiman / gist:1222337
Created September 16, 2011 15:14
Function to view all git commits for a given branch
function git-log-for-branch() {
branch="$1"
git --no-pager log --format=online --no-merges $branch --not \
$(git for-each-ref --format="%(refname)" refs/remotes/origin | \
grep -F -v $branch)
}
@nikreiman
nikreiman / gist:1222474
Created September 16, 2011 16:24
Git safe pull
function git-pull-safe() {
local currentBranch=$(git-branch-current)
local localLastCommit=$(git log --format="%H" $currentBranch | head -1)
local localLastPushCommit="$(git log --format="%H" origin/${currentBranch}.. | tail -n-1)^"
#local remoteLastCommit=$(git log origin/$currentBranch | head -1 | cut -f 2 -d ' ')
git fetch origin $currentBranch
local remoteHeadCommit=$(git log --format="%H" origin/$currentBranch | head -1)
if [ "$remoteHeadCommit" = "$localLastCommit" ] ; then
# Same message as git pull prints in this case
@nikreiman
nikreiman / cowfort.glet
Created November 30, 2011 08:06
GeekTool cowsay fortune geeklet
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Command</key>
<string>$HOME/Dropbox/Nik/Scripts/cowfort</string>
<key>DropShadow</key>
<true/>
<key>FailureImage</key>
<data>
@nikreiman
nikreiman / gist:1408399
Created November 30, 2011 08:06
Unix date formatting cheat sheet
Day
---
%a weekday, abbreviated Tue
%A weekday, full Tuesday
%d day of the month (dd), zero padded 22
%e day of the month (dd) 22
%j day of year, zero padded 001-366
%u day of week starting with Monday (1), i.e. mtwtfss 2
%w day of week starting with Sunday (0), i.e. smtwtfs 2
@nikreiman
nikreiman / gist:1408400
Created November 30, 2011 08:07
Yahoo weather codes
0 tornado
1 tropical storm
2 hurricane
3 severe thunderstorms
4 thunderstorms
5 mixed rain and snow
6 mixed rain and sleet
7 mixed snow and sleet
8 freezing drizzle
9 drizzle