Skip to content

Instantly share code, notes, and snippets.

@amadoalmex
amadoalmex / servefile.sh
Last active October 25, 2020 00:25 — forked from talwai/servefile.sh
One-shot HTTP webserver to serve file contents using netcat
serveit(){
clen=$(wc -c < "$1" | cut -f1 -d' ')
while true ; do
cat <<endheaders
HTTP/1.0 200 OK
Content-Type: application/octet-stream
Content-Length: $clen
Content-Disposition: attachment; filename="$1"
endheaders
@amadoalmex
amadoalmex / mysql-calendario.sql
Last active July 4, 2018 15:15 — forked from bryhal/gist:4129042
MYSQL: Generate Calendar Table
SET lc_time_names = 'es_MX';
DROP TABLE IF EXISTS time_dimension;
CREATE TABLE time_dimension (
id INTEGER PRIMARY KEY, -- year*10000+month*100+day
db_date DATE NOT NULL,
year INTEGER NOT NULL,
month INTEGER NOT NULL, -- 1 to 12
day INTEGER NOT NULL, -- 1 to 31
quarter INTEGER NOT NULL, -- 1 to 4
week INTEGER NOT NULL, -- 1 to 52/53