Skip to content

Instantly share code, notes, and snippets.

View leolara's full-sized avatar

Leo Lara leolara

View GitHub Profile
@leolara
leolara / publisher.go
Last active April 29, 2023 04:30
Example in Go of how to close a channel written by several goroutines
// Package gochannels example of how to close a channel written by several goroutines
package gochannels
import (
"math/big"
"sync"
)
// Publisher write sequences of big.Int into a channel
type Publisher struct {
@leolara
leolara / coffeelint.json
Last active August 30, 2016 10:26
Linting rocketchat
{
"indentation" : {
"level" : "error",
"value" : 1
},
"no_tabs": { "level": "ignore"},
"max_line_length": { "level": "ignore"},
"no_spaces": {"level" : "error"},
"line_endings" : {
"value" : "unix",
@leolara
leolara / debounce.go
Last active July 25, 2022 09:25
Golang port of underscore.js
func debounceChannel(interval time.Duration, output chan int) chan int {
input := make(chan int)
go func() {
var buffer int
var ok bool
// We do not start waiting for interval until called at least once
buffer, ok = <-input
// If channel closed exit, we could also close output
@leolara
leolara / ICL
Created February 19, 2014 15:50
open source projects of Leopoldo Lara Vazquez - Individual Contributor License Agreement v1.0
Thank you for your interest in the open source projects of Leopoldo Lara Vazquez (the "Project"). In order to clarify the intellectual property license granted with Contributions from any person or entity, the Project must have a Contributor License Agreement ("CLA") on file that has been signed by each Contributor, indicating agreement to the license terms below. This license is for your protection as a Contributor as well as the protection of the Project and its users; it does not change your rights to use your own Contributions for any other purpose. If you have not already done so, please complete and sign, then submit this Agreement by filling this electronic form and pressing the Submit button at the end of this electronic form. Please read this document carefully before signing and keep a copy for your records.
You accept and agree to the following terms and conditions for Your present and future Contribut
@leolara
leolara / addrefs.js
Last active December 23, 2015 13:09
Add reference to listings
var setReferenceId = {
getNext: function () {
var seq = db.sequences.findAndModify( { query: { _id: 'listings' } , update : { $inc : { sequence: 1} }, new: true, upsert: true });
return seq.sequence;
},
getCursor: function () {
return db.listings.find( { reference_id: { $exists: false } }, {});
},
setReference: function (id, ref) {
return db.listings.update({ _id: id}, { $set: { reference_id: ref }});