Skip to content

Instantly share code, notes, and snippets.

View lmarburger's full-sized avatar
🥖
Temporally nondeterministic

Larry Marburger lmarburger

🥖
Temporally nondeterministic
View GitHub Profile
@lmarburger
lmarburger / daily-transfer-cost.sql
Created November 14, 2013 13:50
Some queries used with Guardian.
SELECT '$' || round(sum(bytes_sent)::numeric / 1024 / 1024 / 1024 * 0.12, 2) || ' (' || pg_size_pretty(sum(bytes_sent)) || ')' as cost
FROM requests
WHERE
time > current_timestamp - interval '1 day' AND
operation = 'REST.GET.OBJECT' AND
bytes_sent is not null;
@lmarburger
lmarburger / drops_last_modified.rb
Created November 5, 2013 00:51
Memcache boundary class
class DropsLastModified
def self.exists?(user)
Metriks.timer('drops-last-modified.exists').time {
Rails.cache.exist?(user.last_modified_cache_key)
}
end
def self.last_modified(user)
Metriks.timer('drops-last-modified.last_modified').time {
Rails.cache.fetch(user.last_modified_cache_key) do
#!/usr/bin/env ruby
input = "%clipboard"
subs = {
" " => " ",
"a" => "ɐ",
"b" => "q",
"c" => "ɔ",
"d" => "p",
"e" => "ǝ",
// 200 OK
{
"collection": {
"version": "1.0",
"href": "http://cl.ly/",
"links": [
{ "rel": "drops", "href": "https://api.getcloudapp.com/drops" },
{ "rel": "drops-template", "href": "https://api.getcloudapp.com/drops/template" },
{ "rel": "account", "href": "https://api.getcloudapp.com/account" },
{ "rel": "stream", "href": "https://api.getcloudapp.com/drops/stream" }
@lmarburger
lmarburger / log
Created November 1, 2013 00:38
bundler-api slow postgres queries
Oct 31 17:28:01 duration: 2956.023 ms
Oct 31 17:28:03 duration: 5978.428 ms
Oct 31 17:28:04 duration: 6463.118 ms
Oct 31 17:28:06 duration: 8320.839 ms
Oct 31 17:28:06 duration: 8636.274 ms
Oct 31 17:28:06 duration: 8519.324 ms
Oct 31 17:28:06 duration: 8716.902 ms
Oct 31 17:28:06 duration: 8814.047 ms
Oct 31 17:28:06 duration: 8779.041 ms
Oct 31 17:28:06 duration: 8886.432 ms
explain analyze
SELECT rv.name, rv.number, rv.platform, d.requirements, for_dep_name.name dep_name
FROM
(SELECT r.name, v.number, v.platform, v.id AS version_id
FROM rubygems AS r, versions AS v
WHERE v.rubygem_id = r.id
AND v.indexed is true
AND r.name IN ('priceable', 'hitimes', 'rails')) AS rv
LEFT JOIN dependencies AS d ON
d.version_id = rv.version_id
@lmarburger
lmarburger / heterogeneous-collections.md
Last active February 15, 2017 17:32
Heterogeneous Collection+JSON Collections

Heterogeneous Collection+JSON Collections

Account, Plan, and Purchase are independent resources. An Account is your run-of-the-mill account resource. A Plan contains the details of the current paid plan. A Plan may be created by using Apple's In-App Purchase and submitting the receipt with the Plan template. A Purchase contains the details necessary to perform an In-App Purchase in the Mac client.

Clients will likely never need a Plan or Purchase independently from an Account. It's burdensome to request an Account, Plan, and Purchases in order

@lmarburger
lmarburger / api.json
Last active December 26, 2015 13:49
Collection-JSON template link
// root
{
"collection": {
"version": "1.0",
"href": "http://cl.dev/",
"links": [
{ "rel": "drops", "href": "http://api.getcloudapp.dev/drops" },
{ "rel": "drops-template", "href": "http://api.getcloudapp.dev/drops/template" }
]
}
@lmarburger
lmarburger / awesome.md
Last active December 26, 2015 13:49
Playing with assorted Collection+JSON collections.

rel="awesome"

{
  "version": "1.0",
  "href": "http://api.getcloudapp.dev/awesome",
  "items": [

    // Account
    {
@lmarburger
lmarburger / api.md
Last active March 20, 2017 18:29
Experimenting with different Account and Plan representations.

Problem

Account and Plan are independent resources. An Account is your run-of-the-mill account resource. A Plan may be created by using Apple's In-App Purchase and submitting the receipt with the Plan template. Here's the UI

Current Implementation

Account and Plan are separate, linked resources. Clients will likely never