Skip to content

Instantly share code, notes, and snippets.

Avatar

Rodrigo Lessa threeaccents

View GitHub Profile
View cancel.go
func (s *Service) ChunkUpload(ctx context.Context, r *multipart.Reader) error {
chunk, err := s.parseChunk(r)
if err != nil {
return fmt.Errorf("failed parsing chunk %w", err)
}
// checkpoint
select {
case <-ctx.Done():
// Abort / return early
View date.js
export default {
subtract(date, days) {
return this.add(date, -days);
},
add(date, days) {
const result = new Date(date);
result.setDate(result.getDate() + days);
return result;
},
addMonths(date, months) {
@threeaccents
threeaccents / smq.go
Last active Jan 9, 2018
Simple Message Queue
View smq.go
package smq
//SMQ is the main controller for the queue.
type SMQ struct {
jobQueue chan []byte
consumer chan Message
worker chan int
}
//New takes in the max queue size and workers.
View serial.ino
#include <Servo.h>
Servo myservo;
void setup() {
Serial.begin(9600);
myservo.attach(9);
}
void loop() {
View serial.go
package main
import (
"bytes"
"encoding/binary"
"flag"
"fmt"
"io"
"log"
"time"
View node-loffice.js
const spawnSync = require('child_process').spawnSync;
const defaultDestPath = __dirname + '/pdf';
function convertToPdf(filepath, destpath) {
var resp = {};
if (destpath == undefined) {
destpath = defaultDestPath;
}
@threeaccents
threeaccents / openbrowser.go
Created Feb 25, 2016
open chrome browser with golang function
View openbrowser.go
// openBrowser tries to open the URL in a browser,
// and returns whether it succeed in doing so.
func openBrowser(url string) bool {
var args []string
switch runtime.GOOS {
case "darwin":
args = []string{"open"}
case "windows":
args = []string{"cmd", "/c", "start"}
default:
@threeaccents
threeaccents / phantom_setup.sh
Created Feb 1, 2016
Install phantomjs 2 on ubunutu server
View phantom_setup.sh
#!/bin/bash
wget https://github.com/Pyppe/phantomjs2.0-ubuntu14.04x64/raw/master/bin/phantomjs
sudo chmod 755 phantomjs
sudo mv phantomjs /usr/bin
@threeaccents
threeaccents / golang_setup.sh
Last active Mar 26, 2016
install golang 1.6 on ubunutu
View golang_setup.sh
#!/bin/bash
sudo apt-get update
sudo apt-get install git
curl -O https://storage.googleapis.com/golang/go1.6.linux-amd64.tar.gz
tar -xvf go1.6.linux-amd64.tar.gz
@threeaccents
threeaccents / setup_selenium.sh
Last active Feb 17, 2016 — forked from curtismcmullan/setup_selenium.sh
Setup Selenium Server on Ubuntu 14.04
View setup_selenium.sh
#!/bin/bash
# Following the guide found at this page
# http://programmingarehard.com/2014/03/17/behat-and-selenium-in-vagrant.html
echo "\r\nUpdating system ...\r\n"
sudo apt-get update
# Create folder to place selenium in
You can’t perform that action at this time.