Skip to content

Instantly share code, notes, and snippets.

View fourohfour's full-sized avatar

FourOhFour fourohfour

View GitHub Profile
@fourohfour
fourohfour / smh-api.md
Created November 6, 2016 13:25
Information about the Show My Homework API

Show My Homework API


File detailing what I've worked out so far from investigating the Show My Homework API.

API Requests

API requests are made in the form of a HTTPS GET request to the SMH API endpoint.

https://api.showmyhomework.co.uk/api/{request}

@fourohfour
fourohfour / gist:8243657
Created January 3, 2014 18:38
Get nearest player Bukkit.
double closest = Double.MAX_VALUE;
Player closestp = null;
for(Player i : Bukkit.getOnlinePlayers()){
double dist = i.getLocation().distance(event.getPlayer().getLocation());
if (closest == Double.MAX_VALUE || dist < closest){
closest = dist;
closestp = i;
}
}
if (closestp == null){
@fourohfour
fourohfour / paperloader.py
Created March 8, 2018 10:48
Load papers from PMT
import subprocess
import sys
def inp(prmpt):
result = input(prmpt)
if result == "redo":
raise IndexError # lol
elif result == "quit":
sys.exit(0)
n : 10
i : 0
sq : [n - i : ( @s
's' : 0
'c' : 0
'sum': [i - 'c' : (@c
's' : 's' + i
'c' : 'c' + 1
)

Hi Victor,

I'm a reasonably experienced programmer and I've identified some areas in which I feel you could improve your program. Firstly, I'd like to congratulate you on building a working version of your game. I remember working on a similar project about five years ago and it was the first non-trivial program I completed in Python. It was then that I first felt the satisfaction of creating something meaningful with a keyboard and a text editor. Enjoy that feeling - it makes up for the frustration of fighting errors after crashes after bugs.

The first suggestion I would make to you would be to reduce your use of global variables. Beginner programmers tend to overuse global variables, as they are very simple to use. If all the information about your program (commonly called 'state') is stored in global variables, you don't have to think very hard about where it is stored when you need to use it. This might seem like a good thing, but when your programs start to get more complex global variables will qu

@fourohfour
fourohfour / vex.md
Last active July 19, 2017 22:09
Thoughts on VRC in the UK.

On the one hand I feel like JWS could do with putting their younger kids into IQ to develop their skills in the proverbial shallow-end and reduce the sheer number of their robots in VRC UK. On the other hand they do a reasonable job of bringing their younger kids up to a competitive level quickly, and there's a strong argument that the best training for VRC is to compete in VRC!

Besides - is it my place to say that an organisation should restrict the number of robots they enter? Perhaps it is not. Clearly VEX has a great positive impact on the students who participate in it. From my experience, I can say with absolute certainty that you don't have to be competing to be the best team in the country to take a great deal away from VEX competition. Even if you're just building a squarebot and are coming into competitions expecting to be back on the M25 by midday - not to insinuate that JWS teams do that, because they rarely enter genuinely weak teams - there are few more worthwhile extra-curricular pursuits than

@fourohfour
fourohfour / pearson.py
Created March 28, 2017 19:13
Calculate Product Moment Correlation Coefficient (Pearson Coefficient, r)
import math
import random
class Buffer:
def __init__(self, one, two):
self.one = str(one)
self.two = str(two)
self.length = max((len(self.one), len(self.two))) + 1
def __call__(self, obj):
@fourohfour
fourohfour / vex.py
Last active March 20, 2017 05:28
simple script for VEXDB
import requests
params = {"country": "United Kingdom", "grade": "High school"}
r = requests.get("https://api.vexdb.io/v1/get_teams", params = params)
j = r.json()
if j["status"] == 1:
print(len(j["result"]))
@fourohfour
fourohfour / prematch.md
Created March 16, 2017 18:45
prematch.md

Pre-Match Checklist

Deployment:

  • Are stand-offs correctly tightened

Bands:

  • Are the band groups sufficiently fresh
  • Sufficient Strength
/*
======= Vanwall Library Code =======
- Vanwall is a VEX Robotics library intended to streamline the process of programming VEX Robots
- It provides intuitive interfaces for working with Motors and Controllers
*/
/* Motor Types, for the _type member of Motor structs */
typedef enum {HIGH_SPEED, TORQUE} MotorType;
/* Coefficient Presets, for the _coeff member of Motor structs */