Skip to content

Instantly share code, notes, and snippets.

@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'
View gist:eea0c3b04ab6f18c46ccf2ea37d86250
ecarroll  ⋯  code  postgis  extensions   svn-trunk  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'
mkdir -p sql_bits/
/usr/bin/perl -pe 's/BEGIN\;//g ; s/COMMIT\;//g' ../../postgis/postgis_for_extension.sql > sql_bits/postgis.sql
make -C ../../doc comments
View gist:eda5a0a2f4b6ff0e038f
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
You can’t perform that action at this time.