Skip to content

Instantly share code, notes, and snippets.

@odedlaz
odedlaz / less_syntax_highlight.sh
Last active December 25, 2016 21:06
less_syntax_highlight
# The following adds syntax highlighting to various programming languages
# Credit goes to Ter Smitten: https://goo.gl/64YU4u
export LESSOPEN="| /usr/share/source-highlight/src-hilite-lesspipe.sh %s"
export LESS=' -R '
# The following adds syntax highlighting to man pages
# Credit goes to Todd Weed: https://goo.gl/ZSbwZI
export LESS_TERMCAP_mb=$'\e[01;31m' # begin blinking
export LESS_TERMCAP_md=$'\e[01;38;5;74m' # begin bold
export LESS_TERMCAP_me=$'\e[0m' # end mode
@odedlaz
odedlaz / ocr.py
Last active February 4, 2017 22:04
OCR using tesserocr
from tesserocr import PyTessBaseAPI
import sys
import os
# tesserocr -> https://pypi.python.org/pypi/tesserocr
# cython -> https://pypi.python.org/pypi/Cython
# Pillow -> https://pypi.python.org/pypi/Pillow
if len(sys.argv) != 2:
print("you need to pass the path to the image as first argument")
@odedlaz
odedlaz / getenv_idiom.py
Last active January 20, 2017 15:23
os.getenv idiom
import os
def getenv(varname, default=None, typecast_fn=None):
"""
Return the value of the environment variable varname if it exists, or default if it doesn't.
default defaults to None.
:typecast_fn: a function that performs the typecast. if not supplied, defaults to type(value)
"""
@odedlaz
odedlaz / update-nvim-python-client.zsh
Last active January 30, 2017 14:08
A script that updated neovim python packages
#!/usr/bin/zsh
function update_python_packages {
USERNAME=$(logname)
# run command as the user who logged in. see: https://goo.gl/akX2eo
echo "Updating neovim python$1 libraries ..."
source /opt/nvim/python$1/bin/activate
pip install -u --upgrade pip &> /dev/null
packages_to_install=$(pip list --outdated --format=legacy)

Keybase proof

I hereby claim:

  • I am odedlaz on github.
  • I am odedlaz (https://keybase.io/odedlaz) on keybase.
  • I have a public key ASAU1lUk2Ot0OhWdA-AB6YzuAJKxIXTvwesw-v6GAZ1rlAo

To claim this, I am signing this object:

@odedlaz
odedlaz / ds_intro_lab1_solution.sh
Created April 2, 2017 09:18
ds_intro_lab1_solution.sh
#!/usr/bin/env bash
filename="$1"
# solution using bash
count=0
while read -r line
do
if echo "$line" | grep "CHAPTER" > /dev/null; then
((count++))
@odedlaz
odedlaz / coroutine_pipe.py
Created April 11, 2017 16:25
Full gist of my blog post about piping with coroutines
from __future__ import print_function
from functools import wraps
from io import SEEK_END
from re import compile
from sys import argv
from time import sleep
RE_TYPE = type(compile(""))
@odedlaz
odedlaz / bitsrepr.c
Created May 4, 2017 14:58
Represent an integer in binary format
#include <stdio.h>
#include <stdlib.h>
void dtob(unsigned int word, char* text) {
for (int bit = 31; bit >= 0; bit--) {
int shift = word >> bit;
printf("%d", shift & 1);
}
printf(" (%s: %d)\n", text, word);
}
@odedlaz
odedlaz / move.md
Last active June 22, 2017 08:03
Goodbye Gartner, Hello Cybereason

TL;DR: I'm leaving Gartner Innovation Center and joining Cybereason. Why? I found myself in a comfort zone.

The blog post is split into four parts:

  • Past: A brief history of Senexx and how Gartner Innovation Center was formed.
  • Present: What Gartner Innovation Center is doing now
  • The decision to move
  • Future: My thoughts on what's going to happen next

Past

@odedlaz
odedlaz / nginx.conf
Created July 27, 2017 12:47
A simple nginx reverse proxy configuration
user nginx;
worker_processes 4;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}