Skip to content

Instantly share code, notes, and snippets.

@Melbourneandrew
Melbourneandrew / Dealership.java
Created September 20, 2023 16:05
Response to ACM TIP application question
import java.util.ArrayList;
import java.util.List;
class Car{
public Car(){}
}
public class Dealership {
List<Car> inventory;
public Dealership(){
inventory = new ArrayList<Car>();
@Melbourneandrew
Melbourneandrew / Cloudflare_Images_Upload.js
Created April 22, 2022 03:14
Upload to Cloudflare images with Axios NodeJS
const FormData = require('form-data');
const { default: axios } = require("axios");
const deliveryURL = "<CF Image Delivery URL>"
const uploadURL = "<CF Image Upload URL>"
const cf_api_token = "<api_token>"
const form = new FormData();
form.append("file", <image file object>, "<image name for Cloudflare>")
const cfResponse = await axios.post(
@Melbourneandrew
Melbourneandrew / browser_downloader.js
Created June 21, 2021 19:56
Pass in a JS object and you can have it downloaded from the browser in plaintext. Based on https://www.aspsnippets.com/Articles/Download-JSON-object-Array-as-File-from-Browser-using-JavaScript.aspx
function DownloadThis(data){
//Convert JSON Array to string.
var json = JSON.stringify(data);
//Convert JSON string to BLOB.
json = [json];
var blob1 = new Blob(json, {
type: "text/plain;charset=utf-8"
});
["the", "of", "to", "and", "a", "in", "is", "it", "you", "that", "he", "was", "for", "on", "are", "with", "as", "I", "his", "they", "be", "at", "one", "have", "this", "from", "or", "had", "by", "hot", "word", "but", "what", "some", "we", "can", "out", "other", "were", "all", "there", "when", "up", "use", "your", "how", "said", "an", "each", "she", "which", "do", "their", "time", "if", "will", "way", "about", "many", "then", "them", "write", "would", "like", "so", "these", "her", "long", "make", "thing", "see", "him", "two", "has", "look", "more", "day", "could", "go", "come", "did", "number", "sound", "no", "most", "people", "my", "over", "know", "water", "than", "call", "first", "who", "may", "down", "side", "been", "now", "find", "any", "new", "work", "part", "take", "get", "place", "made", "live", "where", "after", "back", "little", "only", "round", "man", "year", "came", "show", "every", "good", "me", "give", "our", "under", "name", "very", "through", "just", "form", "sentence", "great", "think", "say", "
@Melbourneandrew
Melbourneandrew / timer.js
Created June 20, 2021 03:30
Simple javascript timer module. 10ms accurate.
var createTimer = function(){
return {
ms: 0,
clock: 0,
start: function(){
//start incrimenting ms every millisecond
this.clock = setInterval(() => {this.ms += 10;}, 10);
},
stop: function(){clearInterval(this.clock)},
clear: function(){this.ms = 0;},
@Melbourneandrew
Melbourneandrew / txttoarray.py
Last active June 21, 2021 20:01
Convert a text file(newline delimited) into an array saved in a json file
import json
f = open('input.txt', 'r+')
lines = [line for line in f.readlines()]
f.close()
words = []
for line in lines:
words.append(line.strip("\n"))