Skip to content

Instantly share code, notes, and snippets.

# unstage files
git config --global alias.unstage 'reset HEAD --'
# stash changes including untracked files
git config --global alias.stash-unstaged 'stash -k -u'
# switch to previous branch
jalex19100 /
Created Jun 24, 2021
Split on Delimiter in bash
#!/usr/bin/env bash
# Do something with each element separated by ;
IFS=';' read -ra ADDR <<< "$IN"
for i in "${ADDR[@]}"; do
# process "$i"
jalex19100 /
Last active Feb 19, 2020
Rust Resources
jalex19100 / treat_touch_events_as_mouse_events.js
Created Mar 19, 2019
Treat touch events as mouse events. Useful for legacy code that you cannot change but could load a small piece to support touch events.
View treat_touch_events_as_mouse_events.js
/* First we need to listen to touch events and call a function 'touch2Mouse' each time a touch event is fired:
document.addEventListener("touchstart", touch2Mouse, true);
document.addEventListener("touchmove", touch2Mouse, true);
document.addEventListener("touchend", touch2Mouse, true);
/* The following function will initiate and fire mouse events (event.initMouseEvent), for each touch events type we'll fire the equivalent mouse event :
Touchstart => Mousedown
Touchend => Mouseup
jalex19100 /
Last active Oct 9, 2018
Show last commit on all git projects within a dir
# usage <scriptname> <directory below to look in>
find $1 -depth 2 -type d -name .git -execdir git log -1 --format=%cd" `pwd`" \;
jalex19100 /
Created Oct 9, 2018
List open file count for all processes by PID
for i in `ps ax| cut -f1 -d\ |sort |uniq`;do echo -n "$i "; lsof -p $i|wc -l; done| sort -k 2
jalex19100 / auto_dealer_simplify.user.js
Last active Dec 2, 2016
View auto_dealer_simplify.user.js
// ==UserScript==
// @name Auto Dealer Simplification
// @namespace
// @include *://*.com/used-inventory/*
// @version 1
// @grant none
// ==/UserScript==
setTimeout(function () {
$("#salemove > div").remove();
$("body > div.ddc-header.sticky-header-nav.shrink-header-nav").remove();

Keybase proof

I hereby claim:

  • I am jalex19100 on github.
  • I am jalex19100 ( on keybase.
  • I have a public key whose fingerprint is E4E5 28FA A297 330F 0F66 4048 372C 3BE5 261F AC9D

To claim this, I am signing this object:


Cash Register Problem

A cash register has a drawer with separate bins for eight different denominations of money:

  • Pennies
  • Nickels
  • Dimes
  • Quarters
  • Singles
  • Fives
sort -n | awk '
c = 0;
sum = 0;
$1 ~ /^[0-9]*(\.[0-9]*)?$/ {
a[c++] = $1;
sum += $1;