Skip to content

Instantly share code, notes, and snippets.

View tintoy's full-sized avatar

Adam Friedman tintoy

View GitHub Profile
class ApiBase {
const _configurationService;
constructor(configurationService) {
this._configurationService = configurationService;
}
callApi(action: (baseUrl: String) => TResult) : Promise<TResult> {
return new Promise<TResult>((succeeded, failed) => {
this._configurationService.getConfig("Foo")
@tintoy
tintoy / hocon-with-replacements.conf
Created December 24, 2015 09:24
Ok, this is overkill, but HOCON substitutions are nice.
akka {
loggers = [
"akka.event.slf4j.Slf4jLogger"
]
loglevel = warning
actor {
provider = "akka.cluster.ClusterActorRefProvider"
}
log-dead-letters = 5
log-dead-letters-during-shutdown = off
@tintoy
tintoy / guess.exs
Last active January 10, 2016 01:16
Quick-and-dirty guess the number implementation in Elixir
defmodule Guess do
@moduledoc """
Number guessing game module.
"""
@doc """
Guess the supplied `secret` by recursively bisecting the specified number `range`.
"""
def guess(secret, range = lo..hi) when lo <= hi do
_guess(_mid(range), secret, range)
@tintoy
tintoy / AkkaDeciderChaining.cs
Last active March 3, 2016 00:34
Example of chaining supervision deciders in Akka.NET.
/// <summary>
/// Extension methods for Akka's <see cref="IDecider">decider</see>s.
/// </summary>
public static class DeciderChaining
{
/// <summary>
/// Create a new <see cref="LocalOnlyDecider"/> that first calls the <paramref name="decider"/>, but then calls <paramref name="escalateToDecider"/> if the original <paramref name="decider"/> returns <see cref="Directive.Escalate"/>.
/// </summary>
/// <param name="decider">
/// The original <see cref="IDecider"/>.
@tintoy
tintoy / prototypal-inheritance-demo.js
Last active April 29, 2016 23:42
Quick sketch of JS prototypal inheritance
// A basic prototypal inheritance chain (ignores constructor chaining)
// If you ask for property 'a' on an object created from function 'C', it will check if the object has a property 'a'.
// If not, it will check if C's prototype (an instance of B) has a property 'a'.
// If not, it will check if B's prototype (an instance of A) has a property 'a' (which it will).
function A() { }
A.prototype.a = 'A'
function B(a, b) { }
B.prototype = new A();
@tintoy
tintoy / app.ts
Created May 19, 2016 01:29
TypeScript async demo (NodeJS read-line)
"use strict";
import * as Promise from "bluebird";
import { ReadLine, createInterface } from "readline";
const readLine = createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
});
@tintoy
tintoy / main.go
Last active June 20, 2016 21:50
WinRM from Go using Negotiate authentication
package main
import (
"fmt"
"github.com/masterzen/winrm"
"io"
"net/http"
"os"
"time"
@tintoy
tintoy / diffs-do-not-match.tf
Last active June 21, 2016 00:01
Terraform debug log for "diffs do not match"
resource "template_file" "vm-winrm-bootstrap-public" {
template = <<TMPLT
{
"foo": "bar",
"baz": 3
"tpl": "${greeting}, World"
},
TMPLT
vars {
@tintoy
tintoy / VotingSchema.json
Created July 6, 2016 12:40
Voting Schema
{
"$schema": "http://json-schema.org/schema#",
"title": "Polls API messsages",
"oneOf": [
{ "$ref": "#/definitions/PollCreated" },
{ "$ref": "#/definitions/PollUpdated" },
{ "$ref": "#/definitions/QuestionCreated" },
{ "$ref": "#/definitions/QuestionUpdated" },
{ "$ref": "#/definitions/ChoiceCreated" },
{ "$ref": "#/definitions/ChoiceUpdated" }
@tintoy
tintoy / testharness.py
Last active July 9, 2016 15:01
Logging to Seq from Python 3
#!/usr/bin/env python3
import datetime
import logging
import requests
# Well-known keyword arguments used by the logging system.
_well_known_logger_kwargs = [
"extra",
"exc_info",