Skip to content

Instantly share code, notes, and snippets.

cesar pachon cesarpachon

View GitHub Profile
@cesarpachon
cesarpachon / communicate iframe with parent via postMessage
Created May 25, 2016
communicate iframe with parent via postMessage
View communicate iframe with parent via postMessage
//in the parent:
window.addEventListener("message", function(m){console.log(m);})
//in the iframe:
window.parent.postMessage("hola", "*")
View blender.py
# exec an external python script (http://www.blender.org/api/blender_python_api_2_59_2/info_tips_and_tricks.html)
filename = "/full/path/to/myscript.py"
exec(compile(open(filename).read(), filename, 'exec'))
View text.js
// Set up initial code for visualization
var svg = d3.select(controller.element).append("svg")
.attr("width", "100%").attr("height", "100%")
.append("g")
.attr("transform", "translate(10,10)");
// This function receives a JS Array of JS Objects
// representing the current state of your data.
controller.update = function (data) {
// Join new data with old elements, if any.
@cesarpachon
cesarpachon / bash.sh
Last active Aug 29, 2015
useful bash commands
View bash.sh
//download a whole youtube playlist as mp3 files:
youtube-dl -ix -k --audio-format mp3 YOUTUBE_PLAYLIST_URL
GREP
simple use of grep:
grep -n search_string files //ej: grep -n main *.cpp
//list files that contains some string (only .c and .h in this example) -w forces exact word match.
grep --include=\*.{c,h} -rnw './' -e "your_search_string"
#concatenate two mp3 files.
View gist:42cc9e7dd1299b17ed67
ctrl+space open the command list
to enable vim mode: see this readme https://github.com/LightTable/Vim#setup
ctrl+space show user behaviors add this line:
[:editor :lt.objs.editor/line-numbers]
@cesarpachon
cesarpachon / git commands
Last active Aug 29, 2015
useful git commands
View git commands
//-----
this one will save your life, if by mistake you delete both the remote and local branch:
git log -g
http://stackoverflow.com/questions/19592275/git-recover-branch-deleted-on-remote-and-local-folder-deleted
//-----
git checkout phase_3_main //pasarse a la rama de desarrollo activa
git up //verificar que estemos en esa rama
@cesarpachon
cesarpachon / javascript prototype chaining
Created Apr 14, 2014
test the concept of chaining prototypes in javascript
View javascript prototype chaining
var A = function(){
console.log("constructor A");
//create an attribute
this.a0 = "a0";
}
//adding another attribute
A.prototype.a1 = "a1";
@cesarpachon
cesarpachon / vim_commands.sh
Last active Aug 29, 2015
useful vim commands
View vim_commands.sh
:set number #enable line numbering
:set tabstop=2 #set tab size
:set nowrap #disable wrapping
#use vi mode in the shell
set -o vi #for bash
bindkey -v #for zshell
You can’t perform that action at this time.