time cat /tmp/lines_5m.csv > /dev/null
# => 0.01s user 0.26s system 99% cpu 0.277 total
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
use std::io::{self, BufRead, BufReader, BufWriter, Write}; | |
static READ_BUF_SIZE : usize = 1024 * 1024; | |
fn main() { | |
let mut reader = BufReader::with_capacity(READ_BUF_SIZE, io::stdin()); | |
let mut writer = BufWriter::new(io::stdout()); | |
let mut buffer = vec![]; | |
while reader.read_until(b'\n', &mut buffer).unwrap() > 0 { |
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
extern crate rand; | |
use std::io; | |
use rand::Rng; | |
use std::cmp::Ordering; | |
/// Thanks: https://doc.rust-lang.org/book/first-edition/guessing-game.html | |
fn main() { | |
println!("Guess the number!"); |
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
extern crate rand; | |
use std::io; | |
use rand::Rng; | |
use std::cmp::Ordering; | |
fn main() { | |
println!("Guess the number!"); | |
let secret_number = rand::thread_rng().gen_range(1, 101); |
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
FROM postgres:9.3-alpine | |
# Build scratch.sql by running: | |
# $ pg_dump --no-owner --no-acl scratch > scratch.sql.gz | |
COPY scratch.sql /docker-entrypoint-initdb.d/ |
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
<!DOCTYPE html> | |
<html lang="en" manifest="/manifest.appcache"> | |
<head> | |
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]--> | |
<meta charset="UTF-8"> | |
<!-- Meta SEO --> | |
<title>Web App</title> | |
<meta name="author" content="author"> | |
<meta name="description" content="Description"> | |
<!-- RWD --> |
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 ruby | |
require 'open3' | |
# # Dependencies | |
# `sqlformat` and `pygmentize` are Python programs :/ | |
# make sure it's installed and available in your path. | |
# ``` | |
# $ pip install --upgrade sqlparse | |
# $ pip install --upgrade pygment | |
# $ export PATH=$PATH:~/Library/Python/3.5/bin |
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 ruby | |
class GdaxTicker | |
attr_accessor :writer, :stats | |
attr_reader :socket, :feed_url | |
DEFAULT_WS_URL = 'wss://ws-feed.gdax.com' | |
PUBLISH_CHANNEL = 'altalarms:datum' |
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
SELECT | |
t1.*, | |
(start_date, end_date) overlaps (range_start, range_end) as overlaps_func, | |
(start_date <= range_end) AND (end_date >= range_start) as overlap_bool | |
FROM generate_series('2016-12-01'::date, '2017-03-10'::date, '1 day'::interval) as gs(date) | |
JOIN LATERAL ( | |
SELECT | |
'2017-01-01'::date start_date, | |
'2017-01-15'::date end_date, | |
(gs.date::date - '30 day'::interval)::date range_start, |
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
# export source data to file | |
psql anon -c "copy (SELECT * FROM assets WHERE color='red') to stdout csv header" > assets.csv | |
# create new database instance (without password) | |
docker run --name postgres-9.6 -e POSTGRES_PASSWORD='' -d -p 65436:5432 postgres:9.6 | |
# copy table screma | |
pg_dump --schema-only --table=assets anon > schema.sql | |
# might need to remove foreign keys |