Skip to content

Instantly share code, notes, and snippets.

View adiog's full-sized avatar

Aleksander Gajewski adiog

View GitHub Profile
@adiog
adiog / MathJaxToggle.js
Created March 7, 2017 09:37
MathJax toggle
MathJax.Hub.Config({
tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}
});
function hideTypeset()
{
var HTML = MathJax.HTML;
var jax = MathJax.Hub.getAllJax();
for (var i = 0, m = jax.length; i < m; i++)
@adiog
adiog / jsontail
Created March 17, 2017 11:11
Serve stdin with HTTP json
from queue import Queue
from threading import Thread
import json
import sys
import tornado.ioloop
import tornado.web
MAX_NUM_LINES_IN_BUFFER=1000
MAX_NUM_LINES_PER_CHUNK=10
@adiog
adiog / SpeedUpBookmarklet.js
Last active October 24, 2017 08:25
Simple bookmarklet bumping the playback speed (on YT/vimeo/others)
javascript:(function(){(Array.from(document.body.getElementsByTagName('video'))).forEach(function(videoDom){if(videoDom.playbackRate==1.0){videoDom.playbackRate=3.0;}else{videoDom.playbackRate=1.0;}});})();
@adiog
adiog / generate_local_certificate.sh
Created September 10, 2017 19:26
Generate local certificate
#!/usr/bin/env bash
SERVER=$1
OUTPUT=$2
#Overview
# The following is an extremely simplified view of how SSL is implemented and what part the certificate plays in the entire process.
# Normal web traffic is sent unencrypted over the Internet. That is, anyone with access to the right tools can snoop all of that traffic. Obviously, this can lead to problems, especially where security and privacy is necessary, such as in credit card data and bank transactions. The Secure Socket Layer is used to encrypt the data stream between the web server and the web client (the browser).
# SSL makes use of what is known as asymmetric cryptography, commonly referred to as public key cryptography (PKI). With public key cryptography, two keys are created, one public, one private. Anything encrypted with either key can only be decrypted with its corresponding key. Thus if a message or data stream were encrypted with the server's private key, it can be decrypted only using its corresponding public key, ensuring that the
@adiog
adiog / cmake_m4_preprocessor
Created September 19, 2017 06:10
cmake_m4_preprocessor template
cmake_minimum_required(VERSION 2.6)
project( test CXX )
# we need the M4 macro processor
find_program( M4_EXECUTABLE m4 DOC "The M4 macro processor" )
if( NOT M4_EXECUTABLE )
message( SEND_ERROR "Failed to find the M4 macro processor." )
endif( NOT M4_EXECUTABLE )
# - Pass a list of files through the M4 macro processor
@adiog
adiog / sandbox.sh
Created September 20, 2017 05:42
poor man's chroot
# Copyright 2014 Aleksander Gajewski <[email protected]>
# created: Sun 16 Nov 2014 08:40:32 AM CET
# modified: Mon 17 Nov 2014 04:08:15 AM CET
RAMSIZE=128
if [ "$1" == "" ]; then
echo "Simple sandbox with chroot. Usage:"
echo " ./sandbox.sh program_to_run [other_program_or_folder] .."
echo " eg. ./sandbox.sh bash bc"
@adiog
adiog / bashmarks.sh
Created September 20, 2017 05:44
bash directory bookmarks
# Copyright 2014 Aleksander Gajewski <[email protected]>
# created: Sun 26 Oct 2014 11:01:45 AM CET
# modified: Sun 26 Oct 2014 11:02:17 AM CET
# bash marks
MARKS_DIR=~/.bashmarks
MARKS_CWD=.cwd
mkdir -p $MARKS_DIR
function _l() {
@adiog
adiog / graph
Last active October 11, 2017 14:34
(echo "digraph {"; (cat input.txt | sed -e '1!p' | sed -e '$d' | sed -e "/.*/{N;{s#\s*\n\s*# -> #g};p}" | sort | uniq); echo "}") | dot -Tpng -o output.png
@adiog
adiog / forced_doxygen_crap.py
Created October 18, 2017 08:18
forced doxygen crap
import re
import sys
def split_last_space(text):
text = re.sub(r'^ *', '', text)
text = re.sub(r' *$', '', text)
text_split = text.split(' ')
first = ' '.join(text_split[:-1])
second = text_split[-1]
@adiog
adiog / forward.cc
Created October 24, 2017 08:21
cpp's pipe operator
#include <gtest/gtest.h>
template<typename T>
struct Wrapper {
explicit Wrapper(T value) : value(value) {};
operator T() {return value;}
T value;
};
template<typename T>