Skip to content

Instantly share code, notes, and snippets.

@bbeck
bbeck / prime-combinations.ipynb
Created February 5, 2023 17:50
Prime Combinatons
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Foreword

In order to get the most out of a post-mortem process it is imperative that it be run as inclusively as possible and in a blameless fashion. Always assume non-malicious intent because often the root cause of problems that happen are people making mistakes. The purpose of a post-mortem is for everyone involved to grow and to learn from each other's mistakes in a safe environment which can't happen if blame is being assigned.

@bbeck
bbeck / cpu.py
Last active January 2, 2020 17:37
Advent of Code 2019 - Multiprocessing based IntCode CPU implementation
#!/usr/bin/env python3
import multiprocessing
class CPU(multiprocessing.Process):
def __init__(self, memory, input=None, output=None):
super(CPU, self).__init__()
self.memory = memory
self.input = input
self.output = output
import collections
import urllib
import sys
sides = [arg.upper() for arg in sys.argv[1:]]
letters = set("".join(sides))
word_list = urllib.urlopen("https://raw.githubusercontent.com/dwyl/english-words/master/words_alpha.txt")
# word_list = open("/usr/share/dict/words")
@bbeck
bbeck / problem.md
Last active January 19, 2018 00:17
Jenkins milestone issue

Pipeline #1

stage("build") {
  echo "in build"
}

stage("deploy to prod") {
  input message: "Deploy to prod?"
 milestone(ordinal: 20, label: "prod")
@bbeck
bbeck / sequence.py
Created March 9, 2016 03:14
Solution to Eleanor's ordered sequence problem
#!/usr/bin/env python
class Node(object):
def __init__(self, value):
self.value = value
self.left = self.right = None
self.first = self.last = self
def __repr__(self):
return "Node(value=%d, first=%d, last=%d)" % (self.value, self.first.value, self.last.value)
@bbeck
bbeck / Bug.java
Last active August 29, 2015 14:00
Jackson bug with polymorphic deserialization involving Guava optional
package com.bazaarvoice.jackson;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.MappingJsonFactory;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.guava.GuavaModule;
@bbeck
bbeck / jenkins-swarm-client
Created October 28, 2013 23:05
jenkins swarm client init.d script for CentOS
#!/bin/bash
#
# Jenkins Swarm Client
#
# chkconfig: 2345 89 9
# description: jenkins-swarm-client
source /etc/rc.d/init.d/functions
@bbeck
bbeck / example
Created May 2, 2013 14:42
Shell front end that enables you to use Gnuplot from a shell pipeline
#!/bin/bash
set -o errexit
set -o nounset
function data() {
# f(x) = x^2 + noise(500)
# g(x) = x^2 + noise(2500)
for i in {1..100}; do
fx=$((i*i + $RANDOM%1000 - 500))
gx=$((i*i + $RANDOM%5000 - 2500))
@bbeck
bbeck / merge.py
Last active August 9, 2016 13:46
k-way merge sort in python
def merge(generators):
r"Perform a k-way merge of the data contained in the generators."
heap = []
# The last known value for a given generator
values = [None for g in generators]
# Initialize the heap with the first value from each generator
for i, g in enumerate(generators):
heapq.heappush(heap, (g.next(), g, i))