Skip to content

Instantly share code, notes, and snippets.

View fabienengels's full-sized avatar

Fabien Engels fabienengels

  • Strasbourg, France
View GitHub Profile
[
{
"year": 1980,
"earthquake": 439,
"other": 0,
"undefined": 0,
"total": 439
},
{
"year": 1981,
fabien@9b ~ » which postgres_launch
postgres_launch () {
docker run -it --rm --name postgres_$1 -e POSTGRES_USER=$1 -v $HOME/Databases/$1:/var/lib/postgresql/data -p $2:5432 postgres:9.6
}
fabien@9b ~ » which postgres_restore
postgres_restore () {
pg_restore -U $1 -d postgres -j $(grep -c processor /proc/cpuinfo) -O -x -h 127.0.0.1 -p $(postgres_get_port $1) $2
}
fabien@9b ~ » which postgres_get_port
postgres_get_port () {
fabien@9b ~ » which postgres_get_port
postgres_get_port () {
docker inspect postgres_$1 | jq -M -r '.[0].NetworkSettings.Ports."5432/tcp"[0].HostPort'
}
MariaDB [conso]> select DATE_FORMAT(DATE, '%Y-%m'), sum(cIndexDelta) from conso_releve where HOUR(DATE) < 8 AND HOUR(DATE) < 18 GROUP BY DATE_FORMAT(DATE, '%Y-%m') ORDER BY DATE_FORMAT(DATE, '%Y-%m');
+----------------------------+------------------+
| DATE_FORMAT(DATE, '%Y-%m') | sum(cIndexDelta) |
+----------------------------+------------------+
| 2016-12 | 3480 |
| 2017-01 | 229778 |
| 2017-03 | 79683 |
| 2017-05 | 79782 |
+----------------------------+------------------+
4 rows in set (0.19 sec)
@fabienengels
fabienengels / gist:fcac2c1057e90c2ddd16
Created March 3, 2016 09:36
Delete a SeisComP object
Delete on object (cost=0.00..19.66 rows=1 width=6) (actual time=4.508..4.508 rows=0 loops=1)
-> Index Scan using object_pkey on object (cost=0.00..19.66 rows=1 width=6) (actual time=4.441..4.442 rows=1 loops=1)
Index Cond: (_oid = 65262249)
Trigger for constraint amplitude__oid_fkey1: time=5.848 calls=1
Trigger for constraint amplitude__parent_oid_fkey1: time=145.531 calls=1
Trigger for constraint publicobject__oid_fkey: time=0.349 calls=1
Trigger for constraint eventdescription__oid_fkey: time=6.320 calls=1
Trigger for constraint eventdescription__parent_oid_fkey: time=1.502 calls=1
Trigger for constraint comment__oid_fkey: time=0.259 calls=1
Trigger for constraint comment__parent_oid_fkey: time=0.095 calls=1
sudo -u postgres createdb -O test test
echo "CREATE TABLE data AS SELECT d, md5(random()::text) FROM generate_series(1,10000) d;" | sudo -u postgres psql
@fabienengels
fabienengels / gist:9530932
Created March 13, 2014 15:45
SSL renegociation bug with Golang
package main
import (
"database/sql"
"flag"
_ "github.com/lib/pq"
"log"
)
func main() {