Skip to content

Instantly share code, notes, and snippets.

View drorata's full-sized avatar

Dror Atariah drorata

View GitHub Profile
@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: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:146ce50807d16fd4a6aa
Last active February 27, 2024 10:15
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
})
@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 / gist:b05bfd59c45eec0470f6
Last active May 9, 2022 14:12
Nice output of pandas.DataFrame in org-mode
import pandas as pd
import numpy as np
from tabulate import tabulate

df = pd.DataFrame(np.random.random((4,3)), columns=['A','B','C'])
print("foo")
return(tabulate(df, headers="keys", tablefmt="orgtbl"))
@drorata
drorata / gist:6d6be93ca74edffe0760
Created July 16, 2015 07:26
Word count in a file stored on S3 using Spark (python version)
from pyspark import SparkContext
sc = SparkContext(appName = "simple app")
sc._jsc.hadoopConfiguration().set("fs.s3n.awsAccessKeyId", "yourAccessKeyId")
sc._jsc.hadoopConfiguration().set("fs.s3n.awsSecretAccessKey", "yourSecretAccessKey")
text_file = sc.textFile("s3n://bucketName/filename.tar.gz")
counts = text_file.flatMap(lambda line: line.split(" ")) \