Skip to content

Instantly share code, notes, and snippets.

View peterellisjones's full-sized avatar

Peter Jones peterellisjones

View GitHub Profile
package main
import "fmt"
func binarySearchRec(elem int, array []int, accesses int) (bool, int) {
accesses += 1
if len(array) == 0 {
return false, accesses
} else if len(array) == 1 {
@peterellisjones
peterellisjones / gist:426ced0eb025e00d0a94
Last active August 29, 2015 14:06
Create random arithmetic operations using numbers between 0 and 20
# returns a random operation that
# result in n. eg:
# randomOperation(20) => [4, '*', 5]
# randomOperation(10) => [20, '/', 2]
class RandomOperationGenerator
def initialize(min = 0, max = 20)
raise "min must be less than max" unless min < max
@min = min
@max = max
end
@peterellisjones
peterellisjones / go.go
Last active August 29, 2015 14:07
Line 19 Compiles with Go 1.3.3
package main
import "fmt"
type poolJSON struct {
Clusters []clusterJSON `json:"clusters"`
}
type clusterJSON struct {
InstanceID string `json:"instance_id"`
@peterellisjones
peterellisjones / gist:288992fcf2e1e70df003
Created January 29, 2015 14:07
Unit testing external library calls in Meteor
# example class / prototype to test on the client
class ClientThing
clientFoo: ->
Meteor.call 'serverFoo', 'bar'
# client-side test
describe 'ClientThing', ->
clientThing = new ClientThing()
describe '#clientFoo', ->
it 'calls serverFoo with "bar"', (test) ->
@Router = React.createClass
mixins: [ReactMeteor.Mixin]
propTypes:
routes: React.PropTypes.arrayOf(
React.PropTypes.shape(
path: React.PropTypes.string.isRequired
render: React.PropTypes.func.isRequired
subscriptions: React.PropTypes.arrayOf(
React.PropTypes.shape(
@peterellisjones
peterellisjones / Wikipedia Edit Data for 30 Dow Jones Companies
Created January 3, 2013 10:01
CSV Data. Each row contains information about an edit on the Wikipedia page for the 30 companies currently (2013-01-03) in the Dow Jones Industrial Average. Up to 5000 edits per company are provided. Each row contains: company name, company symbol, edit date/time, edit size (absolute). eg: McDonald's,MCD,2012-06-26 19:37:00 UTC,988
This file has been truncated, but you can view the full file.
3M,MMM,2012-12-21 11:23:00 UTC,20
3M,MMM,2012-12-21 11:18:00 UTC,35
3M,MMM,2012-12-11 04:42:00 UTC,2
3M,MMM,2012-12-09 10:59:00 UTC,15
3M,MMM,2012-11-08 14:15:00 UTC,15
3M,MMM,2012-11-05 20:35:00 UTC,154
3M,MMM,2012-10-29 11:22:00 UTC,33
3M,MMM,2012-10-24 05:18:00 UTC,4
3M,MMM,2012-10-08 10:26:00 UTC,24
3M,MMM,2012-10-08 10:26:00 UTC,24
{
"HYDROGEN": {
"atomic_number": 1,
"abbreviation": "H",
"atomic_weight": 1.008
},
"HELIUM": {
"atomic_number": 2,
"abbreviation": "He",
"atomic_weight": 4.003
@peterellisjones
peterellisjones / vm_types.yaml
Created February 24, 2017 13:03
GCP custom vm types in terms of AWS vm sizes
vm_types:
- name: m3.medium
cloud_properties:
cpu: 1
ram: 3840
root_disk_size_gb: 10
root_disk_type: pd-ssd
ephemeral_external_ip: true
preemptible: true
- name: m3.large
@peterellisjones
peterellisjones / player-fixtures.csv
Last active July 22, 2018 10:13
Player-fixture performance for all 2018-2019 FPL players' 2017-2018 FPL fixtures
We can't make this file beautiful and searchable because it's too large.
assists,attempted_passes,big_chances_created,big_chances_missed,bonus,bps,clean_sheets,clearances_blocks_interceptions,completed_passes,creativity,dribbles,ea_index,element,errors_leading_to_goal,errors_leading_to_goal_attempt,fixture,fouls,goals_conceded,goals_scored,ict_index,id,influence,key_passes,kickoff_time,kickoff_time_formatted,loaned_in,loaned_out,minutes,offside,open_play_crosses,opponent_team,own_goals,penalties_conceded,penalties_missed,penalties_saved,recoveries,red_cards,round,saves,selected,tackled,tackles,target_missed,team_a_score,team_h_score,threat,total_points,transfers_balance,transfers_in,transfers_out,value,was_home,winning_goals,yellow_cards,player_long_name,player_id_2017_2018,player_id_2018_2019,player_code,opponent_team_code,player_team_code,player_position
0,10,0,0,0,3,0,0,9,0.6,0,0,443,0,0,9,0,2,0,1.9,443,0.4,0,2017-08-13T15:00:00Z,13 Aug 16:00,0,0,9,0,0,12,0,0,0,0,0,0,1,0,25136,0,0,0,0,4,18.0,0,0,0,0,50,False,0,0,Aaron_Cresswell,443,402,55459,1,21,defender
0,21,0,0,0,16,0,6,17,5
jobs:
plan:
- task: say-hello
config:
platform: linux
image_resource:
type: docker-image
source:
repository: alpine
run: