Skip to content

Instantly share code, notes, and snippets.

View guillermoroblesjr's full-sized avatar

Guillermo Robles, Jr. guillermoroblesjr

View GitHub Profile
@guillermoroblesjr
guillermoroblesjr / gist:867e77c2375d3684400b
Last active August 29, 2015 14:17
Underscore/Lodash each function
_.each( '<collection>', function(item,count,collection) {
// do stuff
}, this /* this becomes available in your function */);
@guillermoroblesjr
guillermoroblesjr / gist:9b5892d8d8d35abb08c5
Last active October 28, 2015 14:59
Git checkout/revert to an older hash on a new branch
# directory goes back to the hash, ALL changes AFTER hash are discarded.
# you can always merge in a different branch to update later changes.
git checkout -b <temp-branch-name> <myHashGoesHere>
# OR
# create a new branch
git checkout -b <temp-branch-name>
# reverts all files that were originally part of this hash back to their
@guillermoroblesjr
guillermoroblesjr / gist:8d55d06cb4af7e5c6fcb
Last active August 29, 2015 14:20
Git set upstream origin remote branch
# git push -u origin my_branch
git push -u [email protected]:name-of-repo.git my-branch
# same as:
git push --set-upstream [email protected]:name-of-repo.git my-branch
@guillermoroblesjr
guillermoroblesjr / gist:0e7881125ac74d0e573f
Created April 30, 2015 15:58
Create a JavaScript function dynamically with strings
// Create the function
// 'a' and 'b' are the arguments available to the function,
// the last string is the body of your new function
var x = Function('a','b','console.log(a+b); return "apples";');
// Implementation
x(1,2); // will return 'apples' and will log to the console '3';
@guillermoroblesjr
guillermoroblesjr / gist:31fcd11738a868858c7c
Created May 12, 2015 01:12
Automate your git commits
#!/bin/bash
git fetch
git add --all .
git status
git commit -m "$2"
git push
@guillermoroblesjr
guillermoroblesjr / gist:ce97301ae8d326093f66
Created May 22, 2015 19:18
Force install of a package with Bower when the bower.json file has errors
# bower install <name-for-your-directory>=http://<url>/<file-name> -S
# example
bower install dom4-polyfill=https://raw.githubusercontent.com/WebReflection/dom4/master/build/dom4.js -S
@guillermoroblesjr
guillermoroblesjr / gist:1c8852caee6a629492de
Created May 28, 2015 18:44
Make a symlink in Windows with Cmder
# mklink /j <directory/shortcut name> <directory to create the link to>
mklink /j OPUSConfirmationsTrunk_v2.0 C:\Users\grobles4\workspace\OPUSConfirmationsTrunk_v2.0
@guillermoroblesjr
guillermoroblesjr / gist:2553cdce2230273e5a26
Last active August 29, 2015 14:22
Running node-inspector to debug Node.js apps
# spin up node-inspector, here i'm pointing it to a specific port
node-inspector --web-port=8081
# open another terminal, start the node app with the --debug-brk option
# to create a breakpoint on line 1 of your app
node --debug-brk ./app.js
# if debugging Gruntfile.js with Windows, use:
node --debug-brk c:\Users\<username>\AppData\Roaming\npm\node_modules\grunt-cli\bin\grunt <taskname>
@guillermoroblesjr
guillermoroblesjr / gist:0cee829b60708eb86ae8
Created June 8, 2015 17:36
Using git diff to view changes on a file with line numbers
# find and copy the: file name, hash of change
git whatchanged
# show the diff
# e.g. git diff ee11453 src/js/my-module.js
git diff <hash> <path/filename>
# when you see this: @@ -26,31 +26,31 @@
# "-26" is the line number,
# "31" is the number of lines changed
node_modules/
bower_components/
*.log
build/
dist/
##########################################################
# ignore everything inside this directory