Skip to content

Instantly share code, notes, and snippets.

View ssadler's full-sized avatar
🤍

Scott Sadler ssadler

🤍
  • utxocontracts.com
  • London, UK
View GitHub Profile
@ssadler
ssadler / test_unspents.py
Created April 21, 2017 11:55
Quick benchmark of time to get unspent transactions
import sys
from bigchaindb.core import Bigchain
from bigchaindb.models import Transaction, Block
from bigchaindb.common.crypto import generate_key_pair
import time
test_size = int(sys.argv[1])
I hereby authorise the spending of output #1 in the following transaction.
{
"asset": {
"id": "e7bf69060ec9c9f814f82455166717044dc8c42decb246144c6825faad59c219"
},
"id": "280a0ba9208298c6e3c76e4b6c3ea5d40bf28a03de4e4a7279ad0d1eb26fde32",
"inputs": [
{
"fulfillment": null,
"fulfills": {
@ssadler
ssadler / all.js
Created January 9, 2017 12:19
ghcjs ccjs minifaction fails
This file has been truncated, but you can view the full file.
var h$currentThread = null;
var h$stack = null;
var h$sp = 0;
var h$initStatic = [];
var h$staticThunks = {};
var h$staticThunksArr = [];
var h$regs = [];
var h$r1 = 0;
var h$r2 = 0;
var h$r3 = 0;
@ssadler
ssadler / object.js
Created January 25, 2016 22:43
purescript export class
"use strict";
// I would like to export a class from Purescript like below.
class MyObjectFromPurescript {
constructor(n) {
this.n = n
}
getN() {
return this.n;
@ssadler
ssadler / wat.js
Last active August 29, 2015 14:06
var nodes = document.querySelectorAll(".js-setLabelWidth");
var elementWidths = [];
var widths = nodes.map(function(node) {
var width = getComputedStyle(node)["width"];
return parseInt(width, 10);
});
var maxWidth = (widths.reduce(Math.max, 0) + 1) / 16;
myReadPixels:: Int -> Int -> Int -> Int -> IO [Pixel]
myReadPixels x y w h = do
let arraySize = w * h * 4
array <- mallocForeignPtrArray arraySize :: IO (ForeignPtr Word8)
let pos = Position (fromIntegral x) (fromIntegral y)
withForeignPtr array $ \ptr -> do
-- fromIntegral is needed because Position and Size store GLints not Ints
readPixels pos
(Size (fromIntegral w) (fromIntegral h))
(PixelData RGBA UnsignedByte ptr)
{
"Bed Capacity": {
"Kidney Dialysis": "7",
"ICCU": "0",
"Gynecology": "0",
"Cardiology": "45",
"Hematology": "14",
"PICU": "4",
"Chemotherapy": "0",
"ICU": "0",
{"Bed Capacity":{"Kidney Dialysis":"0","ICCU":"0","Gynecology":"2","Cardiology":"2","Hematology":"0","PICU":"0","Chemotherapy":"0","ICU":"4","Radiotherapy":"0","Neonatal":"4","Urology":"5","Pediatric":"0","Surgery":"35","Burns":"0","Internal Medicine":"16","Nephrology":"2","Operation Rooms":"3","Ophthalmology":"0","Chest":"0","ENT":"0","Total Beds":"79","Orthopedic":"5","Maternity":"4","Psychiatric":"0","Oncology":"0","Day Care":"0","IMU":"0"},"Activity Statistics in 2007":{"Occupancy Days/ Patient":"4","Infant Mortality":"0","Discharges":"3996","Out Patient Visits":"27238","Total Mortality":"0","Admissions":"4022","Hospitalization Days":"15003","Car Accident":"0","Emergency Room Visits":"1018","C- Section":"0","Normal Delivery":"1","Work Accident":"0","Major Operations":"476","Still Birth":"0","Bed Occupancy Rate":"1","Minor Operations":"2396","Maternal Mortality":"0"},"Human Resources":{"X-Ray Technician":"3","Specialized Doctor":"10","Dentists":"0","Physiotherapiests":"3","Administrative workers":"38","Gen
import Control.Applicative
import Control.Monad
import Data.Aeson
import Data.Maybe
import qualified Data.ByteString.Lazy.Char8 as LC8
import qualified Data.Map as Map
import Network.HTTP.Conduit
import Text.XML.HXT.XPath.Arrows (getXPathTrees)
import Text.XML.HXT.Core
module Actors where
import Control.Concurrent.MVar
import Control.Concurrent (forkIO)
import Control.Monad (forever, replicateM)
type PoolQuery a b = a -> IO b
type PoolActor a = MVar (PoolQuery a ())