Skip to content

Instantly share code, notes, and snippets.

View routonmh's full-sized avatar
🕶️
Auto Scaling

Matthew Routon routonmh

🕶️
Auto Scaling
View GitHub Profile
@routonmh
routonmh / race_event.py
Last active October 4, 2021 03:22
Short example of storing data for a race.
from typing import List
class RaceCar:
def __init__(self, car_number, driver_name):
self.car_number = car_number
self.driver_name = driver_name
class SessionResult:
@routonmh
routonmh / plantsdb.sql
Created May 29, 2020 16:38
Plant Schema
CREATE TABLE plant (
PlantID INT PRIMARY KEY NOT NULL,
CommonName VARCHAR(128),
ScientificName VARCHAR(128),
PlantDescription VARCHAR(16384),
IsEdible TINYINT NOT NULL
);
CREATE TABLE attribute (
@routonmh
routonmh / app.js
Last active May 15, 2020 16:20
Fetch example with POST request
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
app.use(bodyParser.urlencoded());
app.use(bodyParser.json());
app.use(express.static(__dirname + '/public'));
app.post('/submit-customer', (req, res) => {
@routonmh
routonmh / index.html
Created May 10, 2020 23:35
Hover LInk
<html>
<head>
<title>Rando Site</title>
</head>
<body>
<style>
a:hover {
background-color: #f00;
}
@routonmh
routonmh / Dedupe.js
Created May 10, 2020 19:23
Dedupe with Reduce
let deduped = networks.reduce((previous, curr, idx, items) => {
let predicate = it => it.ssid === curr.ssid;
let existing = previous.find(predicate);
if (!existing)
previous.push(curr);
else
previous[previous.findIndex(predicate)]
.radio = items.map(it =>
predicate(it) ? it.radio : null)
@routonmh
routonmh / tweet_dumper.py
Last active May 6, 2020 06:18 — forked from onmyeoin/tweet_dumper.py
A script to download all of a user's tweets into a csv
import tweepy
import csv
def get_all_tweets(screen_name):
consumer_key = ""
consumer_secret = ""
access_key = ""
access_secret = ""
@routonmh
routonmh / encode-png-decode.py
Last active May 3, 2020 21:28
Encode and Decode a PNG
import base64
def read_image(filepath):
with open(filepath, "rb") as img_file:
encoded_str = base64.b64encode(img_file.read())
return encoded_str
def write_decoded_image(output_path, encoded_str):
with open(output_path, "wb") as fh:
fh.write(base64.decodebytes(encoded_str))
@routonmh
routonmh / Base.js
Last active April 13, 2020 23:57
React - Modifying Parent State
import React from 'react';
import {Item} from "./Item";
export class Base extends React.Component {
constructor(props) {
super(props);
this.state = {
exampleValue: "Hello"
@routonmh
routonmh / Comment.cs
Last active April 10, 2020 02:32
Node.js vsASP .NET Core
[HttpPost("submit-comment")]
public async Task<ActionResult> SubmitComment([Required, FromBody] CommentSubmission submission)
{
if (await Model.AddCommentSubmission(submission))
return new OkResult();
return new BadRequestResult();
}
@routonmh
routonmh / index.html
Created April 7, 2020 21:55
Check word
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
</head>
<body>
<script>
var searchTerm = "word";