Skip to content

Instantly share code, notes, and snippets.

View whyvez's full-sized avatar

Yves Richard whyvez

View GitHub Profile
@whyvez
whyvez / superdooper.sh
Created June 1, 2015 00:46
superdooper fkey checker
awk -F, 'NR==FNR{ k[$1 $2]=1; next; } NF{ if(!k[$1 $2]) print; }' ./examples/pgyi/data/plot.csv ./examples/pgyi/data/trees.csv
@whyvez
whyvez / plot.awk
Created May 29, 2015 21:45
bawlk " " update
#!/usr/bin/awk -F, -f
# generated by: awk-csvalid https://github.com/tesera/awk-csvalid
# awk-csvalid csv toolset generator: https://github.com/tesera/awk-csvalid
# usage:
# validate: awk -f action=validate validator.awk > violations.txt
# create table: awk -v action=table -f validator.awk | psql afgo_dev
# sanitize csv: awk -v action=sanitize -f validator.awk > sanitized.csv
# insert sql: awk -v action=insert -f validator.awk | psql afgo_dev
@whyvez
whyvez / kill.sql
Created May 27, 2015 01:58
PG conections
-- get pid for db
SELECT state, client_addr, pid FROM pg_stat_activity where datname = 'afgo_qa';
-- kill pid for db
SELECT pg_terminate_backend(12193);
#!/bin/bash
#
# Script to setup a Elastic Beanstalk AMI with geospatial libraries and postGIS
#
# sh aws_ami_prep.sh > aws_ami_prep.log 2>&1 &
# Go to ec2-user home directory
cd /home/ec2-user
# yum libraries
@whyvez
whyvez / get_dead_live_violations.sql
Created March 30, 2015 15:06
PGYI violation logic example
CREATE OR REPLACE FUNCTION get_dead_live_violations(IN upload_id text)
RETURNS TABLE(
upload_id text,
source_row_index integer,
violating_table text,
violating_key text,
violation_rule text,
violation_severity text,
violation_comment text) AS $$
-- API --
validate_upload(upload_id) --inserts from get_upload_violations
exec delete_duplicates()upload_id -- iterate through eacj onValidate
insert from get_upload_violations(upload_id) into violations -- query on all rules without insert
delete_upload()
-- API --
validate_upload(upload_id) --inserts from get_upload_violations
exec delete_duplicates()upload_id -- iterate through eacj onValidate
insert from get_upload_violations(upload_id) into violations -- query on all rules without insert
delete_upload()
@whyvez
whyvez / conv.sh
Created February 16, 2015 00:41
ski-acro Winfree conversion script
#!/usr/bin/env bash
cat ~/Desktop/AcrobatzMassif21fevrier2015-copy.txt \
| awk '/Name=/ { print $0 }' \
| sed s/Massif/MAS/ \
| sed s/Stoneham/STO/ \
| sed s/Relais/REL/ \
| awk -v group=u8 '{ split($3, y, "/"); split(y[2],x,"-"); if(x[1]>=2007) print $0; }' \
# | awk -v group=u10 '{ split($3, y, "/"); split(y[2],x,"-"); if(x[1]<2007) print $0; }' \
| cat ~/Desktop/acro-prefix.txt - > ~/Desktop/acro-u8.txt
@whyvez
whyvez / ng-template-cache.awk
Created January 28, 2015 13:42
Simple AngularJS template cache generator using AWK.
#!/usr/bin/awk -F"\n" -f
# usage
# the html templates need to be a one liner i.e. no line breaks
# $ ./scripts/ng-template-cache.awk -v module=<module> <templates.html > <templates.js>
# $ ./scripts/ng-template-cache.awk -v module=mvApp app/partials/*.html > app/js/templates.js
BEGIN { print "angular.module('"module"').run(['$templateCache', function($templateCache) {" }
{
@whyvez
whyvez / install-gm-w-librvg.sh
Last active February 15, 2023 23:01
Installs ImageMagick --with-librsvg on Amazon Linux
export PKG_CONFIG_PATH=/usr/lib64/pkgconfig:/usr/lib/pkgconfig
export PATH=/usr/bin:$PATH
export LDFLAGS=-L/usr/lib64:/usr/lib
export LD_LIBRARY_PATH=/usr/lib64:/usr/lib
export CPPFLAGS=-I/usr/include
sudo yum-config-manager --enable epel
#sudo yum update -y
sudo yum install -y gcc gcc-c++ glib2-devel.x86_64 libxml2-devel.x86_64 libpng-devel.x86_64 \
libjpeg-turbo-devel.x86_64 gobject-introspection.x86_64 gobject-introspection-devel.x86_64