Skip to content

Instantly share code, notes, and snippets.

View dekarrin's full-sized avatar

Rebecca Nelson dekarrin

View GitHub Profile
@dekarrin
dekarrin / javascript_debugging.js
Created December 28, 2013 16:25
For writing to a debug document in Google Apps Script
DEBUG_DOC_ID = "Replace this with the ID of document to write debug output to";
function print_r (array) {
var analyze = function(array) {
return format(array, 0);
}
var format = function(obj, depth) {
var str = "";
var padder = "";
var PAD = " ";
@dekarrin
dekarrin / overwrite.sh
Last active August 29, 2015 13:56
Overwrites the last line of the terminal
# Outputs without a newline and overwrites anything that was already on the last line of
# the terminal
overwrite ()
{
output="$1"
if [ -z "$output" ]
then
read output
fi
printf "\r"
@dekarrin
dekarrin / apply_patches.sh
Last active August 29, 2015 13:56
Creates incremental patches containing only the desired changes.
#!/bin/bash
cd ~
apply ()
{
cd "$1"
files=$(echo *)
for f in $files
do
@dekarrin
dekarrin / .bashcolors.sh
Last active December 9, 2017 15:49
Bash RC
#!/bin/bash
#
# ~/.bashcolors
# Defines variables to hold shell text escape sequences
#
# remember, when using in a prompt, put escape code in between \[ and \] so
# terminal can calculate width of prompt correctly.
TEXT_reset='\e[0m'
@dekarrin
dekarrin / .vimrc
Created June 8, 2014 15:46
Vim RC
" Ensure that sourcing twice doesn't set autocmds twice
autocmd!
" Remember things on exit
" 'x : save marks in up to x last files
" "x : save up to x lines for each register
" :x : save up to x lines of command history
" % : save and restore buffer list
" nX : save viminfo in path X
set viminfo='10,\"100,:20,%,n~/.viminfo
@dekarrin
dekarrin / temp_get.sh
Created June 8, 2014 15:49
Get and display computer temperature
#!/bin/bash
sensor_data=$(sensors | tail -n +3 | sed -e 's/^.*: *+//' -e 's/\.\([0-9]\).*/.\1/' | xargs temp_stats | tail -n +2)
sensor_min=$(echo $sensor_data | cut -d ' ' -f 1)
sensor_max=$(echo $sensor_data | cut -d ' ' -f 2)
sensor_avg=$(echo $sensor_data | cut -d ' ' -f 3)
echo "$sensor_avg/$sensor_max"
@dekarrin
dekarrin / git_annihilate.sh
Created June 8, 2014 15:51
Totally remove file from repository history
#!/bin/bash
TEMP_DIR=".git_annhilate_temp"
if [[ $3 == "" ]]
then
echo Usage: $0 ssh-repo-url branch file-to-delete
else
F=0 #failure check
REPO_URL=$1
@dekarrin
dekarrin / dwc.sh
Created June 8, 2014 15:52
Recursively count lines of files in a directory
#!/bin/bash
##############################################################################
# NAME #
# dwc - 'Directory Word Count' - print and format newline, word, and #
# byte counts for each file. #
# #
# SYNOPSIS #
# dwc [OPTION]... [FILE]... #
# dwc [OPTION]... --files0-from=F #
@dekarrin
dekarrin / configure_debug.sh
Created June 8, 2014 15:53
Run ./configure with debug symbols
#!/bin/sh
./configure CPPFLAGS=-DDEBUG CXXFLAGS="-g -O0" "$@"
@dekarrin
dekarrin / batpow.sh
Created June 8, 2014 15:53
Get battery power
#!/bin/bash
# Place in ~/bin
monitercmd="upower -i /org/freedesktop/UPower/devices/battery_BAT1"
powerstatus=$($monitercmd)
percent=
if echo $powerstatus | grep -q "^failed to set path"
then
percent="N/A"
else