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
class trie: | |
def __init__(self): | |
self.parentNodes = {} | |
def search(self, word): | |
if len(word) == 0 or not word[0] in self.parentNodes: | |
return 0 | |
return self.parentNodes[word[0]].find(word[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
pug $1.jade | |
# remove && escapes | |
sed -i.bak "s/&&/\&\&/g" $1.html | |
# remove extra whitespace | |
sed -i.bak -E "s/[[:space:]]+/ /g" $1.html | |
# prettify | |
prettier $1.html > $1.prettier.html | |
# move back to goal file | |
mv $1.prettier.html $1.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
# Make sure to `npm install -g pug prettier` first. | |
# Usage: ./jade_to_html.sh path/to/file/without/extension | |
pug $1.jade | |
# remove && escapes | |
sed -i.bak "s/&&/\&\&/g" $1.html | |
# remove extra whitespace | |
sed -i.bak -E "s/[[:space:]]+/ /g" $1.html | |
# prettify | |
prettier --write $1.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
class GraphRouter { | |
constructor(state) { | |
this.vertices = {}; | |
this.sortedVerticies = []; | |
this.visitedVerticies = []; | |
} | |
addNode(path, dependencies, resolve) { | |
const vertex = { | |
name: path.split('/').pop(), |
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
describe('test, () => { | |
it('should do the same thing it did last time', () => { | |
const snapshot = cy.readFile('./cypress/snapshots/snapshot.html'); | |
let bodyHtml = ''; | |
cy.visit('/home'); | |
cy.get('body').then(b => bodyHtml = b.innerHTML); | |
cy.on('fail', () => { | |
// This throws a "You can't promise inside a promise" | |
// https://on.cypress.io/returning-promise-and-commands-in-another-command | |
cy.writeFile('./cypress/snapshots/snapshot.html', bodyHtml); |
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 | |
read -p "Letters to exclude: " exclude | |
exclude=${exclude:-/\d} | |
read -p "First Letter[.]: " first | |
first=${first:-.} | |
read -p "Second Letter[.]: " second | |
second=${second:-.} | |
read -p "Third Letter[.]: " third | |
third=${third:-.} |
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 ripairs [list] | |
(var index (length list)) | |
(fn [] | |
(match index | |
0 nil | |
_ (do | |
(let [ret (. list index)] | |
(set index (- index 1)) | |
(values index ret)))))) |
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 text = await Deno.readTextFile('./day1'); | |
const digits = new Map(); | |
digits.set('zero', '0'); | |
digits.set('one', '1'); | |
digits.set('two', '2'); | |
digits.set('three', '3'); | |
digits.set('four', '4'); | |
digits.set('five', '5'); | |
digits.set('six', '6'); |
OlderNewer