Skip to content

Instantly share code, notes, and snippets.

View clifton's full-sized avatar
🎯

Clifton King clifton

🎯
View GitHub Profile
;; Fib sequence from http://www.futilitycloset.com/2015/06/28/made-to-order-4/
(def denom 999999999999999999999998999999999999999999999999M)
(->> (.divide 1M denom (java.math.MathContext. 2780))
.toString
(re-find #"\.(\d+)") last ;; extract digits after decimal place
(partition 24)
(map #(apply str %))
clojure.pprint/pprint)
;; =>
["000000000000000000000001"
@clifton
clifton / Vagrantfile
Last active August 29, 2015 14:13
Boot2docker parallels image managed by vagrant with NFS sharing and SSH agent forwarding
VAGRANTFILE_API_VERSION = '2'
Vagrant.require_version '>= 1.6.3'
def require_plugin(name)
unless Vagrant.has_plugin?(name)
raise <<-EOT.strip
#{name} plugin required. Please run: "vagrant plugin install #{name}"
EOT
end
end
@clifton
clifton / vimrc.vim
Created October 20, 2014 16:08
vim.rc
set nocompatible
filetype on " to prevent non-0 exit codes
filetype off
"
" PLUGINS
"
set rtp+=~/.vim/bundle/Vundle.vim

Keybase proof

I hereby claim:

  • I am clifton on github.
  • I am cliftonk (https://keybase.io/cliftonk) on keybase.
  • I have a public key whose fingerprint is 0FD0 6D84 6C24 EAFF DB41 9921 0CE0 D254 8EA0 3B6B

To claim this, I am signing this object:

(defn minmax-by-codepoint
"Takes a string and outputs the most and least common
characters along with their total counts. In the event of a
tie, return the character with the lowest code point"
[s]
(->> (frequencies s)
((juxt (partial sort-by (fn [[c cnt]] [cnt c]))
(partial sort-by (fn [[c cnt]] [(- cnt) c]))))
(map first)))
(defn gen-name []
(let [letter-range (range (int \a) ((comp inc int) \z))
rand-letter #((comp char rand-nth) letter-range)
rand-number #((comp int rand) 1000)]
(format "%s%s%03d" (rand-letter) (rand-letter) (rand-number))))
(def robot #(atom (gen-name)))
(def robot-name #(deref %))
@clifton
clifton / SimpleRequest.java
Created July 3, 2013 20:50
Example file for the upcoming orgsync java api client
package com.orgsync.api.examples;
import java.util.List;
import java.util.concurrent.ExecutionException;
import com.orgsync.api.ApiClient;
import com.orgsync.api.ApiResponse;
import com.orgsync.api.FormsResource;
import com.orgsync.api.OrgSync;
import com.orgsync.api.OrgsResource;
(use '[datomic.api :only [q db] :as d])
(def uri "datomic:mem://accounts")
;; create database
(d/create-database uri)
;; connect to database
(def conn (d/connect uri))
(use '[datomic.api :only [db q] :as d])
;;LOOK IN THE BOTTOM FOR CORRECT USE OF DATOMIC :)
;;not supplied:
;;* connecting to a db named "conn"
;; (checkout awesome Jonas Edlunds gist
;; for inspiration: https://gist.github.com/3122363 )
;;* a schema that fit's the following person-datoms
#!/bin/bash
set -o errexit
set -o nounset
if [[ ${#} -ne 1 ]]
then
echo "Usage: ${0} upstart-conf-file" >&2
exit 1
fi