Skip to content

Instantly share code, notes, and snippets.

View vu3rdd's full-sized avatar

Ramakrishnan Muthukrishnan vu3rdd

View GitHub Profile
(ns algo.sorting.insert)
;; non-lazy version
(defn insert
"insert key into the lst which is assumed to be already sorted"
[key lst]
(if (empty? lst)
(seq [key])
(let [[x & xs] lst]
(if (< key x)
e ()
{
fname=`echo $1 | cut -d ':' -f1`
linenum=`echo $1 | cut -d ':' -f2`
emacs +$linenum $fname
}
(def d {:name "Ram", :job "Engineer", :age 16})
;=> #'user/d
(:name d)
;=> "Ram"
;; we don't have location as a key in the map
(:location d)
;=> nil
(comment "adlkdsjflsdjf")
;=> nil
(comment (defn x[]
dsdfdsfsd))
;=> nil
(comment (defn x[]
dsdfdsfsd:))
; Evaluation aborted.
(defn error [^String string]
(throw (Exception. string)))
;; now warning goes away
@vu3rdd
vu3rdd / hashupdater.rkt
Created July 10, 2011 16:20
update a deeply nested hash table in Racket
(define (hash-set-in ht ks v)
(cond [(not (list? ks)) (error "ks not a list")]
[(empty? (cdr ks)) (hash-set ht (car ks) v)]
[else
(hash-set ht
(car ks)
(hash-set-in (hash-ref ht (car ks))
(cdr ks)
v))]))
@vu3rdd
vu3rdd / modeline.sh
Created November 16, 2011 04:45
Add a new modeline to get native monitor resolution
#!/bin/sh
$ gtf 1920 1080 59.9
# outputs
# Modeline "1920x1080_59.90" 172.51 1920 2040 2248 2576 1080 1081 1084 1118 -HSync +Vsync
$ xrandr --newmode "1920x1080_59.90" 172.51 1920 2040 2248 2576 1080 1081 1084 1118 -HSync +Vsync
$ xrandr --addmode VGA-1 1920x1080_59.90
@vu3rdd
vu3rdd / hrtl-sol-notes-to-reader.txt
Created May 15, 2012 10:53
"Important Advice to the Reader" from the Solution Manual of "Haskell Road to logic"
This companion volume to The Haskell Road to Logic, Math and Programming will enable you to check
your solutions to the exercises. It should be used wisely. You should only turn to the solution of an exercise
after you have tried to solve the exercise on your own. What the following pages do not provide is a shortcut to
understanding.
You don’t expect to improve your swimming or iceskating skills by watching swimming or iceskating contests
on TV. If you want to learn how to swim you must be willing to get wet. If you want to learn how to skate, you
must venture on the ice skating ring and take the risk of falling. Likewise, you can’t expect to improve your skills
in reasoning or programming by watching others reason or program. Just reading through the following pages, to
watch how the authors reason and program, is next to useless. You have to tackle the problems yourself, at the risk
of making mistakes, only using the solutions as checks on your understanding.
@vu3rdd
vu3rdd / hrtl-sol-notes-to-reader.md
Created May 15, 2012 15:28 — forked from btbytes/hrtl-sol-notes-to-reader.md
"Important Advice to the Reader" from the Solution Manual of "Haskell Road to logic"

This companion volume to The Haskell Road to Logic, Math and Programming will enable you to check your solutions to the exercises. It should be used wisely. You should only turn to the solution of an exercise after you have tried to solve the exercise on your own. What the following pages do not provide is a shortcut to understanding.

You don’t expect to improve your swimming or iceskating skills by watching swimming or iceskating contests on TV. If you want to learn how to swim you must be willing to get wet. If you want to learn how to skate, you must venture on the ice skating ring and take the risk of falling. Likewise, you

@vu3rdd
vu3rdd / ssh-socks-proxy.md
Created May 18, 2012 05:46
circumvent Internet censorship
  • You will need a VPS/Unix Shell account on a remote machine sitting in a country with some sane laws.

  • from your local machine, do:

    $ ssh -D 1080 user@host

On your browser (or other applications), go to the network connection settings, select the option to use a proxy and leave everything blank except the SOCKS option, where you fill in hostname as localhost or 127.0.0.1 and port number as 1080 (or whatever you filled in above). That is all!