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 / flatten.go
Last active April 25, 2019 08:49
Flatten a list of lists in Python and Go
package main
import (
"encoding/json"
"fmt"
)
func flatten(s []interface{}) (r []int) {
// type switch already discussed in the tour of go
for _, item := range s {
@oz123
oz123 / upload.js
Created February 12, 2019 20:32
using openpgp to encrypt uploaded file.
import "babel-polyfill";
var openpgp = require('openpgp'); // use as CommonJS, AMD, ES6 module or via window.openpgp
const query = query => document.querySelector(query);
const queryAll = query => Array.prototype.slice.apply(document.querySelectorAll(query));
const pub_key =
['-----BEGIN PGP PUBLIC KEY BLOCK-----',
'Version: GnuPG v2.0.22 (GNU/Linux)',
@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
@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
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 / 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)
#!/usr/bin/python
from __future__ import division
import math
import time
import cairo
import gi
gi.require_version('Gtk', '3.0')
@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)
@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 / 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