Skip to content

Instantly share code, notes, and snippets.

@andrewytliu
andrewytliu / README.md
Last active August 29, 2015 14:04
dx - easy tool for changing long directory path

dx - easy tool for changing long directory path

Install

Put dx to $PATH, and add d function to your shell configuration (bash or fish).

Usage

~/some/long/path $ dx add sc
~/some/long/path $ dx ls
@andrewytliu
andrewytliu / config.fish
Last active February 19, 2020 10:26
RVM fish fix
# in ~/.config/fish/config.fish
# Load the default rubies
if test -z $rvm_bin_path
exec bash --login -c "exec fish" ^&1
end
@andrewytliu
andrewytliu / home.html
Created June 16, 2013 14:46
Websocket chatroom in Go
<html>
<head>
<title>HashGreen</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
var conn, msg = $("#msg"), log = $("#log");
$("#form").submit(function() {
if (!conn) return false;
@andrewytliu
andrewytliu / tagging.py
Last active December 11, 2015 18:19
Fixing encoding problem in Google Music
#!/usr/bin/env python
from gmusicapi.api import Api
from getpass import getpass
class Tagging:
def __init__(self):
self.api = Api()
logged_in = False
@andrewytliu
andrewytliu / Gemfile
Created May 3, 2012 08:38
CCSP 2012 Checkin
# Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.3'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'rest-graph'
gem 'rest-client'
gem 'json'
@andrewytliu
andrewytliu / gist:2405981
Created April 17, 2012 13:31
Rails setup
gem install bundler
gem install rails
rails new blog
cd blog
bundle install
@andrewytliu
andrewytliu / fiber.rb
Created April 4, 2012 02:38
Mutex with fiber: segfault under 1.9.2
m = Mutex.new
i = [0]
a = Fiber.new do
t = nil
m.synchronize { t = i[0] }
Fiber.yield
m.synchronize { i[0] = t + 1 }
end
b = Fiber.new do
t = nil
@andrewytliu
andrewytliu / gist:1946506
Created March 1, 2012 01:41
2012 CCSP schedule
3/1
HTML, CSS, Layout
3/8
HTML, CSS, Layout
Project teams
HW1: CSS
DUE 3/20
@andrewytliu
andrewytliu / app.rb
Created December 16, 2011 16:39
sinatra with rest-graph
require "sinatra"
require "rest-graph"
enable :sessions
# set :raise_errors, false
# set :show_exceptions, false
FACEBOOK_SCOPE = 'read_stream'
unless ENV["FACEBOOK_APP_ID"] && ENV["FACEBOOK_SECRET"]
@andrewytliu
andrewytliu / crash.rb
Created December 4, 2011 15:08
CRASH + HACKER = REBOOT
# CRASH
# +HACKER
# -------
# REBOOT
#
for vector in (0..9).to_a.permutation
a,b,c,e,h,k,o,r,s,t = vector
next if c == 0 or h == 0 or r == 0