Skip to content

Instantly share code, notes, and snippets.

View clifton's full-sized avatar
🎯

Clifton King clifton

🎯
View GitHub Profile
(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"
diff --git a/config/environments/production.rb b/config/environments/production.rb
index f6124a6..7daf949 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -31,5 +31,10 @@ config.after_initialize do
end
$PAYPAL_LOGIN = $PAYPAL_CONFIG[Rails.env]["api_username"]
$PAYPAL_PASSWORD = $PAYPAL_CONFIG[Rails.env]["api_password"]
-config.cache_store = ActiveSupport::Cache::MemCacheStore.new(Memcached::Rails.new("10.211.47.148:11211", :namespace => "wb_data:"))
-ActionController::Base.cache_store = :mem_cache_store, Memcached::Rails.new("10.211.47.148:11211", :namespace => "wb_data:")
class ActiveRecord::ConnectionAdapters::MysqlAdapter
def active?
true
end
def execute_with_retry_if_fail(*args)
execute_without_retry_if_fail(*args)
rescue ActiveRecord::StatementInvalid => e
if e.message =~ /server has gone away/i
warn "Server timed out, retrying"
https://gist.github.com/946747
# join model
class Membership < ActiveRecord::Base
include PortalEntity
include Notifiable
cattr_accessor :skip_create_feed
@@skip_create_feed = false
# virtual attribute for verification purposes
attr_accessor :password
// requires Store.js
OrgSync.cache = (function(store) {
if (!store || typeof store.get !== 'function' || typeof store.set !== 'function') {
throw new Error("Store API not defined.");
}
var api = {};
var now = function () {
return parseInt((new Date).getTime() / 1000);