Skip to content

Instantly share code, notes, and snippets.

View gastongouron's full-sized avatar
🏠
Working from home

Paul gastongouron

🏠
Working from home
View GitHub Profile
@frane
frane / ArrayObjectDemo.coffee
Created December 31, 2011 02:19
Traversing arrays and objects in CoffeeScript
# Traversing arrays and objects in CoffeeScript
# The array and object we use for testing
arr = [1, 2, 3, 4, 5]
obj = {a: 1, b: 2, c: 3, d: 4, e: 5}
# 'in' has a different meaning in CoffeeScript than in JavaScript
# CS: element in array -> JS: array.indexOf(element) >= 0
console.log '5 in arr: ' + (5 in arr)
@rstacruz
rstacruz / index.md
Last active November 3, 2023 09:56
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@bretterer
bretterer / Toggle Button Class
Last active March 11, 2016 09:51
Toggle twitter bootstrap button classes.
$('.btn-group > .btn, .btn[data-toggle="button"]').click(function() {
var buttonClasses = ['btn-primary','btn-danger','btn-warning','btn-success','btn-info','btn-inverse'];
var $this = $(this);
if ($(this).attr('class-toggle') != undefined && !$(this).hasClass('disabled')) {
var btnGroup = $this.parent('.btn-group');
var btnToggleClass = $this.attr('class-toggle');
var btnCurrentClass = $this.hasAnyClass(buttonClasses);
@artjomb
artjomb / 1_phantomErrors.js
Last active April 5, 2022 22:10
Error event handlers for PhantomJS and CasperJS: PhantomJS and CasperJS don't show errors on the page by default. This can give clues as to what did go wrong.
var page = require('webpage').create(),
url = 'http://example.com/';
// Put the event handlers somewhere in the code before the action of
// interest (opening the page in question or clicking something)
// http://phantomjs.org/api/webpage/handler/on-console-message.html
page.onConsoleMessage = function(msg, lineNum, sourceId) {
console.log('CONSOLE: ' + msg + ' (from line #' + lineNum + ' in "' + sourceId + '")');
};
@gastongouron
gastongouron / js
Created November 8, 2015 02:11
Javascript RPN Calculator
// JSRPN - a simple console display javaScript RPN calculator
// by Lars Johnson and Paul Gaston Gouron
var RPN = function(string){
var poppush = function () {
stack.pop()
stack.pop()
stack.push(value)
}
@pierrenoizat
pierrenoizat / native_p2wpkh.rb
Last active February 3, 2022 17:00
Build a Segwit transaction spending a Segwit native P2WPKH utxo and another (standard) transaction funding a native P2WPKH Segwit address
require 'bitcoin'
require 'money-tree'
require 'bip44'
require 'bech32'
include Bitcoin
include Bitcoin::Builder
include Bitcoin::Protocol
include Bitcoin::Util
include Bitcoin::Secp256k1