Skip to content

Instantly share code, notes, and snippets.

View afgomez's full-sized avatar
♻️

Alejandro Fernández Gómez afgomez

♻️
View GitHub Profile
@afgomez
afgomez / dmginstall.sh
Created November 29, 2012 22:29
Download and install a .dmg
#!/bin/bash
# Downloads and install a .dmg from a URL
#
# Usage
# $ dmginstall [url]
#
# For example, for installing alfred.app
# $ dmginstall http://cachefly.alfredapp.com/alfred_1.3.1_261.dmg
#
@afgomez
afgomez / filemerge
Created December 30, 2023 22:10
Invoke filemerge from the command line, and wait for the tool to close
# place in `bin/filemerge` and make it executable
open -a FileMerge -n -W --args "$@"
@afgomez
afgomez / validate_spanish_id.js
Last active December 9, 2023 18:12
Spanish DNI, CIF, NIE validator
/**
* ValidateSpanishID. Returns the type of document and checks its validity.
*
* Usage:
* ValidateSpanishID( str );
*
* > ValidateSpanishID( '12345678Z' );
* // { type: 'dni', valid: true }
*
* > ValidateSpanishID( 'B83375575' );
@afgomez
afgomez / git-checkout-branch-fuzzy
Last active April 9, 2023 18:04
FZF git-checkout
#!/bin/bash
branch=`git branch -a | sed 's/^\*//; s/^[ \t]*//; /HEAD.*/d; /^remotes\/origin\/$/d' | fzf --height 40% --border --reverse --preview 'git log --color=always {} -10' | sed 's/remotes\/origin\///'`
if [[ $branch ]]; then
git checkout $branch
fi
@afgomez
afgomez / iterm_profile.sh
Created June 25, 2013 09:24
function to change iTerm2 color profile from the terminal
#!/bin/bash
# Change the iterm2 profile programatically
function iterm_profile {
if [[ -z $1 ]]; then
profile="Default"
else
profile=$1
fi
@afgomez
afgomez / jquery.fn.js
Created June 11, 2013 14:56
quick template for jQuery plugins
(function($) {
$.fn.plugin = function() {
return this.each(function() {
var $this = $( this );
if ( !$this.data('plugin') ) {
$this.data( 'plugin', new Plugin(this) );
}
});
}
@afgomez
afgomez / colors.json
Last active December 9, 2018 17:08
Pizarra color palette
{
"black": "#040506",
// UI BGs
"grey1": "#08090b",
"grey2": "#101216",
"grey3": "#1c1f25",
// UI subtle
"grey4": "#3e424b",
@afgomez
afgomez / wikistance.rb
Created July 2, 2011 19:59
Measures distance of any wikipedia article to Philosophy. Based on http://xkcd.org/903/ alt text
# WikiStance. A Wikipedia distance meter.
# Based on the alt text of http://xkcd.org/903/
# Gets a Wikipedia URL and measure the distance of this page to the Philosophy article, clicking on links not in parens
# neither italics
#
# Author:: Alejandro Fernández (mailto:antarticonorte@gmail.com)
# Copyright:: Copyright (c) 2011 Alejandro Fernández
# License:: GPL
#
# =Usage=
@afgomez
afgomez / sth.js
Last active August 20, 2018 07:42
/**
* @file Some description of the file
* @author Me
*/
import something from 'somewhere';
const SOMETHING = {
some: 'thing'
}
@afgomez
afgomez / virtualenv-auto-activate.sh
Created May 29, 2018 08:33
virtualenv auto activate
#!/bin/bash
# virtualenv-auto-activate.sh
#
# Adapted from https://gist.github.com/codysoyland/2198913
#
# Installation:
# Add this line to your .bashrc or .bash-profile:
#
# source /path/to/virtualenv-auto-activate.sh
#