This file contains hidden or 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
<html> | |
<head> | |
</head> | |
<body> | |
<script async src="//jsfiddle.net/3M6Xt/31/embed/js,html,css,result/dark/"></script> | |
</body> | |
</html> |
This file contains hidden or 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
// http://www.html5rocks.com/en/tutorials/speed/script-loading/ | |
// how about that? | |
// first load all dependent libs | |
let loadScripts = ( () => { | |
let | |
scripts = [ | |
// 'https://code.jquery.com/jquery-2.2.3.min.js', | |
'https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js', | |
'https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.3.3/backbone-min.js' | |
], |
This file contains hidden or 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
O(1) approximate solution | |
from math import floor, log | |
nth_root = lambda num, n: floor(round(n**(log(num, n) * 1./n), 1)) |
This file contains hidden or 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 gulp = require('gulp'); | |
var sourcemaps = require('gulp-sourcemaps'); | |
var source = require('vinyl-source-stream'); | |
var buffer = require('vinyl-buffer'); | |
var browserify = require('browserify'); | |
var watchify = require('watchify'); | |
var babel = require('babelify'); | |
function compile(watch) { | |
var bundler = watchify(browserify('./src/index.js', { debug: true }).transform(babel)); |
This file contains hidden or 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
from __future__ import unicode_literals | |
from BeautifulSoup import BeautifulStoneSoup | |
def html_decoder(s): | |
return BeautifulStoneSoup(s, convertEntities=BeautifulStoneSoup.HTML_ENTITIES) | |
if __name__ == "__main__": | |
s = "U.S. Adviser’s Blunt Memo on Iraq: Time ‘to Go Home’" | |
print html_decoder(s) |
This file contains hidden or 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
fn = (l, lo, hi, b) => { | |
if (lo<hi) { | |
mid = parseInt((lo+hi)/2); | |
fn(l, lo, mid, b); | |
fn(l, mid+1, hi, b); | |
} | |
else { | |
let c = l[lo].toString(2).match(/1+/gi).join('').length; | |
console.log(c, l[lo]); | |
if (b[0] < l[lo]) b[0] = l[lo]; |
This file contains hidden or 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
"use strict"; | |
let paramRegex = /([a-zA-Z0-9]+\=[a-zA-Z0-9]+)/ig; | |
location.search.match(paramRegex); |
This file contains hidden or 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 | |
sudo add-apt-repository ppa:chris-lea/libsodium; | |
sudo echo "deb http://ppa.launchpad.net/chris-lea/libsodium/ubuntu trusty main" >> /etc/apt/sources.list; | |
sudo echo "deb-src http://ppa.launchpad.net/chris-lea/libsodium/ubuntu trusty main" >> /etc/apt/sources.list; | |
sudo apt-get update && sudo apt-get install libsodium-dev; |
This file contains hidden or 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
import gevent | |
from gevent.server import StreamServer as gStream | |
from gevent import socket as gsocket | |
from gevent import select as gselect | |
from collections import deque, defaultdict | |
def divide(alist, lo, hi, fn, *args): | |
if lo < hi: | |
mid = (hi-lo)/2 + lo | |
divide(alist, lo, mid, fn, *args) |
This file contains hidden or 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
defmodule Model do | |
schema "models" do | |
field :foo, :string | |
has_many :children, Model, foreign_key: :parent_id | |
belongs_to :parent, Model, foreign_key: :parent_id | |
end | |
@doc """ | |
Recursively loads parents into the given struct until it hits nil | |
""" |