Skip to content

Instantly share code, notes, and snippets.

View trescenzi's full-sized avatar

Thomas Crescenzi trescenzi

View GitHub Profile
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');
(fn ripairs [list]
(var index (length list))
(fn []
(match index
0 nil
_ (do
(let [ret (. list index)]
(set index (- index 1))
(values index ret))))))
#! /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:-.}
@trescenzi
trescenzi / on-fail.js
Created June 21, 2019 18:01
Writing a file upon test fail.
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);
@trescenzi
trescenzi / graphrouter.js
Created March 15, 2019 11:19
Rough sketch of a directed graph router.
class GraphRouter {
constructor(state) {
this.vertices = {};
this.sortedVerticies = [];
this.visitedVerticies = [];
}
addNode(path, dependencies, resolve) {
const vertex = {
name: path.split('/').pop(),
@trescenzi
trescenzi / jade_to_html.sh
Last active March 14, 2019 20:48
A quick and dirty jade to html conversion script that leaves the file rather pretty and without any `&`s.
# 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
@trescenzi
trescenzi / jade_to_html.sh
Created March 14, 2019 20:09
A quick and dirty jade to html conversion script that leaves the file rather pretty and without any `&`s. Make sure to `npm install -g pug prettier` first.
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
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:])

Keybase proof

I hereby claim:

  • I am trescenzi on github.
  • I am trescenzi (https://keybase.io/trescenzi) on keybase.
  • I have a public key ASCOqDo6R32CB5hOOsOsNTcbeFrrTS-gT62G73_oiXzqpwo

To claim this, I am signing this object:

@trescenzi
trescenzi / server-vue.js
Last active December 11, 2016 01:17
Vue 2 rendering an RSS Feed
const Vue = require('vue');
const renderer = require('vue-server-renderer').createRenderer();
const rssData = {
title: 'Test Feed',
link: 'www.test.com',
desc: 'A test rss feed',
items: [
{