Skip to content

Instantly share code, notes, and snippets.

@priyadarshan
priyadarshan / imgur-dwnldr.el
Created August 8, 2012 14:34
imgur album downloader (by skeeto)
(require 'cl)
(require 'json)
(defun imgur/get-json (url)
"Get JSON data from an imgur album at URL."
(with-current-buffer (url-retrieve-synchronously url)
(goto-char (point-min))
(search-forward "images: ")
(json-read)))
@priyadarshan
priyadarshan / deduplicate.el
Created August 10, 2012 17:15
Remove one duplicate (as long as heading is numbered)
;;;; deduplicate.el
;; perlgex is
;; (\d+\.*\n*)([^\d]*\n)+
;; elisp is
;; "(\\d+\\.*\\n*)([^\\d]*\\n)+"
(require 'cl)
(require 'pcre2el)
@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."

Awesome PHP

A list of amazingly awesome PHP libraries, resources and shiny things.

Composer

#!/usr/bin/env ruby
#
# Converts VCard to org-mode/org-contacts files
#
# 2012 by Simon Thum
#
# Requires the vpim gem, which in turn needs patches to run (github xing/vpim)
#
# To the extent possible under law, the author(s) have dedicated all
# copyright and related and neighboring rights to this software to the
#!/usr/bin/env python
import os.path
import re
import sys
POEM_RE = re.compile(ur"\s*:GENRE:\s*poem\s*", re.IGNORECASE)
END_RE = re.compile(ur"\s*:END:\s*", re.IGNORECASE)
SECTION_RE = re.compile(ur"[#*]")
BEGIN_VERSE_RE = re.compile(ur"\s*#\+BEGIN_VERSE")
import os
import re
import subprocess
import sys
PART_RE = re.compile(ur"^(.+)-part-\d+$")
if __name__ == "__main__":