Skip to content

Instantly share code, notes, and snippets.

View alfredodeza's full-sized avatar
:octocat:

Alfredo Deza alfredodeza

:octocat:
View GitHub Profile
@alfredodeza
alfredodeza / process.sh
Created March 21, 2017 15:22
Process a qcow2 image so that it can be customized as a vagrant box (meant for rhel images mostly)
#!/bin/bash
# The input is a qcow2 image, that gets copied via virt-customize so that it
# can be modified to work as a vagrant box. It requires the `create_box.sh` script
# from the vagrant-libvirt project::
#
# https://github.com/vagrant-libvirt/vagrant-libvirt/blob/master/tools/create_box.sh
#
# Usage:
#
# bash process.sh rhel-guest-image-7.4-10.x86_64.qcow2 rhel7.qcow2
@alfredodeza
alfredodeza / prepare-commit-msg
Last active March 17, 2017 11:20
Pre-commit hook to prepend the branch name on every commit message
#!/bin/sh
# this file should be marked as executable and placed on .git/hooks/
BRANCH_NAME=$(git branch 2>/dev/null | grep -e ^* | tr -d ' *')
# FogBugz
if [[ $BRANCH_NAME =~ ^case ]]; then
CASE_NUMBER=$(echo $BRANCH_NAME 2>/dev/null | tr -d "case" | tr -d "-" | tr -d "_")
echo "[case $CASE_NUMBER] $(cat $1)" > $1
@alfredodeza
alfredodeza / gist:3f6ee551a7898d639ec7afd76f727e21
Created May 20, 2016 17:40
Install m2crypto on OSX 10.10
env LDFLAGS="-L$(brew --prefix openssl)/lib" \
CFLAGS="-I$(brew --prefix openssl)/include" \
SWIG_FEATURES="-cpperraswarn -includeall -I$(brew --prefix openssl)/include" \
pip install m2crypto
@alfredodeza
alfredodeza / enable_tether.rst
Created April 29, 2016 12:36
tethering enabled for Nexus 5x

Steps to enable tethering on Android 6.0 Marshmallow update

Step 1: Ensure you have the correct OEM drivers installed for your handset on the computer

Step 2: Download and install the necessary ADB drivers (v1.4.2)

Step 3: Enable USB debugging on your Android handset:

Go to Settings > About Device, and tap the build number 7 times or until you see 'You're now a developer' message. Return to Settings > Developer options and use the toggle button to turn on USB debugging. Then tap OK button to accept the warning and continue.

@alfredodeza
alfredodeza / main.yml
Created April 28, 2016 12:07
ensure that the current `hostname` is defined in `/etc/hosts`
---
# Because not everything is correct in this world, we may end up with a host that doesn't have the reported
# hostname in the hosts file.
- name: ensure that the current host is in /etc/hosts. Yes this is a thing.
sudo: true
replace:
backup: yes
dest: /etc/hosts
regexp: '^(127\.0\.1\.1(?!.*\b{{ ansible_hostname }}\b).*)$'
@alfredodeza
alfredodeza / mp4togif.sh
Created March 16, 2016 11:40
convert an mp4 to a gif
mp4=$1
DEFAULT_GIF_NAME="output.gif"
OUTPUT=${2:-$DEFAULT_GIF_NAME}
# -delay is used to control the timing between frames, the scale sets the resolution
ffmpeg -i $mp4 -vf scale=320:-1 -r 10 -f image2pipe -vcodec ppm - | convert -delay 10 -loop 0 - $OUTPUT
@alfredodeza
alfredodeza / .vimrc
Created March 7, 2016 13:45
Read non-plaintext file types in Vim
" requires pandoc, the newest the version the better
autocmd BufReadPost *.doc,*.docx,*.rtf,*.odp,*.odt silent %!pandoc "%" -tplain -o /dev/stdout
@alfredodeza
alfredodeza / gist:6319156
Created August 23, 2013 13:07
Supervisor in Ubuntu
First remove the apt-get supervisor version:
sudo apt-get remove supervisor
Kill the backend supervisor process:
sudo ps -ef | grep supervisor
Then get the newest version(apt-get version was 3.0a8):
@alfredodeza
alfredodeza / gist:5905095
Created July 1, 2013 22:13
Attempting to compile onto tasseo
/opt/heroku-buildpack-ruby/bin/compile .
-----> Using Ruby version: ruby-1.9.2
-----> Installing dependencies using
sh: -c: line 0: unexpected EOF while looking for matching ``'
sh: -c: line 1: syntax error: unexpected end of file
sh: -c: line 0: unexpected EOF while looking for matching ``'
sh: -c: line 1: syntax error: unexpected end of file
/opt/heroku-buildpack-ruby/lib/language_pack/ruby.rb:616:in `load_bundler_cache': private method `load' called for nil:NilClass (NoMethodError)
from /opt/heroku-buildpack-ruby/lib/language_pack/ruby.rb:430:in `block in build_bundler'
from /opt/heroku-buildpack-ruby/lib/language_pack/base.rb:91:in `log'
@alfredodeza
alfredodeza / pyversion.vim
Created June 6, 2013 13:01
Get the current Python version in Vim
function! PyVersion()
let out = system("python --version")
" Match on the first digit, fallback to 2 if nothing found
let major_version = get(matchlist(out, '\d'), 0, '2')
echo "This is Python version " . major_version
endfunction