Skip to content

Instantly share code, notes, and snippets.

View yangchenyun's full-sized avatar

Steven Yang yangchenyun

View GitHub Profile
@yangchenyun
yangchenyun / .osx
Created November 4, 2011 17:12 — forked from paulstefanort/.osx
Mac OS X Lion Modifications
# Originally from https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Enable the 2D Dock
defaults write com.apple.dock no-glass -bool true
# Disable menu bar transparency
defaults write -g AppleEnableMenuBarTransparency -bool false
# Expand save panel by default
defaults write -g NSNavPanelExpandedStateForSaveMode -bool true
@creationix
creationix / about.md
Created November 21, 2012 19:21
Parts of a stream interface

The Basics

Every stream has two basic parts

  • data-in - A chunk or EOF enters the stream
  • data-out - A chunk or EOF leaves the stream

I'm combining both "data" and "end" events since "end" is just a special data packet signifying the end of the stream.

Flow Control

@jehiah
jehiah / dailyphoto.sh
Last active January 15, 2016 20:08
A script to use isightcapture to take photos via crontab on OSX. crontab: `*/10 * * * * sh bin/take_dailyphoto.sh`
#!/bin/sh
# This script takes a photo if the computer has not been idle for longer than a period of time
# it uses isightcapture from https://www.macupdate.com/app/mac/18598/isightcapture
[ -z "$USER" ] && echo "missing variable \$USER " && exit 1
if [ ! -d /Users/$USER/daily_photo ]; then
mkdir -p $/Users/$USER/daily_photo
fi
IDLE=$((`/usr/sbin/ioreg -c IOHIDSystem | sed -e '/HIDIdleTime/!{ d' -e 't' -e '}' -e 's/.* = //g' -e 'q'` / 1000000000 ))
export SUDO_ASKPASS=/Users/$USER/bin/get_pass.sh
@rielz
rielz / dom4.webidl
Last active December 6, 2016 05:56
DOM4 WebIDL
// Extracted from http://www.w3.org/TR/dom/
// Copyright © 2015 W3C® (MIT, ERCIM, Keio, Beihang).
// Some Rights Reserved: this document is dual-licensed, CC-BY and W3C Document License.
// W3C liability, trademark and document use rules apply.
exception DOMException {
const unsigned short INDEX_SIZE_ERR = 1;
const unsigned short DOMSTRING_SIZE_ERR = 2; // historical
const unsigned short HIERARCHY_REQUEST_ERR = 3;
const unsigned short WRONG_DOCUMENT_ERR = 4;
@rklemme
rklemme / album.rb
Created October 24, 2009 17:58
Complete file for blog entry "The Complete Class"
require 'yaml'
Track = Struct.new :title, :duration
# An Album represents an audio medium which has title,
# interpret, a pause duration between tracks and a list
# of individual tracks.
class Album
attr_reader :title, :interpret, :pause
@oubiwann
oubiwann / 01-setup.sh
Last active November 11, 2018 13:56 — forked from digego/keynote.scm
Instructions for Running Andrew Sorensen's OSCON 2014 Keynote Performance
$ git clone https://gist.github.com/8b4404e538e61c7996a5.git
$ cd 8b4404e538e61c7996a5
$ mkdir salamander && cd salamander
$ curl -L -O https://archive.org/download/SalamanderDrumkit/salamanderDrumkit.tar.bz2
$ curl -L -O https://github.com/johnsen/drumsandpercussion/blob/master/SalamanderKick/salamanderdrum-kick-r1.tar.gz
$ curl -L -O http://freepats.zenvoid.org/Piano/SalamanderGrandPianoV3_44.1khz16bit.tar.bz2
$ tar xvfz salamanderDrumkit.tar.bz2
$ tar xvfz salamanderdrum-kick-r1.tar.gz
$ mv Kick/kick* OH/
$ tar xvfz SalamanderGrandPianoV3_44.1khz16bit.tar.bz2
@dansimpson
dansimpson / twilight_pygments.css
Created January 30, 2011 16:57
Pygments stylesheet based on Textmates's Twilight theme
pre.code { background: #181818; padding: 16px; color: #F8F8F8; font-family: Consolas, Monaco,"Lucida Console"; }
pre.code * { font-family: Consolas, Monaco,"Lucida Console"; }
pre.code .hll { background-color: #ffffcc }
pre.code .c { color: #5F5A60; font-style: italic } /* Comment */
pre.code .err { border:#B22518; } /* Error */
pre.code .k { color: #CDA869 } /* Keyword */
pre.code .cm { color: #5F5A60; font-style: italic } /* Comment.Multiline */
pre.code .cp { color: #5F5A60 } /* Comment.Preproc */
pre.code .c1 { color: #5F5A60; font-style: italic } /* Comment.Single */
pre.code .cs { color: #5F5A60; font-style: italic } /* Comment.Special */

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.

Variables

@lucasfais
lucasfais / gist:1207002
Created September 9, 2011 18:46
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@kujohn
kujohn / portforwarding.md
Last active April 27, 2024 20:16
Port forwarding in Mavericks

Port Forwarding in Mavericks


Since Mavericks stopped using the deprecated ipfw (as of Mountain Lion), we'll be using pf to allow port forwarding.

####1. anchor file Create an anchor file under /etc/pf.anchors/<anchor file> with your redirection rule like: