Skip to content

Instantly share code, notes, and snippets.

@priyadarshan
priyadarshan / gist:2464631
Created April 22, 2012 15:28
An O(n) implementation of McCreight's suffix-tree algorithm.
;;; Original URL: http://fpn.mit.edu/Downloads/SuffixTree
;;; Copyright rif@mit.edu 2004.
(defpackage :suffix-tree
(:export :build-suffix-tree :stree-root :*stree-print-string*
:random-string :subtree-size :count-leaves)
(:use :common-lisp))
;; An O(n) implementation of McCreight's suffix-tree algorithm.
;; Usage example:
;;;; -*- Mode: Lisp -*-
;;;; http://pastebin.com/S1FzEZpn
;;
;; vim: filetype=lisp
(in-package :stumpwm)
;; Load swank.
;; ! what's this?
(load "/opt/quicklisp/dists/quicklisp/software/slime-20120307-cvs/swank-loader.lisp")
@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 / 17.org
Created June 21, 2012 19:17
The Vedas: Immortality's First Call (Creative Commons Attribution 3.0 License)

The Vedas: Immortality’s First Call

@priyadarshan
priyadarshan / constants.el
Created June 27, 2012 12:20
constants.el
;;; constants.el --- enter definition of constants into source code
;; Copyright (c) 2003, 2004, 2005 Carsten Dominik
;; Author: Carsten Dominik <dominik@science.uva.nl>
;; Version: 2.2
;; Keywords: programming, languages
;; This file is not part of GNU Emacs.
;; This file is free software; you can redistribute it and/or modify
@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))