Skip to content

Instantly share code, notes, and snippets.

@marcosinger
marcosinger / helper.go
Created March 26, 2020 14:24
Helper to align tables based on its content using the gofpdf library
func wrappedTable(document *gofpdf.Fpdf, encodingFunc report.EncodingFunc,
rows [][]string, cols []float64, marginCell float64, border bool) []position {
var (
padding = 10.0
paddingCell = 2. // padding of top/bottom of cell
rowsPositions []position
)
_, pageh := document.GetPageSize()
@marcosinger
marcosinger / completions-gswitch.fish
Created October 16, 2019 19:40
Fish helpers to handle with gcloud config
# ~/.config/completions/gswitch.fish
#
# creates a variable with the name of gcloud named configurations. Ex.:
#
# ~ glist
# NAME IS_ACTIVE ACCOUNT PROJECT
# aluminium False contact@aluminium.com aluminium-123
# nickel True contact@nickel.com nickel-001
# zinc False hi@zinc.io zinc-project
#
@marcosinger
marcosinger / main.go
Created July 19, 2019 20:31
Example of "errgroup" package
package main
import (
"fmt"
"net/http"
"time"
"golang.org/x/sync/errgroup"
)
@marcosinger
marcosinger / channel.go
Last active July 2, 2019 17:17
Channel example
package main
import (
"fmt"
"sync"
"log"
"net/http"
)
type Response struct {
@marcosinger
marcosinger / sample.rb
Created January 3, 2019 19:32
Classe de exemplo para determinar se um estabelecimento está aberto no momento
class Sample
HOURS = {
'mon' => [],
'tue' => [
['09:00', '19:00'],
],
'wed' => [
['09:00', '19:00'],
],
'thu' => [
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
)
func main() {
@marcosinger
marcosinger / count_tech
Created February 6, 2015 22:16
A shell script to count how many lines of code in each language each author added/removed in a repo
#!/bin/bash
git status &>-
if [ "$?" -ne 0 ]; then
printf "%0s$(echo -en "\033[1;31m")Error :$(echo -en "\033[0m") Run this command in a git repo"
exit 1
fi
declare -A techs=( ["Ruby"]="rb" ["Javascript"]="js" ["Html"]="html" ["Css"]="css")
authors=$(git shortlog -s | awk '{print $2}')
@marcosinger
marcosinger / 0_reuse_code.js
Created December 21, 2013 03:04
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@marcosinger
marcosinger / gist:2781490
Last active October 5, 2015 08:48
Append jQuery on the fly
javascript:(
function(){
a=document.createElement('SCRIPT');
a.type='text/javascript';
a.src='http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js';
document.getElementsByTagName('head')[0].appendChild(a);
}
)();
@marcosinger
marcosinger / gist:2722199
Created May 17, 2012 23:12
Cloning all listed projects, creating a gemset and runs Bundle install
#!/bin/bash
current_path=`pwd`
projects=(webdesk/webdesk webdesk/webdesk-provisioner webdesk/webdesk-product-api
webchat/webchat webchat/webchat-provisioner webchat/webchat-product-api
pabx-virtual/pabx-virtual-2011 pabx-virtual/pabx-provisioner
pabx-virtual/pabx-product-api pabx-virtual/ruby_pabx_core
saas_plan_config/saas_plan_config
locaweb-utilities/x9 package_pipeline/package_pipeline
product-apify/product-apify feed_consumer/feed_consumer