Skip to content

Instantly share code, notes, and snippets.

View gsong's full-sized avatar

George Song gsong

View GitHub Profile
@gsong
gsong / gist:1851146
Created February 17, 2012 06:13
AppleScript to start/stop CrashPlan
log "Deciding what to do with CrashPlan…"
set isCrashPlanRunning to false
try
set pid to do shell script "sudo launchctl list | grep com.crashplan.engine" ¬
user name "@{admin_user}" password "@{admin_password}" ¬
with administrator privileges
set isCrashPlanRunning to true
end try
@gsong
gsong / gist.rb
Created February 29, 2012 04:52
Liquid Gist tag for use in Jekyll
require 'cgi'
require 'open-uri'
# Require the ActiveSupport::Cache module
require 'active_support/cache'
module Fiftyfive
module Liquid
class GistTag < ::Liquid::Tag
def initialize(tag_name, gist_ref, tokens)
@gsong
gsong / net.damacy.releasemem.plist
Created March 17, 2012 18:02
LaunchAgent to release inactive memory on OS X 10.7
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>net.damacy.releasemem</string>
<key>ProgramArguments</key>
<array>
<string>/Users/george/.bin/releasemem.py</string>
</array>
@gsong
gsong / gist:6321633
Last active February 4, 2022 12:06
Bash script to generate SSL csr/key/crt
#!/bin/bash
# Usage:
#
# ssl_setup [--self] <name> <csr_config>
#
# This script is used to generate key and CSR for use HTTPS in Nginx.
#
# --self Generate self-signed certificate in addition to key and CSR.
# name Output files will be named as <name>.key and <name>.csr.
@gsong
gsong / ThreadedSceneDemo.py
Last active December 21, 2015 23:48
Pythonista demo of a single worker thread which polls a website for updates and displays the result in `Scene.draw`.
from datetime import datetime
import Queue
import re
import threading
import urllib2
from scene import *
OUTPUT_TEMPLATE = u"""\
Number of threads: {}
# Source: https://gist.github.com/4702275
#
# All-purpose gist tool for Pythonista.
#
# When run directly, this script sets up four other scripts that call various
# functions within this file. Each of these sub-scripts are meant for use as
# action menu items. They are:
#
# Set Gist ID.py - Set the gist id that the current file should be
# associated with.
@gsong
gsong / tm-last-backup.py
Last active December 26, 2015 14:19
Python script to return the last successful Time Machine backup timestamp.
#!/usr/bin/env python
from datetime import timedelta, tzinfo
from shlex import split
from subprocess import Popen, PIPE
import os
import plistlib
ZERO = timedelta(0)
NOT_ENABLED = u'Not enabled.'
@gsong
gsong / epo_ops_test.py
Last active August 29, 2015 14:07
Test to validate python-epo-ops-client
import platform
import epo_ops
registered_client = epo_ops.RegisteredClient(
key='h07O7iAKj3stHFjGCAZSgFhPHIwDmTqE',
secret='QjzSphsngYD55em0'
)
@gsong
gsong / gifting
Last active December 11, 2016 21:05
Christmas gift exchange
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from random import sample
# people grouped together cannot gift to each other
people = [
('Sue', 'Sam'),
('Heather', 'Matt'),
('Noelle', 'George'),
@gsong
gsong / brew-config.log
Last active May 7, 2017 14:05
`brew install highlight` error
HOMEBREW_VERSION: 1.2.0-50-g3e4547f5
ORIGIN: https://github.com/Homebrew/brew
HEAD: 3e4547f52e7ebec633f8bfefc8a396d944edf908
Last commit: 52 minutes ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 9c4f788f512c3fdb9f83dace59b2194a778c13bd
Core tap last commit: 12 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_REPOSITORY: /usr/local/Homebrew
HOMEBREW_CELLAR: /usr/local/Cellar