Contours of San Francisco overlayed over OpenStreeMap vector tiles using code from mbostock's vector tiles with multiple layers example. View the hi-res file
See gist for code used to generate contours.
# -*- coding: utf-8 -*- | |
""" Small script that shows hot to do one hot encoding | |
of categorical columns in a pandas DataFrame. | |
See: | |
http://scikit-learn.org/dev/modules/generated/sklearn.preprocessing.OneHotEncoder.html#sklearn.preprocessing.OneHotEncoder | |
http://scikit-learn.org/dev/modules/generated/sklearn.feature_extraction.DictVectorizer.html | |
""" | |
import pandas | |
import random |
angular.module('stateMock',[]); | |
angular.module('stateMock').service("$state", function($q){ | |
this.expectedTransitions = []; | |
this.transitionTo = function(stateName){ | |
if(this.expectedTransitions.length > 0){ | |
var expectedState = this.expectedTransitions.shift(); | |
if(expectedState !== stateName){ | |
throw Error("Expected transition to state: " + expectedState + " but transitioned to " + stateName ); | |
} | |
}else{ |
import unittest | |
def foo(x, y, z): | |
return (x != y and x != z or x and z) | |
def get_test_args(): | |
x = y = z = [True, False] | |
from itertools import product, repeat | |
# for each input arg ---> expected arg | |
input_args = list(product(x, y, z)) |
[ | |
{ | |
"title": "How to handle state in React. The missing FAQ.", | |
"author": "Osmel Mora", | |
"url": "https://medium.com/react-ecosystem/how-to-handle-state-in-react-6f2d3cd73a0c" | |
}, | |
{ | |
"title": "You might not need React Router", | |
"author": "Konstantin Tarkus", | |
"url": "https://medium.freecodecamp.com/you-might-not-need-react-router-38673620f3d" |
""" | |
Implement a queue with two stacks | |
Interview practice from coding for interviews - March 2014 | |
""" | |
class Staqueue(object): | |
""" Implements a queue with two stacks | |
One stack is used for enqueing, and the other dequeing. If an enqueue is requested |
Contours of San Francisco overlayed over OpenStreeMap vector tiles using code from mbostock's vector tiles with multiple layers example. View the hi-res file
See gist for code used to generate contours.
// Flyweight.js - Copyright Addy Osmani, 2012. | |
// Consider public domain | |
// My implementation in JS of this: | |
// http://en.wikipedia.org/wiki/Flyweight_pattern | |
// Simulate pure virtual inheritance/'implement' keyword for JS | |
Function.prototype.implementsFor = function (parentClassOrObject) { | |
if (parentClassOrObject.constructor == Function) { | |
// Normal Inheritance | |
this.prototype = new parentClassOrObject; |
If you use sass
and css-modules
and want to restyle some base component without changing its code.
(base component already use css-modules and exposes styles
property)
I know two way how to do it.
import java.util.HashMap | |
class Node[K, V](var key: K, var value: V) { | |
var next: Node[K, V] = null | |
override def toString(): String = s"Node($key, $value) -> $next" | |
} | |
class LRUCache[K, V](val size: Int = 5) { | |
require(size > 0, s"Expected size > 0, found $size") | |
val map = new HashMap[K, Node[K, V]]() |
var isLeft = function(p1, p2, p3) { | |
return (p2.position[0] - p1.position[0])*(p3.position[1] - p1.position[1]) - (p3.position[0] - p1.position[0])*(p2.position[1] - p1.position[1]); | |
}; | |
// chainHull_2D(): Andrew's monotone chain 2D convex hull algorithm | |
// see: http://en.wikibooks.org/wiki/Algorithm_Implementation/Geometry/Convex_hull/Monotone_chain | |
// Input: P[] = an array of 2D points | |
// presorted by increasing x- and y-coordinates | |
// n = the number of points in P[] | |
// Output: H[] = an array of the convex hull vertices (max is n) |