Skip to content

Instantly share code, notes, and snippets.

View dannypage's full-sized avatar
https://danny.page

Danny Page dannypage

https://danny.page
View GitHub Profile
@jackrugile
jackrugile / calc.js
Last active January 8, 2019 15:38
Some common calculation helpers I use in a lot of my demos and games.
class Calc {
/*
------------------------------------------
| rand:float - returns random float
|
| min:number - minimum value
| max:number - maximum value
|
| Get a random float between two values
@joepie91
joepie91 / blockchain.md
Last active June 25, 2023 08:40
Is my blockchain a blockchain?

Your blockchain must have all of the following properties:

  • It's a merkle tree, or a construct with equivalent properties.
  • There is no single point of trust or authority; nodes are operated by different parties.
  • Multiple 'forks' of the blockchain may exist - that is, nodes may disagree on what the full sequence of blocks looks like.
  • In the case of such a fork, there must exist a deterministic consensus algorithm of some sort to decide what the "real" blockchain looks like (ie. which fork is "correct").
  • The consensus algorithm must be executable with only the information contained in the blockchain (or its forks), and no external input (eg. no decisionmaking from a centralized 'trust node').

If your blockchain is missing any of the above properties, it is not a blockchain, it is just a ledger.

@Enkerli
Enkerli / spi-ctl-bpf.rb
Last active September 15, 2023 02:27
A Sonic Pi script (spi-ctl-bpf.rb) and a Processing one (spi_ctl_bpf.pde) to control a band pass filter using the mouse. Been having performance issues with the sound lagging behind. Setting `set_sched_ahead_time!` in Sonic Pi sounds like it helps, but not enough. Original code from Robin Newman: https://gist.github.com/rbnpi/ca5e80258c0c1296b1c…
set_sched_ahead_time! 0 # Setting that one to a negative value makes Sonic Pi complain, it sounds like.
with_fx :bpf do |s| # Setting up the fx to be controlled internally
synth :square, note: 32,release: 400 # Long release as the control will affect a single note
live_loop :ctl do # The loop is inside the fx as this is where the action will be.
ctl=sync "/ctl" # The OSC message which Processing sends, based on mouse coordinates.
rz=ctl[:args][0] # Assigning the first argument to resonance.
ct=ctl[:args][1] # Assigning the second argument to centre.
control s, res: rz, centre: ct # The actual control of the fx.
set_sched_ahead_time! -2 # Sounds like setting this again every time actually helps.
@AlexandreRangel
AlexandreRangel / concrete-v03.rb
Created October 9, 2016 23:20
Sonic Pi music code
# Alexandre rANGEL www.quasecinema.org
# born out of concrete v03
# 9/Oct/2016
# Sonic Pi 2.11 dev
use_bpm 120
live_loop :notes1 do
with_bpm 240 do
x = tick
@matt-bernhardt
matt-bernhardt / ppg_2011-2015.csv
Created July 10, 2016 15:27
Points Per Game after every round of MLS play, from 2011 - 2015
We can make this file beautiful and searchable if this error is corrected: It looks like row 6 should actually have 40 columns, instead of 36 in line 5.
ID,Season,Team,Playoffs,Position,TeamID,G1,G2,G3,G4,G5,G6,G7,G8,G9,G10,G11,G12,G13,G14,G15,G16,G17,G18,G19,G20,G21,G22,G23,G24,G25,G26,G27,G28,G29,G30,G31,G32,G33,G34
1,2011,Columbus,Yes,4,11,0,0.5,1.33,1.25,1.6,1.5,1.71,1.63,1.44,1.3,1.27,1.25,1.38,1.29,1.4,1.5,1.41,1.5,1.47,1.4,1.48,1.55,1.48,1.54,1.6,1.54,1.48,1.46,1.41,1.37,1.32,1.38,1.42,1.38
2,2011,DC,No,7,12,3,1.5,1,1,1.4,1.17,1,1.25,1.22,1.2,1.36,1.33,1.23,1.21,1.2,1.19,1.29,1.28,1.21,1.3,1.29,1.36,1.35,1.29,1.36,1.31,1.3,1.36,1.31,1.27,1.23,1.19,1.18,1.15
3,2011,Chicago,No,6,13,1,2,1.33,1,0.8,0.83,0.86,0.88,0.89,0.8,0.82,0.83,0.85,1,1,1,1,1,0.95,0.9,0.9,0.86,0.87,0.88,0.96,1.04,1,1.07,1.14,1.2,1.19,1.16,1.21,1.26
4,2011,Colorado,Yes,5,14,3,3,3,2.25,1.8,1.5,1.43,1.63,1.56,1.5,1.45,1.42,1.38,1.36,1.47,1.38,1.29,1.28,1.26,1.35,1.29,1.36,1.35,1.42,1.48,1.54,1.52,1.46,1.41,1.37,1.35,1.41,1.39,1.44
5,2011,New England,No,9,15,1,2,1.67,1.5,1.2,1,1.29,1.13,1.11,1.3,1.18,1.08,1,0.93,0.93,0.94,0.88,0.89,0.84,0.95,0.95,0.95,0.91,0.88,0.88,0.88,0.89,0.96,0.93,0.9
@tangotiger
tangotiger / parseSchedule.py
Last active June 20, 2017 23:49
NHL Schedule: JSON to csv/html
import json
print("Parse start")
# http://live.nhl.com/GameData/SeasonSchedule-20152016.json
sourcefile = "C:/Users/TOM/DataNHL/original/SeasonSchedule.json"
targetfile = "C:/Users/TOM/DataNHL/final/parsed_SeasonSchedule.csv"
htmltargetfile = "C:/Users/TOM/DataNHL/final/parsed_SeasonSchedule.htm"
header_row='NHL_GAME_ID' \
@dariusk
dariusk / index.js
Created February 20, 2016 19:28
@TinyAssistant
var Twit = require('twit');
var T = new Twit(require('./config.js'));
var wordfilter = require('wordfilter');
var ent = require('ent');
var readability = require('readability-api');
readability.configure({
consumer_key: 'CONSUMER_KEY',
consumer_secret: 'CONSUMER_SECRET'
});
# The packages we'll be using
packages <- c("rvest","dplyr","tidyr","pipeR","ggplot2","stringr","data.table")
# From those packages, which ones are not yet installed?
newPackages <- packages[!(packages %in% as.character(installed.packages()[,"Package"]))]
# If any weren't already installed, install them now
if(length(newPackages)) install.packages(newPackages)
# Now make sure all necessary packages are loaded
@matt-bernhardt
matt-bernhardt / 070831_mls_salaries.csv
Last active January 27, 2016 04:41
Files describing salary expenditures in Major League Soccer from 2007 through 2015. See more at
Club Last Name First Name Pos Base Salary Compensation
CHI Armas Chris M $225,000.00 $225,000.00
CHI Banner Michael M $12,900.00 $12,900.00
CHI Barrett Chad F $41,212.50 $48,712.50
CHI Blanco Cuauhtemoc F $2,492,316.00 $2,666,778.00
CHI Brown C.J. D $106,391.00 $106,391.00
CHI Busch Jon GK $58,008.00 $58,008.00
CHI Carr Calen F $38,000.00 $50,500.00
CHI Conde Wilman D $144,000.00 $151,500.00
CHI Correa Thiago M $44,100.00 $44,100.00
@blacktm
blacktm / install_ruby_rpi.sh
Last active November 28, 2024 20:35
A Bash script to install Ruby on the Raspberry Pi
#!/bin/bash
# --------------------------------------------------------------------------------------------
# Installs Ruby using rbenv/ruby-build on the Raspberry Pi (Raspbian)
#
# Run from the web:
# bash <(curl -s https://gist.githubusercontent.com/blacktm/8302741/raw/install_ruby_rpi.sh)
# --------------------------------------------------------------------------------------------
# Set the Ruby version you want to install