Skip to content

Instantly share code, notes, and snippets.

From http://www.leancrew.com/all-this/2008/05/snapshotupload-utility-with-gui/ On Wednesday, February 11, 2009 2:11:19 PM I have snapftp saved in my ~/Library/Scripts folder where FastScripts can get at it. The Pashua application is saved in /Applications, as expected, and the Pashua.py Python module is saved in /Library/Python/2.5/site-packages. The module has one line that I feel is unwarranted and that I have commented out. Down near the bottom of Pashua.py, is a loop that looks like this:
for Line in Result:
print Line
Parm, Value = Line.split('=')
ResultDict[Parm] = Value.rstrip()
I think a print command in a library utility that is supposed to read lines is just plain wrong, so IÕve commented out the print Line.
-- A function for escaping URLs and skeleton code for a test.
on URLescape(myURL)
set myURL to quoted form of myURL
set myURL to text from character 2 to -2 of myURL
set cmd to "
from urllib import quote
print quote(\"" & myURL & "\", \"/:\")
"
--return cmd
#!/usr/bin/env perl
# Description: http://daringfireball.net/2010/08/open_urls_in_safari_tabs
# License: See below.
# http://gist.github.com/507356
use strict;
use warnings;
use URI::Escape;
#!/usr/bin/env perl
# Description: http://daringfireball.net/2010/08/open_urls_in_safari_tabs
# License: See below.
# http://gist.github.com/507356
use strict;
use warnings;
use URI::Escape;
@drdrang
drdrang / smarten.js
Created November 18, 2010 14:51
A very simple quote and dash smartener in JS. Used to make my tweets look nicer.
// Change straight quotes to curly and double hyphens to em-dashes.
function smarten(a) {
a = a.replace(/(^|[-\u2014/(\[{"\s])'/g, "$1\u2018"); // opening singles
a = a.replace(/'/g, "\u2019"); // closing singles & apostrophes
a = a.replace(/(^|[-\u2014/(\[{\u2018\s])"/g, "$1\u201c"); // opening doubles
a = a.replace(/"/g, "\u201d"); // closing doubles
a = a.replace(/--/g, "\u2014"); // em-dashes
return a
};
@drdrang
drdrang / rss-subscribers.sh
Created September 29, 2012 04:42
Bash script to parse Apache log for a count of RSS subscribers and email it to you
#!/bin/bash
# Schedule this to run once a day with cron. Doesn't matter what time since it parses yesterday's hits (by default).
# I only tested this on the Marco.org server, which runs CentOS (RHEL). No idea how it'll work on other distributions, but it's pretty basic.
# Required variables:
RSS_URI="/rss"
MAIL_TO="[email protected]"
LOG_FILE="/var/log/httpd/access_log"
@drdrang
drdrang / pyplot-contents.html
Created November 28, 2012 01:29
Hyperlinked table of contents for matplotlib's pyplot library.
<html>
<head>
<title>matplotlib.pyplot contents</title>
<style type="text/css">
table {
border-collapse: collapse;
}
table th {
padding: .5em 1em .25em 1em;
@drdrang
drdrang / simple-mathjax.html
Created December 5, 2012 03:27
Simple MathJax example
<html>
<head>
<title>MathJax Test</title>
<meta name="generator" content="BBEdit">
<script type="text/javascript"
src="https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
</head>
<body>
@drdrang
drdrang / Cleanbar.py
Last active July 6, 2017 20:28
Clean up the statusbar of an iOS screenshot. The time in the statusbar is maintained, but all other graphics are stripped out and replaced with graphics that show full battery and signal strength. The cellular provider is replaced with the Apple logo, . All graphics are built into the script, which works for any Retina iOS device in any orienta…
#!/usr/bin/python
import Image
import base64, zlib
# Jay Parlar convinced me to turn this data structure
# from a dictionary into an object.
class PackedImage(object):
def __init__(self, mode, size, data):
self.mode = mode
@drdrang
drdrang / Cleanbar Side by Side.py
Created November 16, 2013 03:32
Create a new image from two screenshots chosen from the Camera Roll. Clean the statusbars of both screenshots using the Cleanbar.py module (https://gist.github.com/drdrang/7365980).
import Image
from Cleanbar import cleanbar
import console, photos
s1 = cleanbar(photos.pick_image())
s2 = cleanbar(photos.pick_image())
w = s1.size[0] + s2.size[0] + 60
h = max(s1.size[1], s2.size[1]) + 40
ss = Image.new('RGB', (w,h), '#888')