Skip to content

Instantly share code, notes, and snippets.

View richistron's full-sized avatar
:octocat:
Coding like a baws

Ricardo Rivas richistron

:octocat:
Coding like a baws
View GitHub Profile
@richistron
richistron / squash.sh
Created September 9, 2014 13:35
Merge and clean history
#! /bin/bash
# move to your local branch
git checkout local_branch
# pull the remotes
git fetch --all
# merge and squash
git merge origin/dirty_branch --squash
@richistron
richistron / private_closure.js
Created March 2, 2014 17:17
Private values inside object clusure
/**
* Object with hidden values
*/
var ObjectClosure = (function(){
var privateValue = "hello there!!";
return {
getValue: function(){
return privateValue;
},
setValue: function(newValue){
@richistron
richistron / hanoi.js
Created March 2, 2014 17:06
Hanoi towers recursive function with JavaScript
/*
* Hanoi recursive function
*/
var hanoi = function(disc,src,aux,dest){
if(disc > 0){
hanoi(disc -1,src,dest,aux);
console.log('Move disc '+disc+' from '+src+' to '+dest);
hanoi(disc -1,aux,src,dest);
}
@richistron
richistron / ns_and_class.js
Last active December 23, 2015 23:09
Respuesta a Cristian Camilo Chaparro
/*
No se si en en entendí to pregunta, pero me suena a estos posibles casos
*/
// Herencia de un objeto
// padre
var Parent = (function(){
<?php
$db = new PDO('mysql:host=localhost;dbname=test', $user, $pass);
$sql = sprintf("SELECT contenido FROM barra_lateral WHERE 1 ");
echo '<div id="barra_lateral">';
foreach($db->query($sql) as $row){
echo '<div class="item">' . $row['contenido'] . '<br></div>';
@richistron
richistron / thisJS.coffee
Created August 22, 2013 00:22
Usando this con coffeeScript
(($)->
class Test
constructor:(@error = null)->
log: ->
if window.log? and error is not null then console.log @error
select: ->
$elements = $("div")
$elements.on "click" , ->
###
En este momento @ = this es un elemento de jquery
$(selector).bind("change", function() {
return $.ajax({
success: function() {
return $(this).hide(function() {
return $(this).show("slow", function() {
return mainCallback(function() {
return alert("Hola Mundo");
});
});
});