Skip to content

Instantly share code, notes, and snippets.

# References:
# http://blog.mixu.net/2011/08/13/nginx-websockets-ssl-and-socket-io-deployment/
# http://blog.exceliance.fr/2012/09/10/how-to-get-ssl-with-haproxy-getting-rid-of-stunnel-stud-nginx-or-pound/
#
global
nbproc 2
maxconn 16384
defaults
@dstrbad
dstrbad / ati_hdmi.md
Last active August 29, 2015 13:57
Configuring external LCD over HDMI (ATI graphic card) through shell on Debian based system
  • install drivers apt-get install fglrx-updates
  • check output device name using xrandr, in my case HDMI output name is DFP1
  • set external device as master xrandr --output DFP1 --primary
  • (optional) turn off laptop display xrandr --output LVDS --off
  • my screen didn't fill whole external LCD (overscan/underscan), in order to fix that I've used aticonfig
    • positioning screen to upper left corner
    aticonfig --set-dispattrib=DFP1,positionX:0
    aticonfig --set-dispattrib=DFP1,positionY:0
    
@dstrbad
dstrbad / haproxy.cfg
Last active August 29, 2015 13:57 — forked from rnewson/haproxy.cfg
# Bind SSL port with PFS-enabling cipher suite
bind :443 ssl crt path_to_certificate no-tls-tickets ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-RSA-RC4-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES128-SHA:AES256-SHA256:AES256-SHA:RC4-SHA
# Distinguish between secure and insecure requests
acl secure dst_port eq 443
# Mark all cookies as secure if sent over SSL
rsprep ^Set-Cookie:\ (.*) Set-Cookie:\ \1;\ Secure if secure
# Add the HSTS header with a 1 year max-age
#!/usr/bin/env python
import sys, os, time, atexit
from signal import SIGTERM
class Daemon:
"""
A generic daemon class.
Usage: subclass the Daemon class and override the run() method
SELECT 'UNLOAD (\'select * from '||n.nspname ||'.'|| c.relname||'\') TO \'s3://bucket/' || c.relname || '_\';' as "Name"
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r','v','S','')
AND n.nspname LIKE 'nu_alibris';
SELECT 'COPY ' || n.nspname ||'.'|| c.relname ||' from \'s3://bucket/' || c.relname || '_\';' as "Name"
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
SELECT 'drop table '||n.nspname ||'.'|| c.relname||' CASCADE;' as "Name"
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r','v','S','')
AND n.nspname = 'destination_schema';
SELECT 'create table '||n.nspname ||'.'|| c.relname||' as select * from source_schema.' || c.relname||';' as "Name"
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r','v','S','')

Application specific host grouping in Riemann-dash

It is generally desirable to group all the hosts for a specific service into a single dashboard view. For example, all the web servers are in single view while all the database servers are in another view.

This is usually not an issue when you are sending custom metrics using Riemann client. However, there are cases where you are using something that you do not control how the metrics are being sent. i.e., Riemann-tools.

Since Riemann-tools scripts are application agnostic, in order for the dashboard view to group hosts, we must inject some application specific information into the tags field. Tags is a collection of arbitrary strings. In the case of Riemann-tools scripts you can pass in arbitrary strings on the command line.

riemann-health --host 127.0.0.1 --tag "prod" --tag "webserver"

from tastypie import fields
from tastypie.authentication import Authentication
from tastypie.authorization import Authorization
from tastypie.bundle import Bundle
from tastypie.exceptions import NotFound
from tastypie.resources import Resource
# a dummy class representing a row of data
class Row(object):

Keybase proof

I hereby claim:

  • I am dstrbad on github.
  • I am dstrbad (https://keybase.io/dstrbad) on keybase.
  • I have a public key ASA2L1_UMoX-kPGjT5qL2Uq9HepKpype7bczEVLy9MFlCQo

To claim this, I am signing this object:

@dstrbad
dstrbad / jenkins-go.sh
Created November 28, 2016 15:37 — forked from marinbek/jenkins-go.sh
jenkins golang setup
export GOROOT=/usr/local/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH:$WORKSPACE/bin
export GOPATH=$WORKSPACE
git config url."git@github.com:".insteadOf "https://github.com/"
go get github.com/AlekSi/gocov-xml
go get github.com/axw/gocov/gocov
mkdir -p $GOPATH/src/github.com/NextUserSF/