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
@dannypage
dannypage / f24.rb
Created October 4, 2012 16:08
Importing Opta F24 XML files - Will add F7 importing soon.
require 'nokogiri'
module Import
class F24
def self.get_xml_doc
print "File Name > "
fname = gets.strip
pn = "#{::Rails.root.to_s}/db/match_data/#{fname}.xml"
puts "Path and File Name: #{pn}"
@dannypage
dannypage / CreateOptaEvents.rb
Created October 5, 2012 01:32
Migrations Needed for OptaRails
class CreateOptaEvents < ActiveRecord::Migration
def change
create_table :opta_events, :id => false do |t|
t.column :opta_game_id, :integer, :null => false
t.column :id, :integer, :primary => true
t.column :event_id, :integer
t.column :type_id, :integer
t.column :period_id, :integer
t.column :timeline, :integer
t.column :min, :integer
@dannypage
dannypage / dot.dot
Created October 9, 2012 20:02
dotdotdot
................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................<3
@dannypage
dannypage / bet.sh
Created May 30, 2013 13:13
Betting
#!/bin/bash
# Retreives and timestamps various XML feeds for later use
cd /Users/danielpage/Documents/BetCharts/
curl http://lines.bookmaker.eu/ > bookmaker-$(date +%Y-%m-%d-%H.%M.%S).xml
curl http://xmlfeed.intertops.com/XMLOddsFeed/IntertopsOdds.aspx > intertops-$(date +%Y-%m-%d-%H.%M.%S).xml
curl http://xml.betclick.com/odds_en.xml > betclick-$(date +%Y-%m-%d-%H.%M.%S).xml
@dannypage
dannypage / pregame.rb
Created December 30, 2013 19:30
Scraping the Pregame betting site for analysis of their results. As they use Divs for their tables, it took some trial and error to find the right fields with Nokogiri. This will create a CSV and covers the 2013 year, although it craps out quickly. Hmm. No records are shown, where I'm pretty sure there were before. Hacked up in a few hours, so t…
#!/usr/bin/env ruby
require 'nokogiri'
require 'open-uri'
require 'net/http'
require 'cgi'
require 'fileutils'
require "date"
begin
### Keybase proof
I hereby claim:
* I am dannypage on github.
* I am dannypage (https://keybase.io/dannypage) on keybase.
* I have a public key whose fingerprint is 6507 FFBB EDDC 57B9 093C 9A64 3B40 998C E000 81BF
To claim this, I am signing this object:
#!/bin/sh
# Simple Twitter backup script
export DAY=`date +'%Y-%m-%d'`
echo "Backing up tweets..."
t timeline @jphpsf --csv --number 3000 > tweets-$DAY.csv
echo "Backing up retweets..."
t retweets --csv --number 3000 > retweets-$DAY.csv
echo "Backing up favorites..."
@dannypage
dannypage / XGsimulation.rb
Last active September 3, 2015 17:21
Team 1 has 3 good shots. Team 2 has 20 bad shots. Both total an xG of 1. Who wins? - Sample result: {:win=>35710, :tie=>31614, :lose=>32676}
#!/bin/ruby
def generate_game(team_1_shots, team_2_shots)
score1 = (team_1_shots.map { |x| if rand < x then 1 else 0 end }).inject(:+)
score2 = (team_2_shots.map { |x| if rand < x then 1 else 0 end }).inject(:+)
return [score1,score2]
end
def evaluate(game)
if game[0] > game[1]
@dannypage
dannypage / mlstransactions.rb
Last active August 29, 2015 14:08
Grab Transactions from MLS. Mostly cleaned, outputs changes so could run on a weekly basis if one chose to...
#!/usr/bin/env ruby
require 'nokogiri'
require 'open-uri'
require 'csv'
require 'diffy'
def clean_up(year, transaction)
transaction = transaction.gsub!(/IN:/,'') || transaction
transaction = transaction.gsub!(/OUT:/,'') || transaction
@dannypage
dannypage / pixel.html
Last active August 29, 2015 14:09
Socialcode Pixel testing.
<html>
<body>
<h2>SC WCA Pixel</h2>
<p>Thanks for your help!</p>
<script>(function() {
var _fbq = window._fbq || (window._fbq = []);
if (!_fbq.loaded) {
var fbds = document.createElement('script');
fbds.async = true;
fbds.src = '//connect.facebook.net/en_US/fbds.js';