Skip to content

Instantly share code, notes, and snippets.

View scale.js
//scale returns the number scaled to its corresponding SI suffix.
// scale(1234) => "1.2 K"
//MIT License, Copyright jpillora © 2019
function scale(n, d) {
// set default number
if (typeof n !== "number" || isNaN(n)) n = 0;
if (n === 0) return "0";
// set default digit count
if (typeof d !== "number" || isNaN(d)) d = 1;
// find scale index 1000,100000,... becomes 1,2,...
@jpillora
jpillora / http-btn.js
Created Mar 12, 2019
Random Vue Stuff
View http-btn.js
import defaults from "lodash.defaults";
let httpBtn = {
bind: (el, binding) => {
//get options (evald expression)
let opts = binding.value;
if (typeof opts === "function") {
opts = {fn: opts};
}
//provide defaults
@jpillora
jpillora / _README.md
Created Oct 11, 2018
Export 28degress master card transactions to CSV
View _README.md

export-28deg.js

Export 28degress master card transactions to CSV

  1. Visit 28 degress transactions page
  2. Open Developer Console
  3. Paste code
  4. Press enter
View rdiff-example.sh
# $ apt install rdiff
# $ rdiff --help
# Usage: rdiff [OPTIONS] signature [BASIS [SIGNATURE]]
# [OPTIONS] delta SIGNATURE [NEWFILE [DELTA]]
# [OPTIONS] patch BASIS [DELTA [NEWFILE]]
# Options:
# -v, --verbose Trace internal processing
# -V, --version Show program version
# -?, --help Show this help message
View pgp-public-key.txt
-----BEGIN PGP PUBLIC KEY BLOCK-----
Comment: GPGTools - https://gpgtools.org
mQENBFOraBABCACwTSt0zrIvHgKQVigkukGghPy+04IbIZPSjALucermep/qQij5
RDkXEgNulSceHJp7cAfm48QLXgC7mxNTqLRX/dW6HpErHVjH/3JffITZW/rCIeEA
ULAj2b/7N/e7VpcujhotH0m8g/jVCOiX+f+LxHJNYEW734+DUe3qcorbKWSHTR1t
2WY5oOxd//4F+0CYCcy+8Jkl6lv//Yz/7EHNUEHp/If+TiIEf2gnfI08Qlbfefz1
n7MUk0ixSrfF8cxmQ8YBOstp/ruQD0lD7Qz1/K9Z10U9Fmlvtq5cj3M70QCI+Qn+
Fcr+6lnltqR5l4OBqYeJ6+kwQbMCtaSwdWjdABEBAAG0IkphaW1lIFBpbGxvcmEg
PGpwaWxsb3JhQGdtYWlsLmNvbT6JAT0EEwEKACcFAlOraBACGwMFCQeGH4AFCwkI
@jpillora
jpillora / s3get.sh
Last active May 19, 2020
S3 signed GET in plain bash (Requires openssl and curl)
View s3get.sh
#!/bin/bash
#set these in your environment/profile (NOT HERE)
AWS_ACCESS_KEY=""
AWS_SECRET_KEY=""
function s3get {
#helper functions
function fail { echo "$1" > /dev/stderr; exit 1; }
#dependency check
@jpillora
jpillora / tomp3
Created Oct 16, 2016
Concatenate multiple MP3s into a single MP3
View tomp3
#!/bin/bash
# concat multiple mp3 files into a single mp3
# installation:
# chmod +x tomp3 and save to /usr/local/bin/tomp3
# usage: tomp3 <DIR> [NAME]
# finds all mp3 files in DIR, writes a single mp3 to NAME.mp3
# set NAME to --preview to list mp3s in the order they will
# be concatenated.
# requires: ffmpeg
View install-tm.sh
#tmux helper
echo '#!/bin/bash
NAME="${1}"
if [[ "$NAME" = "" ]]; then
tmux ls
else
tmux attach-session -t "$NAME" || tmux new-session -s "$NAME"
fi' > /usr/local/bin/tm &&
chmod +x /usr/local/bin/tm
View install-micro.sh
#!/bin/bash
#os check
case `uname -s` in
Darwin) OS="osx";;
Linux) OS="linux64";;
*) echo "unknown os: $(uname -s)" && exit 1;;
esac
#version check
echo -n "checking latest version... "
VER=`curl -sI https://github.com/zyedidia/micro/releases/latest | grep Location | sed "s~^.*tag\/v~~" | tr -d '\n' | tr -d '\r'`
@jpillora
jpillora / unix-to-tcp.go
Last active Jun 8, 2020
Forward unix socket to tcp socket
View unix-to-tcp.go
package main
import (
"io"
"log"
"net"
"os"
)
const (
You can’t perform that action at this time.