Skip to content

Instantly share code, notes, and snippets.

View bash_cheetsheet
if [[ "$aa" ]]; then echo "Test0" ; fi
if [[ "$bb" ]]; then echo "Test0.1" ; fi
if [[ !"$aa" ]]; then echo "Test0.2" ; fi
if [[ ! "$aa" ]]; then echo "Test0.3" ; fi
if [[ "$aa" && ! "$bb" ]]; then echo "Test1" ; fi
if [[ "$aa" && ! "$aa" ]]; then echo "Test2" ; fi
if [[ "$aa" ]] && ! [[ "$bb" ]]; then echo "test3" ; fi
agounaris /
Created Apr 28, 2017
Word count of markdown jupyter notebook cells
import io
from IPython.nbformat import current
with, 'r', encoding='utf-8') as f:
nb =, 'json')
word_count = 0
for cell in nb.worksheets[0].cells:
if cell.cell_type == "markdown":
word_count += len(cell['source'].replace('#', '').lstrip().split(' '))
agounaris / xelatex_macos.txt
Last active Sep 22, 2017
Jupyter notebook pdf export fix on macos
View xelatex_macos.txt
Download and install xelatex from
Based on the exact version etc add the executable on path
export PATH="$PATH:/usr/local/texlive/2016basic/bin/x86_64-darwin"
install all the following
sudo tlmgr update --self
sudo tlmgr install collectbox
sudo tlmgr install ucs
sudo tlmgr install adjustbox
import collections
def json_object_hook(d):
return namedtuple('X', d.keys())(*d.values())
def json2obj(data):
return json.loads(data, object_hook=json_object_hook)
data = '{"name": "whatever","phone_number": {"home": "aaaa1","mobile": "aaaa2"}}'
obj = json2obj(data)
agounaris / logging_requests
Created Dec 17, 2015
full info on a python requests request
View logging_requests
import requests
import logging
import httplib
httplib.HTTPConnection.debuglevel = 1
requests_log = logging.getLogger("requests.packages.urllib3")
View tmux-cheatsheet.markdown

tmux shortcuts & cheatsheet

start new:


start new with session name:

tmux new -s myname
agounaris / gulpfile.js
Created Jun 15, 2015
gulp auto run test cases
View gulpfile.js
var gulp = require('gulp'),
sys = require('sys'),
exec = require('child_process').exec;
gulp.task('phpunit', function() {
exec('phpunit', function(error, stdout) {
agounaris / jquery_drop_events.html
Last active Aug 29, 2015
Grab drop events with jquery
View jquery_drop_events.html
<!DOCTYPE html>
<meta charset="utf-8">
<title>JS Drop Events</title>
<style media="screen">
agounaris / .tmux.conf
Last active Aug 29, 2015
tmux configuration
View .tmux.conf
set -g status on
set -g status-keys vi
set -g history-limit 1000000
# Setup 'v' to begin selection as in Vim
bind-key -t vi-copy v begin-selection
bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
# Set prefix to Ctrl-Space
unbind C-b
agounaris / es_score_matching.json
Last active Aug 29, 2015
Elasticsearch score matching
View es_score_matching.json
"from": 0,
"query": {
"function_score": {
"functions": [
"weight": 1.5,
"filter": {
"term": {
"_type": "store"