Skip to content

Instantly share code, notes, and snippets.

@ismyrnow
ismyrnow / tg-test-api.js
Created March 10, 2023 03:32
Module for async access to a fake task and user API
// A reference implementation of an API service that stores data in memory,
// and executes asynchronous CRUD operations on tasks and users.
// ---
//
// getUsers() : Promise{Array.<User>}
// getTasks() : Promise{Array.<Task>}
// updateTask(PartialTask) : Task
// createTask(NewTask) : Task
// deleteTask(id) : void
//
@ismyrnow
ismyrnow / retire.clj
Created July 22, 2022 01:34
When would you like to retire? IN CLOJURE!!!
(do
(print "How old are you? ")
(def currentAge (Integer/parseInt (read-line)))
(flush)
(println currentAge)
(print "At what age would you like to retire?")
(flush)
(def retirementAge (Integer/parseInt (read-line)))
(println retirementAge)
(def yearsToRetirement (- retirementAge currentAge))
@ismyrnow
ismyrnow / git-branch-cleanup.md
Last active October 12, 2022 14:18
Cleanup Git Branches

Delete merged branches

git branch --merged | egrep -v "(^\*|master)" | xargs git branch -d

Delete local refs to remote branches that no longer exist

git fetch --prune
@ismyrnow
ismyrnow / package-lock-reset.sh
Last active March 4, 2020 18:37
Reset weird package-lock changes
rm -rf ./node_modules
npm cache clean --force
npm install --prefer-online
@ismyrnow
ismyrnow / compact-cards.css
Last active November 5, 2019 17:30
TeamGantt Stylish Styles
.board-card .card-body .user-icons,
.board-card .card-body .notification-wrapper,
.card-header .static-task-progress {
display: none;
}
.board-column {
width: 400px;
}
@ismyrnow
ismyrnow / diff.js
Created February 25, 2019 20:28
Diff function to compare two objects and return the values for keys that differ
import {uniq} from 'lodash';
/**
* Shallow compare two objects, returning those props that are different with values from `b`.
* @param {*} a
* @param {*} b
*/
const diff = (a, b) => {
if (a === b) {
return {};
@ismyrnow
ismyrnow / setup-parameterized-tests.js
Created December 14, 2018 18:47
Parameterized test helper for Jest
/**
* Setup parameterized tests for a dictionary of inputs and outputs.
* This allows you to run tests over a list of inputs and outputs,
* without much setup. For example:
*
* setupParameterizedTests(x => getFirstName(x))([
* ['John M. Smith', 'John'],
* ['Joe Schmoe Jr.', 'Joe']
* ]);
*
@ismyrnow
ismyrnow / child.html
Last active June 14, 2017 14:39
Iframe'd modal with close
<div id="modal">I am a modal. Click outside me to "close the modal", which actually closes the iframe.</div>
<div id="mask" />
<style>
body {
background-color: rgba(255,255,255,0.5);
}
#modal {
z-index: 1;
@ismyrnow
ismyrnow / mac-clear-icon-cache.sh
Created May 5, 2017 19:28
Clear the icon cache on a Mac when you start seeing generic icons in Finder or the Dock
sudo rm -rfv /Library/Caches/com.apple.iconservices.store; sudo find /private/var/folders/ \( -name com.apple.dock.iconcache -or -name com.apple.iconservices \) -exec rm -rfv {} \; ; sleep 3;sudo touch /Applications/* ; killall Dock; killall Finder
@ismyrnow
ismyrnow / download-list.sh
Created February 10, 2017 06:34
Given a space-separated list of URL and filename pairs, download them in sequence
# feed each line of text file to sed, which extracts url/filename, and outputs a curl command, which is fed to shell.
cat url-filename-list.txt | sed 's/\([^ ]*\) \(.*\)/curl "\1" -o "\2"/' | sh