Skip to content

Instantly share code, notes, and snippets.

@yinghau76
yinghau76 / mount-aosp
Created January 27, 2014 15:48
Mount Android image on Mac
hdiutil attach ~/android.dmg.sparseimage -mountpoint /Volumes/android
@yinghau76
yinghau76 / fixairplay
Created January 27, 2014 15:44
Restart coreaudiod so that Airplay Device can be selected.
sudo kill `ps -ax | grep 'coreaudiod' | grep 'sbin' |awk '{print $1}'`
@yinghau76
yinghau76 / pyg.sh
Created October 19, 2013 04:32
Format Ruby code with Pygments and copy to clipboard on Mac OS X
pygmentize -f rtf -O "style=monokai,fontface=Menlo" -l ruby | pbcopy
@yinghau76
yinghau76 / ruby-module.rb
Created October 19, 2013 04:29
Ruby module idiom
module Yaffle
def self.included(base)
base.send :extend, ClassMethods
end
module ClassMethods
def acts_as_something
send :include, InstanceMethods
end
end
@yinghau76
yinghau76 / cleanup-dup-open-with.sh
Last active December 25, 2015 22:39
Clean-up duplicated 'Open With ...' on Mac OS X
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain system -domain user
@yinghau76
yinghau76 / build.gradle
Last active December 17, 2015 15:29
My first gradle build script
// With Gradle 1.6
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
@yinghau76
yinghau76 / root_controller.rb
Created March 24, 2013 17:24
random_pragmatic_tip
require 'open-uri'
class RootController < ApplicationController
def index
@tip = random_pragmatic_tip.html_safe
end
private
def random_pragmatic_tip
@yinghau76
yinghau76 / macros.rb
Created November 20, 2012 18:49
Add html macro to insert raw html
desc "Insert HTML"
macro :html do |obj, args, text|
return raw text
end
@yinghau76
yinghau76 / term.rb
Created September 1, 2012 18:21
Coderay scanner for terminal commands
module CodeRay
module Scanners
# Scanner for terminal commands
class Term < Scanner
register_for :term
protected
@yinghau76
yinghau76 / gist:3396798
Created August 19, 2012 18:05
Setup java6 in Ubuntu 12.04
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_33/bin/javac 1
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_33/bin/java 1
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_33/bin/java 1
sudo update-alternatives --config javac
sudo update-alternatives --config java
sudo update-alternatives --config javaws