Skip to content

Instantly share code, notes, and snippets.

View BenjaminSchaaf's full-sized avatar

Benjamin Schaaf BenjaminSchaaf

View GitHub Profile
@BenjaminSchaaf
BenjaminSchaaf / grant_medals.py
Created January 5, 2018 15:38
Used by ozf to grant players medals after a season has finished
import sys
import requests
GRANT_ITEM_URL = 'http://api.steampowered.com/ITFPromos_440/GrantItem/v0001/'
def main(api_key):
# ======================================================================== #
# Change 'medals/XXXXX' to whatever path to the file containing steam ids
# Change PromoID to the specific promotion id for that
grant_medals('medals/open_1st', 'PromoID', api_key)
@BenjaminSchaaf
BenjaminSchaaf / example.json
Created July 8, 2017 14:41
Example web-platform-tests json results for webvtt
{
"results": [
{
"test": "/webvtt/api/VTTCue/align.html",
"subtests": [
{
"name": "VTTCue.align, script-created cue",
"status": "PASS",
"message": null
},
@BenjaminSchaaf
BenjaminSchaaf / WTF.rb
Created April 19, 2017 10:39
wtf ruby
2.3.3 :004 > URI.parse(URI.escape('http://localhost/[]'))
URI::InvalidURIError: bad URI(is not URI?): http://localhost/[]
from /home/benjamin/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/uri/rfc3986_parser.rb:67:in `split'
from /home/benjamin/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/uri/rfc3986_parser.rb:73:in `parse'
from /home/benjamin/.rvm/rubies/ruby-2.3.3/lib/ruby/2.3.0/uri/common.rb:227:in `parse'
from (irb):4
from /home/benjamin/.rvm/rubies/ruby-2.3.3/bin/irb:11:in `<main>'
<!doctype html>
<title>WebVTT parser test: timings, omitted hours</title>
<link rel="help" href="https://w3c.github.io/webvtt/#file-parsing">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
var t = async_test('timings, omitted hours');
t.step(function(){
var video = document.createElement('video');

5. Parsing

  • 2.2. Unicode Normalization (U+212B != U+00C5 for identifiers)
  • EOF everywhere
  • I've written a spec-equivalent parser in python for vtt file parsing to analyse test coverage
  • style parsing
  • region parsing
  • cue text parsing

6. Rendering

@BenjaminSchaaf
BenjaminSchaaf / an_observation.md
Created September 27, 2016 18:38
Some late night thoughts

An Observation on Science, Religion and the Human Condition

We are the most successful species on earth. We may have made marvellous advances in technology and science, but that all pales in comparison to how good we are at surviving. We have become the dominant species on every major continent. In comparison to everything else we know, we are practically a superspecies. Evolved to build on top of our natural environment, naturally selected for one purpose: survival and reproduction.

Evolution has hardwired us to strive for living as long as possible, such that

@BenjaminSchaaf
BenjaminSchaaf / dependent-types.jam.rb
Last active September 14, 2016 06:14
Possible Syntax for dependent types in Jam
def sqrt(n)
assume n >= 0
return #stuff
end
n = input() as Int
# Type error, n doesn't meet condition: n >= 0
puts(sqrt(n))
mixin template belongsTo(string association, O, fields...) {
static assert(fields.length == getFieldsByUAD!(O, PrimaryKey).length);
private mixin("bool __" ~ association ~ "Cached;");
private mixin("Nullable!O __" ~ association ~ ";");
mixin("@property auto ref " ~ association ~ "() {" ~ q{
import std.conv;
enum cached = "this.__" ~ association ~ "Cached";
@BenjaminSchaaf
BenjaminSchaaf / what.rb
Created December 21, 2015 05:46
Language Quirks
module A
def host
2
end
extend self
end
p A.host #=> 2 (as expected)
module B
@BenjaminSchaaf
BenjaminSchaaf / emitter.py
Created December 17, 2015 09:59
An extract from jam/compiler/llvm/emitter.py, no idea what the commented out lines used to do....
@patch
def Function_emitEntry(self):
#self.llvm_context = State.builder.alloca(self.llvm_closure_type, "context")
self.llvm_context = State.builder.cast(self.llvm_value.getParam(0), llvm.Pointer.new(self.llvm_closure_type, 0), "")
#State.builder.store(context, self.llvm_context)