Skip to content

Instantly share code, notes, and snippets.

View hugollm's full-sized avatar

Hugo Mota hugollm

  • Montes Claros - MG - Brasil
View GitHub Profile
@crazybyte
crazybyte / encrypt_openssl.txt
Created November 25, 2012 10:10
File encryption using OpenSSL
For symmetic encryption, you can use the following:
To encrypt:
openssl aes-256-cbc -salt -a -e -in plaintext.txt -out encrypted.txt
To decrypt:
openssl aes-256-cbc -salt -a -d -in encrypted.txt -out plaintext.txt
For Asymmetric encryption you must first generate your private key and extract the public key.
@judges119
judges119 / hampel.js
Last active November 10, 2020 18:12
JS Hampel Filter
/*
Hampel Filter implemented in JavaScript by Adam O'Grady
AN: Very basic (ie: improve before using in production) function I needed for some work stuff, used for detecting and removing outliers in a moving window via Median Absolute Deviation (MAD)
PARAMS:
data - Array of numbers to be examined
half_window: Integer representing half the moving window size to use
threshold: Integer for the maximum multiple of the Median Absolute Deviation before it's considered an outlier and replaced with the median
RETURNS:
object:
data: updated, smoothed array
// Talking console
//
// Support: http://caniuse.com/#search=SpeechSynthesisUtterance
//
// Copy paste the code into dev console or
// use http://mrcoles.com/bookmarklet/ to create a bookmarklet.
/* ✂️ ......................................................................................... */
if(console.log.name !== 'talkLog') {
console.l = console.log;
@hugollm
hugollm / spotify-pause.txt
Created March 11, 2017 01:25
Adding shortcut to play/pause music on Spotify (if media key is not already working)
Whisker menu > Keyboard > Application Shortcuts > Add
dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
@hugollm
hugollm / envy
Created April 26, 2017 23:34
Script to easily jump into a python3 virtualenv
#!/bin/bash
if [ ! -d ".env" ]; then
virtualenv -p `which python3` .env
fi
source .env/bin/activate
@hugollm
hugollm / Vagrantfile
Created May 12, 2017 19:02
Vagrantfile to spawn an ubuntu box with python and ssh (ready for ansible scripts)
host_public_key = File.readlines("#{Dir.home}/.ssh/id_rsa.pub").first.strip
setup_ssh = <<SCRIPT
mkdir -p /home/ubuntu/.ssh
echo '#{host_public_key}' >> /home/ubuntu/.ssh/authorized_keys
SCRIPT
install_python = 'DEBIAN_FRONTEND=noninteractive apt-get install -y python'
Vagrant.configure('2') do |config|
@rkrzr
rkrzr / auto_tags.py
Last active April 10, 2024 11:14
Automatically generate ansible tags of the same name for each role in a playbook
"""
This module implements an Ansible plugin that is triggered at the start of a playbook.
The plugin dynamically generates a tag for each role. Each tag has the same name as its role.
The advantage of this is that it saves you some boilerplate, because you don't have to wrap
all tasks of a role in an additional block and assign a tag to that.
Additionally, it works automatically when you add new roles to your playbook.
Usage is exactly the same as without this plugin:
@hugollm
hugollm / async-popup.js
Last active December 27, 2017 14:05
Pseudo code showing how to open a popup "assinchronously" without being blocked by the browsers
// The idea is to load a placeholder popup right after the click
// and then redirect it later to the real location.
// on click
let popup = showPlaceholderPopup('Loading...');
api.get('/obtain-the-real-url').then(url => {
popup.location.href = url;
});