Skip to content

Instantly share code, notes, and snippets.

View yangchenyun's full-sized avatar

Steven Yang yangchenyun

View GitHub Profile
require 'delegate'
class A
end
class B < SimpleDelegator
def initialize(obj)
super(obj)
end
@yangchenyun
yangchenyun / karma-e2e.conf.js
Created August 8, 2013 08:39
karma-e2e.conf.js
'use strict';
// Karma E2E configuration
module.exports = function (config) {
config.set({
// base path, that will be used to resolve files and exclude
basePath: '',
// list of files / patterns to load in the browser
# https://gist.github.com/f75759a3f97fadffe6aa
:host = http://127.0.0.1:4444/wd/hub
GET :host/status
########################
# Session/Browser API
########################
@yangchenyun
yangchenyun / fetch_kindle.js
Last active February 19, 2023 10:10
Get back my books from Kindle
/*
* @fileoverview Program to free the content in kindle books as plain HTML.
*
* This is largely based on reverse engineering kindle cloud app
* (https://read.amazon.com) to read book data from webSQL.
*
* Access to kindle library is required to download this book.
*/
// The Kindle Compression Module copied from http://read.amazon.com application
@yangchenyun
yangchenyun / tty2gif.py
Last active May 3, 2016 23:22
tty2gif.py
#!/usr/bin/env python
"""Script to convert ttyrec file to gifs on OSX with Terminal.app."""
import argparse
import os
import sys
import struct
import glob
import time
import subprocess
(defun yangchenyun-org/post-init-org ()
;; Disable whitespace-mode highlighting
(message "post init org is executed")
(with-eval-after-load 'org
(progn
(defvar org-dir "~/Dropbox/.org")
(setq org-bullets-bullet-list '("■" "◆" "▲" "▶"))
(setq org-directory (expand-file-name org-dir)
org-agenda-files (list (concat org-dir "/plans.org")
(concat org-dir "/work.org")
@yangchenyun
yangchenyun / index.js
Last active December 7, 2016 03:43
sw-benchmark.js
window.benchmark = function() {
const countSet = [
1, 10, 100, 1000
];
const cookie = "__utma=27069237.741610204.1414116129.1427060728.1427929525.10; __utmc=27069237; EXPERIMENTS_EXCLUSIVE_OPTIN=False; wide=1; llbcs=2;";
const msgSet = [
undefined,
@yangchenyun
yangchenyun / 1.js
Last active December 15, 2016 23:06
firebase-handle-oauth
_handleOauth(e, detail) {
const systemErrorCodes = [
'auth/auth-domain-config-required',
'auth/operation-not-allowed',
'auth/operation-not-supported-in-this-environment',
'auth/timeout',
];
const userErrorCodes = [
'auth/account-exists-with-different-credential',
@yangchenyun
yangchenyun / txhandler.java
Created July 17, 2017 07:33
assignment1 snippet
/**
* Handles each epoch by receiving an unordered array of proposed transactions, checking each
* transaction for correctness, returning a mutually valid array of accepted transactions, and
* updating the current UTXO pool as appropriate.
*/
public Transaction[] handleTxs(Transaction[] possibleTxs) {
// The side effect is to advance the state of the pool.
// Convert the unordered list into a graph, and perform topological sort
/** Mapping from hash to corresponding transaction. */
@yangchenyun
yangchenyun / compareGen.js
Last active October 28, 2017 01:02
Compare two generator strings
function compareGen(leader, runner, leadStr='') {
const runnerNxt = runner.next();
if (runnerNxt.done) {
if (leadStr !== '') {
return false; // NOTE: The runner loses
}
const leaderNxt = leader.next();
if (leaderNxt.done) {