Skip to content

Instantly share code, notes, and snippets.

@ivanalejandro0
ivanalejandro0 / pyside-to-virtualenv.sh
Created September 30, 2013 02:27
Symlinks PySide from global installation into virtualenv site-packages
#!/bin/bash
# Symlinks PySide from global installation into virtualenv site-packages
platform='unknown'
unamestr=$(uname)
if [[ "$unamestr" == 'Linux' ]]; then
platform='linux'
elif [[ "$unamestr" == 'Darwin' ]]; then
platform='darwin'
fi
@ivanalejandro0
ivanalejandro0 / buildqt.py
Last active November 16, 2019 12:22
PySide *.ui and *.qrc files compiler command for setup.py
# Borrowed from: https://github.com/glue-viz/glue/blob/master/setup.py
# Copyright (c) 2013, Glue developers
import os
import subprocess
import sys
from glob import glob
from setuptools import Command
@ivanalejandro0
ivanalejandro0 / ps1.sh
Last active December 28, 2015 06:39
My custom PS1 prompt with virtualenv and git support.
# Define some colors
RED="\[\e[0;38;5;196m\]"
GREEN="\[\e[01;32m\]"
BLUE="\[\e[01;34m\]"
WHITE="\[\e[37;1m\]"
LIGHT_BLUE="\[\e[36m\]"
PURPLE="\[\e[35m\]"
NIL="\[\e[m\]"
function git_branch(){
@ivanalejandro0
ivanalejandro0 / .tmux.conf
Last active August 28, 2024 06:50
Tmux configuration file with Powerline-like status bar, system clipboard integration and some other nice tweaks.
# Install tpm + plugins with:
# git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
# trigger plugin install with: prefix + I
# trigger plugin update with: prefix + U
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'laktak/extrakto'
@ivanalejandro0
ivanalejandro0 / spotify-monitor.sh
Last active January 4, 2016 19:49
Script that monitors Spotify and mute the system volume when an ad is played.
#!/bin/bash
# Problem: if there is an ad you will be muted, no matter of what. You need to
# stop this script to avoid that.
set -euo pipefail
IFS=$'\n\t'
source volume.sh
get_systray_title(){
@ivanalejandro0
ivanalejandro0 / progress_bar_helper.sh
Last active March 14, 2018 14:42
Progress bar helper method for scripts.
#!/usr/bin/env bash
progress(){
# example usage:
# progress 30G 9G 30
# 30G [================>.................................] 30% (9G)
# params:
# $1 = total value (e.g.: source size)
# $2 = current value (e.g.: destination size)
@ivanalejandro0
ivanalejandro0 / signals-slots.py
Created April 16, 2014 19:18
Signaling test
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from PySide import QtCore, QtGui
class Foo(QtGui.QWidget):
some_signal_1 = QtCore.Signal(str)
@ivanalejandro0
ivanalejandro0 / json-simplejson-loads.py
Created June 12, 2014 22:16
Python stdlib's json.loads() vs simplejson.loads()
#!/usr/bin/env python
# encoding: utf-8
# I was getting different results on json.loads() depending if I was using
# stdlib's json or simplejson. So after a little research I reached a
# conclusion:
# `simplejson` optimizes(*) the `loads` and returns `str` when is possible,
# otherwise it returns `unicode`.
# stdlib's `json`'s `loads` returns always `unicode`.
@ivanalejandro0
ivanalejandro0 / typecheck.py
Created July 16, 2014 18:50
Python type checker decorator.
#!/usr/bin/env python
# encoding: utf-8
# Copyright (c) 2014, Ivan Alejandro
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
#!/usr/bin/env python
# encoding: utf-8
"""
A Finite State Machine for the EIP service, based on
https://leap.se/code/issues/5616#note-2
"""
import random
from pprint import pprint
# see: http://xworkflows.readthedocs.org/en/latest/reference.html