Skip to content

Instantly share code, notes, and snippets.

Avatar

Iván López Santiago greuze

View GitHub Profile
@greuze
greuze / move-folder-with-history.txt
Created Apr 10, 2019
Move folder to other repo with history
View move-folder-with-history.txt
# 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 Jun 4, 2015
Autocomplete grunt task if Gruntfile.js is present
View .grunt_bash_completion
# 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 Aug 29, 2015
node.js .ctags
View .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 Feb 26, 2015
Force HTTP error in node.js requests
View force-http-error.js
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);
View .git-prompt
# 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