Skip to content

Instantly share code, notes, and snippets.

@sethcall
sethcall / gist:15308ccde298bff74584
Created September 23, 2014 21:53
Find rows that do not exist in a table by supplying literal values and without using a temporary table
-- here's my table with some data in it
CREATE TABLE sample ( client_id INT );
INSERT INTO sample VALUES (1);
-- here's the challenge; if my app has values 1, 2, and 3, I want a query that returns '2' and '3'... i.e., all values not currently in the 'sample' table. CTE to the rescue.
WITH app_client_ids(client_id) AS (VALUES(1), (2), (3))
SELECT client_ID from app_client_ids WHERE client_id NOT IN (SELECT client_id FROM sample);
-- result from psql:
@sethcall
sethcall / gist:4512952
Created January 11, 2013 18:43
starter logback columnar log format
<configuration scan="true">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{MMMdd HH:mm:ss.SSS} %8.8thread %3.-3level %15.-15logger{0} %msg %X %n</pattern>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="STDOUT"/>
</root>
@sethcall
sethcall / nginx.conf
Created November 19, 2012 03:53
incron script to watch gems coming into a gem server directory
# safe-network listener to place
# Do a put to http://internal:9000/gems/gemname.gem
# curl -T some.gem http://internal:9000/gems/some.gem
server {
listen 9000;
root /var/www/data/gems;
client_body_temp_path /tmp;
server_name localhost;
dav_methods PUT DELETE;
create_full_put_path on;
@sethcall
sethcall / gist:3113108
Created July 14, 2012 20:06
first time postgres database creation made easy
# first create a user in the database that is your current username (answer 'y' for superuser if this is a development machine.)
sudo su postgres -c "createuser seth"
# create a database of the same name, so that just typing 'psql' will drop you into the psql command-line against database 'seth'
sudo su postgres -c "createdb seth --owner seth"
# now you don't need to sudo for any subsequest pg commands, if you are logged in as this user, for example:
initdb /var/lib/pgsql91/data
createdb "test_this"
@sethcall
sethcall / ivy-git-resolver
Created July 6, 2012 20:31
A git tarball fetching ivy url resolver!
<!-- untested !-->
<!-- organization = should be name of the github user -->
<!-- module = should be name of the project -->
<!-- revision = should be name of branch or tag -->
<!-- example: https://github.com/isaacs/npm/tarball/master -->
<url name="git-tarball">
<artifact pattern="https://github.com/[organization]/[module]/tarball/[revision]"/>
@sethcall
sethcall / gist:2998514
Created June 26, 2012 20:03
rvm trust hanging on... something. have to hit enter
[rpmbuild@localhost dhcpgen-listener]$ rvm --trace rvmrc trust /home/rpmbuild/dhcpgen-listener/target/src/dhcpgen-listener
+ [[ -n '' ]]
+ export 'PS4=+ ${BASH_SOURCE##${rvm_path:-}} : ${FUNCNAME[0]:+${FUNCNAME[0]}()} ${LINENO} > '
+ PS4='+ ${BASH_SOURCE##${rvm_path:-}} : ${FUNCNAME[0]:+${FUNCNAME[0]}()} ${LINENO} > '
+ /scripts/cli : __rvm_parse_args() 790 > [[ -z '' ]]
+ /scripts/cli : __rvm_parse_args() 790 > [[ -n '' ]]
+ /scripts/cli : __rvm_parse_args() 792 > [[ 0 -eq 1 ]]
+ /scripts/cli : __rvm_parse_args() 792 > [[ -n '' ]]
+ /scripts/cli : __rvm_parse_args() 13 > [[ -n rvmrc ]]
+ /scripts/cli : __rvm_parse_args() 15 > rvm_token=rvmrc