Skip to content

Instantly share code, notes, and snippets.

import json
import pathlib
from datetime import datetime
def key(job_id: str, op: str):
return f"{job_id}-{op}"
if __name__ == "__main__":
@laser
laser / vanilla.js
Last active November 4, 2023 04:01
Socket.IO + Vanilla JS
var request = require('request-json'),
express = require('express'),
app = express(),
http = require('http').Server(app),
io = require('socket.io'),
db = require('mongodb').MongoClient;
///////////////////////////////////////////////////////////
// boilerplate code: ignore
//
@laser
laser / 0a.hs
Last active April 13, 2023 14:06
An Introduction to ADTs and Structural Pattern Matching in TypeScript
data Failable t e = Success t | Failure e
@laser
laser / formatter.rb
Last active November 3, 2022 22:29
A Procfile formatting script, written in Ruby
#!/usr/bin/env ruby
require 'optparse'
def get_procfile_lines
STDIN.read.split("\n")
end
def get_process_type_max_width(lines)
processes = []
@laser
laser / interface.idl
Created April 14, 2014 17:29
03: UserService IDL
// services/user_service/interface.idl
struct UserProperties {
email string
full_name string
phone_number string [optional]
}
struct User extends UserProperties {
id int
@laser
laser / runthis.sh
Created March 31, 2020 18:31
start daemon with custom genesis block
#!/usr/bin/env bash
genesis_miner_addr="t01000"
BASEDIR=$(mktemp -d -t "lotus-interopnet.XXXX")
git clone --branch "testnet/3" https://github.com/filecoin-project/lotus.git "${BASEDIR}/build"
mkdir -p "${BASEDIR}/scripts"
mkdir -p "${BASEDIR}/bin"
@laser
laser / movie.md
Last active November 18, 2020 19:02

Movie Ticket Kata

First, head here to join our Zoom meeting. It will help me following along while you work through the assignment.

What Are We Building?

Write a program that calculates purchase price for movie tickets using any language you like. It should not be a full-blown web app; it can be a simple class or collection of methods invokable by your test suite. We'll provide you with some requirements, test-cases, and even a sample interface - all you have to do is give us some software.

Base Admission Rate

@laser
laser / Notes.md
Last active September 20, 2020 07:43
Cousera - Python Notes

Week 4

Constants

  • Cannot change
  • Examples: 1, 9.12, True, or "Foo"

Variables

@laser
laser / filecoin-storage-retrieval-cluster-test.sh
Last active June 26, 2020 16:13
Run Filecoin storage and retrieval flows on a local development network
#!/usr/bin/env bash
# USAGE:
#
# Option 1: Build and run tests using specific lotus Git SHA:
#
# > ./test-storage-and-retrieval-local-dev-net.sh --lotus-git-sha=15b3e57634458af983082dcbb736140bba2abfdb
#
# Option 2: Build and run using binaries you've built previously (much faster)
#
#!/usr/bin/env bash
set -x
public_ip=$(curl -m 5 http://169.254.169.254/latest/meta-data/public-ipv4 || echo "127.0.0.1")
daemon_multiaddr=$(lotus net listen | grep 127 | sed -En "s/127\.0\.0\.1/${public_ip}/p")
miner_multiaddr=$(lotus-storage-miner net listen | grep 127 | sed -En "s/127\.0\.0\.1/${public_ip}/p")
miner_id=$(lotus-storage-miner info | grep Miner | cut -d ' ' -f2)
cd $(mktemp -d)