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
const factorial = (n, acc=1) => { | |
if (n < 1) { return undefined; } | |
if (n === 1) { return acc; } | |
return factorial(n-1, n*acc); | |
}; | |
const sumFibonacci = (n, prev=0, next=1, acc=0) => { | |
if (n === 0) { return acc; } |
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
// Some stuff requires ES6 | |
// Watch this first | |
// Philip Roberts: What the heck is the event loop anyway? | JSConf EU 2014 | |
// https://www.youtube.com/watch?v=8aGhZQkoFbQ | |
// Then read this | |
// https://rainsoft.io/gentle-explanation-of-this-in-javascript/ | |
// https://strongloop.com/strongblog/higher-order-functions-in-es6easy-as-a-b-c/ |
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 http://codepen.io/kad3nce/pen/bEdwOE | |
var map = L.map('map').setView(center, 13); | |
var circle = L.circle(center, 1000).addTo(map); | |
circle.on('mousedown', function (event) { | |
map.dragging.disable(); | |
var _circle$_latlng = circle._latlng; | |
var circleStartingLat = _circle$_latlng.lat; | |
var circleStartingLng = _circle$_latlng.lng; | |
var _event$latlng = event.latlng; |
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
npm install --save react react-dom | |
npm install --save-dev babel webpack webpack-dev-server | |
npm install --save-dev babel-core babel-loader babel-preset-es2015 babel-preset-react |
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
# Guide http://blog.hypriot.com/post/how-to-compile-go-on-arm/ | |
# Todo | |
# Use named variables for versions | |
# Take version as a cmd argument | |
# Error handling | |
# Download Go 1.4.3 source | |
wget https://storage.googleapis.com/golang/go1.4.3.src.tar.gz | |
# Extract it |
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 CRC16 do | |
use Bitwise | |
@constant 0xA001 | |
def calculate(data) do | |
crc = 0x0000 | |
table = init_table() | |
:binary.bin_to_list(data) | |
|> Enum.reduce(crc, fn(value, crc) -> | |
(crc >>> 8) ^^^ Enum.at(table, (crc ^^^ value) &&& 0x00ff) |
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 ( | |
crand "crypto/rand" | |
"math/big" | |
) | |
// Generates random n sized hex string | |
func RandString(n int) string { | |
const alphanum = "0123456789ABCDEF" | |
symbols := big.NewInt(int64(len(alphanum))) | |
states := big.NewInt(0) |
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
type CRC16 struct { | |
Tab []uint16 | |
Constant uint16 | |
} | |
// Init crc16 | |
func (c *CRC16) Init() { | |
c.Constant = 0xA001 | |
for i := 0; i < 256; i++ { |
NewerOlder