Skip to content

Instantly share code, notes, and snippets.

Avatar

Evan Carroll EvanCarroll

View GitHub Profile
View steam system info
Computer Information:
Manufacturer: Unknown
Model: Unknown
Form Factor: Laptop
No Touch Input Detected
Processor Information:
CPU Vendor: GenuineIntel
CPU Brand: Intel(R) Core(TM) i7-3520M CPU @ 2.90GHz
CPU Family: 0x6
View gist:44469d42a6e5b6e46207d1f0eada7e97
ecarroll=# explain SELECT j1.*, jsonb_typeof(j1.value) FROM jsonb_array_elements('[ 7,2, [6,7], 2,10 ]'::jsonb) AS j1 LEFT OUTER JOIN LATERAL jsonb_array_elements(j1."value") ON jsonb_typeof(j1.value) = 'array';
QUERY PLAN
-------------------------------------------------------------------------------------
Nested Loop Left Join (cost=0.01..251.25 rows=100 width=64)
Join Filter: (jsonb_typeof(j1.value) = 'array'::text)
-> Function Scan on jsonb_array_elements j1 (cost=0.00..1.00 rows=100 width=32)
-> Function Scan on jsonb_array_elements (cost=0.00..1.00 rows=100 width=0)
(4 rows)
@EvanCarroll
EvanCarroll / enjoy.c
Last active Aug 16, 2018
Why C is impossible to teach?
View enjoy.c
#include <stdio.h>
int a[2][2] = {{1,2},{3,4}};
int (*b)[2] = a;
int main () {
printf("%d\n", *b[1]);
printf("%d\n", (*b)[1]);
printf("%d\n", (*b+1)[1]);
printf("%d\n", (*(b+1))[1]);
View ch3.js
function f() {
let counter = 0;
return function () {
counter = counter + 1;
return function () { return counter }
}
}
Explain what the above code does and how we can use it.
View make.sh
#!/bin/sh
export PGROOT=/home/ecarroll/code/postgres/
gcc \
-I "$PGROOT/src/include/" \
-I "$PGROOT/src/interfaces/ecpg" \
-I "$PGROOT/src/interfaces/ecpg/include" \
./test.c \
-o a.out
View PG Serializability
Session 1
====
Will sleep for 5 seconds giving you time to launch TXN2.
DROP TABLE foo;
CREATE TABLE foo(x) AS
VALUES (1),(2),(3);
View nationscript.sh
TMPDIR="/gisdata/temp/"
UNZIPTOOL=unzip
WGETTOOL="/usr/bin/wget"
export PGBIN=/usr/bin
export PGPORT=5433
export PGDATABASE=rl
PSQL=psql
SHP2PGSQL=shp2pgsql
cd /gisdata
View tx.sh
TMPDIR="/gisdata/temp/"
UNZIPTOOL=unzip
WGETTOOL="/usr/bin/wget"
export PGBIN=/usr/lib/postgresql/9.6/bin
export PGPORT=5432
export PGHOST=localhost
export PGUSER=postgres
export PGPASSWORD=yourpasswordhere
export PGDATABASE=geocoder
PSQL=${PGBIN}/psql
View tx.sh
TMPDIR="/gisdata/temp/"
UNZIPTOOL=unzip
WGETTOOL="/usr/bin/wget"
export PGBIN=/usr/bin
export PGPORT=5433
export PGDATABASE=rl
PSQL=${PGBIN}/psql
SHP2PGSQL=shp2pgsql
cd /gisdata
cd /gisdata
View gist:4832bf7c8ba24c27d7ce085392843c69
make
for DIR in postgis postgis_tiger_geocoder postgis_topology address_standardizer; do \
echo "---- Making all in ${DIR}"; \
make -C "${DIR}" all || exit 1; \
done
---- Making all in postgis
make[1]: Entering directory '/home/ecarroll/code/postgis/extensions/postgis'
cp ../../doc/postgis_comments.sql sql_bits/postgis_comments.sql
make[1]: *** No rule to make target '../../raster/rt_pg/rtpostgis_for_extension.sql', needed by 'sql_bits/rtpostgis.sql'. Stop.
make[1]: Leaving directory '/home/ecarroll/code/postgis/extensions/postgis'