Skip to content

Instantly share code, notes, and snippets.

// a) As Mac OS X does not have byteswap.h
// needed this for a c util I had used over the years on linux.
// did not find a solution to stopgap via macports, sadly, but this did the trick
#if HAVE_BYTESWAP_H
#include <byteswap.h>
#else
#define bswap_16(value) \
((((value) & 0xff) << 8) | ((value) >> 8))
@atr000
atr000 / gatherFinderWindows.scpt
Created February 10, 2011 04:41
gatherFinderWindows.scpt
tell application "Finder"
-- get desktop dimensions (dw = desktop width; dh = desktop height)
set db to bounds of window of desktop
set {dw, dh} to {item 3 of db, item 4 of db}
end tell
tell application "System Events"
repeat with proc in application processes
tell proc
repeat with win in windows
@atr000
atr000 / findProxy.c
Created February 5, 2011 16:23
findProxy.c
/*
* FindProxies.c
*
* --------------------------------------------------------------------------------------
*
* The contents of this file are subject to the NOKOS License Version 1.0a (the
* "License"); you may not use this file except in compliance with the License.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
#!/usr/bin/env python
# take a screenshot via pyobjc
from AppKit import *
def screenShot(self):
rect = NSScreen.mainScreen().frame()
image = NSImage.alloc().initWithSize_((rect.size.width, rect.size.height
))
window = NSWindow.alloc().initWithContentRect_styleMask_backing_defer_(
rect,
/*
usbdevs - list mounted USB devices & their volume paths on Mac OS X
References:
- http://stackoverflow.com/questions/2459414/osx-how-to-get-a-volume-name-or-bsd-name-from-a-iousbdeviceinterface-or-locati
- http://superuser.com/questions/103755/whats-up-with-stat-on-mac-os-x-darwin-or-filesystems-without-names
- http://stackoverflow.com/questions/1698124/how-to-tell-if-a-given-path-is-mounted-removable-media-in-mac-os-x
- http://developer.apple.com/mac/library/samplecode/VolumeToBSDNode/Introduction/Intro.html
/* keyremap.c
*
* features:
* 1. map lower enter to forward delete key - useful for macbooks
* (works only when secure event input is not activated,
* which happens very rarely, e.g. when password fields are focused)
* 2. send enter key event when right command key is released
* without any other key pressed while it was down
*
* by Bert Mu"nnich, January 2009
@atr000
atr000 / autossh init.d
Created October 24, 2010 18:22
launches and maintains uniquely named autossh tunnels alive
#! /bin/sh
#
# Author: Andreas Olsson <andreas@arrakis.se>
# Version: @(#)autossh_tunnel.foo 0.1 27-Aug-2008 andreas@arrakis.se
#
# For each tunnel; make a uniquely named copy of this template.
## SETTINGS
#
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
<key></key>
<dict>
<key></key>
<string>noop:</string>
<key>$</key>
<string>moveToEndOfLine:</string>
#include <stdio.h>
#include <string.h>
#include <IOKit/hidsystem/IOHIDLib.h>
#include <IOKit/hidsystem/IOHIDParameter.h>
#include <IOKit/hidsystem/event_status_driver.h>
int main(int argc, char **argv)
{
const int32_t accel = -0x10000;
io_connect_t handle = NXOpenEventStatus();
// gcc -framework ApplicationServices testfade.c
#include <stdio.h>
#include <ApplicationServices/ApplicationServices.h>
int main()
{
fprintf(stdout, "Fading to blue...\n");
CGDisplayFadeReservationToken token;