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
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" crossorigin="" /> | |
<script src="https://unpkg.com/[email protected]/dist/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script> | |
<script src="https://kartena.github.io/Proj4Leaflet/lib/proj4-compressed.js"></script> | |
<script src="https://kartena.github.io/Proj4Leaflet/src/proj4leaflet.js"></script> | |
<div id="map" style="height: 1000px"></div> | |
<script> | |
const originX = -35597500; | |
const originY = 48953100; |
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
/** | |
* Create a function which will call the callback function | |
* after the given amount of milliseconds has passed since | |
* the last time the callback function was called. | |
*/ | |
const idle = (callback, delay) => { | |
let handle; | |
return () => { | |
if (handle) { |
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 React, { Component } from 'react'; | |
import { findDOMNode } from 'react-dom'; | |
/** | |
* A higher order component which scrolls the user to the bottom of the | |
* wrapped component, provided that the user already was at the bottom | |
* of the wrapped component. Useful for chats and similar use cases. | |
* @param {number} treshold The required distance from the bottom required. | |
*/ | |
const scrollToBottom = (treshold = 0) => WrappedComponent => { |
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
public class LightsOut { | |
private List<Integer> board; | |
public LightsOut() { | |
board = generateBoard(); | |
while (!validateBoard()) { | |
board = generateBoard(); | |
} | |
} |
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 getIndex = (permutation, affected) => { | |
const indexes = affected.map(i => permutation.indexOf(i)); | |
if (affected.length === 1) { | |
return permutation.indexOf(affected[0]); | |
} | |
let base = permutation.length; | |
let index = indexes[indexes.length - 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
const cantor = (arr) => { | |
if (arr.length === 2) { | |
return 1 / 2 * (arr[0] + arr[1]) * (arr[0] + arr[1] + 1) + arr[1]; | |
} | |
return cantor( | |
arr.slice(0, arr.length - 2) | |
.concat( | |
cantor([arr[arr.length - 1], arr[arr.length - 2]]) | |
) |
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
def is_leap_year(year): | |
if year % 400 == 0: | |
return True | |
elif year % 100 == 0: | |
return False | |
elif year % 4 == 0: | |
return True | |
return False | |
days = ('man', 'tir', 'ons', 'tor', 'fre', 'lor', 'son') |
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 NumberTheory = {}; | |
/** | |
* @param {number} n | |
* @param {number} k | |
*/ | |
NumberTheory.binomial = function(n, k) { | |
if (n === k) return 1; | |
if (k === 1) return n; | |
return binomial(n - 1, k) + binomial(n - 1, k - 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
// Prototype that stores information about a given polynomial. | |
function Polynomial(data) { | |
// Support providing already existing Polynomials. | |
this.polynomial = data instanceof Polynomial ? data.polynomial : data; | |
} | |
// Rank all coefficients in the polynomial and return the largest. | |
Polynomial.prototype.getLargestCoefficient = function() { | |
var re = /(\d+)/g, match, max = 0; | |
while(match = re.exec(this.getPolynomial())) |