Skip to content

Instantly share code, notes, and snippets.

@ivanalejandro0
ivanalejandro0 / leap-docker.sh
Last active August 29, 2015 14:10
Firts attempt to run the LEAP platform on a single docker container.
#!/bin/bash
# Following instructions from: https://leap.se/en/docs/platform/tutorials/single-node
# Docker command line:
# docker run -it --name leap -h node1 -v ~/tmp/:/shared debian:wheezy /bin/bash
set -e # Exit immediately if a command exits with a non-zero status.
set -x # show commands
# Prepare your environment
// see:
// http://stamm-wilbrandt.de/GraphvizFiddle/
// http://graphviz-dev.appspot.com/
digraph g{
OFF [label="OFF", style="filled", shape=doublecircle];
ON [label="ON", fillcolor="palegreen", style="filled" shape=doublecircle];
error [label="error", fillcolor="red", style="filled" shape=doublecircle];
OFF -> fw_start [label="start"];
#!/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
@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,
@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 / 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 / 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 / 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 / .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 / 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(){