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 / 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
@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 / 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 / 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 / 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 / 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"
#!/bin/bash
. /etc/os-release
IMAGE="container-demo.img"
die() { echo "FATAL: $@" >&2 ; exit 1 ; }
info() { echo "INFO: $@" ; }
install_dependencies() {
@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
@grafuls
grafuls / async_ssh_tasks.py
Created June 23, 2018 16:26
asyncssh example
import asyncio, asyncssh, sys
class MySSHClientSession(asyncssh.SSHClientSession):
def data_received(self, data, datatype):
print(data, end='')
def connection_lost(self, exc):
if exc:
print('SSH session error: ' + str(exc), file=sys.stderr)
@grafuls
grafuls / BZ1608842-remedy.sh
Last active August 9, 2018 14:08
BZ1608842-remedy.sh
#!/usr/bin/env bash
TOKEN=$(oc whoami -t)
podman login docker-registry.default.svc:5000 -u test_admin -p $TOKEN
git clone https://github.com/ansibleplaybookbundle/import-vm-apb.git && cd import-vm-apb
docker build -t docker-registry.default.svc:5000/openshift/import-vm-apb:latest .
docker save docker-registry.default.svc:5000/openshift/import-vm-apb:latest -o import-vm-apb.tar
podman import import-vm-apb.tar docker-registry.default.svc:5000/openshift/import-vm-apb:latest