Skip to content

Instantly share code, notes, and snippets.

View oz123's full-sized avatar
🎯
Focusing

Oz Tiram oz123

🎯
Focusing
View GitHub Profile
@oz123
oz123 / Makefile
Created February 26, 2015 17:47
A rudimentary task queue using multiprocessing in Python
#SHELL = bash -xv
.PHONY: create_all_tasks, quick, slow, task_one, task_two show_tree, sleep
slow:
$(shell echo "this task will hang around;15" > 4.task)
quick:
$(shell echo "this task will finish quickly;5" > 3.task)
@oz123
oz123 / state.sls
Last active November 2, 2015 12:58
snippet from my state
{% if grains['os'] == 'CentOS' %}
{% set piploc = '/usr/bin/pip' %}
{% elif grains['os'] == 'Ubuntu' %}
{% set piploc = '/usr/local/bin/pip' %}
{% endif %}
{% if not salt['file.file_exists'] == piploc %}
@oz123
oz123 / gist:c8d69d0121d5c8acdf82
Created November 4, 2015 09:11
weired output from salt
vagrant@saltmaster:/srv/salt$ vim common/py_packages.sls # edit and mark django for downgrade
vagrant@saltmaster:/srv/salt$ sudo salt minion1 state.sls common.py_packages
minion1:
----------
ID: install_django == 1.8.0
Function: pip.installed
Name: django == 1.8.0
Result: True
Comment: All packages were successfully installed
Started: 08:58:20.748303
@oz123
oz123 / mnt-gentoo.sh
Created January 17, 2016 14:28
Automatically mount gentoo partition for working on the handbook
# use this script to initialize work on gentoo install
# this is the base for fully installing automatically
# we still have lot's of work to do ...
# mount everything needed for a working chroot
function mount_all(){
mount $1 /mnt/gentoo
mount -t proc proc /mnt/gentoo/proc
mount --rbind /sys /mnt/gentoo/sys
mount --make-rslave /mnt/gentoo/sys
@oz123
oz123 / sessiontest.py
Created September 11, 2016 07:24 — forked from thedemz/sessiontest.py
Example of using beaker sessions with bottle
import bottle
from beaker.middleware import SessionMiddleware
session_opts = {
'session.type': 'memory',
'session.cookie_expires': 300,
'session.auto': True
}
app = SessionMiddleware(bottle.app(), session_opts)
#!/usr/bin/python
from __future__ import division
import math
import time
import cairo
import gi
gi.require_version('Gtk', '3.0')
@oz123
oz123 / kombu_example.py
Last active February 27, 2017 15:07 — forked from vgoklani/kombu_example.py
update for Python3
from kombu import Exchange
from kombu import Queue
from kombu import BrokerConnection
class ProduceConsume(object):
def __init__(self, exchange_name, **options):
exchange = Exchange(exchange_name, type='fanout', durable=False)
queue_name = options.get('queue', exchange_name+'_queue')
self.queue = Queue(queue_name ,exchange)
import asyncio
loop = asyncio.get_event_loop()
async def hello():
await asyncio.sleep(3)
print('Hello!')
if __name__ == '__main__':
loop.run_until_complete(hello())
@oz123
oz123 / app.py
Created July 26, 2017 12:26
basic bottle authentication
from bottle import Bottle, auth_basic, request, run
app = Bottle()
def check(user, passwd):
if user == 'oz123':
return True
return False
@oz123
oz123 / men
Created October 1, 2018 09:14
german population register 2016
Stadt,"Post-leitzahl 1)","Fläche in km2 2)",männlich
"Berlin, Stadt",10178,891.12,1755700
"Hamburg, Freie und Hansestadt",20038,755.3,886289
"München, Landeshauptstadt",80331,310.71,714112
"Köln, Stadt",50667,405.02,524790
"Frankfurt am Main, Stadt",60311,248.31,363754
"Stuttgart, Landeshauptstadt",70173,207.33,313295
"Düsseldorf, Stadt",40213,217.41,296231
"Dortmund, Stadt",44135,280.71,287897
"Essen, Stadt",45127,210.34,283065