Skip to content

Instantly share code, notes, and snippets.

View wrobstory's full-sized avatar

Rob Story wrobstory

View GitHub Profile
@wrobstory
wrobstory / gist:6ca2a3104ec323771ffd
Created September 15, 2015 03:29
Python Data Vis deps
Babel==1.3
Cython==0.22.1
Flask==0.10.1
Jinja2==2.7.3
Markdown==2.6.2
MarkupSafe==0.23
PyYAML==3.11
Pygments==2.0.2
Sphinx==1.3.1
Werkzeug==0.10.4
@wrobstory
wrobstory / memcached.md
Created August 31, 2015 20:44
IMDM 2015 Cost-based Memory Partitioning and Management in Memcached

Cost-based Memory Partitioning and Management in Memcached, Damiano Carra (University of Verona), Pietro Michiardi (Eurecom)

  • Memcached: Key-value store, common component of web architectures (caching layer), all data kept in-memory (RAM)
  • Memchached divides objects in classes depending on size (small, medium, large)
  • Memory divided into blocks called "slabs", default slab is 1 MB. Slab contains variable number of objects.
  • Slabs are assigned to classes upon request
  • After many requests, available memory (divided into slabs) is full, what happens with new request?
  • Memcaches uses LRU eviction within the class
  • Challenges: how is memory divided among the classes? Static vs. dynamic assignment
  • Given a trace and an eviction policty, can compute miss-ratio curves (MRC)
@wrobstory
wrobstory / Legend.ipynb
Last active October 13, 2017 10:20
Seaborn legend
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wrobstory
wrobstory / pytest.md
Last active October 20, 2015 22:21
PyTest4Tim

Why py.test?

py.test Assertions

IMO, py.test tests read better, because of the assert magic. When comparing two Python objects, py.test performs introspection on them for the comparison. As the end user, you don't really need to care about that; you just need to care that your test suite is much more readable. Compare the following:

def test_my_thing():
    # Assume we make some things we want to compare
    assert expected_list == result_list
 assert expected_set == result_set
zero_to_ten = loans.loc[(loans['funded_amnt'] >= 0) &
(loans['funded_amnt'] < 10000)]
ten_to_twenty = loans.loc[(loans['funded_amnt'] >= 10000) &
(loans['funded_amnt'] <= 20000)]
ten_to_twenty = loans[loans['funded_amnt'] >= 200000]
@wrobstory
wrobstory / time_queue.clj
Last active August 29, 2015 14:21
Sliding Window Queue
;; Assume we initialize this queue at 11:00
(def time-queue (SlidingWindowQueue "1", "HOUR"))
;; We put some things in it over the hour
(put time-queue {:time "2015-05-21 11:01:00" :value 18})
(put time-queue {:time "2015-05-21 11:29:00" :value 10})
(put time-queue {:time "2015-05-21 11:31:00" :value 15})
(put time-queue {:time "2015-05-21 11:45:00" :value 7})
(get-all time-queue)
[{:time "2015-05-21 11:01:00" :value 1}
val byteBlob = s3.get(s3config.bucket, s3config.file)
val lines = new String(byteBlob).split("\n")
lines.slice(1, lines.length).map(line => {
line.split(",") match {
case Array(col1, col2, col3) => {
doSomethingHere(col1, col2, col3)
}
}
})
@wrobstory
wrobstory / gist:4d861241dc579bb6688f
Last active August 29, 2015 14:20
Magic Rares/Valuable

Saviors of Kamagawa:

  • Reverence
  • Arashi, The Sky Asunder
  • Miren, The Moaning Well
  • Pithing Needle
  • Kami of the Crescent Moon
  • Erayo, Soratami Ascendant

Darksteel:

  • Greater Harvester
scala> scalaMap.
+ collect filter groupBy keysIterator partition seq toArray transpose
++ collectFirst filterKeys grouped last product size toBuffer unzip
++: companion filterNot hasDefiniteSize lastOption reduce slice toIndexedSeq unzip3
- compose find head lift reduceLeft sliding toIterable updated
-- contains flatMap headOption map reduceLeftOption span toIterator values
/: copyToArray flatten init mapValues reduceOption splitAt toList valuesIterator
:\ copyToBuffer fold inits max
select cut, price
from diamonds
where cut in ('Ideal', 'Premium')
order by price desc
limit 10;