Skip to content

Instantly share code, notes, and snippets.

View gregtzar's full-sized avatar
⚔️

Gregory Tzar gregtzar

⚔️
View GitHub Profile
@gregtzar
gregtzar / query.sql
Last active August 1, 2018 10:34 — forked from ramiroaznar/query.sql
How to find duplicate values with PostgreSQL
select * from tablename t1
where (select count(*) from tablename t2
where t1.fieldname = t2.fieldname) > 1
order by fieldname
@gregtzar
gregtzar / gist:314ec85091017fc3a8ce56221cbfc709
Created May 28, 2018 11:48
Find all tables with a foreign key reference to a table column (PostgreSQL)
select confrelid::regclass, af.attname as fcol,
conrelid::regclass, a.attname as col
from pg_attribute af, pg_attribute a,
(select conrelid,confrelid,conkey[i] as conkey, confkey[i] as confkey
from (select conrelid,confrelid,conkey,confkey,
generate_series(1,array_upper(conkey,1)) as i
from pg_constraint where contype = 'f') ss) ss2
where af.attnum = confkey and af.attrelid = confrelid and
a.attnum = conkey and a.attrelid = conrelid
AND confrelid::regclass = 'my_table'::regclass AND af.attname = 'my_referenced_column';
@gregtzar
gregtzar / main.go
Last active August 29, 2015 14:16 — forked from gdey/README.md
package main
import (
"fmt"
"log"
"net/http"
"net/url"
"os"
"os/signal"
"strings"
@gregtzar
gregtzar / gist:3505e7c94171da90a97d
Last active September 1, 2015 01:25
NGINX Dynamic Proxy Endpoint
# Proxy all requests dynamically. Eg: http://127.0.0.1/proxy/192.168.1.1/foo/bar >> http://192.168.1.1/foo/bar
location ~ "^/proxy/([^/]*)/(.*)$" {
proxy_pass $scheme://$1/$2$is_args$args;
}
'use strict';
/**
* ui-ladda
*
* To use, simply use normal Ladda classes and attributes and pass a model to ui-ladda. You can
* use truthy or falsey values, or pass decimals from 0 to 1 to show the progress bar animation.
*
*
* @param uiLadda (mixed): Sets wether or not to show the ladda loading
//take this script and place it in your firebug or javascript console (when you are on the invoice edit page)
//it will segment billable and non-billable (0.00) and total them up (could be improved to group by rate)
var total=0;
function add_them(index, e){
var num = parseFloat($(e).val());
if (!isNaN(num)) {
total += num;
}
}
<?php
/**
* Github WebHook processor
* POST to: postreceive.php?key=REPLACE_ME_WITH_A_UNIQUE_KEY
*
* @author Luis Abreu
* @version 0.1
* @copyright Quodis, 24 February, 2011
* @package default
@gregtzar
gregtzar / gist:4392368
Created December 27, 2012 21:51
Clone a github repo from bash via http. Uses http auth and encodes username/password.
uname='BOBDOBBS'
pwd='3n*90!23nl1'
sedEncode='s/%/%25/g;s/ /%20/g;s/ /%09/g;s/!/%21/g;s/"/%22/g;s/#/%23/g;s/\$/%24/g;s/\&/%26/g;s/'\''/%27/g;s/(/%28/g;s/)/%29/g;s/\*/%2a/g;s/+/%2b/g;s/,/%2c/g;s/-/%2d/g;s/\./%2e/g;s/\//%2f/g;s/:/%3a/g;s/;/%3b/g;s//%3e/g;s/?/%3f/g;s/@/%40/g;s/\[/%5b/g;s/\\/%5c/g;s/\]/%5d/g;s/\^/%5e/g;s/_/%5f/g;s/`/%60/g;s/{/%7b/g;s/|/%7c/g;s/}/%7d/g;s/~/%7e/g;s/ /%09/g'
encodedUname=$(echo "$uname" | sed "$sedEncode")
encodedPwd=$(echo "$pwd" | sed "$sedEncode")
repoStr="http://$encodedUname:$encodedPwd@github.com/fnord/five-tons-of-flax.git"
cd ~/
git clone "$repoStr"