Skip to content

Instantly share code, notes, and snippets.

#!/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']
# 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
# 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):
# 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.
"""
#!/bin/bash
# Turns an mp3 file into an iPhone ringtone file.
if [ $1 = "-help" ]; then
echo "
Usage:
iprc -help | before_file after_file
Arguments:
#!/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
<!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}"/>
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);
@scottjacksonx
scottjacksonx / TypoTextExpander
Created April 20, 2011 16:19
Shawn and Patrick asked about a TextExpander thing, and then I made it.
#!/usr/bin/env python
# coding: utf-8
import random
# Instructions: this is a TextExpander snippet. Copy and paste all of this (starting with #!/usr and
# ending with "— Shawn") as the content of a new snippet in TextExpander. Then, set the content of the
# snippet to "Shell Script".
# This is the list of sentences. Add as many as you want. Just write sentences.append("your sentence here") on
@scottjacksonx
scottjacksonx / stylesheet.css
Created November 29, 2011 05:03
My modified of Brent Simmons's “Ballard” NetNewsWire style. I like smaller text when I'm on my 13" MacBook.
body {
color: #333;
font-size: 14px;
line-height: 1.4em;
font-family: Palatino, Georgia, serif;
background-color: #fff;
margin: 0px;
}
a {
text-decoration: none;