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 Data.List | |
| import Prelude hiding (id, pure) | |
| import System.Directory | |
| import System.Exit | |
| import System.IO | |
| import System.IO.Error | |
| import System.Process | |
| import Text.Read | |
| data Route |
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 cv2 | |
| import numpy as np | |
| import sys | |
| if len(sys.argv) < 3: | |
| print 'Usage: python match.py <template.png> <image.png>' | |
| sys.exit() | |
| template_path = sys.argv[1] | |
| template = cv2.imread(template_path, cv2.IMREAD_UNCHANGED) |
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
| // ==UserScript== | |
| // @name NoPeekDuolingo | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.1 | |
| // @description Prevents peeking in Duolingo practice sessions | |
| // @author Michael Snowden | |
| // @match https://www.duolingo.com/practice | |
| // @grant none | |
| // @require http://code.jquery.com/jquery-latest.js | |
| // ==/UserScript== |
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 operator import add, mul | |
| from functools import reduce | |
| from math import log | |
| NUM_PIXELS = 784 | |
| NUM_ROWS = 28 | |
| NUM_COLS = 28 | |
| def display(x_X): |
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 parse(s): | |
| return value(s)[1] | |
| def stringify(o, indent=0): | |
| if isinstance(o, dict): | |
| if not o: | |
| return '{}' | |
| return '{\n' + ",\n".join(' ' * (indent + 4) + "'" + k + "' : " + stringify(v, indent + 4) for k, v in o.items()) + '\n' + ' ' * indent + '}' | |
| if isinstance(o, list): | |
| if not o: |
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 maxflow(E, s, t): | |
| while True: | |
| prev = {} | |
| q = [s] | |
| while q: | |
| u = q.pop(0) | |
| for v in E[u]: | |
| if v not in prev and E[u][v].cap > E[u][v].flow: | |
| prev[v] = u | |
| q.append(v) |
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 ac3(X, D, R1, R2): | |
| for x in X: | |
| D[x] = set(vx for vx in D[x] if x not in R1 or R1[x](vx)) | |
| arcs = set((x, y) for x in R2 for y in R2[x]) | |
| while arcs: | |
| x, y = arcs.pop() | |
| c = len(D[x]) | |
| D[x] = set(vx for vx in D[x] if any(R2[x][y](vx, vy) for vy in D[y])) |
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 lombok.*; | |
| import org.joda.time.format.DateTimeFormat; | |
| import org.joda.time.format.DateTimeFormatter; | |
| import org.openqa.selenium.By; | |
| import org.openqa.selenium.Keys; | |
| import org.openqa.selenium.WebDriver; | |
| import org.openqa.selenium.WebElement; | |
| import org.openqa.selenium.support.ui.Select; | |
| import java.io.File; |
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
| "Lessons left: " + Array.prototype.map.call(document.getElementsByClassName("lessons-left"), a => a.innerText).filter(s => s.length > 0).map(v => +v[2] - v[0]).reduce((a, b) => a + b) |
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 java.io.BufferedReader; | |
| import java.io.File; | |
| import java.io.FileReader; | |
| import java.util.Arrays; | |
| import java.util.function.Function; | |
| import java.util.stream.Collectors; | |
| public class Example { | |
| interface ExceptionalFunction<T, R> { | |
| R apply(T t) throws Exception; |