Skip to content

Instantly share code, notes, and snippets.

View cyberbikepunk's full-sized avatar

Loic cyberbikepunk

  • France
  • 11:26 (UTC -12:00)
View GitHub Profile
@cyberbikepunk
cyberbikepunk / simple_threaded_counter.py
Last active September 13, 2015 09:04
a simple threaded counter implemented in pythobn
from logging import basicConfig, DEBUG, debug
from threading import Lock, Thread, current_thread, enumerate
from time import sleep
from random import random
basicConfig(level=DEBUG, format='[%(thread)d: %(message)s]')
class Counter(object):
def __init__(self, start=0):
@cyberbikepunk
cyberbikepunk / image_linker.py
Last active August 29, 2015 14:27
Recursively look for images inside a source folder and create flat symlinks inside a destination folder.
#! /usr/bin/python3
"""
Recursively look for images inside a source folder
and create flat symlinks inside a destination folder.
"""
from argparse import ArgumentParser
from os import walk
from pathlib import Path
@cyberbikepunk
cyberbikepunk / sshd_config
Last active September 12, 2015 13:06 — forked from pachacamac/sshd_config
sshd_config
# Package generated configuration file
# See the sshd_config(5) manpage for details
# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
@cyberbikepunk
cyberbikepunk / repo.sh
Last active September 12, 2015 15:48 — forked from james2doyle/create-repo.sh
Create a repo on Github from the command line
function repo() {
if [ $# -eq 2 ]; then
# name of repo to be created
PROJECTNAME="$1"
DESCRIPTION="$2"
POST="{\"name\":\"$PROJECTNAME\",\"description\":\"$DESCRIPTION\"}"
curl –sS -u 'cyberbikepunk' https://api.github.com/user/repos -d "$POST"
git remote add origin git@github.com:cyberbikepunk/$PROJECTNAME.git
echo "remote origin added"
else
@cyberbikepunk
cyberbikepunk / bokeh_send_plot_to_the_server.ipynb
Created September 12, 2015 19:02
Render a Bokeh plot with the server
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cyberbikepunk
cyberbikepunk / create_pandas_dataframe_without_column_or_row_names.ipynb
Created September 12, 2015 19:06
It's possible to create a panda dataframe without defining columns or row names
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cyberbikepunk
cyberbikepunk / using_a_class_instance_as_a_decorator.py
Created September 13, 2015 08:50
use a class instance to make a decorator
# Write a tracer decorator
class Tracer():
def __init__(self):
pass
def __call__(self, f):
def wrapper(*args, **kwargs):
print('Called function %s' % f.__name__)
return f(*args, **kwargs)
return wrapper
@cyberbikepunk
cyberbikepunk / decorator_experiments.ipynb
Created September 13, 2015 09:32
Monkey-patching with decorators: a tutorial for beginners
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cyberbikepunk
cyberbikepunk / decorator_experiments.ipynb
Created September 13, 2015 09:36
Monkey-patching with decorators: a tutorial for beginners
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cyberbikepunk
cyberbikepunk / ipython_to_jekyll.py
Created September 13, 2015 12:03
convert ipthon notebook files to jekyll
#!/usr/bin/env python
# coding=utf-8
from __future__ import print_function
import functools
import json
import os
import re
import sys