Skip to content

Instantly share code, notes, and snippets.

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

@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
@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 / 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 ]

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: