Skip to content

Instantly share code, notes, and snippets.

View greuze's full-sized avatar

Iván López Santiago greuze

  • Telefónica I+D
  • Boecillo
View GitHub Profile
@greuze
greuze / move-folder-with-history.txt
Created April 10, 2019 09:11
Move folder to other repo with history
# Clone a fresh copy of origin repo and enter into it
git clone <giturl-repoA>
cd <repoA>
# Optional, to avoid pushing to the wrong remote repository
git remote rm origin
# From the repo source, remove all the files and history ourside the folder
git filter-branch --subdirectory-filter <folder-name> -- --all
# Optional, move all the files previously in the folder to a new one, as they are in the repo root now, and commit them (no push)
mkdir <directory-new-name>
mv * <directory-new-name>
@greuze
greuze / .grunt_bash_completion
Created June 4, 2015 15:31
Autocomplete grunt task if Gruntfile.js is present
# Create function that will run when a certain phrase is typed in terminal
# and tab key is pressed twice
_grunt_complete()
{
# fill local variable with a list of completions
local COMPLETES=`grep -s 'grunt\.registerTask' Gruntfile.js | sed "s/\s*grunt.registerTask('\([^']*\)',.*$/\1/g"`
# we put the completions into $COMPREPLY using compgen
COMPREPLY=( $(compgen -W "$COMPLETES" -- ${COMP_WORDS[COMP_CWORD]}) )
return 0
@greuze
greuze / .ctags
Last active August 29, 2015 14:17
node.js .ctags
--exclude=node_modules
--exclude=site
--exclude=test
--langdef=js
--langmap=js:.js
--regex-js=/([A-Za-z0-9_$]+)[ \t]*[:=][ \t]*function[A-Za-z0-9_$ \t]*\(/\1/f, function, functions/
--regex-js=/\[[ \t]*['"]([A-Za-z0-9_$ ]+)['"][ \t]*\][ \t]*=[ \t]*function[A-Za-z0-9_$ \t]*\(/\1/f, function, functions/
--regex-js=/['"]([A-Za-z0-9_$ ]+)['"][ \t]*:[ \t]*function[A-Za-z0-9_$ \t]*\(/\1/f, function, functions/
--regex-js=/function[ \t]+([A-Za-z0-9_$]+)[ \t]*([^)])/\1/f, function, functions/
@greuze
greuze / force-http-error.js
Created February 26, 2015 16:16
Force HTTP error in node.js requests
var http = require('http');
var request = require('request');
function forceHttpError(error) {
var originalHttpRequest = http.request;
// Monkey-patch the http.request method with
// our implementation
http.request = function (opts, cb) {
// Call the original implementation of http.request()
var req = originalHttpRequest(opts, cb);
@greuze
greuze / .git-prompt
Last active December 4, 2017 15:38
# SETUP CONSTANTS
# Bunch-o-predefined colors. Makes reading code easier than escape sequences.
# Reset
Color_Off="\[\033[0m\]" # Text Reset
# Regular Colors
Black="\[\033[0;30m\]" # Black
Red="\[\033[0;31m\]" # Red
Green="\[\033[0;32m\]" # Green