Skip to content

Instantly share code, notes, and snippets.

Christoffer Sawicki qerub

Block or report user

Report or block qerub

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
qerub / httpsExchange.ts
Created Dec 18, 2016
[TypeScript] Dependency-free Promise-based Node.js HTTP client
View httpsExchange.ts
// Based on
import * as https from "https";
async function httpsExchange(requestOptions: https.RequestOptions): Promise<string> {
return new Promise<string>((resolve, reject) => {
const request = https.request(requestOptions, (response) => {
if (response.statusCode < 200 || response.statusCode > 299) {
reject(new Error("Non-2xx status code: " + response.statusCode));
qerub / lifx.yaml
Created Jun 25, 2016
First stab at a Swagger/OpenAPI specification for the LIFX API
View lifx.yaml
swagger: "2.0"
title: LIFX HTTP Remote Control API
version: v1
basePath: /v1
- https
qerub / properties.xml
Created Jun 25, 2016
Good starter properties for Java 8 and Maven
View properties.xml
qerub / lifx-http-api.clj
Last active Apr 3, 2016
[Clojure] Interacting with LIFX's HTTP API using schemas
View lifx-http-api.clj
(ns lifx-http-api
(:require [schema.core :as s]
[clj-http.client :as http]))
(def ^:dynamic *base-url* "")
(def ^:dynamic *auth-token* "<get yours at>")
qerub /
Last active Aug 29, 2015
Java 8: The Missing Parts, Chapter 1:
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import static;
import static;
public class Optionals {
qerub / fancy-defn.clj
Last active Aug 29, 2015
[Clojure] fancy-defn: Proof of concept of schema.core/defn augmented with automatically generated clojure.core.typed annotations via circle.schema-typer
View fancy-defn.clj
(ns fancy-defn
(:require [schema.core :as s]
[clojure.core.typed :as t]
[circle.schema-typer :as st]))
;; Schemas created with s/defn end up using this.
(defmethod st/convert schema.core.One [schema]
(assert (= false (:optional? schema))) ;; No support for optional arguments yet.
(st/convert (:schema schema)))
qerub / gist:96104c9844aa399b679e
Created Jul 28, 2014
Integrating Thrift's JSON serializer with Jackson
View gist:96104c9844aa399b679e
class ThriftSerializer extends JsonSerializer<TBase> {
public void serialize(TBase value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
try {
TProtocolFactory f = new TSimpleJSONProtocol.Factory();
String s = new TSerializer(f).toString(value);
catch (TException e) {
throw new IOException(e);
qerub /
Last active Aug 29, 2015
Bash script to exec program in given working directory
# Usage: /app /usr/bin/python
cd $1 && exec "${@:2}"
qerub /
Last active Nov 6, 2016
Useful Docker commands

How to remove dangling/untagged images

docker images -q -f dangling=true | xargs docker rmi

How to remove stopped/exited containers

docker ps -q -f status=exited | xargs docker rm
qerub / lifx-sunrise-simulator.rb
Last active Nov 24, 2018
LIFX Sunrise Simulator
View lifx-sunrise-simulator.rb
require "lifx" #
def calculate_color(i) # 0 <= i <= 1
h = [40 * 2 * i, 40].min # will be 40 (yellow) at i=1/2 and stay there
s = 1.0 - [(i - 0.5) * 2, 0].max # will be 1 until i=1/2 and then go down to 0
b = i
LIFX::Color.hsbk(h, s, b, LIFX::Color::KELVIN_MIN)
duration = 10 * 60 # seconds
You can’t perform that action at this time.