Skip to content

Instantly share code, notes, and snippets.

View drorata's full-sized avatar

Dror Atariah drorata

View GitHub Profile
@drorata
drorata / gist:8709182
Last active August 29, 2015 13:55
Colorful drawing of the spiral of roots using TikZ
% The Spiral of Roots (https://gist.github.com/drorata/8709182)
%
% Inspired by Felix Lindemann (http://www.texample.net/tikz/examples/rooty-helix/)
%
% Author: Dror Atariah, drorata@gmail.com
\documentclass[border=4pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
sid=res['_scroll_id']
IDs=[]
scroll_size=res['hits']['total']
while (scroll_size > 0):
sys.stdout.write('.')
sys.stdout.flush()
try:
res=es.scroll(scroll_id=sid,scroll='1m')
IDs += res['hits']['hits']
sid=res['_scroll_id']
@drorata
drorata / gist:a8eccd3e07c2f72970b2
Last active August 29, 2015 14:10
Flatten list of dictionaries to a tuple
{
"metadata": {
"name": "",
"signature": "sha256:d5b3e958f7624194296f7f343c6dd48ae49eb42a47ccc694f35bc575a2bd23d7"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@drorata
drorata / gist:8b6d9332c05b272426f1
Created December 9, 2014 13:54
Print mixed dtypes in columns of DataFrame
{
"metadata": {
"name": "",
"signature": "sha256:63382758aa4c42ca13e1a47f0deebe1617a89f35f5fcc00ce9f6b2e24efa2e9e"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@drorata
drorata / remove_output.py
Created March 12, 2015 08:59
Remove output cells and execution counts
"""
Usage: python remove_output.py notebook.ipynb [ > without_output.ipynb ]
Modified from remove_output by:
damianavila (https://gist.github.com/damianavila/5305869)
"""
import sys
import io
import os
from IPython.nbformat import read, write
@drorata
drorata / sparkWordCount.py
Created August 18, 2015 10:31
Sample of word count using spark from a local file. Order the result in a descending order.
import re
from pyspark import SparkContext
print "-----------------===========================-----------------"
print "-----------------==========Staring==========-----------------"
print "-----------------===========================-----------------"
sc = SparkContext(appName = "simple app")
print "-----------------===========================-----------------"
print "-----------------==========Loaded file======-----------------"
print "-----------------===========================-----------------"
Cat,Country,Count
A,DE,0.4596065657
B,DE,0
C,US,0.3224789091
A,UK,0.4740651803
B,US,5
C,UK,0.6467712916
A,UK,0.4206986968
B,DE,0.647481787
C,UK,0.7009353881
@drorata
drorata / gist:7437306
Created November 12, 2013 19:37
Place '>' sign aligned with a piecewise linear curve and mark its vertices using decorations. See the discussion in this thread: http://tex.stackexchange.com/q/144584/412
\begin{tikzpicture}[
mnode/.style={circle,draw=black,fill=black,inner sep=0pt,minimum size=2pt},
node at every point/.style={%
decoration={%
show path construction,
lineto code={%
\coordinate (pos) at ($0.5*(\tikzinputsegmentlast)+0.5*(\tikzinputsegmentfirst)$);
\coordinate (direction) at ($(\tikzinputsegmentlast)-(\tikzinputsegmentfirst)$);
\gettikzxy{(direction)}{\dirx}{\diry}
\pgfmathsetmacro\rotationdir{atan(\diry/\dirx)}
@drorata
drorata / gist:7950857
Created December 13, 2013 20:29
Backtrace of error with org-mobile-push.
Debugger entered--Lisp error: (wrong-type-argument sequencep :grouptags)
mapconcat(identity ("PRIVATE" "{" "WORK" :grouptags "WORK@mittagseminar" "WORK@open_questions" "WORK@diss" "WORK@CV" "}" "{" "IT" :grouptags "IT@emacs" "IT@git" "IT@TeX" "}" "{" "PROG" :grouptags "PROG@mathematica" "PROG@cgal" "}" "}" "4freeTime" "bms_friday" "emacs" "interesting_questions" "mittagseminar" "Mittagsseminar" "NOTE" "private" "results" "work" "Yvinec" "Ziegler") " ")
(insert "#+TAGS: " (mapconcat (quote identity) tags " ") "\n")
(save-current-buffer (set-buffer temp-buffer) (while (setq entry (car (prog1 def-todo (setq def-todo (cdr def-todo))))) (insert "#+READONLY\n") (setq kwds (mapcar (function (lambda (x) (if (string-match "(" x) (substring x 0 ...) x))) (cdr entry))) (insert "#+TODO: " (mapconcat (quote identity) kwds " ") "\n") (setq dwds (member "|" kwds) twds (org-delete-all dwds kwds) todo-kwds (org-delete-all twds todo-kwds) done-kwds (org-delete-all dwds done-kwds))) (if (or todo-kwds done-kwds) (progn (in
@drorata
drorata / gist:e58b673fd87edfc92960
Last active January 19, 2016 08:44
Multi-type frequency count
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Assume you have events log with two event types `foo` and `bar`. The goal is to obtain a frequency bar plot of the events per some predescribed time interval."
]
},
{