Skip to content

Instantly share code, notes, and snippets.

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]
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 'colored'
class RegExAvailableDomains
def initialize(regex, show_output)
@regex = regex
@show_output = show_output
@matching_words = []
@available_domains = []
find
@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) {
@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 / 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 / create-wallet.js
Last active August 29, 2015 14:22
Create a Bitcoin wallet
var bitcoin = require('bitcoinjs-lib');
document.getElementById("generate-wallet").addEventListener("click", function(event) {
var seedString = document.getElementById("brainwallet-seed").value;
seed = bitcoin.crypto.sha256(seedString);
wallet = new bitcoin.Wallet(seed, bitcoin.networks.testnet);
address = wallet.generateAddress();
document.getElementById("wallet-address").innerHTML = address;
var bitstore = require("bitstore");
document.getElementById("generate-bitstore-client").addEventListener("click", function(event) {
var signMessage = function (message, cb) {
var key = wallet.getPrivateKey(0);
var network = bitcoin.networks.testnet;
cb(null, bitcoin.Message.sign(key, message, network).toString('base64'));
};
var dragDrop = require('drag-drop');
dragDrop('#drop', function (files) {
files.forEach(function (droppedFile) {
file = droppedFile;
bitstoreClient.files.put(file, function (err, res) {
var receipt = res.body;
hash_sha1 = receipt.hash_sha1;
hash_btih = receipt.hash_btih;
uri = receipt.uri;
var xhr = require('xhr');
document.getElementById("get-wallet").addEventListener("click", function(event) {
xhr("https://www.blockai.com/chain/testnet/addresses/" + address, function(err, res, body) {
var data = JSON.parse(body);
var balance = data.balance;
document.getElementById("balance").innerHTML = balance;
});