Skip to content

Instantly share code, notes, and snippets.

View kmatt's full-sized avatar
😐

Matt Keranen kmatt

😐
  • SE US
View GitHub Profile

Types of index scans

Indexes

Sequential Scan:

  • Read every row in the table
  • No reading of index. Reading from indexes is also expensive.
————————————————————————————————————————————————————————————————————————————————————————————————————
BBEDIT/TEXTWRANGLER REGULAR EXPRESSION GUIDE MODIFIED 2014-01-13 : 00:12
————————————————————————————————————————————————————————————————————————————————————————————————————
NOTES:
The PCRE engine (Perl Compatible Regular Expressions) is what BBEdit and TextWrangler use.
Items I'm unsure of are marked '# PCRE?'. The list while fairly comprehensive is not complete.
import urlparse
import argparse
import redis
import sys
from multiprocessing import Pool
import signal
def parse_redis_url(s):
url = urlparse.urlparse(s)
if not url.scheme:
@kmatt
kmatt / wer_all.R
Created April 23, 2014 19:27 — forked from glamp/wer_all.R
library(plyr)
find_zones <- function(x) {
x.mean <- mean(x)
x.sd <- sd(x)
boundaries <- seq(-4, 4)
# creates a set of zones for each point in x
zones <- sapply(boundaries, function(i) {
i * rep(x.sd, length(x))
})
WITH btree_index_atts AS (
SELECT nspname, relname, reltuples, relpages, indrelid, relam,
regexp_split_to_table(indkey::text, ' ')::smallint AS attnum,
indexrelid as index_oid
FROM pg_index
JOIN pg_class ON pg_class.oid=pg_index.indexrelid
JOIN pg_namespace ON pg_namespace.oid = pg_class.relnamespace
JOIN pg_am ON pg_class.relam = pg_am.oid
WHERE pg_am.amname = 'btree'
),
@kmatt
kmatt / rrdxml.py
Last active August 29, 2015 14:06 — forked from afternoon/rrdxml.py
#!/usr/bin/env python
"""Export CSV from an RRD XML dump.
Usage: rrdxml.py file.xml rra
Where rra is the 0-based index for the RRA you want to dump.
"""
from csv import writer
from itertools import chain, izip
@kmatt
kmatt / .tmux.conf
Last active August 29, 2015 14:18 — forked from mjswensen/.tmux.conf
set-window-option -g status-left " #S "
set-window-option -g status-left-fg black
set-window-option -g status-left-bg white
set-window-option -g status-right " %H:%M %d-%b-%y "
set-window-option -g status-right-fg black
set-window-option -g status-right-bg white
set-window-option -g window-status-format " #I: #W "
@kmatt
kmatt / columnice.py
Last active August 29, 2015 14:25 — forked from bas080/columnice.py
Easily columize code. Example would be "columnice.py ,". This will columize the text using the comma ',' as the delimeter.
#!/usr/bin/env python
import sys
def matrix( text, seperator_x='\t', seperator_y='\n'):
table = []
rows = text.split( seperator_y )
for index, row in enumerate( rows ):
table.insert( index, row.split( seperator_x ) )
return table
@kmatt
kmatt / send_mail.py
Last active August 29, 2015 14:27 — forked from vjo/send_mail.py
[Python] Send email with embedded image and application attachment
#! /usr/bin/python
import smtplib
from optparse import OptionParser
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
from email.mime.application import MIMEApplication
@kmatt
kmatt / sqlpostgres.vim
Created May 21, 2012 16:09 — forked from chanmix51/sqlpostgres.vim
SQL postgres vim syntax file
" Vim syntax file
" Language: SQL, PGSQL (postgres 9.1)
" Last Change: 2012 May 21st
" Maintainer: Grégoire Hubert <greg DOT hubert AT gmail DOT com>
" Based on the work of Paul Moore <pf_moore AT yahoo.co.uk>
" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
if version < 600
syntax clear