Skip to content

Instantly share code, notes, and snippets.

View richardartoul's full-sized avatar

Richard Artoul richardartoul

View GitHub Profile
@richardartoul
richardartoul / goroutine_pool.go
Created July 24, 2023 14:15
A simple Goroutine pool for amortizing stack growth overhead
package pool
import (
"fmt"
"sync"
"runtime"
)
// GoroutinePool pools Goroutines to avoid performance penalties associated with spawning many
// short-lived goroutines that each have to individually grow their stack.
@richardartoul
richardartoul / server.js
Created December 4, 2018 23:38
NodeJS Observability demo
const prometheus = require('prom-client');
const winston = require('winston');
const express = require('express');
const app = express();
const port = 3000;
const logTransports = {
console: new winston.transports.Console({ level: 'info' }),
// Could also configure logging to a file at a different level here.
@richardartoul
richardartoul / schema.go
Created March 30, 2018 21:09
M3DB Msgpack forwards/backwards compatibility schema.go
// Copyright (c) 2016 Uber Technologies, Inc
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
@richardartoul
richardartoul / truffle.js
Created December 17, 2017 00:15
Truffle Kovan Configuration
module.exports = {
networks: {
kovan: {
host: "localhost",
port: 8545,
network_id: "*",
gas: 4700000
}
}
};
@richardartoul
richardartoul / 1512863228_initial.js
Created December 17, 2017 00:09
Truffle SingleMessage migration script
var SingleMessage = artifacts.require('../contracts/SingleMessage.sol');
module.exports = function(deployer, network, accounts) {
return liveDeploy(deployer, accounts);
};
async function liveDeploy(deployer, accounts) {
const initialMessage = "Hello world!";
const initialPriceInWei = 1;
const maxLength = 200;
@richardartoul
richardartoul / 1_initial_migration.js
Created December 17, 2017 00:05
Truffle initial migration
var Migrations = artifacts.require("./Migrations.sol");
module.exports = function(deployer) {
deployer.deploy(Migrations);
};
@richardartoul
richardartoul / TestSingleMessage.js
Created December 14, 2017 05:37
Example tests for SingleMessage contract
var SingleMessage = artifacts.require("SingleMessage");
contract("SingleMessage", function(accounts) {
const initialMessage = "hello world!";
const initialPrice = 10;
const maxLength = 200;
beforeEach(async function() {
this.contract = await SingleMessage.new(initialMessage, initialPrice, maxLength);
});
@richardartoul
richardartoul / SingleMessage.sol
Created December 14, 2017 00:17
SingleMessage Solidity Contract
contract SingleMessage is Ownable {
string public message;
uint256 public priceInWei;
uint256 public maxLength;
event MessageSet(string message, uint256 priceInWei, uint256 newPriceInWei, address payer);
function SingleMessage(string initialMessage, uint256 initialPriceInWei, uint256 maxLengthArg) public {
message = initialMessage;
priceInWei = initialPriceInWei;
hyperdash_free=> explain analyze SELECT sdk_run_uuid FROM heartbeats WHERE last_seen_at < NOW() - INTERVAL '30 seconds' AND eligible_for_disconnect_scan = true AND run_completed = false LIMIT 10;
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=0.43..2.64 rows=10 width=16) (actual time=191.810..191.810 rows=0 loops=1)
-> Index Scan using heartbeats_last_seen_at_idx on heartbeats (cost=0.43..15066.99 rows=68307 width=16) (actual time=191.809..191.809 rows=0 loops=1)
Index Cond: (last_seen_at < (now() - '00:00:30'::interval))
Planning time: 0.089 ms
Execution time: 191.837 ms
(5 rows)
@richardartoul
richardartoul / public.key
Created December 3, 2017 21:12
kovan faucet sink
0x4e1086e599178104e71a818a28320923402f5743