Skip to content

Instantly share code, notes, and snippets.

View Noxville's full-sized avatar
🎮
esports

Ben Steenhuisen Noxville

🎮
esports
View GitHub Profile
@Noxville
Noxville / HeadToHeadService.groovy
Created July 4, 2014 21:12
Monte Carlo Simulation
package twopee
import grails.transaction.Transactional
@Transactional
class HeadToHeadService {
def eloService
List<Double> headToHead(Team team1, Team team2) {
@Noxville
Noxville / gist:6092d141be552cb13f69
Last active August 29, 2015 14:06
/r/Dota2 Discussion about effect 4 slots for Spirit Bear
import itertools
import operator
def evaluateDps(items):
bat = 1.45
ias = min(4.00, 0.35 + sum(c.ias for c in items)) # ias is capped at 400, AC gives 35% IAS
dmg = 33 + 60 + sum(c.damage for c in items) # 33 is the mean base damage, 60 damage from desolator
aps = (1. + ias) / bat
return dmg * aps
def longestStreak() {
Integer best = 0
Map<String, Integer> currentStreaks = new HashMap<>()
Map<String, Date> startStreaks = new HashMap<>()
Mtch.list().sort { it.matchId }.each { Mtch m ->
def winner = m.winner.trim().toLowerCase() == "radiant" ? m.radiantTeam : m.direTeam
def loser = m.winner.trim().toLowerCase() == "radiant" ? m.direTeam : m.radiantTeam
@Noxville
Noxville / notail_wisp.py
Created January 6, 2015 15:20
Reduction and coversion of csv data to Reddit markdown tables for Notails Wisp.
import datetime
import operator
f = file("notail_wisp.csv", 'r')
m = [e.strip() for e in f.readlines()]
class MonthSummary:
def __init__(self, key, order):
self.key = key
self.order = order
@Noxville
Noxville / HeroService.groovy
Created January 6, 2015 16:10
Hero <-> ID translation
package twopee
import grails.transaction.Transactional
import javax.annotation.PostConstruct
@Transactional
class HeroService {
Map<String, String> lookupMap
@Noxville
Noxville / gist:40b53443a0c3603fa12b
Created February 2, 2015 11:31
SQL Winner Group By Faction, limited by teams Rating.
SELECT m.winner as winner, count(*) as cnt
from mtch m
JOIN elo_team_data_point radiant_elo
ON (m.radiant_team = radiant_elo.team and DATE(m.date) = radiant_elo.elo_date)
JOIN elo_team_data_point dire_elo
ON (m.dire_team = dire_elo.team and DATE(m.date) = dire_elo.elo_date)
WHERE
(radiant_elo.rating > 1200) and
(dire_elo.rating > 1200) and
(m.match_id >= 1098011255) and
@Noxville
Noxville / HeroEloService.groovy
Created February 18, 2015 19:45
Elo Ratings for Heroes
package twopee
import grails.transaction.Transactional
import org.hibernate.Session
import javax.annotation.PostConstruct
import java.text.DateFormat
import java.text.DecimalFormat
import java.text.SimpleDateFormat
@Noxville
Noxville / el_classicos.sql
Created February 19, 2015 16:37
El Classics
SELECT
CASE
WHEN radiant_team < dire_team
THEN radiant_team
ELSE dire_team
END as lhs,
CASE
WHEN radiant_team > dire_team
THEN radiant_team
ELSE dire_team
@Noxville
Noxville / HitboxStream.groovy
Created March 23, 2015 15:03
Stream Interface Example
package streams
import org.codehaus.jackson.JsonNode
class HitboxStream implements Stream {
String getName() {
'Hitbox'
}
1970-01-01 00:00:00,1,0.0,0.49329889739590865
1970-01-01 00:00:00,1,500.0,0.6286283334174981
1970-01-01 00:00:00,1,1000.0,0.7462400571692649
1970-01-01 00:00:00,1,1500.0,0.8159095057788456
1970-01-01 00:00:00,1,2000.0,0.8467042056272068
1970-01-01 00:00:00,1,2500.0,0.8552794447316951
1970-01-01 00:00:00,1,3000.0,0.9174904652047625
1970-01-01 00:00:00,1,3500.0,0.9569027662675057
1970-01-01 00:00:00,1,4000.0,0.974462882425239
1970-01-01 00:00:00,1,4500.0,0.9910090740879556