Skip to content

Instantly share code, notes, and snippets.

float actual_usage(pth_t thread)
{
float p_run_time = (float)clock() / 100000;
long t_run_time = thread->running.tv_sec;
return (t_run_time/p_run_time) * 100;
}
float target_usage()
{
return 100/(pth_ctrl(PTH_CTRL_GETTHREADS_NEW) + 1);
<!DOCTYPE html>
<html>
<head>
<title>{Title}</title>
<meta name="color:Background" content="#FFFFFF"/>
<meta name="color:Link" content="#000000"/>
<meta name="font:Text" content="Helvetica"/>
<meta name="viewport" content="width= 600">
<link rel="shortcut icon" href="{Favicon}"/>
#!/bin/bash
# Gives you a Growl notification telling you details about the currently playing track in iTunes.
artist=`osascript -e 'tell application "iTunes" to artist of current track as string'`;
track=`osascript -e 'tell application "iTunes" to name of current track as string'`;
album=`osascript -e 'tell application "iTunes" to album of current track as string'`;
/usr/local/bin/growlnotify -t "Currently Playing" -m "Artist: $artist
Track: $track
#!/bin/bash
# Turns an mp3 file into an iPhone ringtone file.
if [ $1 = "-help" ]; then
echo "
Usage:
iprc -help | before_file after_file
Arguments:
# Globals
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
### Basic Conversion Functions
def letterToNumber(letter):
"""
Returns the number (0-25) equivalent of a letter.
"""
#!/usr/bin/env python
# TextExpander Snippet for turning a Flickr photo URL on the clipboard into a shortened Flickr URL.
# Just make a new snippet in TextExpander, select "Shell Script" from the "Content" pull-down,
# and paste this code in.
from subprocess import Popen, PIPE, STDOUT
import sys
def getLongID(url):
# I have this on my server so that I can find out the size of any remote file just by SSHing into my server and running this script.
import urllib2
import sys
url = sys.argv[1]
usock = urllib2.urlopen(url)
size = usock.info().get('Content-Length')
if size is None:
size = 0
#!/usr/bin/env python
#I have this as a [TextExpander][1] snippet for naming things "randomly."
#So I type "rstr" (without quotes, duh) anywhere in OS X and I get a random 24-character string.
#
#[1]: http://www.smileonmymac.com/TextExpander/index.html
import random
import sys
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']