Skip to content

Instantly share code, notes, and snippets.

View grafuls's full-sized avatar
🐍
Hissing

Gonzalo Rafuls grafuls

🐍
Hissing
  • Red Hat, Inc
  • Czech Republic
View GitHub Profile
@grafuls
grafuls / jit.js
Created September 24, 2013 15:06
JavaScript InfoVis Toolkit › How to use a dotted / dashed lines?
'dashed': function(adj, canvas) {
var data = adj.data, econfig = this.edge;
var orn = this.getOrientation(adj);
var nodeFrom = adj.nodeFrom, nodeTo = adj.nodeTo;
var begin = this.viz.geom.getEdge(nodeFrom._depth <
nodeTo._depth?
nodeFrom:nodeTo, 'begin', orn);
var end = this.viz.geom.getEdge(nodeFrom._depth <
nodeTo._depth?
nodeTo:nodeFrom, 'end', orn);
@grafuls
grafuls / best_prax.py
Last active November 9, 2022 15:04
Python Best practices
# substracted from https://www.youtube.com/watch?v=OSGv2VnC0go among others
# Raymond Hettinger
# Learn to take better advantage of Python's best features and improve existing code through a series of code transformations,
# "When you see this, do that instead."
from itertools import izip
from functools import partial
from functools import wraps
from collections import defaultdict
import csv
with open('wafer.csv', 'r') as f:
reader = csv.reader(f, delimiter=',')
wafer = [row for row in reader]
wafer_set = set([i[1] for i in wafer])
result = []
for n in wafer_set:
@grafuls
grafuls / rcc.py
Last active August 29, 2015 14:12
script for running terminator custom commands
#!/usr/bin/python
# /usr/lib/python2.7/site-packages/terminatorlib/plugins/rcc.py
import sys
import os
from terminatorlib.config import Config
def runCustomCommands():
config = Config()
@grafuls
grafuls / res_1408x792.sh
Last active August 29, 2015 14:12
Shell script for switching screen resolution to 1408x792(not detected) w/xrandr on my eDP-0
#!/bin/bash
xrandr --newmode "1408x792_60.00" 90.75 1408 1480 1624 1840 792 795 800 823 -hsync +vsync
xrandr --addmode eDP-0 1408x792_60.00
xrandr --output eDP-0 --mode 1408x792_60.00
@grafuls
grafuls / ovirt_wiki_scrap.py
Last active August 29, 2015 14:15
Ovirt feature status scrap
from bs4 import BeautifulSoup
from xtermcolor import colorize
import requests
import re
URL = 'http://www.ovirt.org'
FEATURES_PREFIX = "/Category:Feature"
def fetch_source(source_url):
@grafuls
grafuls / idos.py
Last active July 13, 2021 19:25
python script for getting time left for next bus with idos(Brno)
from BeautifulSoup import BeautifulSoup as bs
from dateutil import parser
from datetime import datetime
import requests
import re
# search for all buses leaving from one station in any direction
URL = 'http://jizdnirady.idnes.cz/brno/odjezdy/?f=cervinkova&fc=302003&lng=E&submit=true'
@grafuls
grafuls / keybase.md
Created May 27, 2015 07:15
Keybase proof

Keybase proof

I hereby claim:

  • I am grafuls on github.
  • I am grafuls (https://keybase.io/grafuls) on keybase.
  • I have a public key whose fingerprint is 3F43 383B 506E CE86 06F3 DCAA 7929 CD4A 2C07 02E5

To claim this, I am signing this object:

@grafuls
grafuls / virtualmethod.py
Last active August 29, 2015 14:24
Virtual method implementation example - some magic to bind an XML-RPC method to an RPC server
class VirtualMethod(object):
# some magic to bind an XML-RPC method to an RPC server.
# supports "nested" methods (e.g. examples.getStateName)
# supports named arguments (if server does)
def __init__(self, func, name):
self.__func = func
self.__name = name
def __getattr__(self, name):
return type(self)(self.__func, "%s.%s" % (self.__name, name))
def __call__(self, *args, **opts):
def main():
global shared_directory, rhel_version, rhevm_version, workspace, \
mount_directory_name, tmp_directory_name
parser = argparse.ArgumentParser(
description='Retrieve the latest ova image for rhevm appliance')
parser.add_argument('--shared-dir', nargs='?', default=shared_directory,
help='Shared directory where to store the image '
'(Default: %s)' % shared_directory)
parser.add_argument('--rhel-version', nargs='?', default=rhel_version,