Skip to content

Instantly share code, notes, and snippets.

@advantis
advantis / iOS → Export Groups.jsx
Created April 12, 2012 17:29
Export PS top-level layer groups as PNG images
// enable double clicking from the Macintosh Finder or the Windows Explorer
#target photoshop
const ScriptResult =
{
CANCEL: 'cancel' // quit, returning 'cancel' (dont localize) makes the actions palette not record our script
};
function exportGroups(document, folder, retina)
{
@advantis
advantis / mouse_battery.sh
Created April 12, 2012 17:24
Get Magic Mouse battery level
#!/bin/sh
percentage=$( ioreg -rS -c BNBMouseDevice -k BatteryPercent -d 1 | grep BatteryPercent | tail -1 | awk '{print $NF}' )
if [ "$percentage" == "" ]; then
echo "Disconnected";
else
if ((50 <= percentage)); then
color=32; #green
elif ((20 <= percentage)); then
@advantis
advantis / ADVExecutionTime.h
Created March 30, 2012 10:15
Measure code execution time
//
// Copyright © 2012 Yuri Kotov
//
/*!
@function ADVGetExecutionTime
@abstract Measure code execution time
@param block
code block to execute
@result elapsed time (in nanoseconds)