Skip to content

Instantly share code, notes, and snippets.

View clifton's full-sized avatar
🎯

Clifton King clifton

🎯
View GitHub Profile
@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;
(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 %))
(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)))

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:

@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
@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
;; 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"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
const _ = require('lodash');
export default class MemcachedStore {
constructor (memcached, { keyPrefix, ttl = 15 * 60 }) {
this.memcached = memcached;
this.keyPrefix = keyPrefix;
this.ttl = ttl;
this.queuedGets = {};
}