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
@hugollm
hugollm / conky.conf
Created February 2, 2019 21:48
Sample conky config
background no
alignment top_right
gap_x 20
gap_y 20
default_color cornflowerblue
default_outline_color white
default_shade_color white
@hugollm
hugollm / mouse-sensitiviy.sh
Created April 22, 2018 17:11
Reduces the mouse sensitiviy on Xubuntu, when the GUI fails to do so
xset m 3/2 4
@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;
});
@hugollm
hugollm / .bashrc
Last active September 24, 2017 16:47
bashrc script to add newlines before and after each prompt, for easier reading
#---------------------------------------------
# Newlines before and after each prompt line
#---------------------------------------------
function pre_command() {
printf "\n"
}
function post_command() {
printf "\n"
}
@hugollm
hugollm / golang.profile
Created June 17, 2017 15:34
Personal setup for go lang
# /etc/profile
# go lang
export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/Desktop/go
export PATH=$PATH:$GOPATH/bin
@hugollm
hugollm / ajax-csrf-token.js
Created June 13, 2017 13:17
CSRF ajax setup for Django and JQuery
// https://docs.djangoproject.com/en/1.11/ref/csrf/#ajax
$.ajaxSetup({
beforeSend: function(xhr, settings) {
if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));
}
}
});
@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|
@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 / git-log-alias.sh
Created April 12, 2017 16:30
Alias for a good git log, shown as graph
git config --global alias.l "log --graph --abbrev-commit --decorate --format=format:'%C(blue)%h%C(reset) %C(white)%s%C(reset) %C(dim white)- %an [%ar]%C(reset)%C(cyan)%d%C(reset)' --all"
@hugollm
hugollm / bug.py
Created April 9, 2017 17:17
A bug that I found with python http.cookies.SimpleCookie
# watch -n 1 python3 -m unittest bug.py
from unittest import TestCase
from http.cookies import SimpleCookie
class BugTestCase(TestCase):
def test_bug(self):
morsel = list(SimpleCookie('token=abc; HttpOnly; SameSite=Strict').values())[0]