Skip to content

Instantly share code, notes, and snippets.

@zjrosen1
zjrosen1 / wtf,sh
Last active May 28, 2017 11:28
wtf
#!/bin/bash
HEART='♥'
if [[ `uname` == 'Linux' ]]; then
current_charge=$(cat /proc/acpi/battery/BAT1/state | grep 'remaining capacity' | awk '{print $3}')
total_charge=$(cat /proc/acpi/battery/BAT1/info | grep 'last full capacity' | awk '{print $4}')
else
battery_info=`ioreg -rc AppleSmartBattery`
current_charge=$(echo $battery_info | grep -o '"CurrentCapacity" = [0-9]\+' | awk '{print $3}')
@zjrosen1
zjrosen1 / gist:b425475cf8fe5fe671a34c992f231caa
Last active December 20, 2016 04:45
Open Files in VIM from eslint output
vim `eslint --no-eslintrc -f compact --rule no-unused-vars:error 'src/**/*.js' | sed -ne 's/:.*$//p' | uniq`
@zjrosen1
zjrosen1 / es6_batch.js
Last active May 10, 2021 05:20
ES6 Batch Util
// Async Chunking or Sync
class Batch {
constructor(opt) {
this.fn = opt.fn;
this.transformFn = opt.transformFn || null;
this.args = opt.args || [];
this.argsIndex = opt.argsIndex || 0;
this.dataset = opt.dataset || null;
this.start = 0;
@zjrosen1
zjrosen1 / batch.js
Created August 30, 2016 16:40
Batch Requests Async or Sync
var moment = require('moment');
var _ = require('lodash');
function p(i) {
return new Promise(resolve => {
setTimeout(() => {
resolve({id: i});
}, 300)
})
}
#!/bin/bash
HEART='♥'
if [[ `uname` == 'Linux' ]]; then
current_charge=$(cat /proc/acpi/battery/BAT1/state | grep 'remaining capacity' | awk '{print $3}')
total_charge=$(cat /proc/acpi/battery/BAT1/info | grep 'last full capacity' | awk '{print $4}')
else
battery_info=`ioreg -rc AppleSmartBattery`
current_charge=$(echo $battery_info | grep -o '"CurrentCapacity" = [0-9]\+' | awk '{print $3}')
# @gf3’s Sexy Bash Prompt, inspired by “Extravagant Zsh Prompt”
# Shamelessly copied from https://github.com/gf3/dotfiles
default_username='austen'
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
export TERM=gnome-256color
elif infocmp xterm-256color >/dev/null 2>&1; then
export TERM=xterm-256color
fi
@zjrosen1
zjrosen1 / pi
Last active November 6, 2015 08:33
π
###############################
# | |_ _ __ ___ _ ___ __ #
# | __| '_ ` _ \| | | \ \/ / #
# | |_| | | | | | |_| |> < #
# \__|_| |_| |_|\__,_/_/\_\ #
###############################
# 1 VIM ♥♥♥ 20:04
# [ Reset Prefix ] {{{1
@zjrosen1
zjrosen1 / random_cow.sh
Last active September 22, 2015 01:57
Random Forturne
#!/bin/bash
function rnum {
echo $((RANDOM % $1))
}
COWS=("bong" "unipony" "sodomized" "head-in" "vader" "elephant" "tux")
VOICES=("Daniel" "Karen")
TIMER=10
audio=1
@zjrosen1
zjrosen1 / Tmux-Commands
Last active July 9, 2022 14:44
TMUX Aliases
alias ta='tmux attach -t'
alias tkss='tmux kill-session -t'
alias tksv='tmux kill-server'
alias tl='tmux list-sessions'
alias tmux=_zsh_tmux_plugin_run
alias ts='tmux new-session -s'
Bind Key
ctrl-a