Skip to content

Instantly share code, notes, and snippets.

View gowda's full-sized avatar

Basavanagowda Kanur gowda

View GitHub Profile
@gowda
gowda / around-with-io.clj
Created September 3, 2012 21:51
Handling combination of IO blocks and LazySequence in clojure
;; while working within a 'with-open' block care should be taken
;; about the procedure which return a lazy sequence.
;; block which might trigger a "Stream closed" error
(with-open [s (-> (java.io.StringReader. "you may not get this string")
java.io.BufferedReader.)]
(read-line s))
;; block which will surely return the line read
@gowda
gowda / htc-desire-s.txt
Created September 12, 2012 16:14
HTC Desire S - How not to get lost!
# fastboot oem rebootRUU - takes the phone into RUU mode
# fastboot flash zip <path-to-zip-file-from-RUU> [required twice, will be directed by fastboot itself]
@gowda
gowda / gist:4692597
Created February 1, 2013 17:03
Find frequency of a character in a string
(let [string "this is a string"]
(reduce (fn [h ch]
(if (get h ch)
(assoc h ch (inc (get h ch)))
(assoc h ch 1)))
{}
string))
@gowda
gowda / gist:4692703
Created February 1, 2013 17:22
Find frequency of each character in a string
"this is a string".scan(/./).reduce(Hash.new(0)) { |hash, ch| hash[ch] += 1; hash }
def frequency(hash, char):
if hash.has_key(char):
hash[char] = hash[char] + 1
else:
hash[char] = 1
return hash
reduce(frequency, list("string it is"), {})
for branch in $(git branch -r | grep -v master); do
git checkout -tb $(echo $branch | cut -d'/' -f2) $branch;
done
@gowda
gowda / screenrc
Created February 5, 2016 14:27
Screen Configuration
startup_message off
# Allow bold colors - necessary for some reason
attrcolor b ".I"
# Tell screen how to set colors. AB = background, AF=foreground
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
# Enable 256 color term
term xterm-256color
@gowda
gowda / bash-startup-time-with-rvm.sh
Last active October 3, 2018 11:33
Bash interactive login shell startup time when configuring rvm
$ time echo 'exit' | bash -li
$ exit
logout
real 0m0.382s
user 0m0.174s
sys 0m0.163s
@gowda
gowda / bash-startup-time-without-rvm.sh
Created October 3, 2018 11:40
Bash interactive login shell startup time when not configuring rvm
$ time echo 'exit' | bash -li
$ exit
logout
real 0m0.039s
user 0m0.009s
sys 0m0.020s
@gowda
gowda / bash-lazy-rvm-loader-for-rvm.sh
Created October 3, 2018 11:43
Bash lazy loader function to configure rvm when rvm itself is invoked
function rvm() {
unset -f "rvm";
local SCRIPT="$HOME/.rvm/scripts/rvm"
  [[ -s ${SCRIPT} ]] && source ${SCRIPT};
rvm "$@";
}