Skip to content

Instantly share code, notes, and snippets.

@fritzy
fritzy / json_pagination.sql
Last active November 27, 2020 11:22
Getting JSON paginated results of a table SELECT
SELECT json_build_object(
'total', (SELECT n_live_tup FROM pg_stat_user_tables WHERE relname='sometable'),
'count', count(sometable_rows.*),
'offset', 0,
'results', json_agg(row_to_json(sometable_rows))
)
FROM (SELECT * FROM sometable
ORDER BY "time"
LIMIT 10 OFFSET 0)
sometable_rows;
@acolyer
acolyer / service-checklist.md
Last active June 20, 2024 08:47
Internet Scale Services Checklist

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?
@jeffkole
jeffkole / gist:4047435
Created November 9, 2012 18:41
Avro IO with different reader and writer schemas
WRITER_SCHEMA = <<-JSON
{ "type": "record",
"name": "User",
"fields" : [
{"name": "username", "type": "string"},
{"name": "age", "type": "int"},
{"name": "verified", "type": "boolean", "default": "false"}
]}
JSON
@myobie
myobie / mountain-lion-brew-setup.markdown
Created February 18, 2012 20:14
Get Mountain Lion and Homebrew to Be Happy

Get Mountain Lion and Homebrew to Be Happy

1) Install XCode 4.4 into /Applications

Get it from the App Store.

2) Install Command Line Tools

In XCode's Preferences > Downloads you can install command line tools.