This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am lihanli on github. | |
* I am lihanli (https://keybase.io/lihanli) on keybase. | |
* I have a public key ASBFj9MOD5Yy0tYa0OiC5Y_SKdVM40Di06PWnxFXOfwV5Ao | |
To claim this, I am signing this object: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'formula' | |
class PkgExtract < CurlDownloadStrategy | |
def stage | |
safe_system '/usr/bin/xar', '-xf', @tarball_path | |
chdir | |
safe_system 'mv *.pkg/Payload Payload.gz' | |
safe_system 'ls | grep -v Payload | xargs rm -r' | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit' | |
def flatten(array) | |
flattened_array = [] | |
array.each { |item| | |
if item.is_a?(Array) | |
flattened_array += flatten(item) | |
else | |
flattened_array << item |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark/ips' | |
require 'active_model' | |
# run this | |
# bundle exec ruby benchmark.rb && second_run=y bundle exec ruby benchmark.rb | |
class Person | |
include ActiveModel::Dirty | |
define_attribute_methods :name, :age |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <netdb.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <errno.h> | |
#define CANARY "in_the_coal_mine" | |
struct { | |
char buffer[1024]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'pry' | |
file = ARGV[0] | |
raise('dump not found') unless File.exists?(file) | |
UNPAKT_DIR = '/Users/Unpakt/workspace/unpakt' | |
def run(cmd, raise_on_error: true, output: false, bundle_exec: false, working_dir: false) | |
cmd = "bundle exec #{cmd}" if bundle_exec | |
cmd = "cd #{working_dir}; #{cmd}" if working_dir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var srcs = []; | |
$('script[src]').each(function () { | |
srcs.push($(this).attr('src')); | |
}); | |
srcs.sort(); | |
var last = srcs[0]; | |
for (var i=1; i<srcs.length; i++) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.defineProperty Object::, "__obs", | |
enumerable: false | |
configurable: true | |
writable: false | |
value: (prop, handler) -> | |
val = this[prop] | |
if delete this[prop] # can't watch constants | |
Object.defineProperty this, prop, | |
get: -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -u | |
set -e | |
APP_NAME='myapp' | |
APP_ROOT="/home/ubuntu/$APP_NAME" | |
PID="$APP_ROOT/tmp/pids/unicorn.pid" | |
ENV=production |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mysqldump -u <USERNAME> -p<PASSWORD> --add-drop-table --no-data <DB_NAME> | grep ^DROP | mysql -u <USERNAME> -p<PASSWORD> <DB_NAME> |