Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View csu's full-sized avatar

Christopher Su csu

  • San Francisco, CA
View GitHub Profile
@csu
csu / serialwrite.py
Created August 31, 2012 16:06
Write to serial with Python
#!/usr/bin/python
import serial
ser = serial.Serial('/dev/tty.usbmodem621', 9600)
ser.write('1')
@csu
csu / creationdater.sh
Created August 31, 2012 16:17
Copy creation dates of files from a mirror directory
# Part of the txt-to-dayone repository: https://github.com/christophersu/txt-to-dayone
IFS=$'\n'
files=$(ls | egrep '(.txt)')
for i in $files; do
#get original creation dates
original=$( GetFileInfo -d "$i" )
#change the creation date of the same file in the destination
if [ -e "/Users/christophersu/Desktop/test/$i" ]; then
SetFile -d "$original" "/Users/christophersu/Desktop/test/$i"
@csu
csu / import.sh
Created August 31, 2012 16:18
Import all txt files in a directory into Day One
# Part of the txt-to-dayone repository: https://github.com/christophersu/txt-to-dayone
IFS=$'\n'
files=$(ls | egrep '(.txt)')
for i in $files; do
created=$( GetFileInfo -d "$i" )
dayone -d="$created" new < "$i"
done
unset IFS
@csu
csu / latestgrowl.sh
Created September 1, 2012 01:23
Retrieve latest entries from Growl history
#!/bin/bash
sqlite3 /Users/christophersu/Library/Application\ Support/Growl/notifications.history "SELECT ZTITLE FROM ZNOTIFICATION" | tail -5
@csu
csu / gist:3616693
Created September 4, 2012 04:48
homebrew fail :(
Last login: Tue Sep 4 12:43:23 on ttys000
csu:~ christophersu$ brew pip Glances
==> pip install glances==1.4 --install-option=--prefix=/usr/local/Cellar/glances/1.4
==> Build Environment
HOMEBREW_VERSION: 0.9.3
HEAD: 7053db47f7f62e8d88238ffc8b56b5059364add6
CPU: 8-core 64-bit ivybridge
OS X: 10.8.1-x86_64
Xcode: 4.4.1
@csu
csu / bits.php
Created September 17, 2012 12:01
Bits WordPress Page Template
<?php
/*
Template Name: Bits
*/
get_header(); ?>
<?php
query_posts('cat=13');
while ( have_posts() ) : the_post(); ?>
@csu
csu / gist:5252291
Created March 27, 2013 06:55
Interactive Data Map iFrames
<iframe name="mapframe" id="mapframe" src="http://18069595.nhd.weebly.com/files/theme/mapframe.html" height=400 width=58%></iframe>
<iframe name="dataframe" id="dataframe" src="http://18069595.nhd.weebly.com/files/theme/dataframe.html" height=400 width=40%></iframe>
@csu
csu / gist:5252295
Last active December 15, 2015 11:19
Link to control iFrame
<a href="/files/theme/map_guangdong.html" TARGET="dataframe" id="rectangle11">
@csu
csu / gist:5252298
Created March 27, 2013 06:57
Embedding PDF documents using Google Docs
<iframe src="http://docs.google.com/gview?url=http://18069595.nhd.weebly.com/files/theme/dikotter-transcript.pdf&embedded=true" style="width:900px; height:900px;" frameborder="0"></iframe>
#!/usr/bin/env python
import urllib2
import pinboard
pinuser = raw_input('Pinboard username: ')
pinpasswd = raw_input('Pinboard password: ')
oldtag = raw_input('Tag to rename: ')
newtag = raw_input('Rename tag to: ')