Skip to content

Instantly share code, notes, and snippets.

@williamcotton
williamcotton / ResultWriter.fsx
Last active May 17, 2024 20:32
A ResultWriter Computation Expression in F#
// Define types
type Result<'T> =
| Success of 'T
| Error of string
type LogState = { Logs: string list }
type ResultLog<'T> = Result<'T> * LogState
#ifndef MEMORY_MANAGER_H
#define MEMORY_MANAGER_H
#define HEAP_SIZE (10 * 1024 * 1024)
#include <stdlib.h>
typedef struct memory_manager_malloc_t {
void *ptr;
} memory_manager_malloc_t;
document.getElementById("get-unspents").addEventListener("click", function(event) {
getUnspentOutputs = function(callback) {
xhr("https://www.blockai.com/chain/testnet/addresses/" + address + "/unspents", function(err, res, body) {
var unspentOutputs = JSON.parse(body);
unspentOutputs.forEach(function(utxo) {
utxo.txHash = utxo.hash;
utxo.index = utxo.outputIndex;
});
callback(err, unspentOutputs);
[
"/earth/me/me/kittery-point/03905",
"/earth/me/me",
"/earth/us/me",
"/earth/me/me/kittery",
"/earth/us/me/south-eliot",
"/earth/us/co",
"/earth/us/ca/huntington-beach/92647",
"/earth/us/ca/huntington-beach/92648",
"/earth/us/ca/huntington-beach/92646",
@williamcotton
williamcotton / index.html
Created August 7, 2013 18:11
via:geojson.io
<!DOCTYPE html>
<html>
<head>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
.marker-properties {
border-collapse:collapse;
@williamcotton
williamcotton / black-box.js
Last active December 18, 2015 13:39
RunLoop
RunLoop(document.querySelector("canvas"), function(context, tick) {
context.fillRect(Math.sin(tick/5)*20 + 100, 20, 40, 40);
}).play();
@williamcotton
williamcotton / edge.js
Created December 19, 2012 22:26
edge.js from GEAR
define(['graph_editor/register_core'], function(registerCore) {
var Edge = function(options) {
this._initEdge(options);
};
Edge.prototype = {
_initEdge: function(options) {
require 'colored'
class RegExAvailableDomains
def initialize(regex, show_output)
@regex = regex
@show_output = show_output
@matching_words = []
@available_domains = []
find
def play
`osascript -e 'tell application "iTunes" to play'`
end
def pause
`osascript -e 'tell application "iTunes" to pause'`
end
pause
(1..50).to_a.reverse.each do |n|
require "matrix"
#First, you construct an adjacency matrix. An adjacency matrix is just a matrix of what is linking to what.
#[0, 1, 1, 1, 1, 0, 1]
#[1, 0, 0, 0, 0, 0, 0]
#[1, 1, 0, 0, 0, 0, 0]
#[0, 1, 1, 0, 1, 0, 0]
#[1, 0, 1, 1, 0, 1, 0]
#[1, 0, 0, 0, 1, 0, 0]