Skip to content

Instantly share code, notes, and snippets.

create or replace function get_partitions(spec text, conditions text)
returns table (id bigint, partition jsonb)
as
$body$
select j.ord, j.value
from subscriptions_fulfillmentplan plan, jsonb_array_elements(plan.new_segments) segment, jsonb_array_elements(segment->'partitions') with ordinality as j(value,ord)
where plan.spec = spec
and segment->'rule'->>'conditions' = conditions
$body$
language sql;
@classmethod
def group_key(cls, box_shipment: NamedTuple) -> str:
return ",".join(
[
str(box_shipment.club_id),
str(box_shipment.theme_id),
",".join(sorted([str(book_id) for book_id in box_shipment.book_ids])),
str(box_shipment.outgoing_label),
str(box_shipment.sent),
str(box_shipment.box_weight_oz),
@mekhami
mekhami / gist:d996f2a53c470085cab9fc85f2ed1231
Created September 16, 2019 23:04 — forked from pablorecio/gist:7022796
Example TestCase for unit test Django middlewares
from django.test import RequestFactory, TestCase
from myapp.middleware import MyMiddleware
class MyMiddlewareTestCase(TestCase):
def setUp(self):
super(MyMiddlewareTestCase, self).setUp()
self.factory = RequestFactory()
[00:53:55] [Server thread/INFO]: <Twipples> Time to watch stuff rip
[00:53:58] [Server thread/INFO]: Twipples lost connection: Disconnected
[00:53:58] [Server thread/INFO]: Twipples left the game
[01:25:16] [Server thread/WARN]: Can't keep up! Is the server overloaded? Running 2405ms or 48 ticks behind
[01:44:04] [Server thread/WARN]: Can't keep up! Is the server overloaded? Running 2684ms or 53 ticks behind
[02:48:13] [Server thread/WARN]: Can't keep up! Is the server overloaded? Running 2238ms or 44 ticks behind
[04:06:12] [Server thread/WARN]: Can't keep up! Is the server overloaded? Running 2101ms or 42 ticks behind
[04:13:52] [Server thread/INFO]: Mekhami has made the advancement [Local Brewery]
[04:34:11] [Server thread/WARN]: Can't keep up! Is the server overloaded? Running 2686ms or 53 ticks behind
[04:36:50] [Server thread/WARN]: Can't keep up! Is the server overloaded? Running 2646ms or 52 ticks behind
def parse_range(years):
years = years.split(', ')
years = [split_years(year.strip()) for year in years if split_years(year)]
years = flatten(years)
return [x for x in sorted(set(years)) if in_valid_years(x)]
def in_valid_years(year):
return 1999 <= year <= 2018
@mekhami
mekhami / index.js
Last active November 1, 2018 18:21
const findNode = (id, group) => {
let stack = new Array(group)
while (stack.length) {
let node = stack.pop()
if (node.id === id) { return node }
else if (node.children && node.children.length) {
node.children.forEach(child => stack.push(child))
}
}
const findNode = (id, current) => {
if (id === current.id) {
return current
} else {
if (current.children) {
current.children.forEach(child => {
return findNode(id, child)
})
}
}
return this.variables.reduce((obj, current) => {
obj[current.field] = current.value
return obj
})
<graphql-query :query="query">
<template slot-scope="{ items: samples }">
<sample-table :samples="samples"></sample-table>
<infinite-loading
ref="infiniteLoading"
v-if="samplesLoaded"
@infinite="infiniteHandler"
spinner="waveDots"
>
<span slot="no-more"><!-- empty --></span>
Thermopylae [Semi-Vanilla] [SMP] {Whitelist} {USA} {21+}
Thermopylae is just another survival Minecraft world, relatively new and unexplored. There are a couple of us who play regularly and a couple who only play a few hours a week, and we're looking for active players to build fun stuff with, share our creations, and take on big projects together.
We have a discord server for good times. Nothing crazy.
Adults only; sorry, guys, but horses for courses.
# Rules