Skip to content

Instantly share code, notes, and snippets.

View ogiovannyoliveira's full-sized avatar
🔥
Focusing

Giovanny Oliveira ogiovannyoliveira

🔥
Focusing
View GitHub Profile
@ogiovannyoliveira
ogiovannyoliveira / dockerUpWithoutCache.sh
Last active July 5, 2020 18:30
Docker command for up a container without use the cache and in detached mode
sudo docker-compose -f docker-compose.yml build --no-cache --force-rm
&& sudo docker-compose -f docker-compose.yml up -d
&& sudo docker image prune -a -f
import "bytes"
func StreamToByte(stream io.Reader) []byte {
buf := new(bytes.Buffer)
buf.ReadFrom(stream)
return buf.Bytes()
}
func StreamToString(stream io.Reader) string {
buf := new(bytes.Buffer)
@ogiovannyoliveira
ogiovannyoliveira / locale.sql
Created April 9, 2020 14:13
Pegar todos os dados em um raio de X km de acordo com as coordenadas
SELECT
*
FROM
geo_located_data
WHERE
111.195 * sqrt(power(latitude-($1),2) + power(cos(pi()/180*($2))*(longitude-($2)),2)) < $3
@ogiovannyoliveira
ogiovannyoliveira / previewImage.vue
Last active April 9, 2020 14:07
File example for preview of images before upload
<template>
<div>
<input ref="inputFile" type="file" accept="image/*" hidden @change="upload">
<button @click="openInputFile">Upload</button>
<div>
<div v-show="view">
<img id="imgFile" style="width: 600px; height: 400px" />
<button @click="cleanInputFile"><i>&times;</i></button>
</div>
</div>
@ogiovannyoliveira
ogiovannyoliveira / accumulative.sql
Last active April 9, 2020 14:10
Consulta SQL com valor acumulativo.
SELECT
sum(sum(column)) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) as accumulated
FROM
table
WHERE id_foo = ?
@ogiovannyoliveira
ogiovannyoliveira / transformSeconds.dart
Last active April 9, 2020 14:14
Transformando segundos em dias, horas, minutos e segundos
int segundos = 86400;
int days = (segundos / 86400).floor();
int hours = ((segundos - (days * 86400)) / 3600).floor();
int minutes;
int seconds;
minutes = ((segundos - (days * 86400) - (hours * 3600)) / 60).floor();
seconds = (segundos - (days * 86400) - (hours * 3600) - (minutes * 60)).floor();