Skip to content

Instantly share code, notes, and snippets.

@alabid
alabid / gist:a875b56f9fb106c977aa
Last active August 29, 2015 14:16
Rust MongoDB driver TODOs
1. Use cargo (https://crates.io/) to eliminate over-dependence on the make build utility.
2!! Adhere to the drivers API spec onion:
https://docs.google.com/a/10gen.com/spreadsheets/d/13Iy5CDwMeKAlkrPOl8oOJ6_uei6SzIo0NnpdUOaFYvI/edit#gid=0
3. Remove obsolete language features: use of tildes for owned pointers, deprecated macros (like fmt!, fail!),
deprecated crates and modules (like the 'extra' crate), and so on.
4. Use new language features.
5. Create online documentation for the Rust driver.
6. Write a more thorough driver test suite for CRUD functionality.
7. Register repo with Travis CI.
8. Remove unsafe pointer finagling in codebase.
@alabid
alabid / longevity.setup.txt
Last active August 29, 2015 14:11
Longevity tests setup
1. Set ulimits for number of file descriptors and num processes
* soft nofile 100000
* hard nofile 100000
* soft nproc 100000
* hard nproc 100000
in /etc/security/limits.conf
2. logout and then in again
3. install mongo repo (max's fork).

The installation directions for marvel -- a plugin for elastic search -- is very scant and unnecessarily indirect. The clearest instructions I found on how to install the marvel plugin through homebrew was on Twitter! Twitter! Why?! Anyways, to install marvel via brew, you can do this:

brew update
brew upgrade elasticsearch
cd /usr/local/Cellar/elasticsearch/<whatever version>
bin/plugin -i elasticsearch/marvel/latest
@alabid
alabid / maxsub.py
Created September 16, 2012 22:15
solution to max sub array problem in python
def maxSubArray(ls):
if len(ls) == 0:
raise Exception("Array empty") # should be non-empty
runSum = maxSum = ls[0]
i = 0
start = finish = 0
for j in range(1, len(ls)):
if ls[j] > (runSum + ls[j]):
@alabid
alabid / collapse-dict.py
Created July 21, 2012 05:15
Collapse Dict code in python
"""
# How to use:
complicated_dict = {"dict1key": {"dict2key": [{"dict3key": {"tell":"me"}}]}}
one_level_dict = makeSimpleDict(complicated_dict)
print one_level_dict
# prints out {'dict1key.dict2key.[0].dict3key.tell': u'me'}
"""
def makeSimpleDict(complex_dict):
"""
@alabid
alabid / collapse-dict-output.json
Created July 21, 2012 04:58
Output of collapsedict method
{
"apiVersion": "2.0",
"data.updated": "2010-01-07T19:58:42.949Z",
"data.totalItems": "800",
"data.startIndex": "1",
"data.itemsPerPage": "1",
"data.items.[0].id": "hYB0mn5zh2c",
"data.items.[0].uploaded": "2007-06-05T22:07:03.000Z",
"data.items.[0].updated": "2010-01-07T13:26:50.000Z",
"data.items.[0].uploader": "GoogleDeveloperDay",
@alabid
alabid / collapse-dict.js
Created July 21, 2012 04:56
collapses a multi-level JS object into a one-level object
// CollapseLib by Daniel Alabi (alabidan.me)
// isPlainObject is part of the jQuery source (I modified the method a little)
/**
* Example use:
* complicated = {"dict1key": {"dict2key": [{"dict3key": {"tell":"me"}}]}}
*
* var dict = CollapseLib.collapseDict(collapse);
* console.log(JSON.stringify(dict, undefined, 2));
*
@alabid
alabid / prettyprintres1.json
Created July 21, 2012 03:03
Pretty Print result
{
"apiVersion": "2.0",
"data": {
"updated": "2010-01-07T19:58:42.949Z",
"totalItems": 800,
"startIndex": 1,
"itemsPerPage": 1,
"items": [
{
"id": "hYB0mn5zh2c",
@alabid
alabid / prettyprintres.js
Created July 21, 2012 02:56
Built-in JS function to pretty print an object
JSON.stringify(objectToPrettyPrint, undefined, 2);
@alabid
alabid / complicated.json
Created July 21, 2012 01:30
Complicated and Collapsed JSON
{"apiVersion":"2.0","data":{"updated":"2010-01-07T19:58:42.949Z","totalItems":800,"startIndex":1,"itemsPerPage":1,"items":[{"id":"hYB0mn5zh2c","uploaded":"2007-06-05T22:07:03.000Z","updated":"2010-01-07T13:26:50.000Z","uploader":"GoogleDeveloperDay","category":"News","title":"Google Developers Day US - Maps API Introduction","description":"Google Maps API Introduction ...","tags":["GDD07","GDD07US","Maps"],"thumbnail":{"default":"http://i.ytimg.com/vi/hYB0mn5zh2c/default.jpg","hqDefault":"http://i.ytimg.com/vi/hYB0mn5zh2c/hqdefault.jpg"},"player":{"default":"https://www.youtube.com/watch?v=hYB0mn5zh2c","mobile":"https://m.youtube.com/details?v=hYB0mn5zh2c"},"content":{"1":"rtsp://v5.cache3.c.youtube.com/CiILENy.../0/0/0/video.3gp","5":"http://www.youtube.com/v/hYB0mn5zh2c?f...","6":"rtsp://v1.cache1.c.youtube.com/CiILENy.../0/0/0/video.3gp"},"duration":2840,"aspectRatio":"widescreen","likeCount":171,"rating":4.63,"ratingCount":68,"viewCount":220101,"favoriteCount":201,"commentCount":22,"status":{"value":"rest