Skip to content

Instantly share code, notes, and snippets.

@jehiah
jehiah / activity_snapshot.sh
Created January 7, 2013 18:43
A cron job script to capture computer activity every 30 seconds
#!/bin/sh
# computer activity data collection for http://jehiah.cz/one-two/
# by Jehiah Czebotar
FILE="activity_log/`date +%Y%m%d`.log"
function log_activity()
{
local UTC=`date "+%s,%Z"`
local IDLE=$((`/usr/sbin/ioreg -c IOHIDSystem | sed -e '/HIDIdleTime/!{ d' -e 't' -e '}' -e 's/.* = //g' -e 'q'` / 1000000000 ))
@jehiah
jehiah / dailyphoto.sh
Last active January 15, 2016 20:08
A script to use isightcapture to take photos via crontab on OSX. crontab: `*/10 * * * * sh bin/take_dailyphoto.sh`
#!/bin/sh
# This script takes a photo if the computer has not been idle for longer than a period of time
# it uses isightcapture from https://www.macupdate.com/app/mac/18598/isightcapture
[ -z "$USER" ] && echo "missing variable \$USER " && exit 1
if [ ! -d /Users/$USER/daily_photo ]; then
mkdir -p $/Users/$USER/daily_photo
fi
IDLE=$((`/usr/sbin/ioreg -c IOHIDSystem | sed -e '/HIDIdleTime/!{ d' -e 't' -e '}' -e 's/.* = //g' -e 'q'` / 1000000000 ))
export SUDO_ASKPASS=/Users/$USER/bin/get_pass.sh
@jehiah
jehiah / iphone_messages_dump.py
Last active September 28, 2020 03:53
Script to dump out messages to csv from an iPhone Backup sqlite file
# Copyright Jehiah Czebotar 2013
# http://jehiah.cz/
import tornado.options
import glob
import os
import sqlite3
import logging
import datetime
import csv
@jehiah
jehiah / go.spec
Created October 10, 2012 17:13
golang specfile for CentOS 5.x and RHEL5
# Specfile for go used @ bitly for CentOS 5.*, RHEL5
%define name go-devel
%define path /usr/local
%define version go1.0.2
%define release 13
%define group Development/Languages
%define __os_install_post %{nil}
Name: %{name}
@jehiah
jehiah / test_shell_scripts.sh
Created September 15, 2012 02:14
bash shell script syntax checking
#!/bin/sh
#
# This is a script to run syntax check (via `sh -n $filename`) but it
# supports recursive checking and --quiet
QUIET=0
while [ "$1" != "" ]; do
PARAM=`echo $1 | awk -F= '{print $1}'`
VALUE=`echo $1 | awk -F= '{print $2}'`
case $PARAM in
@jehiah
jehiah / strange_bash_feature.sh
Created May 22, 2012 21:17
Weird (annoying) feature of bash
#!/bin/bash
COUNT=1
FILE=$0
# run this script with bash
# i bet you can't predict the outcome
function printsleep {
echo COUNT=$(( COUNT++ ))
echo printsleep >> $FILE
@jehiah
jehiah / increment_build_number.sh
Created December 6, 2011 03:37
Auto-increment build number script for Xcode
TARGET="$PROJECT_DIR/project/Info.plist"
echo $TARGET
if [ ! -f "$TARGET" ]; then
echo "missing file $TARGET"
exit 1;
fi
# the perl regex splits out the last part of a build number (ie: 1.1.1) and increments it by one
# if you have a build number that is more than 3 components, add a '\.\d+' into the first part of the regex.
@jehiah
jehiah / AppDelegate.h
Created December 5, 2011 04:16
Example for building an OSX app with Chameleon UIKit
#import <Cocoa/Cocoa.h>
#import <UIKit/UIKit.h>
@class ChameleonAppDelegate;
@interface AppDelegate : NSObject <NSApplicationDelegate> {
@private
NSWindow *window;
IBOutlet UIKitView *chameleonNSView;
ChameleonAppDelegate *chameleonApp;
}
@jehiah
jehiah / git-branch-status
Last active March 21, 2024 12:39
show git ahead/behind info for branches
moved to github --> https://github.com/bill-auger/git-branch-status/
@jehiah
jehiah / simulate_memcached.py
Created August 20, 2011 01:43
test script to simulate a partially reachable memcached instance
#!/bin/env python
"""
This is a test script to simulate a memcached instance on a server
that has gone south and is accepting connections, but generally not
responding.
The goal of this script is to help test/develop correct client
side settings for timeouts/failure scenarios