Skip to content

Instantly share code, notes, and snippets.

View julianpistorius's full-sized avatar

Julian Pistorius julianpistorius

View GitHub Profile

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

Docker In Production

There was once an oral surgeon named Lytle S. Adams. He lived a long time ago, when America was fighting a war against Japan. Japan had attacked a military base in Hawaii, and—the day that happened—Adams was on vacation at Carlsbad Caverns. That’s a system of caves in New Mexico, where thousands and thousands of bats live. Adams was very impressed with the bats, and he came up with an idea: a swarm of weaponized bats, with miniature incendiary bombs strapped to their bodies—bats that would be dropped over Japanese cities to streak through the air, scatter far and wide, and then explode, sparking thousands of little fires all over the place, burning down buildings and frightening everyone.

Adams was friendly with Eleanor Roosevelt, the president’s wife, and he used his connections to send a brief to the president; the president gave it to a military commander with a note that said, ‘This man is not a nut.’ And so, by 1943, there was a top secret bat-bomb project up a

@julianpistorius
julianpistorius / Event-stream based GraphQL subscriptions.md
Created June 15, 2017 21:16 — forked from OlegIlyenko/Event-stream based GraphQL subscriptions.md
Event-stream based GraphQL subscriptions for real-time updates

In this gist I would like to describe an idea for GraphQL subscriptions. It was inspired by conversations about subscriptions in the GraphQL slack channel and different GH issues, like #89 and #411.

Conceptual Model

At the moment GraphQL allows 2 types of queries:

  • query
  • mutation

Reference implementation also adds the third type: subscription. It does not have any semantics yet, so here I would like to propose one possible semantics interpretation and the reasoning behind it.

@julianpistorius
julianpistorius / Event-stream based GraphQL subscriptions.md
Created June 15, 2017 21:16 — forked from OlegIlyenko/Event-stream based GraphQL subscriptions.md
Event-stream based GraphQL subscriptions for real-time updates

In this gist I would like to describe an idea for GraphQL subscriptions. It was inspired by conversations about subscriptions in the GraphQL slack channel and different GH issues, like #89 and #411.

Conceptual Model

At the moment GraphQL allows 2 types of queries:

  • query
  • mutation

Reference implementation also adds the third type: subscription. It does not have any semantics yet, so here I would like to propose one possible semantics interpretation and the reasoning behind it.

import React from 'react';
import { connect } from 'react-redux';
import { push, replace } from 'redux-router';
export function requireLoggedIn(Component) {
// a wrapper that requires a user be logged in. You can decide what 'logged in' means - in this example,
// a user is considered to be logged in if usersStore.meta.self !== null
class AuthComponent extends React.Component {
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@julianpistorius
julianpistorius / k8s-pi.md
Created January 26, 2018 19:08 — forked from alexellis/k8s-pi.md
K8s on Raspbian

K8s on (vanilla) Raspbian Lite

Yes - you can create a Kubernetes cluster with Raspberry Pis with the default operating system Raspbian. Carry on using all the tools and packages you're used to with the officially-supported OS.

Pre-reqs:

  • You must use an RPi2 or 3 for Kubernetes
  • I'm assuming you're using wired ethernet (Wi-Fi also works)

Master node setup

So, as I mentioned last time, I have two fundamental goals with dat that are not addressed by simply running dat share.

  • Uptime: making sure that the site is seeded even if my local laptop is closed, eaten by a bear, or disconnected from the internet
  • Resilience: ensuring that there's a way to restart my website if the original seeding computer is lost. I try to make everything on my primary work/personal computer work in such a way that I can recover it all, easily, onto a new machine if I need to

To break these down a bit more, uptime is a combination of two things:

  • Ensuring that there are seeders
  • Ensuring that those seeders are seeding, and they're up-to-date
@julianpistorius
julianpistorius / Containerfile
Created May 4, 2018 23:22 — forked from max-mapper/Containerfile
CALeDNA container (build with npm i mkcontainer -g)
ENV NSPAWN_BOOTSTRAP_IMAGE_SIZE=10GB
FROM ubuntu:xenial
# set unlimited bash history
# nspawn needs resolv.conf to be set up for internet to work
# password gets changed so we can login later
RUN mkdir /usr/local/anacapa && \
cd /usr/local/anacapa && \
echo "export HISTFILESIZE=" >> .bashrc && \
echo "export HISTSIZE=" >> .bashrc && \
@julianpistorius
julianpistorius / saas_metrics.sql
Created June 21, 2019 16:46 — forked from arikfr/saas_metrics.sql
SaaS Metrics Query
/*
Explanation of what's going on in this query can be found in this blog post: https://blog.redash.io/sql-query-to-calculate-saas-metrics-dd25d72a0521.
*/
WITH v_charges AS (
SELECT org_id,
date_trunc('month', start_date) AS month,
coalesce((extra::json->>'amount')::float, (extra::json->>'charged_amount')::integer/100) as total
FROM charges
WHERE extra::json->>'months' = '1'