Skip to content

Instantly share code, notes, and snippets.

View git_aliases.sh
#!/bin/bash
# https://raygun.com/blog/git-aliases/
# 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
jalex19100 / split_on_delimiter.sh
Created Jun 24, 2021
Split on Delimiter in bash
View split_on_delimiter.sh
# https://stackoverflow.com/questions/918886/how-do-i-split-a-string-on-a-delimiter-in-bash
#!/usr/bin/env bash
IN="example@example;struff@stuff"
# Do something with each element separated by ;
IFS=';' read -ra ADDR <<< "$IN"
for i in "${ADDR[@]}"; do
# process "$i"
done
@jalex19100
jalex19100 / rust_info.md
Last active Feb 19, 2020
Rust Resources
View rust_info.md
@jalex19100
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
jalex19100 / git_last_commit.sh
Last active Oct 9, 2018
Show last commit on all git projects within a dir
View git_last_commit.sh
# usage <scriptname> <directory below to look in>
find $1 -depth 2 -type d -name .git -execdir git log -1 --format=%cd" `pwd`" \;
@jalex19100
jalex19100 / open_fh_by_pid.sh
Created Oct 9, 2018
List open file count for all processes by PID
View open_fh_by_pid.sh
for i in `ps ax| cut -f1 -d\ |sort |uniq`;do echo -n "$i "; lsof -p $i|wc -l; done| sort -k 2
@jalex19100
jalex19100 / auto_dealer_simplify.user.js
Last active Dec 2, 2016
auto_dealer_simplify.user.js
View auto_dealer_simplify.user.js
// ==UserScript==
// @name Auto Dealer Simplification
// @namespace jalex.net
// @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();
View keybase.md

Keybase proof

I hereby claim:

  • I am jalex19100 on github.
  • I am jalex19100 (https://keybase.io/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:

View cash-register-problem.md

Cash Register Problem

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

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