Skip to content

Instantly share code, notes, and snippets.

View rcassani's full-sized avatar
🦫

Raymundo Cassani rcassani

🦫
View GitHub Profile
@rcassani
rcassani / notifyrun.sh
Created October 29, 2017 16:38
Notify and run a command
#!/bin/bash
# Usage
if [ ${#@} == 0 ]
then
echo "Usage: $0 notification_msg [command] [icon-path]"
echo "* notification: <Mensage for notification>"
echo "* [command] : <Command to execute>"
echo "* [icon-path] : <Path to icon path, Default Star icon>"
fi
@rcassani
rcassani / copy_images_wp.sh
Created October 29, 2017 22:21
Copy original image files from WordPress backup
find . -regex ".*\.\(png\|jpg\|gif\|jpeg\)$" | grep -v "[0-9]x[0-9]" | xargs -I {} cp -i {} ~/Desktop/tmp/
@rcassani
rcassani / toggle_sound.py
Created October 31, 2017 16:36
Program to toggle aming the available audio output devices
#!/usr/bin/python3
'''
Toggle the audio output devices among the available
'''
import pulsectl
def main():
pulse = pulsectl.Pulse('my-client')
# Create list of sink objects
@rcassani
rcassani / find_hardlinked.py
Created May 21, 2019 21:05
Find all hardlinked files in an specific path
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Find all hardlinked files in an specific path
Hardlinked files share inode, however the same inode can be found in
different partitions, as such, besides the inode it is needed to check the
device number where the file exists
See -printf option %D
https://www.computerhope.com/unix/ufind.htm
"""
@rcassani
rcassani / example_argparse.py
Created August 26, 2019 18:24
Pass arguments to Python code
import argparse
parser = argparse.ArgumentParser()
# Positional argument
parser.add_argument('echo', help='Response text')
# Optional arguments
parser.add_argument('--value', type=int, default=0)
parser.add_argument('--flag', action='store_true', help='Flag, true if present')
args = parser.parse_args()
print(args.echo)
@rcassani
rcassani / interactive_test.ipynb
Last active April 17, 2020 19:20
Interactive Jupyter Notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rcassani
rcassani / hist_norm.m
Created May 7, 2020 16:50
Histogram overlap
function [nElementsNorm, xCenters, heightsNorm, edges] = hist_norm(data, nBins)
%
% HIST_NORM(DATA, NBINS) computes the Histogram for the vector DATA
% using NBINS, and normalize it so the area occupied by the bars with heigth
% NELEMENTSNORM with center at XCENTERS sums up to 1.
% The resulting histogram (i.e., the barrs) can be plotted with
% bar(xCenters, nElementsNorm)
% alternatively, the empirical PDF can be plotted with
% area(heightsNorm,edges)
@rcassani
rcassani / desklet.js
Last active October 19, 2023 13:52
Simple desklet for Cinnamon (desktop environment)
const Desklet = imports.ui.desklet;
const St = imports.gi.St;
function MyDesklet(metadata, desklet_id) {
this._init(metadata, desklet_id);
}
MyDesklet.prototype = {
__proto__: Desklet.Desklet.prototype,
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# This is the code for the simulation and figures described in the post:
# "Multiple comparisons problem, visual approach" in
# https://www.castoriscausa.com/posts/2020/06/19/multiple-comparisons-visual/
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as stats
@rcassani
rcassani / bluetooth-sleep.service
Created September 9, 2020 14:57
systemd service file to turn OFF the bluetooth controller on Sleep, and turn it ON on Wake
[Unit]
Description= Controls the power of the bluetooth controller when sleep and wake
Before=sleep.target
StopWhenUnneeded=yes
[Service]
Type=oneshot
RemainAfterExit=yes
# Uses bluetoothctl to change the power of bluetooth the controller
ExecStart=/usr/bin/bash -c "bluetoothctl power off"