Skip to content

Instantly share code, notes, and snippets.

@userhooke
userhooke / calculator.js
Created July 12, 2021 07:01
simple lexer, parser and evaluator to run calculations
const assert = require('assert').strict;
const readline = require('readline');
const TOKEN_TYPES = {
INT: 'INT',
PLUS: 'PLUS',
MINUS: 'MINUS',
MUL: 'MUL',
DIV: 'DIV',
LPAREN: 'LPAREN',
@userhooke
userhooke / monobank-ynab.js
Created February 3, 2020 11:16
Serverless script to link Monobank API and YNAB
const ynab = require("ynab");
const ynabAPI = new ynab.API(process.env.YNAB_TOKEN);
const adMaioraBudgetId = process.env.BUDGET_ID;
const monoDebitAccountId = process.env.MONO_DEBIT_ACCOUNT_ID;
module.exports.handler = (event, context, callback) => {
const body = JSON.parse(event.body);
console.log('Event body: ', body);
@userhooke
userhooke / isEven
Last active December 13, 2019 09:07
function isEven(n) {
return n % 2 === 0;
}
@userhooke
userhooke / stand-up-reminder.sh
Created December 9, 2019 08:49
Remind me to stand up every 45mins. Zenity required
#!/usr/bin/env bash
while :
do
for (( i=1; i <= 45; i++ ))
do
clear
echo $((46-i)) "minutes left"
sleep 1m
done
@userhooke
userhooke / dj-play-that-shit.sh
Created December 9, 2019 08:48
Play Free Code Camp radio from command line via VLC player
cvlc https://coderadio-admin.freecodecamp.org/public/coderadio/playlist/pls
@userhooke
userhooke / local-server.js
Created October 13, 2019 15:41
Simple Express server to test Lambda functions locally
const express = require('express');
// path to lambda function
const getAccountDetails = require('../get-account-details/src/index');
const app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.post('/', async (req, res) => {
{
"editor.fontSize": 14,
"editor.tabSize": 2,
"editor.fontFamily": "Hasklig, Menlo, Monaco, 'Courier New', monospace",
"editor.fontLigatures": true,
"emmet.includeLanguages": {
"javascript": "javascriptreact"
},
"workbench.startupEditor": "newUntitledFile",
"editor.minimap.enabled": false,
@userhooke
userhooke / left-right_hand_mouse.ahk
Created March 28, 2019 10:00
AHK > change mouse keys for left and right hands
; Path to startup folder Windows 10 = C:\Users\${user.name}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
DllCall("SwapMouseButton",int,true) ;> left hand
; DllCall("SwapMouseButton",int,false) ;> right hand
@userhooke
userhooke / swap-alt-ctrl.ahk
Created March 28, 2019 09:58
AHK > swap alt and ctrl keys
; Path to startup folder Windows 10 = C:\Users\${user.name}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
; This file by Alan J. Hogan
; https://alanhogan.com/tips/swap-left-alt-and-ctrl-keys-in-windows
; Switches the left Control and Alt keys.
LCtrl::Alt
LAlt::Ctrl
@userhooke
userhooke / text_expander.ahk
Last active March 28, 2019 10:00
AHK > expand text from abbreviation
; Path to startup folder Windows 10 = C:\Users\${user.name}\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; Type this abbreviation and hit Tab
::br::