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 / centos.ks.cfg
Last active January 27, 2018 13:38
centos minimal kickstart
install
lang en_GB.UTF-8
keyboard us
timezone --utc GMT
auth --useshadow --enablemd5
selinux --disabled
firewall --disabled
services --enabled=NetworkManager,sshd
eula --agreed
#!/bin/bash
. /etc/os-release
IMAGE="container-demo.img"
die() { echo "FATAL: $@" >&2 ; exit 1 ; }
info() { echo "INFO: $@" ; }
install_dependencies() {
@grafuls
grafuls / logstamps.py
Last active August 24, 2017 15:31
Script for retrieving Jenkins job art_test_runner logs timestamps
#! /usr/bin/python
from __future__ import print_function
from ast import literal_eval
from argparse import ArgumentParser
import urllib2
BASE_URL = "https://{jenkins}/job/%s/%s"
@grafuls
grafuls / copy_refs.js
Last active November 1, 2016 16:06
gerrit bookmark for copying refs for jenkins
javascript:(function(){
function copyTextToClipboard(text) {
var textArea = document.createElement("textarea");
textArea.style.position = 'fixed';
textArea.style.top = 0;
textArea.style.left = 0;
textArea.style.width = '2em';
textArea.style.height = '2em';
textArea.style.padding = 0;
textArea.style.border = 'none';
@grafuls
grafuls / twentiment.py
Created October 30, 2016 07:24
Tweeter sentiment analysis
from textblob import TextBlob
from tweepy import API
from tweepy import OAuthHandler
import config
import logging
LOGGER = logging.getLogger("twentiment")
logging.basicConfig(
level=logging.INFO,
@grafuls
grafuls / gerrit_reviewers.py
Created October 26, 2016 10:24
Script to include reviewers to gerrit based on specific format
#! /env/bin/python
# https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#get-change-detail
# https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html
# #add-reviewer
# https://review.openstack.org/Documentation/cmd-set-reviewers.html
"""
user1 to review [user2, user3]
user2 to review [user1, user3]
@grafuls
grafuls / tweepystream.py
Last active October 20, 2016 22:55
tweeter listener
from tweepy import API
from tweepy import Stream
from tweepy import OAuthHandler
from tweepy.streaming import StreamListener
import os
import re
import urllib2
C_KEY = os.environ['C_KEY']
@grafuls
grafuls / spotify_duplicates.py
Created April 24, 2016 16:46
Find spotify duplicate songs in one playlist
'''
export SPOTIPY_REDIRECT_URI='http://localhost:8888/callback'
export SPOTIPY_CLIENT_ID={API_CLIENT_ID}
export SPOTIPY_CLIENT_SECRET={API_CLIENT_SECRET}
'''
import collections
import math
import spotipy
import spotipy.util as util
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,
@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):