Skip to content

Instantly share code, notes, and snippets.

@bricef
bricef / Instructions.md
Created December 16, 2021 21:44
Universal Paperclip quantum computing helper

Instructions

When playing the game Universal Paperclips copy and paste this code in your browser to automatically trigger the quantum computer button when it would yield a compute benefit.

@bricef
bricef / entropy.ts
Created August 14, 2021 07:51
typescript password entropy
const classes : Array<[RegExp, number]>= [
[ /^[0-9]+$/, 3.322],
[ /^[0-9A-F]+$/, 4.000],
[ /^([A-Z]+|[a-z]+)$/, 4.700],
[ /^([A-Z0-9]+|[a-z0-9]+)$/, 5.170],
[ /^[A-Za-z]+$/, 5.700],
[ /^[A-Za-z0-9]+$/, 5.954],
[ /^[a-z0-9!"#$%&'()*+,.\/:;<=>?@\[\] ^_`{|}~-]*$/i, 6.555],
@bricef
bricef / podinfo.yaml
Created November 13, 2020 02:14
Podinfo deployment manifest
apiVersion: v1
kind: Service
metadata:
name: podinfo
namespace: dev
labels:
app: podinfo
spec:
type: ClusterIP
ports:
@bricef
bricef / __main__.py
Created November 13, 2020 00:03
Basic pulumi digital ocean k8s cluster
import pulumi
import pulumi_digitalocean as do
config = pulumi.Config()
# Define a digital ocean cluster
cluster = do.KubernetesCluster(
"brice-demo-cluster",
node_pool={
"name": "worker-pool",
@bricef
bricef / trace_calls.py
Created January 18, 2020 07:17
Call tracing decorator
class TraceCalls(object):
""" Use as a decorator on functions that should be traced. Several
functions can be decorated - they will all be indented according
to their call depth.
source: https://eli.thegreenplace.net/2012/08/22/easy-tracing-of-nested-function-calls-in-python
"""
def __init__(self, stream=sys.stdout, indent_step=2, show_ret=False):
self.stream = stream
self.indent_step = indent_step
self.show_ret = show_ret
@bricef
bricef / tmp_file_value_context.py
Created January 18, 2020 07:16
Given a value, create a temporary file and make this file available for the duration of the context.
class ValueContext(object):
"""
A ValueContext is constructed from a value that can be writtent to a file
and then exposes the value as a temporary file in its context.
The temporary file path can be accessed using its `name` attribute.
For example:
@bricef
bricef / merge_mappings.py
Last active December 13, 2019 20:27 — forked from angstwad/dict_merge.py
Recursive dictionary merge in Python
# Recursive dictionary merge
# Copyright (C) 2019 Brice Fernandes <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
B_BLACK="\[\e[40m\]"
B_RED="\[\e[41m\]"
B_GREEN="\[\e[42m\]"
B_YELLOW="\[\e[43m\]"
B_BLUE="\[\e[44m\]"
B_MAGENTA="\[\e[45m\]"
B_CYAN="\[\e[46m\]"
B_WHITE="\[\e[47m\]"
F_BLACK="\[\e[30m\]"
1 - ???
2 - The Matrix
3 - Speed
4 - Leaving Las Vegas
5 - Lalaland
6 - 12 monkeys
7 - π
8 - Dr No
9 - Seven
10 - Home Alone
@bricef
bricef / docker-compose output
Last active February 19, 2018 18:00
Error on following readme instructions
➤ docker-compose -f services/dev.yml up --build
Starting services_api_1 ... done
Starting services_web_1 ... done
Attaching to services_api_1, services_web_1
api_1 |
api_1 | > json-server@ prestart /home
api_1 | > npm install
api_1 |
web_1 |
web_1 | > [email protected] prestart /home