Skip to content

Instantly share code, notes, and snippets.

💭
workon on https://github.com/omegaml

miraculixx

💭
workon on https://github.com/omegaml
  • Switzerland
Block or report user

Report or block miraculixx

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@miraculixx
miraculixx / cities_match.py
Last active Feb 9, 2020
map cities by rotated letters
View cities_match.py
from itertools import combinations
# quick and dirty implementation, not optimized
cities = ['Tokyo', 'London', 'Rome', 'Donlon', 'Kyoto', 'Paris']
normalized = [(c, ''.join(sorted(c.lower()))) for c in cities]
cartesian = list(combinations(normalized, 2))
matches = [[l[0], r[0]] for l, r in cartesian if l[1] == r[1]]
matches.extend([c for c in cities if c not in [m[0] for m in matches] + [m[1] for m in matches]])
matches
# output [['Tokyo', 'Kyoto'], ['London', 'Donlon'], 'Rome', 'Paris']
@miraculixx
miraculixx / requirements.txt
Created Nov 28, 2018
Python multiprocess parallel selenium web scraping with improved performance
View requirements.txt
beautifulsoup4==4.6.3
certifi==2018.10.15
chardet==3.0.4
idna==2.7
lxml==4.2.5
requests==2.20.1
selenium==3.141.0
urllib3==1.24.1
@miraculixx
miraculixx / readcsv.py
Created Mar 1, 2019
read a large csv file and subset on datetime column
View readcsv.py
from dateutil.parser import parse
with open('data.csv') as fin:
for line in csv.reader(fin):
date1 = parse(row[1])
date2 = datetime.now() - timedelta(days=3)
if date1 > date2:
continue
process(row) # whatever your logic
@miraculixx
miraculixx / docker-compose.yml
Last active Feb 9, 2020
a threaded mqtt client using the gmqtt python library
View docker-compose.yml
version: '3'
services:
rabbitmq:
image: rabbitmq:latest
ports:
# 5672 amqp
# 15672 mgmt ui
# 1883 mqtt
- "5672:5672"
- "15672:15672"
@miraculixx
miraculixx / github-add-user
Last active Dec 9, 2019
batch adding users to github accounts
View github-add-user
#!/bin/bash
# Collaborator list, add, remove from a repository
# (c) 2015 miraculixx
# Author: github.com/miraculixx
# MIT License, see below
function help {
echo "Add collaborators to one or more repositories on github"
echo ""
echo "Syntax: $0 -u user -p password [-l] [-D] -r repo1,repo2 <collaborator id>"
@miraculixx
miraculixx / LICENSE
Last active Nov 14, 2019
A simple stack VM and assembler/compiler
View LICENSE
The MIT License (MIT)
Copyright (c) 2015 miraculixx
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
@miraculixx
miraculixx / rules.py
Last active Sep 3, 2019
a simple python based rule engine
View rules.py
"""
(c) 2014 miraculixx at gmx.ch
"""
from shrutil.dictobj import DictObject
class RuleContext(DictObject):
"""
rule context to store values and attributes (or any object)
"""
def __init__(self):
@miraculixx
miraculixx / .bash_k8s.rc
Created Jul 25, 2019
useful kubectl shortcuts
View .bash_k8s.rc
# put in $HOME/.bash_k8s.rc
# . $HOME/bash_k8s.rc
# podlog <any pod name substring>
function podlog() {
kubectl get pods -o name | grep $1 | cut -d / -f 2 | head -n1 | xargs kubectl logs $2
}
# exec a command in a pod, defaults to bash
function podssh() {
View how-to-install-latest-gcc-on-linux-mint.txt
These commands are based on a askubuntu answer http://askubuntu.com/a/581497 and https://askubuntu.com/questions/26498/choose-gcc-and-g-version
To install gcc-7 (gcc-7.2.0), I had to do more stuff as shown below.
USE THOSE COMMANDS AT YOUR OWN RISK. I SHALL NOT BE RESPONSIBLE FOR ANYTHING.
ABSOLUTELY NO WARRANTY.
If you are still reading let's carry on with the code.
sudo apt-get update && \
sudo apt-get install build-essential software-properties-common -y && \
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
View gitdeploy
#!/usr/bin/env bash
# adopted from https://raw.githubusercontent.com/X1011/git-directory-deploy/master/deploy.sh
#
# changes
# * deploy from current directory is possible
# * set options from either .deploy file or parameters
set -o errexit #abort if any command fails
PREFIX=.
CONFIG=.deploy
You can’t perform that action at this time.