Skip to content

Instantly share code, notes, and snippets.

Avatar
🎮

Chris Yip chrisyip

🎮
View GitHub Profile
@chrisyip
chrisyip / copy_iPhoto.rb
Last active Dec 14, 2015
Copy raw photos from iPhoto folder.
View copy_iPhoto.rb
#!/usr/bin/env ruby
# encoding: utf-8
require 'optparse'
require 'fileutils'
def get_photo (path)
photos = []
if File.directory?(path) then
Dir[path + '/*'].each { |path|
@chrisyip
chrisyip / vagrant-lamp.sh
Created May 8, 2013
Vagrant shell script for LAMP.
View vagrant-lamp.sh
#!/usr/bin/env bash
apt-get update
echo mysql-server-5.5 mysql-server/root_password password PASSWORD | debconf-set-selections
echo mysql-server-5.5 mysql-server/root_password_again password PASSWORD | debconf-set-selections
apt-get install -y mysql-common mysql-server mysql-client
apt-get install -y apache2
@chrisyip
chrisyip / base64.js
Created Jun 12, 2013
Base64 Encoder and Decoder shims for client-side. Based on: https://github.com/dankogai/js-base64/
View base64.js
/*
* Base64 Encoder and Decoder shims for client-side.
* Based on: https://github.com/dankogai/js-base64/
*
* Licensed under the MIT license.
* http://opensource.org/licenses/mit-license
*
* References:
* http://en.wikipedia.org/wiki/Base64
*/
View http_request_interceptor.coffee
# http://docs.angularjs.org/api/ng.$http
#
# - display loading effect
# - do other jobs before request start
# - ...
angular
.module('httpRequestServices', [])
.config(['$httpProvider', ($httpProvider) ->
@chrisyip
chrisyip / who_uses_my_ports.sh
Created Dec 16, 2014
List ports being used
View who_uses_my_ports.sh
sudo lsof -i -P | grep -i "listen"
@chrisyip
chrisyip / hosts.rb
Last active Dec 24, 2015
a command line tool to help add / delete / list / search hosts file.
View hosts.rb
#!/usr/bin/env ruby
# encoding: utf-8
require 'optparse'
require 'fileutils'
@options = {}
@hosts_path = '/private/etc/hosts'
OptionParser.new { |opts|
@chrisyip
chrisyip / fluid_gmail.js
Last active Jan 1, 2016 — forked from kirbysayshi/fluid_gmail.js
Gmail Unread Badge for Fluid
View fluid_gmail.js
setTimeout(updateDockBadge, 1000)
setTimeout(updateDockBadge, 3000)
setInterval(updateDockBadge, 5000)
function updateDockBadge() {
var inboxLink = document.querySelector('a[href*="shva=1#inbox"]')
, badge = window.fluid.dockBadge
if (inboxLink && inboxLink.href && inboxLink.href.indexOf('mail.google.com') > -1) {
var match = inboxLink.title.match(/\((\d+)\)$/)
@chrisyip
chrisyip / regex.js
Created Jan 7, 2014
Regex Collection
View regex.js
// 邮箱
/^(?:[a-z0-9]+[_\-+.]?)*[a-z0-9]+@(?:([a-z0-9]+-?)*[a-z0-9]+.)+([a-z]{2,})+$/i
// 手机:13012345678 - 19012345678
/^1[3-9]\d{9}$/
// 座机:02012345678、020-12345678、020 12345678、12345678,1234567
/^(?:((?:0\d{2,3}[- ]?)?[1-9]\d{6,7})|(?:[48]00[- ]?[1-9]\d{6}))$/
@chrisyip
chrisyip / modify.sh
Created Jan 20, 2014
Modify committer and author information in Git
View modify.sh
git filter-branch -f --env-filter "GIT_AUTHOR_NAME=''; GIT_AUTHOR_EMAIL=''; GIT_COMMITTER_NAME=''; GIT_COMMITTER_EMAIL='';" HEAD
@chrisyip
chrisyip / wechat-fluid-badge.js
Last active Jan 6, 2016
Add badge for WeChat w/ Fluid
View wechat-fluid-badge.js
setInterval(updateDockBadge, 500)
function updateDockBadge() {
var dots = document.querySelectorAll('.nav_view .chat_item .avatar .web_wechat_reddot_middle')
var badge = [].reduce.call(dots, function(pv, cv) {
var badge = Math.floor(cv.textContent)
if (isNaN(badge)) {
return 0