Skip to content

Instantly share code, notes, and snippets.

Avatar

Christopher Su csu

View GitHub Profile
@csu
csu / serialwrite.py
Created Aug 31, 2012
Write to serial with Python
View serialwrite.py
#!/usr/bin/python
import serial
ser = serial.Serial('/dev/tty.usbmodem621', 9600)
ser.write('1')
@csu
csu / creationdater.sh
Created Aug 31, 2012
Copy creation dates of files from a mirror directory
View creationdater.sh
# 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 Aug 31, 2012
Import all txt files in a directory into Day One
View import.sh
# 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 Sep 1, 2012
Retrieve latest entries from Growl history
View latestgrowl.sh
#!/bin/bash
sqlite3 /Users/christophersu/Library/Application\ Support/Growl/notifications.history "SELECT ZTITLE FROM ZNOTIFICATION" | tail -5
@csu
csu / gist:3616693
Created Sep 4, 2012
homebrew fail :(
View gist:3616693
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 Sep 17, 2012
Bits WordPress Page Template
View bits.php
<?php
/*
Template Name: Bits
*/
get_header(); ?>
<?php
query_posts('cat=13');
while ( have_posts() ) : the_post(); ?>
@csu
csu / gist:5252291
Created Mar 27, 2013
Interactive Data Map iFrames
View gist:5252291
<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 Dec 15, 2015
Link to control iFrame
View gist:5252295
<a href="/files/theme/map_guangdong.html" TARGET="dataframe" id="rectangle11">
@csu
csu / gist:5252298
Created Mar 27, 2013
Embedding PDF documents using Google Docs
View gist:5252298
<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>
View rename_pinboard_tag.py
#!/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: ')
You can’t perform that action at this time.