nodejs
Use n module from npm in order to upgrade node
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
// A slice of pairs that implements sort.Interface to sort and reverse by values | |
type PairList []Pair | |
func (p PairList) Len() int { return len(p) } | |
func (p PairList) Swap(i, j int) { p[i], p[j] = p[j], p[i] } | |
func (p PairList) Less(i, j int) bool { return p[i].Value < p[j].Value } | |
func sortMapByValues(m map[string]float64) PairList { | |
p := make(PairList, len(m)) |
package main | |
import ( | |
"database/sql/driver" | |
"github.com/google/uuid" | |
) | |
type ID string |
package main | |
import ( | |
"fmt" | |
"math" | |
"time" | |
) | |
func RoundTime(input float64) int { | |
var result float64 |
func Round(input float64) int { | |
var result float64 | |
if input < 0 { | |
result = math.Ceil(input - 0.5) | |
} else { | |
result = math.Floor(input + 0.5) | |
} | |
// only interested in integer, ignore fractional | |
i, _ := math.Modf(result) | |
return int(i) |
func main() { | |
req, err := http.NewRequest(method, url, body) | |
if err != nil { | |
return nil, err | |
} | |
req.Header.Add("Accept-Encoding", "gzip") | |
httpClient := &http.Client{Timeout: 15 * time.Second} | |
res, err := httpClient.Do(req) | |
if err != nil { |
nodejs
Use n module from npm in order to upgrade node
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
SELECT | |
pg_terminate_backend(pid) | |
FROM | |
pg_stat_activity | |
WHERE | |
-- don't kill my own connection! | |
pid <> pg_backend_pid() | |
-- don't kill the connections to other databases | |
AND datname = 'database_name' | |
; |
name: Deploy using Dokku | |
on: | |
push: | |
branches: [ master ] | |
jobs: | |
build: | |
name: Deploy |
FROM httpd:2.4 as apache | |
RUN sed -i '/LoadModule rewrite_module/s/^#//g' /usr/local/apache2/conf/httpd.conf && \ | |
sed -i 's#AllowOverride [Nn]one#AllowOverride All#' /usr/local/apache2/conf/httpd.conf | |
FROM apache as production-stage | |
WORKDIR /usr/local/apache2/htdocs/ | |
RUN rm index.html |