View boilerplate.html
<html>
<head>
<style>
body { margin: 0; }
canvas { width: 100%; height: 100% }
</style>
</head>
<body>
<script src='https://cdnjs.cloudflare.com/ajax/libs/three.js/88/three.min.js'></script>
<script src='https://threejs.org/examples/js/controls/TrackballControls.js'></script>
View mp4_to_jpgs.py
import cv2, sys
vidcap = cv2.VideoCapture(sys.argv[1])
success,image = vidcap.read()
count = 0
success = True
while success:
success, image = vidcap.read()
print(' * writing frame', count)
cv2.imwrite('frame-' + str(count) + '.jpg', image)
View what-forces-layout.md

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()
View upload_to_s3.sh
# gzip a text file
gzip -9 data.json
# remove the gzip file extension
mv data.json.gz data.json
# upload to s3
aws s3 cp data.json s3://bucket/data.json --acl public-read --content-type application/json --content-encoding gzip --metadata-directive REPLACE
View clear_cache.sh
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
View web-servers.md

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
View no-style.js
document.head.parentNode.removeChild(document.head);
View nmf.py
from __future__ import division
from sklearn.metrics.pairwise import cosine_similarity
from sklearn.feature_extraction.text import TfidfVectorizer
from collections import defaultdict
from sklearn import decomposition
import sys, glob, json, codecs, os
import numpy as np
def read_file(path):
with codecs.open(path, 'r', 'utf8') as f: