Skip to content

Instantly share code, notes, and snippets.

View ramn's full-sized avatar

ramn ramn

View GitHub Profile
@ramn
ramn / dot_ctags
Last active October 2, 2015 22:08 — forked from awl/dot_ctags
scala regular expressions for ctags and tagbar in vim
--langdef=Scala
--langmap=Scala:.scala
--regex-Scala=/^[ \t]*(((implicit|private|protected)?[ \t]*)*(\[[a-zA-Z0-9_]*\])?[ \t]*)*object[ \t]*([a-zA-Z0-9_]+)/\5/o,objects/
--regex-Scala=/^[ \t]*(((implicit|private|protected|sealed)?[ \t]*)*(\[[a-zA-Z0-9_]*\])?[ \t]*)*trait[ \t]*([a-zA-Z0-9_]+)/\5/t,traits/
--regex-Scala=/^[ \t]*(((implicit|private|protected|sealed)?[ \t]*)*(\[[a-zA-Z0-9_]*\])?[ \t]*)*(case[ \t]*)?class[ \t]*([a-zA-Z0-9_]+)/\6/c,classes/
--regex-Scala=/^[ \t]*abstract[ \t]*class[ \t]*([a-zA-Z0-9_]+)/\1/a,aclasses/
--regex-Scala=/^[ \t]*((implicit|override|lazy|private|protected|private\[[a-zA-Z]+\])[ \t]*)*def[ \t]*([a-zA-Z0-9_=]+)[ \t]*/\3/m,methods/
--regex-Scala=/^[ \t]*(((override|lazy|private|protected)?[ \t]*)*(\[[a-zA-Z0-9_]*\])?[ \t]*)*val[ \t]*([a-zA-Z0-9_]+)[ \t]*[:=]/\5/V,values/
--regex-Scala=/^[ \t]*(((override|lazy|private|protected)?[ \t]*)*(\[[a-zA-Z0-9_]*\])?[ \t]*)*var[ \t]*([a-zA-Z0-9_]+)[ \t]*[:=]/\5/v,variables/
--regex-Scala=/^[ \t]*type[ \t]*([a-zA-Z0-9_]+)[ \t]*[\[<>=]/\1
@ramn
ramn / .muttrc
Last active June 4, 2025 14:35
Muttrc example with GMail support
##
## IMAP CREDENTIALS
##
set smtp_url = "smtp://[email protected]:587/"
#set smtp_pass = "password"
set from = "[email protected]"
set realname = "Some User"
##
## IMAP SETTINGS
@ramn
ramn / bash_mutt_aliases.sh
Created February 18, 2012 13:39
Bash Mutt aliases for each IMAP account
# Mutt aliases, one for each imap account
for conf in ~/.mutt/imap_*
do
alias mutt_${conf#*imap_}="mutt -e 'source $conf'"
done
@ramn
ramn / bash_array.sh
Created December 22, 2011 06:23
Arrays in Bash
unset xs; declare -a xs; xs=(${xs[@]} 11); xs=(${xs[@]} 23); echo length: ${#xs[@]}; for n in ${xs[@]}; do echo $n; done
@ramn
ramn / normalizeWebpageStyle.js
Last active September 28, 2015 19:28
Javascript bookmarklet to normalize webpage style
javascript:s=document.body.style;void(s.fontFamily='ubuntu light, lucida grande, verdana' );void(s.background='#EEEEEE');void(s.color='black');void(function(){for(i=0;i<document.links.length;i++){document.links[i].style.color='blue'}}());
@ramn
ramn / netcat_http_server.sh
Created November 26, 2011 22:54
Netcat HTTP server in one line
while true; do nc -l 8989 < <(FILE=my_image.gif; echo -e "HTTP/1.1 200 OK\nContent-type: $(file -nb --mime-type $FILE)\n"; cat $FILE); done
@ramn
ramn / autocompile.sh
Created November 21, 2011 14:41
autocompile: inotifywait loop that autocompiles using given command and file pattern
if [ -z $1 ] || [ -z $2 ]
then
echo "Usage: autocompile <compiler-command> <pattern>"
echo "Examaple: autocompile fsc *.scala"
exit
fi
while true
do
inotifywait -q -e modify,attrib --format='%w' --fromfile <( find . -iname "$2") | while read FILE
@ramn
ramn / pinboard_save_bookmarklet.js
Created October 3, 2011 19:32
Pinboard save bookmarklet, stripping utm_*
javascript:(function(){q=location.href.replace(/utm_source=[^&]+&?|utm_medium=[^&]+&?|utm_campaign=[^&]+&?|utm_content=[^&]+&?/g, "").replace(/[?&]+$/, "");if(document.getSelection){d=document.getSelection();}else{d='';};p=document.title;full_url='https://pinboard.in/add?url='+encodeURIComponent(q)+'&description='+encodeURIComponent(d)+'&title='+encodeURIComponent(p); a=function(){if(!window.open(full_url))location.href=full_url};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})();
@ramn
ramn / simple_template.scala
Created September 12, 2011 20:09
Simple Template (Scala)
val varPattern = """\$\{([^}]*)}""".r
def template(text: String, vars: Map[String, String]) =
varPattern replaceSomeIn (text, m => vars get (m group 1))
@ramn
ramn / shutdownHook.scala
Created August 21, 2011 23:14
Register ShutdownHook (Scala)
object ShutDown {
def main(args: Array[String]) {
sys.ShutdownHookThread {
println("exiting")
}
println("begin sleep")
Thread.sleep(5000L)
println("done sleeping")