Skip to content

Instantly share code, notes, and snippets.

@mrbalihai
mrbalihai / aliases.sh
Last active September 30, 2019 11:36
shell aliases for timeclock logging with hledger
export TIMELOG="/home/rbollons/Documents/Work Log/Log.timeclock"
log_time_in () {
echo i $(date "+%Y-%m-%d %H:%M:%S") $* >>$TIMELOG
}
@mrbalihai
mrbalihai / EventBus.ts
Last active August 21, 2019 13:43
A basic event bus in TypeScript
type SubscriptionFn = (data: object) => void
interface EventSubscription {
event: GameEvent;
fn: SubscriptionFn;
}
export enum GameEvent {
MouseClick
}
ledger print -l 'amount > 0' Assets:Main # Print entries where an account has recieved a credit
ledger reg Assets:Main -b 'this month' # Show running monthly balance
ledger budget -b 'this month' # Show if we are on track with budgets this month
@mrbalihai
mrbalihai / .bashrc
Last active March 10, 2016 13:12
Copy passbox to clipboard
# Add the following to your .bashrc
# USAGE: pass "password entry name"
function pass() {
local PASS=$(passbox get ${1} | grep Password\: | cut -c 10-)
echo $PASS > /dev/clipboard # /dev/clipboard is for cygwin but this could be replaced with any clipboard command e.g:
# `echo $PASS | xclip -selection clipboard` # Linux with xclip
# `echo $PASS | pbcopy # OSX/Darwin
echo ""
echo "Copied password to clipboard for 15s"
" Strip the newline from the end of a string
function! Chomp(str)
return substitute(a:str, '\n$', '', '')
endfunction
" Find a file and pass it to cmd
function! DmenuOpen(cmd)
let fname = Chomp(system("git ls-files | rofi -dmenu -i -l 20 -p " . a:cmd))
if empty(fname)
return
@mrbalihai
mrbalihai / vim-session-management-functions.vim
Last active August 29, 2015 14:06
Vim - Session Management Functions
" Helper function to save the session to my vim dir
function! s:SaveSession(sessionName)
execute "mksession! ~/.vim/session/" . a:sessionName . ".vim"
endfunction
function! s:RestoreSession(sessionName)
execute "source ~/.vim/session/" . a:sessionName . ".vim"
endfunction
" Create editor commands for the functions
" Turn relative line numbers on/off depending on focus or mode
" Place in your .vimrc
set number
autocmd FocusLost * :set relativenumber!
autocmd FocusGained * :set relativenumber
autocmd InsertEnter * :set relativenumber!
autocmd InsertLeave * :set relativenumber
autocmd BufEnter * :set relativenumber
autocmd BufLeave * :set relativenumber!