Skip to content

Instantly share code, notes, and snippets.

View RexGibson's full-sized avatar

Rex Gibson RexGibson

  • looker.com
  • Hastings On Hudson, NY
View GitHub Profile
@RexGibson
RexGibson / gist:4627739
Last active December 11, 2015 16:28
WEEK and YEARWEEK SQL Functions with dates to understand how different formats display
SELECT YEARWEEK('2012-1-1', 0) '2012-1-1'
, YEARWEEK('2012-12-30', 0) '2012-12-30'
, YEARWEEK('2012-12-31', 0) '2012-12-31'
, YEARWEEK('2013-1-1', 0) '2013-1-1'
, YEARWEEK('2013-1-5', 0) '2013-1-5'
, YEARWEEK('2013-1-6', 0) '2013-1-6'
, 0 type
UNION
SELECT YEARWEEK('2012-1-1', 1) '2012-1-1'
, YEARWEEK('2012-12-30', 1) '2012-12-30'
@RexGibson
RexGibson / .azkabanrc
Last active December 28, 2015 08:29
Azkaban Python Project File Example
# remove this comment and save file in ~/.azkabanrc
[DEFAULT]
user =
session_id =
[vagrant]
url = https://localhost:8443
user = azkaban
session_id = 3b25ac47-a791-4648-8434-bcbc737e4ba5
@RexGibson
RexGibson / link_numpy_scipy_to_virtual_env.sh
Last active August 29, 2015 14:01
Link Numpy and Scipy to a virtual env
#!/usr/bin/python
import re, urllib, urllib2
class Spreadsheet(object):
def __init__(self, key):
super(Spreadsheet, self).__init__()
self.key = key
class Client(object):
# to install the latest stable version:
brew install scala --with-docs
# to install scala-2.10:
brew install https://raw.github.com/gist/4340744/scala.rb --with-docs
# to switch versions (from https://github.com/mxcl/homebrew/wiki/External-Commands):
brew switch scala 2.9.2
brew switch scala 2.10.0
@RexGibson
RexGibson / custom_table_info.view.lookml
Created March 10, 2015 08:17
Looker Redshift Management Model
- view: custom_table_colmn_info
derived_table:
sql: |
SELECT
a.schemaname
, b.table_name
, b.ordinal_position
, b.column_name
, REPLACE(b.udt_name, 'bpchar', 'char') data_type
, character_maximum_length data_length
CREATE OR REPLACE FUNCTION kaplan_meier(text)
RETURNS TABLE (
time_period int,
pivot text,
exposed int,
events int,
marginal_probability double precision,
cumulative_probability double precision
) AS
$PROC$
@RexGibson
RexGibson / looker_log_jsonify.py
Last active June 15, 2017 15:50 — forked from frank-kutzey/looker_log_jsonify.py
converts looker logs from plain text log to json like format - usefull for importing logs to EBK or ELK
#!/usr/bin/env python
from json import dumps
import sys
while True:
string = sys.stdin.readline()
if not string:
break
@RexGibson
RexGibson / test for looker.lkml
Created October 30, 2017 19:52
test for looker
foo
bar
biz
baff
bang!