Skip to content

Instantly share code, notes, and snippets.

@kxzk
kxzk / hn_cli.rs
Created January 5, 2018 23:16
Hacker News CLI using PrettyTable
// specifying we'll be using a macro from
// the prettytable crate (ex: row!())
#[macro_use]
extern crate prettytable;
extern crate reqwest;
extern crate select;
use select::document::Document;
use select::predicate::{Class, Name, Predicate};
use prettytable::Table;
@cangoal
cangoal / LargestBSTSubtree.java
Created April 21, 2016 00:32
LeetCode - Largest BST Subtree
// Given a binary tree, find the largest subtree which is a Binary Search Tree (BST), where largest means subtree with largest number of nodes in it.
// Note:
// A subtree must include all of its descendants.
// Here's an example:
// 10
// / \
// 5 15
// / \ \
// 1 8 7
@msoap
msoap / Go vs Perl memory usage.md
Last active April 11, 2018 07:13
Go vs Perl memory usage

Go vs Perl memory usage

{int}->{int} = int:
  lang (keys² q-ty): MB of memory
  Go   (1500²):   66.38 ■■■■■■■■■■■■■■■■■■■■■■■■■■
  Perl (1500²):  131.46 ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■

  Go   (1000²):    40.8 ■■■■■■■■■■■■■■■■

Perl (1000²): 57.65 ■■■■■■■■■■■■■■■■■■■■■■■

@jpbriend
jpbriend / Dockerfile
Created July 28, 2015 13:58
Dockerfile Nginx reverse-proxy with SSL and SPDY support
FROM debian:jessie
MAINTAINER Jean-Philippe Briend <jeanphilippe.briend@gmail.com> (@jpbriend)
ENV NGINX_VERSION 1.9.3
# Install dependency packages
RUN apt-get update && \
apt-get install -y \
curl \
@ggtools
ggtools / create_secrets.sh
Created February 13, 2017 06:54
Docker Secrets & Letsencrypt automation
#!/usr/bin/env bash
LE_ARC_DIR="etc/archive"
SECRETS=$(docker secret ls | tail -n +2 | awk '{print $2}')
find $LE_ARC_DIR -name 'fullchain*.pem' -o -name 'privkey*.pem' | sed "s,$LE_ARC_DIR/,," | while read file
do
base_file=$(basename $file .pem | sed -r 's/[0-9]+$//')
version=$(basename $file .pem | sed -r 's/^.*?([0-9]+)$/\1/')
@osteenbergen
osteenbergen / example.js
Created April 23, 2015 12:08
Laterjs Timezone support with MomentJS Timezone library
// Timezone library
var moment = require("moment-timezone");
// Later
var later = require("later");
// The schedule we would like to support:
var sched = later.parse.text("at 17:00");
// In March CET switches to CEST (daylight saving) so this is a nice example
var timezone = "Europe/Amsterdam";

Intermediate CA Signing with Puppet

Problem statement

Many sites have a requirement to use an enterprise-wide certificate authority. They either have a "real" signing cert that chains to a public root CA or an internal root (usually air-gapped) which only signs issuing CA certificates, one per PKI application.

Puppet does not have a currently supported configuration which fits into this model. The [existing documentation][existing] describes using an "external CA" instead of Puppet's internally generated CA (which is a combined self-signed Root and issuing CA in one), but requires that the user turn off Puppet's issuance code and leaves the whole certificate generation and distribution workflow as an "exercise to the reader".

The procedure in this document describes a supportable configuration which bridges the gap between these two positions: it is possible to use Puppet's internal signing code to issue certificates from an intermediate CA cert which was externally generated and signed. There are a

// ==UserScript==
// @name Grab HB keys
// @namespace org.chloetigre.perso
// @description Grab game keys from a humble bundle page
// @include https://www.humblebundle.com/home/keys
// @version 1
// @grant none
// ==/UserScript==
var hbkeys = {
};
function! UseBookMode()
LivedownPreview
Goyo
IndentLinesDisable
Limelight
g:saving_at_every_edit = 0
call ToggleSaveEveryEdit()
set linebreak
set wrap
nnoremap j gj
@StevenLangbroek
StevenLangbroek / class.js
Last active May 3, 2019 20:05
Private variables in ES6 Classes.
/**
* So, obviously this is by no means a "new trick",
* but encapsulation in classes works the same as
* it does in "Modules" (IIFE pattern): You hide them
* in a scope, and define the methods that need access
* to them within that same scope. The constructor is
* as good a place as any for that.
*/
import _ from 'underscore';