Skip to content

Instantly share code, notes, and snippets.

@zhiboz
zhiboz / gist:dc8c4f9d4a0590cad41b2d0941b4ebfd
Created May 27, 2016 15:29 — forked from drorata/gist:146ce50807d16fd4a6aa
Minimal Working example of Elasticsearch scrolling using Python client
# Initialize the scroll
page = es.search(
index = 'yourIndex',
doc_type = 'yourType',
scroll = '2m',
search_type = 'scan',
size = 1000,
body = {
# Your query's body
})
#==========================================================#
# Visualizing Facebook networks with friend photos #
# Katya Ognyanova, www.kateto.net, @ognyanova #
#==========================================================#
# Find more details at http://bit.ly/fbgephi
#==========================================================#
#### Collect the data using the RFacebook package ####
@zhiboz
zhiboz / python-requests-postgrest-client.py
Last active November 13, 2017 20:02 — forked from davidthewatson/python-requests-postgrest-client.py
python-requests-postgrest-client
import requests
import requests_jwt
import json
# email and password auth through postgrest
resp = requests.post('http://localhost:3000/rpc/login', json={"email": "you@yours.com", "pass": "dog"})
print resp # <Response [200]>
# JWT token-based auth through postgrest using the returned token from above
auth = requests_jwt.JWTAuth(json.loads(resp.text)['token'])
@zhiboz
zhiboz / first_debate_2016.R
Last active November 13, 2017 20:01 — forked from benmarwick/first_debate_2016.R
data science in R
library(tidyverse)
library(stringr)
# read in the transcript
# I simply copied the text from the page at
# https://www.washingtonpost.com/news/the-fix/wp/2016/09/26/the-first-trump-clinton-presidential-debate-transcript-annotated/
# and popped it into a txt file
xx <- scan("first_debate_2016.txt", "character")
@zhiboz
zhiboz / downloadAndWrite.sh
Created April 27, 2018 17:56 — forked from amcp/downloadAndWrite.sh
This groovy script loads the Enron email graph and performs a traversal for the shortest path between two nodes
#!/bin/bash
wget https://snap.stanford.edu/data/email-Enron.txt.gz
gunzip email-Enron.txt.gz
bin/gremlin.sh #and then :load enron.groovy
import collections
import datetime
import logging
from goblin import properties
logger = logging.getLogger(__name__)
CARD_MAPPING = {'Cardinality.single': 'Cardinality.SINGLE',

Keybase proof

I hereby claim:

  • I am zhiboz on github.
  • I am zhiboz (https://keybase.io/zhiboz) on keybase.
  • I have a public key ASBWlDFjzlEHuko04YOZT2uF3aKU9v7cjlGXyNnKIeK7gQo

To claim this, I am signing this object:

@zhiboz
zhiboz / inputrc
Created February 28, 2019 00:03 — forked from snipe/inputrc
~/.inputrc for nice bash history up-arrows. This allows you to search through your history using the up and down arrows … i.e. type "cd /" and press the up arrow and you'll search through everything in your history that starts with "cd /". Create ~/.inputrc and fill it with this:
"\e[A": history-search-backward
"\e[B": history-search-forward
set show-all-if-ambiguous on
set completion-ignore-case on
@zhiboz
zhiboz / Makefile
Created March 17, 2020 01:00
JSON to BSON conversion in C
all: json2bson
clean:
rm -f json2bson
json2bson: json2bson.c
${CC} $(shell pkg-config --cflags json libmongo-client glib-2.0) -Wall -O0 -ggdb3 -std=c99 ${CFLAGS} \
$(shell pkg-config --libs json libmongo-client glib-2.0) -o $@ $^
check: all
./json2bson <test.json >test.bson