Skip to content

Instantly share code, notes, and snippets.

def awakeFromNib
@menu = NSMenu.alloc.initWithTitle("Main Menu")
@status_bar = NSStatusBar.systemStatusBar
@status_item = @status_bar.statusItemWithLength(NSVariableStatusItemLength)
@status_item.setHighlightMode(true)
@status_item.setMenu(@menu)
@app_icon = NSImage.imageNamed('iplayer_logo_small_black.tiff')
@app_icon_alt = NSImage.imageNamed('iplayer_logo_small_white.tiff')
// Check that you have a minimum amount of disk space free on an iPhoneOS device
- (BOOL)hasDiskSpaceAvailable {
NSUInteger minimumDiskSpace = 400 * 1024 * 1024; // 400MB limit
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
struct statfs tStats;
statfs([[paths lastObject] cString], &tStats);
@nickludlam
nickludlam / When is Easter?
Created April 15, 2011 18:12
Pseudo code to calculate when Easter falls. From http://www.smart.net/~mmontes/nature1876.html
a=year%19
b=year/100
c=year%100
d=b/4
e=b%4
f=(b+8)/25
g=(b-f+1)/3
h=(19*a+b-d-g+15)%30
i=c/4
k=c%4
@nickludlam
nickludlam / gist:1399857
Created November 28, 2011 10:09
bitbake crash
nick@ubuntu:/mnt/disk2/koan/angstrom/setup-scripts$ MACHINE=at91sam9g20ek ./oebb.sh bitbake console-image
Configured layers:
layer repository name: bitbake
layer uri: git://github.com/openembedded/bitbake.git
layer branch/revision: master/HEAD
Updating layer at layers/bitbake
Current branch 1.12 is up to date.
Layers present in repository:
@nickludlam
nickludlam / gist:4468122
Created January 6, 2013 16:00
A MacRuby subclass of NSWindow which will fade away when closed
class FadeWindow < NSWindow
def fadeInAndMakeKeyAndOrderFront(orderFront)
self.setAlphaValue(0);
if orderFront
self.makeKeyAndOrderFront(nil)
end
self.animator.setAlphaValue(1.0)
end
@nickludlam
nickludlam / gist:4510674
Created January 11, 2013 13:31
A dump of the serial console output while booting a Miniand mk803 Android on Arm stick computer
0x000000bb
00=0x00000000
01=0x00000000
02=0x00000320
03=0x00000180
04=0x000002ee
05=0x00000000
06=0x00000000
07=0x000000bb
08=0x00000000
@nickludlam
nickludlam / gist:4666172
Last active December 11, 2015 21:58
A section of my .profile which puts the running VM count into the prompt.
function parse_vagrant_vms {
# Use sed to strip out the whitespace, can't seem to get wc to give nice formatting standalone
# Thanks to @pkqk for showing me the speedy 'VBoxManage' command
local vm_count=$(VBoxManage list runningvms | wc -l | sed 's/^ *//; s/; */;/g')
# I use curly braces to mean vm count, edit to taste
if [ $vm_count -eq 1 ]; then
echo "{${vm_count}vm}"
fi
if [ $vm_count -gt 1 ]; then
echo "{${vm_count}vms}"
@nickludlam
nickludlam / install.bat
Created June 25, 2013 09:05
This script is designed to accelerate your local workflow when working on ArmA3 content via git
:: install.bat
::
:: This script has two functions, and is designed to allow easy development
:: of your ArmA3 mission from within a git repository clone
::
:: 'install.bat test' - Copies the mission to your local MPMissions folder
:: 'install.bat package' - Compiles a PBO for testing with a standlone server
::
:: Nick Ludlam 15/7/2013
@nickludlam
nickludlam / gist:5904971
Created July 1, 2013 21:53
Fatigue system for ArmA3
#ifdef __RUNNING_FATIGUE__
private["_cumulativePlayerFatigue", "_maxEntries", "_sleepInterval", "_fatigueRecoveryLevel", "_fatigueWarningThreshold", "_fatigueExhaustionThreshold", "_extraThirstDecrement", "_tiredEffectApplied", "_exhaustedEffectApplied", "_msg"];
[] spawn {
//diag_log format ["DEBUG: Starting fatigue checks"];
// We sample every _sleepInterval, and keep _maxEntries samples in total. An average is calculated,
// and then we determine if its over _fatigueWarningLevel or _fatigueExhaustionThreshold
@nickludlam
nickludlam / gist:6287823
Last active December 21, 2015 09:49
My mods to DynamicWeatherEffects by Engima
/* DynamicWeatherEffects.sqf version 1.01 by Engima of Ostgota Ops
* Description:
* Script that generates dynamic (random) weather. Works in single player, multiplayer (hosted and dedicated), and is JIP compatible.
* Arguments:
* [_initialFog]: Optional. Fog when mission starts. Must be between 0 and 1 where 0 = no fog, 1 = maximum fog. -1 = random fog.
* [_initialOvercast]: Optional. Overcast when mission starts. Must be between 0 and 1 where 0 = no overcast, 1 = maximum overcast. -1 = random overcast.
* [_initialRain]: Optional. Rain when mission starts. Must be between 0 and 1 where 0 = no rain, 1 = maximum rain. -1 = random rain. (Overcast must be greater than or equal to 0.75).
* [_initialWind]: Optional. Wind when mission starts. Must be an array of form [x, z], where x is one wind strength vector and z is the other. x and z must be greater than or equal to 0. [-1, -1] = random wind.
* [_debug]: Optional. true if debug text is to be shown, otherwise false.
*/