Skip to content

Instantly share code, notes, and snippets.

View scotthaleen's full-sized avatar
λ

スコット scotthaleen

λ
View GitHub Profile
@scotthaleen
scotthaleen / reorganize-list.clj
Last active August 29, 2015 13:56
Given a list and a vector of indexes -- return a reorganized list from the indexes supplied, e.g. [A B C] [2 3 1] => [B C A]
(defn reorganize-list
([lst idxs] (reorganize-list lst idxs nil))
([lst idxs out-of-range]
(let [n (fn [i] (fn [l] (nth l i out-of-range)))
f (apply juxt (map n idxs))]
(f lst))))
;;=> (reorganize-list (range 10 20) [1 -1 5] 99)
;;[11 99 15]
@scotthaleen
scotthaleen / 0_reuse_code.js
Created June 2, 2014 23:26
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@scotthaleen
scotthaleen / emacs-list.sh
Created August 29, 2014 00:53
debian emacs install
wget -q http://londo.ganneff.de/apt.key -O- | apt-key add -
echo "deb http://londo.ganneff.de wheezy main" > /etc/apt/sources.list.d/emacs.list
aptitude update
aptitude install emacs-snapshot
@scotthaleen
scotthaleen / spark_es_search_list.py
Last active August 29, 2015 14:24
Spark Elastic Search List
#!/usr/bin/env python
from pyspark import SparkContext, SparkConf
import urllib2
import json
conf = SparkConf().setAppName("ES Search List")
sc = SparkContext(conf=conf)
url='localhost:9200'
@scotthaleen
scotthaleen / lein_jars_local.txt
Created October 26, 2015 18:37
leiningen download project dependencies locally
# download transitive dependencies to local directory
lein pom
mvn dependency:copy-dependencies
ls -la target/dependency/
@scotthaleen
scotthaleen / gmail_downloader.py
Created November 4, 2015 15:41
Download Gmail
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import re
import imaplib
import email
from email.utils import getaddresses
import datetime
import getpass
import argparse
(def lookup-int-val
(merge
{\* 36 \@ 37 \# 38}
(zipmap (map char(range 48 58)) (range))
(zipmap
(map char (range 65 91))
(drop 10 (range)))))
(defn inc-sum [sum v i]
(let [val (if (even? i) (* 2 v) v)]
(defvar helm-fzf-source
(helm-build-async-source "fzf"
:candidates-process 'helm-fzf--do-candidate-process
:nohighlight t
:requires-pattern 2
:candidate-number-limit 9999))
(defun helm-fzf--do-candidate-process ()
(let* ((cmd-args `("fzf" "-x" "-f" ,helm-pattern))
(proc (apply #'start-file-process "helm-fzf" nil cmd-args)))
@scotthaleen
scotthaleen / vimium-emacs.md
Created January 8, 2016 17:50
Emacs-Style Key Bindings for Vimium

My Vimium Key Bindings (Emacs-Style)

This is a full set of key bindings (as of Vimium v1.45); covering all Vimium functionality. I have tried to map all Vimium functionality to comparable Emacs functionality (whenever possible). In cases where there is no equivalent, those commands are prefixed by <c-g> (indicating <c-g>oogle Chrome; and because <c-g> does not conflict with other Emacs shortcuts at all).

Commented Shortcuts: There are a few Emacs-style shortcuts that are simply not possible in Vimium. All of my shortcuts (including those which were not possible; i.e. where I used a decent alternative) have been commented below. This should help to clarify my rationale.

_Compatibility: All of these shortcuts were tested on Mac OS X (Mavericks). Please note that all of my shortcuts operate under the assumption that your Emacs Meta key is the Alt/Option key. This really was my only choice, because the key is already used in Chrome for shortcuts that c