Skip to content

Instantly share code, notes, and snippets.

@ziyunli
ziyunli / ff.sh
Last active March 31, 2016 19:36
ffmpeg cheatsheet
# use reinstall if ffmpeg has already been installed via homebrew
brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-libvorbis --with-libvpx --with-opus --with-x265
# export the movie to frames using ffmpeg then make the GIF with convert from ImageMagick
# from http://superuser.com/questions/556029/how-do-i-convert-a-video-to-gif-using-ffmpeg-with-reasonable-quality#
mkdir frames
ffmpeg -i input -vf scale=320:-1:flags=lanczos,fps=10 frames/ffout%03d.png # export frames
convert -loop 0 frames/ffout*.png output.gif
# Add an empty audio track to video
@ziyunli
ziyunli / church.py
Created April 9, 2016 17:54 — forked from vivekhaldar/church.py
Church numerals in Python
#! /usr/bin/python
#
# Church numerals in Python.
# See http://en.wikipedia.org/wiki/Church_encoding
#
# Vivek Haldar <vh@vivekhaldar.com>
#
# https://gist.github.com/2438498
zero = lambda f: lambda x: x
@ziyunli
ziyunli / keybase.md
Last active May 31, 2021 01:58
keybase.md

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@ziyunli
ziyunli / System Design.md
Created April 19, 2016 03:55 — forked from vasanthk/System Design.md
System Design Cheatsheet

#System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

##Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@ziyunli
ziyunli / Getting-Cheat-Sheet.md
Last active January 4, 2017 20:54 — forked from akras14/Getting-Cheat-Sheet.md
Git Cheat Sheet
@ziyunli
ziyunli / after
Created May 5, 2016 02:41
let's encrypt
# /etc/nginx/sites-available/default
server {
listen 80;
server_name <domain name>;
return 301 https://<domain name>$request_uri;
}
server {
listen 80;
server_name www.<domain name>;
@ziyunli
ziyunli / letsencrypt_2016.md
Created May 18, 2016 00:25 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

There are two modes when you don't want Certbot to edit your configuration:

  • Standalone: replaces the webserver to respond to ACME challenges
  • Webroot: needs your webserver to serve challenges from a known folder.

Webroot is better because it doesn't need to replace Nginx (to bind to port 80) to renew certificates.

In the following, we're setting up mydomain.com to be served from /var/www/mydomain, and challenges will be served from /var/www/letsencrypt.

@ziyunli
ziyunli / company-ownership.md
Created July 6, 2016 13:39 — forked from jdmaturen/company-ownership.md
Who pays when startup employees keep their equity?

Who pays when startup employees keep their equity?

JD Maturen, 2016/07/05, San Francisco, CA

As has been much discussed, stock options as used today are not a practical or reliable way of compensating employees of fast growing startups. With an often high strike price, a large tax burden on execution due to AMT, and a 90 day execution window after leaving the company many share options are left unexecuted.

There have been a variety of proposed modifications to how equity is distributed to address these issues for individual employees. However, there hasn't been much discussion of how these modifications will change overall ownership dynamics of startups. In this post we'll dive into the situation as it stands today where there is very near 100% equity loss when employees leave companies pre-exit and then we'll look at what would happen if there were instead a 0% loss rate.

What we'll see is that employees gain nearly 3-fold, while both founders and investors – particularly early investors – get dilute

def longest_exp_inc_seq(a):
"""
>>> longest_exp_inc_seq([0, 4, 8, 2, 1, 3, 7, 15, 2, 9, 7])
[0, 1, 3, 7, 15]
"""
if len(a) == 0:
return a
s = [1] * len(a) # the longest subsequence that ends at i
p = [-1] * len(a) # the index of the previous element in the longest subsequence at i