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 / gist:b40b46b5634a0288f845
Created July 12, 2015 02:49
get all repo ssh_urls
REPOLIST=`curl --silent https://api.github.com/users/csu/repos -q | grep "\"ssh_url\"" | awk -F': "' '{print $2}' | sed -e 's/",//g'`
@csu
csu / gist:7b605646bf686218878d
Created July 12, 2015 02:50
clone all repos
#!/bin/bash
GIT_CLONE_CMD="git clone --quiet --mirror --recursive "
REPOLIST=`curl --silent https://api.github.com/users/csu/repos -q | grep "\"ssh_url\"" | awk -F': "' '{print $2}' | sed -e 's/",//g'`
for REPO in $REPOLIST; do
${GIT_CLONE_CMD}${REPO}
done
@csu
csu / gist:99ba5c637cb40ff50f90
Created October 3, 2015 19:49
recursively unzip all zip archives in a directory and its subdirectories
find . -name "*.zip" | while read filename; do unzip -o -d "`dirname "$filename"`" "$filename"; done;
@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 / 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 / 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 / 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(); ?>
var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0)),l=d.location,e=encodeURIComponent,p='"'+((e(s))?e(s):e(document.title))+'" '+e(l.href);window.open('http://circular.io/?p='+p);