This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "sync" | |
type Cond struct { | |
lock sync.RWMutex | |
changed chan struct{} | |
} | |
func (c *Cond) Listen() <-chan struct{} { | |
c.lock.RLock() | |
defer c.lock.RUnlock() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"net/http" | |
) | |
func handleResponse[T any](resp *http.Response, err error, t *T) error { | |
if err != nil { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package cond | |
type Cond struct { | |
lock sync.RWMutex | |
changed chan struct{} | |
} | |
func newCond() *Cond { | |
return &Cond{changed: make(chan struct{})} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Newbie programmer | |
def factorial(x): | |
if x == 0: | |
return 1 | |
else: | |
return x * factorial(x - 1) | |
print factorial(6) | |
#First year programmer, studied Pascal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find . -type d -depth 1 -exec git --git-dir={}/.git --work-tree=$PWD/{} pull origin master \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\x auto | |
\timing on | |
SET work_mem='512MB'; | |
SET maintenance_work_mem='1GB'; | |
-- Nicer PSQL prompt | |
-- Prompt1 / Prompt2 | |
-- %M : server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package bigfloat | |
import ( | |
"fmt" | |
"math/big" | |
) | |
func Zero() *big.Float { return big.NewFloat(0.0) } | |
func Sub(x, y *big.Float) *big.Float { return Zero().Sub(x, y) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE USER admin; -- create user with name 'admin' | |
ALTER USER admin WITH PASSWORD 'hello123'; -- set password | |
GRANT SELECT ON users TO admin; -- give 'select' access on 'users' table to 'admin' user | |
REVOKE SELECT ON users FROM admin; -- revoke access on 'users' table from 'admin' user | |
GRANT SELECT ON ALL TABLES IN SCHEMA public TO admin; -- give access to all tables in public schema to 'admin' user | |
REVOKE ALL ON ALL TABLES IN SCHEMA public FROM admin; -- revoke access on all tables from 'admin' user | |
DROP USER admin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- PSQL queries which also duplicated from https://github.com/anvk/AwesomePSQLList/blob/master/README.md | |
--- some of them taken from https://www.slideshare.net/alexeylesovsky/deep-dive-into-postgresql-statistics-54594192 | |
-- I'm not an expert in PSQL. Just a developer who is trying to accumulate useful stat queries which could potentially explain problems in your Postgres DB. | |
------------ | |
-- Basics -- | |
------------ | |
-- Get indexes of tables |
NewerOlder