Skip to content

Instantly share code, notes, and snippets.

View dzamlo's full-sized avatar

Loïc Damien dzamlo

  • Geneva, Switzerland
View GitHub Profile
import itertools
import json
import math
import string
############################
encrypted_hex = """
put the encrypted response here
"""
@dzamlo
dzamlo / stopwatch.py
Created December 7, 2018 12:11
A very simple cli stopwatch in python
#! /bin/env python3
from datetime import datetime
start = datetime.now()
while True:
now = datetime.now()
print("\r"+str(now-start), end="")
[alias]
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(cyan)<%an>%Creset' --abbrev-commit --date=relative
# Configration for https://github.com/dzamlo/pureline
colors[Orange]='\[\e[38;5;208m\]' # 256 Col Orange Foreground
colors[On_Orange]='\[\e[48;5;208m\]' # 256 Col Orange Background
colors[DarkGrey]='\[\e[38;5;237m\]' # 256 Col Dark Grey Foreground
colors[On_DarkGrey]='\[\e[48;5;237m\]' # 256 Col Dark Grey Background
colors[Blue]='\[\e[38;5;21m\]' # 256 Col Blue Foreground
colors[On_Blue]='\[\e[48;5;21m\]' # 256 Col Blue Background
colors[Red]='\[\e[38;5;1m\]' # 256 Col Red Foreground
colors[On_Red]='\[\e[48;5;1m\]' # 256 Col Red Background
colors[Pink]='\[\e[38;5;13m\]' # 256 Col Pink Foreground
import fileinput
import tokenize
import matplotlib.pyplot as plt
from wordcloud import WordCloud
if __name__ == '__main__':
# If some files don't have the same encoding, this is likely to not work correctly.
tokens = tokenize.tokenize(fileinput.input(mode='rb').readline)
tokens_no_string = (t for t in tokens if t.type not in [tokenize.ENCODING, tokenize.STRING])
@dzamlo
dzamlo / .bashrc
Last active September 25, 2020 12:53
history_dir="${HOME}/.history/$(date +%Y/%m)"
mkdir -p "$history_dir"
HISTFILE="$history_dir/$(date --iso-8601=seconds)_${HOSTNAME}_$$"
export HISTSIZE="NOTHING"
export HISTFILESIZE="NOTHING"
export HISTTIMEFORMAT='%F %T '
HISTCONTROL=ignoreboth
shopt -s histappend
shopt -s histverify
shopt -s cmdhist
@dzamlo
dzamlo / 99-lifx-keyboard.rules
Created September 11, 2016 16:41
Quick and dirty way to use a cheap bluetooth selfie remote on a linux server (like a raspberry pi) to control lifx lights
ACTION=="add", SUBSYSTEM=="input", ATTRS{name}=="AB Shutter3 ", TAG+="systemd", PROGRAM="/bin/systemd-escape -p --template=lifx-remote@.service $env{DEVNAME}", ENV{SYSTEMD_WANTS}+="%c"
@dzamlo
dzamlo / gist:9b38af519a17b6647483
Created May 6, 2014 13:01
PyOpenCL bug, minimum working example
import pyopencl as cl
import pyopencl.array as clarray
import numpy as np
context = cl.create_some_context()
queue = cl.CommandQueue(context)
a = clarray.empty(queue, (10,20), np.float32, order='F')
print(a.get())