This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH params AS ( | |
-- Parameters for down stream queries | |
SELECT | |
15 AS bucket_count, | |
80 AS max_bars | |
), | |
numbers AS ( | |
-- Change this query to select real data. | |
-- For now we make random set of numbers. | |
SELECT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'tk' | |
# set up fake data | |
data = ('a'..'z').map do |i| | |
('a'..'z').map {|j| i + j} | |
end | |
headings = data.shift | |
root = TkRoot.new { title 'TREE' } | |
root.minsize = [400, 300] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'tempfile' | |
Pry::Commands.create_command 'golumn', keep_retval: true, use_shellwords: false do |text| | |
description 'Send SQL or scope to `psql` and then to `golumn`: golumn Model.all' | |
banner <<-BANNER | |
Usage: golumn [SQL or Ruby which evaluates to String or a Rails Model] | |
Saves SQL to Dir.tmpdir/pry-psql.sql with adds basic formatting. | |
Then sends statemnet to `psql` or Rails determined system command. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1) Listen for data on 65000 | |
nc -vv -kl 65000 | |
# 2) In a new [session|tab|window|split], connect to `example.server` forwarding 65001 back to clients 65000 | |
ssh -R 65001:localhost:65000 example.server | |
# 3) Within 2's `ssh` session, send data to the client | |
ls -al | nc localhost 65001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import sys | |
from tempfile import SpooledTemporaryFile | |
try: | |
with SpooledTemporaryFile() as temp: | |
temp.write(sys.stdin.read()) | |
logging.debug("tell: %i" % temp.tell()) | |
if temp.tell() > 0: | |
temp.seek(0) | |
# do something with the data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tee /usr/local/bin/griddy <<-EOF | |
#!/bin/bash | |
cat /dev/stdin > /tmp/griddy.csv | |
open -a Griddy.app /tmp/griddy.csv | |
EOF | |
chmod +x /usr/local/bin/griddy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# open results in golumn | |
psql -Ac 'select * from pg_tables' | golumn --title pg_tables |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2 | |
""" | |
Requirements: | |
brew install wxMac | |
brew install pip | |
pip install wxPython | |
Usage: | |
pop.py https://www.gdax.com/trade/BTC-USD | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StreamZipController < ApplicationController | |
include ActionController::Live | |
# list of interesting file paths to include in the zip. | |
def paths | |
[] | |
end | |
def send_message | |
response.headers['Content-Type'] = 'text/event-stream' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE __test AS | |
SELECT *, | |
CURRENT_TIMESTAMP | |
FROM generate_series(0, 100); | |
SELECT * FROM __test; | |
UPDATE __test SET now = COALESCE(NULLIF('' || pg_sleep(0.01), '')::timestamp, clock_timestamp()); | |
SELECT * FROM __test; |