Skip to content

Instantly share code, notes, and snippets.

View filipposc5's full-sized avatar

Filippos Chalvatzoglou filipposc5

View GitHub Profile
@filipposc5
filipposc5 / pinentry-sniffer.sh
Created November 23, 2017 21:08
pinentry "sniffer" to use with flag --pinentry-program
#!/bin/bash
cat | tee -a ~/pinentry-in.log | pinentry-mac "$@" | tee -a ~/pinentry-out.log
@filipposc5
filipposc5 / dockersave.py
Last active March 29, 2017 12:02
Docker Save - export docker image, calculate md5 / sha 256 on the fly and write to disk
# Small util to avoid hammering the disk by reading and writing files
# all the time. Attempts to export the docker container, calculate md5
# and sha256 sums on the fly, compress, gpg encrypt and write it to disk
#
# Some credit to some Stack Overflow posts is due!
import hashlib
import os
import resource
import subprocess
@filipposc5
filipposc5 / gist:ad4d529ac54fb09ce86de37b721a1baa
Last active March 21, 2017 16:59 — forked from sawicki-maciej/gist:1242279
This D-trace script lists all run programs with their arguments/pid and ppid(edited) - works with OSX
#!/usr/sbin/dtrace -C -s
#pragma D option quiet
proc:::exec-success,proc::posix_spawn:exec-success,proc::__mac_execve:exec-success
{
this->isx64=(curproc->p_flag & P_LP64)!=0;
#define SELECT_64_86(x64, x86) (this->isx64 ? (x64) : (x86))
#define GET_POINTER(base, offset) (user_addr_t)SELECT_64_86(*(uint64_t*)((base)+sizeof(uint64_t)*(offset)), *(uint32_t*)((base)+sizeof(uint32_t)*(offset)))
@filipposc5
filipposc5 / dump-es.py
Last active March 3, 2017 15:04
dump from logstash to json serially
import elasticsearch
from elasticsearch import helpers
import json
es = elasticsearch.Elasticsearch()
zz= helpers.scan(es,
query={"query":{"filtered": {"filter": {"bool": {"must_not": [], "must": [
{"range": {"@timestamp": {"gte": 1488365745648, "lte": 1488378342740}}}]}}, "query": {"query_string": {"analyze_wildcard": True, "query": "project: \"fr-staffapp\""}}}}},
@filipposc5
filipposc5 / refactored-pars-for-science.py
Last active February 3, 2017 12:32
some BNF/grammar/parsing fun
# refactored version purely for science
# use to parse python variables. Grammar a bit limited but worked for the sample python files I was parsing
from pyparsing import *
NAME = Word(alphanums+'_')
VALUE = Suppress(Empty()) + restOfLine
EQUALS,LBRACE,RBRACE,LPAR,RPAR = map(Suppress,"={}()")
@filipposc5
filipposc5 / fabfile.py
Last active February 2, 2017 14:48
F.. docker
from fabric.api import task, sudo, warn_only
import pdb
def docker_exec(contr, cmd="true"):
return 'docker exec -ti {} bash -c "{}"'.format(contr, cmd)
def healthcheck(c):
ret = {}
a152m:lemur-docker filippos$ docker-compose down
Removing lemurdocker_lemur-nginx_1 ... done
Removing lemurdocker_lemur-web_1 ... done
Removing lemurdocker_postgres_1 ... done
a152m:lemur-docker filippos$ docker-compose build
postgres uses an image, skipping
Building lemur-web
Step 1 : FROM ubuntu:14.04
---> b549a9959a66
Step 2 : MAINTAINER Netflix Open Source Development <[email protected]>
@filipposc5
filipposc5 / .vimrc
Created July 4, 2016 23:08
diffupdate, diffput and diffget
; (taken from someone, not mine!)
nnoremap <f8> :diffupdate<cr>
command! -nargs=? -range=1 -bar Diffput <line1>,<line2>diffput <args>|diffupdate
command! -nargs=? -range=1 -bar Diffget <line1>,<line2>diffget <args>|diffupdate
nnoremap <f3> :Diffget-
@filipposc5
filipposc5 / visualise-dependson.md
Created July 4, 2016 15:24
Visualising DependsOn dependency graph

Visualising dependency graph

This is a very simple dependency graph from a template, I am not a "jq" expert so it might be slightly limited.

  1. Obtain stack template aws --region=eu-west-1 --profile=... cloudformation get-template --stack-name ...-... > ~/template-3

  2. Create graph dot (echo digraph G \{ ; cat ~/template-3 | jq -r '.TemplateBody.Resources | keys[] as $k | select((.[$k] | .DependsOn) != null) | "\($k) -> \(.[$k] | .DependsOn);"'| tr -d \]\[ ; echo \} ) > DependsOn.dot

  3. Create graph image

@filipposc5
filipposc5 / encodings-1.py
Last active July 1, 2016 17:39
utf-16le ?
import codecs
aaa = [ "aa", "bb", "cc", ]
with codecs.open("old.txt", mode='w', encoding='utf-16le') as f:
f.write("\n".join(aaa) + "\n")
file_old = codecs.open('old.txt', mode='r', encoding='utf-16-le')
file_new = codecs.open('new.txt', mode='w', encoding='utf-16')