Skip to content

Instantly share code, notes, and snippets.

View gtato's full-sized avatar

Genc Tato gtato

View GitHub Profile
@gtato
gtato / kafka_pause_resume.py
Last active August 25, 2021 11:15
Pause and resume kafka
import queue
from confluent_kafka import Producer, Consumer, TopicPartition, OFFSET_END, OFFSET_BEGINNING
from multiprocessing import Queue
from threading import Thread
import time
import string
import random
@gtato
gtato / redis-syncer.js
Last active July 18, 2018 12:55
Synchronize only some keys between independent Redis instances
const express = require('express')
const bodyParser = require('body-parser')
var redis = require('redis');
const app = express()
app.use(bodyParser.urlencoded());
app.use(bodyParser.json());
var ptrn = 'sess*'
var redisClients = {}
<!DOCTYPE html>
<meta charset="utf-8" xmlns="http://www.w3.org/1999/html">
<html>
<head>
<title>Scatter plot coordinates</title>
<style>
.content {
/*text-align:center */
}
#!/usr/bin/env python
import libcloud.security, time
from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver
from libcloud.common.exceptions import BaseHTTPError
uname = 'dummy'
pwd = 'foo'
tenant = 'dummy'
@gtato
gtato / links
Created January 29, 2015 12:02
Useful links
@gtato
gtato / ssh config
Last active August 29, 2015 14:11
ssh stuff
Host axel07 maia01
HostName %h.doc.ic.ac.uk
User gtato
ProxyCommand ssh -q docgate /bin/nc -q0 %h %p
Host docgate
User gtato
HostName shell2.doc.ic.ac.uk
ControlMaster auto
ControlPath ~/.ssh/ssh_control_%h_%p_%r
@gtato
gtato / openstack.sh
Last active August 29, 2015 14:09
Some openstack commands
# save docker image in glance
docker save conpaas-director-squeeze | glance image-create --is-public=True --container-format=docker --disk-format=raw --name conpaas-director-squeeze
# start a vm on a particular network
nova boot --flavor m1.small --image conpaas-director-squeeze --security-groups demo-secgroup --key-name demo-keypair --nic net-id=e0afdf0f-a081-48ab-935b-67694d15e7fb --user_data=conpaas_director.rc director-squeeze
# associate floating IPs to a VM
nova floating-ip-associate fc353186-8d2c-46e4-afe7-2e1b125d29f5 10.13.0.102
# download user data
@gtato
gtato / mount.sh
Created May 15, 2014 10:03
Mounting and unmounting raw disk images which have one partition
#/dev/loop0 and /dev/loop1 are assumed to be free, otherwise use 'losetup -f' and store the result
losetup /dev/loop0 disk.img
kpartx -as /dev/loop0
losetup /dev/loop1 /dev/mapper/loop0p1
mkdir disk
mount /dev/loop1 disk
@gtato
gtato / handlers.py
Last active August 29, 2015 14:01
A simple mechanism for allowing HTTP servers to add request handlers (managers) dynamically
exposed_functions_http_methods = {}
def expose(http_method):
def decorator(func):
exposed_functions_http_methods[id(func)] = http_method
def wrapped(self, *args, **kwargs):
return func(self, *args, **kwargs)
return wrapped
return decorator