Skip to content

Instantly share code, notes, and snippets.

@samrat
samrat / archive.html
Created March 21, 2012 13:53
_templates
{% extends "base.html" %}
{% block title %}Archive- Samrat Man Singh{% endblock %}
{% block content %}
<div class="container" style="padding-bottom:100px;">
<div class="row">&nbsp;</div>
<div class="row">&nbsp;</div>
<div class="row">
@samrat
samrat / rc.xml
Created April 26, 2012 21:06
openbox/rc.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- Do not edit this file, it will be overwritten on install.
Copy the file to $HOME/.config/openbox/ instead. -->
<openbox_config xmlns="http://openbox.org/3.4/rc" xmlns:xi="http://www.w3.org/2001/XInclude">
<resistance>
<strength>10</strength>
<screen_edge_strength>20</screen_edge_strength>
</resistance>
<focus>
<focusNew>yes</focusNew>
@samrat
samrat / goodreads_export.py
Created July 19, 2012 16:51
Python file to convert Goodreads-exported CSV to markdown friendly list
import csv
books = csv.reader(open('goodreads_export.csv', 'rb'))
output_file = open('books.md', 'a')
for row in books:
if 'read' in row:
output = "- **"+row[1]+"** by " + row[2] + "\n"
output_file.write(output)
print outpu
(define cutA 7)
(define growA 3)
(define cutB 5)
(define growB 2)
(define (attack-monster heads)
(use-sword heads 0 '()))
(define (use-sword n grow s)
(cond ((< n 0) 0)
(define cutA 7)
(define growA 3)
(define cutB 5)
(define growB 2)
(define (attack-monster heads)
(use-sword heads 0 null))
(define (use-sword n grow s)
(cond ((< n 0) null)
(define cutA 7)
(define growA 3)
(define cutB 5)
(define growB 2)
(define (attack-monster heads)
(use-sword heads 0 '()))
(define (use-sword n grow s)
(cond ((< n 0) '())
@samrat
samrat / gist:3850914
Created October 8, 2012 05:47
Fibonacci numbers with the golden ratio
(define golden-ratio (/ (+ 1 (sqrt 5)) 2))
(define (fib n)
(inexact->exact (round (/ (expt golden-ratio n) (sqrt 5)))))
nrepl.el wasn't playing very well with Evil-mode(the cursor didn't move to the next line). And this fixed it:
```(defadvice nrepl-return (before switch-to-normal-mode activate)
(evil-execute-in-emacs-state 1))```
@samrat
samrat / gist:5712313
Created June 5, 2013 08:01
Migrate blog posts to YYYY-MM-DD-post-title.md naming.
(defn new-file-name [file]
(let [metadata (metadata file)
slug (or nil (:slug metadata))
parsed-date (or (or (parse (:date metadata)) nil)
(local-now))]
(if slug (-> (clojure.string/replace slug #"\/" "-")
(clojure.string/replace #"-blog-" ""))
(str
(year parsed-date) "-"
(if (= (count (str (month parsed-date))) 2)
(defn max-key-val
"Like max-key, but returns [x (f x)] for which (f x) is greatest"
[f & args]
(let [z (zipmap args (map f args))]
(reduce (fn [max i]
(if (> (second i) (second max))
i
max))
(first z)
(rest z))))