Skip to content

Instantly share code, notes, and snippets.

View cyberbikepunk's full-sized avatar

Loic cyberbikepunk

  • France
  • 01:12 (UTC -12:00)
View GitHub Profile
@cyberbikepunk
cyberbikepunk / generic.ipynb
Last active September 19, 2015 12:13
The generic ipython notebook format
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cyberbikepunk
cyberbikepunk / string_processors.py
Last active September 19, 2015 12:35
Random string processors
from string import ascii_letters, digits
from re import match, sub
from time import strptime
from unicodedata import normalize
from datetime import datetime
SLUG_SEPERATOR = '-'
_multiple_seperators_regex = '%s{2,}' % SLUG_SEPERATOR # eg. bla-bla--bla
@cyberbikepunk
cyberbikepunk / aggregator.py
Last active September 19, 2015 17:10
Download all files from a GitHub repo
""" This module interfaces with GitHub. """
from os.path import splitext
from json import loads
from base64 import b64decode
from requests import get
from .murls import https
@cyberbikepunk
cyberbikepunk / micro_cv.md
Created September 20, 2015 17:33
Micro CV

Micro CV

Personal info

  • Born in 1975 in Paris, currently in Berlin
  • English (native), French (native), German (pretty good)

Education

  • MSci. in physics, Imperial College London
  • Ph.D in experimental atmospheric physics, University of Toronto
@cyberbikepunk
cyberbikepunk / dpaste.de_snippet.py
Last active October 5, 2015 19:36 — forked from anonymous/dpaste.de_snippet.py
Quick Unittest Mock tutorial
my_singleton = None
class Foo(object):
def __init__(self):
pass
def do(arg):
@cyberbikepunk
cyberbikepunk / defender.js
Created October 13, 2015 22:26
Quizz for BaseCase
/*
This AI simply saves the planet.
*/
function find_closest_rock(rocks){
var closest = 0
for (var i = 1; i < rocks.length; i++){
if (rocks[i].distance < rocks[closest].distance){
closest = i
@cyberbikepunk
cyberbikepunk / postal_codes.py
Last active October 22, 2015 09:38
Regex patterns for postal codes of ~150 countries
# Source: http://download.geonames.org/export/dump/countryInfo.txt
POSTAL_CODES = {
'AD': '(?:AD)*(\d{3})',
'AM': '(\d{6})',
'AR': '[A-Z]\d{4}[A-Z]{3})',
'AT': '(\d{4})',
'AU': '(\d{4})',
'AX': '(?:FI)*(\d{5})',
'AZ': '(?:AZ)*(\d{4})',
'BA': '(\d{5})',
@cyberbikepunk
cyberbikepunk / parametrized_pytest.py
Last active May 10, 2016 08:23
StackOverflow Question 37124766
from pytest import mark
items = [
{
'text': 'bla bla',
'fields': [('bla', 0), ('foo', -1)]
},
{
'text': 'foo bar',
@cyberbikepunk
cyberbikepunk / print_all_settings.py
Created May 16, 2016 10:10
Print all CAPITALIZED settings in a settings file.
def show_settings():
""" Echo all settings. """
print('Current m5 settings:', end='\n\n')
objects = dir(modules[__name__])
parameters = [x for x in objects if x.isupper() and x is not 'PASSWORD']
for p in parameters:
value = getattr(modules[__name__], p)
print('{item} = {value!r}'.format(item=p.rjust(20, ' '), value=value))
@cyberbikepunk
cyberbikepunk / ElasticSearch.sh
Created June 18, 2016 11:42 — forked from ricardo-rossi/ElasticSearch.sh
Installing ElasticSearch on Ubuntu 14.04
#!/bin/bash
### USAGE
###
### ./ElasticSearch.sh 1.7 will install Elasticsearch 1.7
### ./ElasticSearch.sh will fail because no version was specified (exit code 1)
###
### CLI options Contributed by @janpieper
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch