Skip to content

Instantly share code, notes, and snippets.

@zackmdavis
zackmdavis / gist:8870302
Last active August 29, 2015 13:56
answer this later
http://askubuntu.com/questions/410302/how-good-does-ubuntu-run-on-lenovo-y510p?rq=1
this helped me http://askubuntu.com/a/290358
@zackmdavis
zackmdavis / gist:8911197
Created February 10, 2014 06:18
very basic .emacs
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(cua-mode t nil (cua-base))
'(inhibit-startup-screen t)
'(make-backup-files nil))
(custom-set-faces
;; custom-set-faces was added by Custom.
@zackmdavis
zackmdavis / gist:9056258
Created February 17, 2014 18:31
HyTimer scratch work
(import re)
(import functools)
(defn parse [formatted]
(setv time_regex (.compile re "(\d+):?(\d{2}):(\d{2})"))
(setv s&m&h (map (fn [x] (if (empty? x) 0 (int x)))
(.group (.match time_regex formatted)
3 2 1)))
; (print (list (enumerate s&m&h)))
(functools.reduce sum
Before we take a closer look at consistent hashing in Swift, let’s
examine a simpler way in which one might determine where to store
objects. This will illustrate some of the fundamental problems that
need to be solved in order to efficiently add or remove capacity to a
cluster.
A _hash function_ takes in some data and outputs a number that
seemingly has nothing to do with the input but is actually completely
determined by it. This is useful for our purposes, because we want a
predictable way to assign objects to devices, but we don't want our
def underscores_to_hyphens(string)
string.gsub!('_', '-')
end
I'm having trouble verifying the container creation with cURL; as before, I can auth, but I can't do anything else. Not sure what I'm doing wrong ...
curl -v -H 'X-Auth-User: test:tester' -H 'X-Auth-Key: testing' http://localhost:8080/auth/v1.0/
* About to connect() to localhost port 8080 (#0)
* Trying 127.0.0.1... connected
> GET /auth/v1.0/ HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: localhost:8080
> Accept: */*
> X-Auth-User: test:tester
{
"id": "2036184099",
"type": "DeleteEvent",
"actor": {
"id": 903479,
"login": "openstack-gerrit",
"gravatar_id": "319605a7b6f36f2cd80214b2fc4d0e92",
"url": "https://api.github.com/users/openstack-gerrit",
"avatar_url": "https://avatars.githubusercontent.com/u/903479?"
},
@zackmdavis
zackmdavis / reed_solomon.py
Last active August 29, 2015 14:01
demonstration of simple variant of Reed-Solomon coding
from string import ascii_uppercase
ALPHABET = " "+ascii_uppercase
CHAR_TO_INT = dict(zip(ALPHABET, range(27)))
INT_TO_CHAR = dict(zip(range(27), ALPHABET))
def pad(text, chunk_size):
return text + ' '*(chunk_size - len(text) % chunk_size)
def chunkify(text, chunk_size):
@zackmdavis
zackmdavis / swift_authors.py
Created May 29, 2014 03:39
counting SwiftStackers' contributions to Swift
from collections import Counter
import subprocess
import re
# run in a clone of git@github.com:openstack/swift.git
# thanks to http://stackoverflow.com/a/13687302
blame_output = subprocess.check_output('''git ls-tree --name-only -z -r HEAD | egrep -z -Z -E '\.py$' | xargs -0 -n1 git blame --line-porcelain | grep "^author " | sort | uniq -c | sort -nr''', shell=True)
number_regex = re.compile("(\d+)")
(ns interpreter
(:require [clojure.test :refer :all]))
(defn operation_mod_n [operation n]
(fn [& args]
(mod (apply operation args) n)))
(def m+ (operation_mod_n + 1000))
(def m* (operation_mod_n * 1000))