Skip to content

Instantly share code, notes, and snippets.

View jrziviani's full-sized avatar

Jose R. Ziviani jrziviani

View GitHub Profile
@jrziviani
jrziviani / focus.start.bash
Created June 9, 2012 22:33 — forked from minhajuddin/focus.start.bash
My xmonad config
#!/bin/bash
# load resources
xrdb -merge .Xresources
#xsetroot -solid '#222'&
# map caps lock as extra escape
xmodmap -e 'clear Lock' -e 'keycode 0x42 = Escape'&
# start clipboard manager
parcellite&
@jrziviani
jrziviani / serial_arduino.py
Created October 12, 2012 03:52
Arduino - read serial debug
import serial
import time
sr = serial.Serial('/dev/ttyACM0', 9600)
data = ''
while(True):
data += sr.read(1)
if (data[-1:] == '\n'):
@jrziviani
jrziviani / socket_select.py
Created October 1, 2013 01:36
Servidor simples que aceita várias conexões de clientes ao mesmo tempo usando select.
import select
import socket
import os
serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
serv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
serv.bind(('', 9090))
serv.listen(1)
sockets = [serv]
unsigned int nonFloatingWindows = 0;
using lbPair = std::pair<const long unsigned int,
std::unique_ptr<IWindow>>;
// couting only non-floating windows to calcule the areas
// for tiling them.
std::for_each(
_desktops[_currentDesktop].begin(),
_desktops[_currentDesktop].end(),
@jrziviani
jrziviani / blivet_kickstart
Last active August 29, 2015 14:07
Blivet sample using kickstart
from pykickstart.parser import *
from pykickstart.version import makeVersion
import blivet
# parse kickstart
ksparser = KickstartParser(makeVersion())
ksparser.readKickstart("test.ks")
# create blivet object
b = blivet.Blivet(ksparser.handler)
>>> sda = b.devicetree.getDeviceByName("sda")
>>> new_part = b.newPartition(size=Size("10GiB"), parents=[sda])
>>> b.createDevice(new_part)
>>> blivet.partitioning.doPartitioning(b)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/blivet/partitioning.py", line 889, in doPartitioning
allocatePartitions(storage, disks, partitions, free)
File "/usr/lib/python2.7/site-packages/blivet/partitioning.py", line 1006, in allocatePartitions
disklabel = disklabels[_disk.path]
// http://svn.python.org/view/python/trunk/Include/object.h
#define PyObject_HEAD \
_PyObject_HEAD_EXTRA \
Py_ssize_t ob_refcnt; \
struct _typeobject *ob_type;
#define PyObject_VAR_HEAD \
PyObject_HEAD \
Py_ssize_t ob_size; /* Number of items in variable part */
@jrziviani
jrziviani / p.patch
Created December 21, 2015 13:19
multifunction support
---
src/conf/domain_addr.c | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
@jrziviani
jrziviani / lvm.sh
Created January 27, 2016 16:16
Create PVs and VG
[root@localhost ~]# ls /dev/sd*
/dev/sda /dev/sda1 /dev/sda2 /dev/sdb
[root@localhost ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.27).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): n
@jrziviani
jrziviani / listen.py
Created January 27, 2016 19:03
listen socket python
def listen1(self):
self._console.eventAddCallback(libvirt.VIR_STREAM_EVENT_READABLE,
self._send_to_client,
None)
def libvirt_event_loop():
while True:
libvirt.virEventRunDefaultImpl()