Skip to content

Instantly share code, notes, and snippets.

@priyadarshan
priyadarshan / gist:2637561
Created May 8, 2012 17:19 — forked from magnars/gist:2360578
ido-imenu as used in Emacs Rocks #10
(require 'thingatpt)
(require 'imenu)
(defun mine-goto-symbol-at-point ()
"Will navigate to the symbol at the current point of the cursor"
(interactive)
(ido-goto-symbol (thing-at-point 'symbol)))
(defun ido-goto-symbol (&optional a-symbol)
"Will update the imenu index and then use ido to select a symbol to navigate to"
@priyadarshan
priyadarshan / gist:2637666
Created May 8, 2012 17:30 — forked from magnars/gist:2350388
Push mark when using ido-imenu
;; Push mark when using ido-imenu
(defvar push-mark-before-goto-char nil)
(defadvice goto-char (before push-mark-first activate)
(when push-mark-before-goto-char
(push-mark)))
(defun ido-imenu-push-mark ()
(interactive)
@priyadarshan
priyadarshan / toggle-earmuffs.el
Created June 15, 2012 18:50 — forked from itoshkov/toggle-earmuffs.el
Emacs lisp toggle-earmuffs
(defun toggle-earmuffs ()
"Add or remove earmuffs (asterisks at front and end) of
variables."
(interactive)
(let* ((saved-point (point))
(variable (thing-at-point 'symbol))
(bounds (bounds-of-thing-at-point 'symbol))
(len (- (cdr bounds) (car bounds)))
(start-char (elt variable 0))
@priyadarshan
priyadarshan / *sbcl*.lisp
Created June 27, 2012 12:24 — forked from valvallow/*sbcl*.lisp
Common Lisp, On Lisp
;; On Lisp P.400
(princ (let ((syms nil))
(do-symbols (s)
(push s syms))
(sort syms #'(lambda (x y)
(> (length (symbol-name x))
(length (symbol-name y)))))))
;; (LEAST-NEGATIVE-NORMALIZED-SINGLE-FLOAT
@priyadarshan
priyadarshan / coin-flip.el
Created August 8, 2012 14:32 — forked from skeeto/coin-flip.el
Monte Carlo Elisp throwaways
;; Minimum Number Of Coin Tosses Such That Probability Of Getting 3
;; Consecutive Heads Is Greater Than 1/2
;; http://blog.eduflix.tv/2012/05/contest-answer-minimum-number-of-coin-tosses-such-that-probability-of-getting-3-consecutive-heads-is-greater-than-12/
(require 'cl)
(defun flip ()
"Flip a coin."
(if (< 0 (random)) 'H 'T))
@priyadarshan
priyadarshan / coin-flip.el
Created August 8, 2012 14:33 — forked from skeeto/coin-flip.el
Monte Carlo Elisp throwaways
;; Minimum Number Of Coin Tosses Such That Probability Of Getting 3
;; Consecutive Heads Is Greater Than 1/2
;; http://blog.eduflix.tv/2012/05/contest-answer-minimum-number-of-coin-tosses-such-that-probability-of-getting-3-consecutive-heads-is-greater-than-12/
(require 'cl)
(defun flip ()
"Flip a coin."
(if (< 0 (random)) 'H 'T))
@priyadarshan
priyadarshan / gist:3338086
Created August 13, 2012 08:03 — forked from jaseg/gist:3334991
Password manager without a password manager

Prelude

Since password managers are big and complicated and I currently am pretty bored since I am sitting in a car for a few hours, here is a simple algorithm to generate resource-specific, unique passwords using a master password and no password database.

WARNING

It is 00:23 local time and I spent the part of the last night that I slept on a couch with loud music playing, so I would recommend you not to rely on my brilliant mind to produce a cryptographically secure algorithm at this time. I would, however, appreciate any comments and especially improvements of this algorithm. The first person to find a flaw has the honor to name the algorithm.

Usage

@priyadarshan
priyadarshan / pictures.markdown
Created August 29, 2012 16:51 — forked from sent-hil/pictures.markdown
River (getriver.com): Keep a programming journal.

One of my favorite past times is to look at the notebooks of famous scientists. Da Vinci's notebook is well known, but there plenty others. Worshipping Da Vinci like no other, I bought a Think/Create/Record journal, used it mostly to keep jot down random thoughts and take notes. This was great in the beginning, but the conformity of lines drove me nuts. Only moleskines made blank notebooks, so I had to buy one.

At the same time I started a freelance project. The project itself is irrelevant, but suffice to say it was very complex and spanned several months. It seemed like a perfect opportunity to use the moleskine. Looking back, all my entries fell under few categories:

  • Todo
  • Question
  • Thought
  • Bug
  • Feature
(setq mu4e-mu-binary "/usr/local/bin/mu"
mu4e-sent-folder "/[Gmail].Sent Mail"
mu4e-drafts-folder "/[Gmail].Drafts"
mu4e-trash-folder "/[Gmail].Trash"
mu4e-refile-folder "/Archives"
mu4e-use-fancy-chars nil)
(setq user-mail-address "foo"
user-full-name "bar"
mail-user-agent 'message-user-agent
(defun wc/narrow-window ()
(let (( new-right
(max 0 (+ (or (cdr (window-margins)) 0)
(- (window-body-width) fill-column)))))
(set-window-margins nil (car (window-margins)) new-right)
(set-window-fringes nil (car (window-fringes)) 2)))
(define-minor-mode wrap-column-mode
"Wrap the text at `fill-column'.
Works by adjusting the right margin."