Skip to content

Instantly share code, notes, and snippets.

View ramn's full-sized avatar

ramn ramn

View GitHub Profile
@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 / 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 / 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 / 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 / .muttrc
Last active June 17, 2024 16:29
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 / 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 / cartesianProduct.js
Created July 13, 2012 08:22
Produce cartesian product of a list of lists (javascript)
// Lives at: https://gist.github.com/3103615/
function cartesianProduct(xss) {
if (!xss || xss.length < 1)
return [];
else {
var head = xss[0];
var tail = xss.slice(1);
var result = [];
for (var i = 0; i < head.length; i++) {
var productOfTail = cartesianProduct(tail);
@ramn
ramn / gnuplot_examples.sh
Last active October 9, 2015 17:57
Gnuplot examples
# Create svg graph file
cat plotdata_raw | gnuplot -e "set terminal svg; plot '-' using 2:1 with lines" > my_graph.svg
# where plotdata_raw is a file with data, 2 columns separated by whitespace.
# using 2:1 means: use column 2 as x, column 1 as y axis
# with lines: draw a line graph
# Parse time
cat plotdata_raw | gnuplot -e "set xdata time; set timefmt '%s'; plot '-' using 2:1 with lines" -p
@ramn
ramn / webrick_and_erb.rb
Created September 1, 2012 10:50
Simple ruby webserver
require 'webrick'
require 'erb'
template = <<TEMPLATE
<html>
<head>
<title>Ruby as PHP</title>
</head>
<body>
<h1>Loop</h1>
@ramn
ramn / cgi.rb
Created September 1, 2012 10:51 — forked from kek/gist:3153275
Writing a CGI script with templates. For PHP programmers
#!/usr/bin/ruby
require 'cgi'
require 'erb'
cgi = CGI.new('html')
template = <<TEMPLATE
<html>
<head>