Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am huyhong on github.
  • I am huyhong (https://keybase.io/huyhong) on keybase.
  • I have a public key ASCo4kd1v_v4x78FxqawTd3DuGJ6g65OpIeYmOXbKvmcMAo

To claim this, I am signing this object:

@huyhong
huyhong / fanny_knapsack.py
Created October 23, 2017 05:36
fanny's knapsack problem
from ortools.algorithms import pywrapknapsack_solver
def main():
# Create the solver.
solver = pywrapknapsack_solver.KnapsackSolver(
pywrapknapsack_solver.KnapsackSolver.
KNAPSACK_MULTIDIMENSION_BRANCH_AND_BOUND_SOLVER,
'test')
values = [ 6361805,3746995,3760474,2911334,2237414,2298067,2106000,1964477,1886976,1550016,1843171,2015021,1809475,1607299,1603930,1172621,1745453,1533168,1479254,1644365,1600560,1334362,1290557,1344470,1213056,1266970,579571,1159142,970445,1098490,990662,815443,798595,6739,6739,454896 ]
@huyhong
huyhong / gist:9696c051c83a05bad2ef
Created June 24, 2015 00:57
orderByPreferred AngularJS filter
/**
* @ngdoc filter
* @name orderByPreferred
* @memberof clrFilter
*
* @description
* Orders collection based on preferred values first
*
* @param {Object} input - Object you want to order
* @param {String} inputKey - Key of the object you want to prefer ordering by
@huyhong
huyhong / filter_by_frontmatter.rb
Last active June 28, 2018 13:31
Custom Frontmatter Filter for Jekyll
module Jekyll
module CustomFrontmatterFilter
# Returns back filtered list of posts based on custom frontmatter data types
# Usage: {{ site.posts | filter_by_frontmatter:'subcategories','design' }}
# => Returns all posts with the frontmatter 'subcategories' containing 'design'
def filter_by_frontmatter(posts, frontmatter, type)
filtered = []
for post in posts
if post.data[frontmatter]
filtered.push(post) if post.data[frontmatter].include? type

Setup

1. Run software update

Make sure everything is up to date.

2. Install Xcode and/or "Command Line Tools"

"Command Line Tools" can be downloaded separate from Xcode at

[
"https://fbcdn-sphotos-d-a.akamaihd.net/hphotos-ak-xap1/t31.0-8/1492622_793008530741778_5001572426441309314_o.jpg",
"https://scontent-b-sea.xx.fbcdn.net/hphotos-xap1/t31.0-8/10669136_790715467637751_5014888847986707696_o.jpg",
"https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-xfp1/t31.0-8/10712542_787137031328928_6065770549473643086_o.jpg",
"https://scontent-a-sea.xx.fbcdn.net/hphotos-xaf1/t31.0-8/10700291_785304654845499_4430432684479576713_o.jpg",
"https://fbcdn-sphotos-c-a.akamaihd.net/hphotos-ak-xaf1/v/t1.0-9/10616066_782214548487843_3071510223817145555_n.jpg?oh=ee2b94076cdf0a15122fc7f5dff57764&oe=54F69CAF&__gda__=1422611998_ee42ade03956c881e62857c2aa9e2379",
"https://fbcdn-sphotos-a-a.akamaihd.net/hphotos-ak-xaf1/t31.0-8/10629453_778884362154195_5877912472267300922_o.jpg",
"https://fbcdn-sphotos-e-a.akamaihd.net/hphotos-ak-xpa1/t31.0-8/10514193_776573405718624_6210020417955787752_o.jpg",
"https://fbcdn-sphotos-d-a.akamaihd.net/hphotos-ak-xpa1/t31.0-8/10633304_774135589295739_1572734040
# Rake task to copy local files to remote server via FTP
# required credentials.yml file, that contains keys:
# server, username, password
require "net/ftp"
require "yaml"
class FTPClient
attr_reader :remote_path
@huyhong
huyhong / m2tech-hiface-1-mavericks
Last active January 2, 2016 15:29
Getting your M2Tech hiFace 1 working in Mavericks 10.9.x
# Following uninstalls older hiFace and previous async192/Northstar drivers
sudo kextunload -b 'com.m2tech.driver'
sudo kextunload -b 'com.async.driver.async192'
sudo rm -rf /System/Library/Extensions/Hiface.kext
sudo rm -rf /System/Library/Extensions/async192.kext
sudo pkgutil --forget com.m2tech.driver
sudo pkgutil --forget com.async.driver.async192
sudo touch /System/Library/Extensions
# Now go download and install the Wired 4 Sound DAC-2 async drivers: http://www.wyred4sound.com/uploads/74030/files/async_159r2_W4S.pkg.zip
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
@huyhong
huyhong / .slate
Last active December 24, 2015 22:39
.slate config for https://github.com/jigish/slate, replaces Divvy for me
config defaultToCurrentScreen true
config nudgePercentOf screenSize
config resizePercentOf screenSize
config orderScreensLeftToRight false
default color resolutions:1920x1200;1200x1920;1200x1920
# Old Divvy Setup
# bind 1:ctrl;cmd move 0;0 screenSizeX/1.75;screenSizeY
# bind 2:ctrl;cmd move (screenSizeX-(screenSizeX/1.75));0 screenSizeX/1.75;screenSizeY