Skip to content

Instantly share code, notes, and snippets.

View themasch's full-sized avatar

Mark Schmale themasch

View GitHub Profile
var Route = function(config) {
this.path = config.path || ''
var keys = [],
raws = {},
regexp = new RegExp(
this.path.replace(
/{([a-zA-Z0-9_-]+)}/g,
function(full, name) {
raws[name] = full
keys.push(name)
@themasch
themasch / require-selection.sublime-macro
Created May 28, 2014 08:31
Sublime Macro to add a require() for the currently selected variable (pretty dirty)
{
"keys": ["ctrl+alt+r"],
"command": "run_macro_file",
"args": {"file": "Packages/User/require-selection.sublime-macro"}
}
@themasch
themasch / doc.md
Last active December 31, 2024 17:34
unofficial docs of the LoL Spectator API

REST Service for LoL spectators

This is an unofficial, uncomplete and (pretty sure) wrong documentation of the RESTful service which powers the League of Legends spectator mode.

This documentation is desgined to be community driven and should be extended by everyone. If you find things missing, add them please!

How it works

Riot's spectator mode works by requesting replay data via HTTP form a service. The data is split in chunks which usually contain about 30 seconds of gameplay. Additionally there are key frames which seem to contain more information then a single chunk. They seem to be used to support

@themasch
themasch / fast_concat.js
Created December 19, 2013 12:31
faster for me (v0.10.21)
function faster_concat(list)
{
var len = 0;
var listLen = list.length;
var offset = 0;
if(listLen === 1) {
return list[0]
}
for(var i=0;i<listLen;i++) {
mod AMod {
pub enum FunnyEnum {
FirstVariant,
SecondVariant
}
}
mod AnotherMod {
use AMod::FunnyEnum;
@themasch
themasch / limited.js
Last active December 29, 2015 18:39
speed limited stream
var Stream = require('stream')
, util = require('util')
util.inherits(Limited, Stream.Transform)
function Limited( options ) {
if(!(this instanceof Limited)) {
return new Limited( options )
@themasch
themasch / benchmark.js
Last active December 23, 2015 01:09
can someone explain those results?
var log_2 = Math.log(2);
suite('getTagLength', function() {
set('mintime', 1000);
bench('log(x) / log_2', function() {
return ~~(4 - Math.log(0x42 >> 4) / log_2)
})
bench('log(x) / log(2)', function() {
return ~~(4 - Math.log(0x42 >> 4) / Math.log(2))
})
bench('log(x) / 0.69..', function() {
var xml = null, xsl = null;
function transformModern(type) {
return function() {
if(type == 'xml') {
xml = this.responseXML;
} else {
xsl = this.responseXML;
}
if(xml && xsl) {
@themasch
themasch / gitlab
Created August 26, 2013 12:45
gitlab init script for gentoo
#!/sbin/runscript
# GitLab 6.0 init script for Gentoo Linux
# see https://github.com/gitlabhq/gitlabhq/blob/master/doc/installation.md
GITLAB_BASE=/home/git/gitlabhq
GITLAB_USER=git
depend() {
need net
}
% node_modules/matcha/bin/matcha benchmark/*.js
buffer vs string
30,483 op/s ⨠ buffer
16,052 op/s ⨠ string
decode to buffer
29,790 op/s ⨠ bencode
28,577 op/s ⨠ bencoding
26,095 op/s ⨠ dht_bencode