Skip to content

Instantly share code, notes, and snippets.

package main
import (
"fmt"
"log"
"net/http"
"html/template"
"github.com/gorilla/sessions"
@gerep
gerep / stdin.go
Last active February 23, 2017 19:50
Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then print the respective minimum and maximum values as a single line of two space-separated long integers.
package main
import (
"bufio"
"fmt"
"os"
"sort"
"strconv"
"strings"
)
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
package main
import (
"bufio"
"fmt"
"log"
"os"
"strconv"
"strings"
)
package main
import (
"bufio"
"fmt"
"log"
"os"
"strconv"
"strings"
)
@gerep
gerep / pg.txt
Created June 7, 2017 20:50
Some PG commands
Last Vaccum: select * from pg_stat_all_tables;
Dead tuples: select relname, n_dead_tup, last_vacuum, last_autovacuum from pg_catalog.pg_stat_all_tables where n_dead_tup > 0 and relname = 'precificacao_campanha' order by n_dead_tup desc;
Run Vaccum: VACUUM FULL VERBOSE precificacao;
set search_path to pricing;
newPrice = fmt.Sprintf("%.2f", (current.Price*c.DiscountValue)/100)
current.NewPrice, err = strconv.ParseFloat(newPrice, 64)
if err != nil {
current.Message = "Ocorreu um erro ao calcular o novo valor deste produto: " + err.Error()
}
package main
import "fmt"
func main() {
x := []byte(`{
"hash":"123456",
"order":123456
}`)
x2 := []byte(`{
@gerep
gerep / pg-dates.sql
Created August 22, 2017 13:28
PostgreSQL: yesterday, today, tomorrow
select TIMESTAMP 'yesterday';
select DATE 'yesterday';
select TIMESTAMP 'today';
select DATE 'today';
select TIMESTAMP 'tomorrow';
select DATE 'tomorrow';
select TIME 'allballs';
select now();
select TIMESTAMP 'now';
select DATE 'now';