Skip to content

Instantly share code, notes, and snippets.

@suhailshergill
suhailshergill / reverse-proxy.hs
Created August 5, 2012 16:27 — forked from snoyberg/reverse-proxy.hs
A minimalist reverse HTTP proxy using conduit
{-# LANGUAGE OverloadedStrings #-}
import Data.Conduit
import Data.Conduit.List (peek)
import Data.Conduit.Network
import qualified Data.ByteString.Char8 as S8
import Data.Char (toLower, isSpace)
import Network (withSocketsDo)
import Control.Monad.IO.Class
import Control.Concurrent (forkIO)
import Network.Wai
@suhailshergill
suhailshergill / gist:3467113
Created August 25, 2012 15:27 — forked from nicferrier/gist:3466870
converting a bson datetime to an elisp time
(defun bson-datetime-int64-to-time (byte-list)
(let ((calc-num
(concat
"16#"
(mapconcat
(lambda (x) (format "%02X" x))
byte-list ""))))
(list
(calc-eval
"rsh(and(idiv($,1000),16#ffff0000),16)"
(setq org-export-htmlize-output-type 'css)
(setq org-footnote-section nil)
(setq org-footnote-auto-label t)
(setq org-time-stamp-custom-formats
'("<%Y-%m-%d %a>" . "<%Y-%m-%d %a %H:%M %z>"))
(defun su/journal/select-current-entry ()
"helper to select current org entry"
(org-back-to-heading)
(set-mark (point))
(org-end-of-subtree)
@suhailshergill
suhailshergill / .gitattributes
Last active December 15, 2015 02:09
gpg smudge/clean filter
* filter=gpg diff=gpg
[merge]
renormalize=true
@suhailshergill
suhailshergill / 0001-bugfix-fix-org-babel-execute-src-block-on-remote-hos.diff
Created March 24, 2013 20:09
[PATCH] bugfix: fix `org-babel-execute-src-block' on remote hosts
From 7037a45f3504a8d95019bd2b496a919081e85331 Mon Sep 17 00:00:00 2001
From: Suhail Shergill <[email protected]>
Date: Sat, 23 Mar 2013 19:26:31 -0400
Subject: [PATCH] bugfix: fix `org-babel-execute-src-block' on remote hosts
* lisp/ob.el (org-babel-temp-file): For remote hosts, modify the prefix
and leave `temporary-file-directory' unchanged.
The reason setting `temporary-file-directory' doesn't work here is
because `make-temp-file' recursively calls itself (indirectly).
@suhailshergill
suhailshergill / deploy.org
Created April 5, 2013 11:57
provorg: blog deployment

prereqs

  • set remote host + auto-confirm
(setq su/provorg/host "chaos"
      org-confirm-babel-evaluate nil)
@suhailshergill
suhailshergill / doc-view.el
Created January 25, 2014 02:22
emacs: have doc-view-open-text remember correct page
(defadvice doc-view-open-text (around
su/advice/doc-view/doc-view-open-text/around/goto-page
last a c pre)
"grab the page when in doc-view mode and ensure that doc-view-open-text
opens the correct page"
(let ((su/dv/page (doc-view-current-page))
(su/dv/text-buffer-name (concat "Text contents of " (buffer-name))))
ad-do-it
(with-current-buffer su/dv/text-buffer-name
(re-search-forward " " nil t (1- su/dv/page))
@suhailshergill
suhailshergill / Foo.scala
Created January 30, 2014 18:18
scala: granular permissions/access restrictions
object Foo {
// consider the code in each `Foo.scala` object as if it were defined in a
// separate file
object `Traits.scala` {
object Permissions {
private[Permissions] sealed trait Permitted[C] { self: C => }
private[Permissions] sealed trait Permission { self: Permitted[_] =>
protected val Permission: Permission
}
@suhailshergill
suhailshergill / Foo.scala
Created February 12, 2014 21:26
versionable things with access to version
object Def {
object WithoutEnum {
sealed trait Version {
val version: Version
}
trait Version1 extends Version {
val version = Version1
}
implicit object Version1 extends Version1
trait Version2 extends Version {
@suhailshergill
suhailshergill / x-select.el
Created February 23, 2014 16:58
emacs: get inter-program kill/yank to work
(setq x-select-enable-clipboard t)
;; [[https://hugoheden.wordpress.com/2009/03/08/copypaste-with-emacs-in-terminal/][source]]
;; If emacs is run in a terminal, the clipboard- functions have no
;; effect. Instead, we use of xsel, see
;; http://www.vergenet.net/~conrad/software/xsel/ -- "a command-line
;; program for getting and setting the contents of the X selection"
(unless window-system
(when (getenv "DISPLAY")
;; Callback for when user cuts