Skip to content

Instantly share code, notes, and snippets.

View JimRottinger's full-sized avatar

Jim Rottinger JimRottinger

View GitHub Profile
@JimRottinger
JimRottinger / hs_stats.js
Last active April 27, 2018 16:38
Random HS Game Data Generation
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'redacted',
user : 'redacted',
password : 'redacted',
database : 'redacted'
});
function randomClass() {
@JimRottinger
JimRottinger / example.hsreplay
Created May 21, 2018 20:28
Example hsreplay xml file
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hsreplay SYSTEM "https://hearthsim.info/hsreplay/dtd/hsreplay-1.6.dtd">
<HSReplay version="1.6">
<Game ts="11:27:02.657831">
<GameEntity id="1">
<Tag tag="202" value="1"/>
<Tag tag="49" value="1"/>
<Tag tag="53" value="1"/>
</GameEntity>
<Player id="2" playerID="1" accountHi="144115193835963207" accountLo="24163744" name="jrott#1315">
@JimRottinger
JimRottinger / server.js
Last active August 13, 2018 20:04
Booting up two node servers on different ports than can serve html or JS files
const http = require('http');
const fileSystem = require('fs');
const path = require('path');
const hostname = 'localhost';
const host_port = 8000;
const client_port = 8001;
function serveAsset(rootPath, url, res) {
// default root route to index.html in the folder
const checkLoopInvariant = (newArr, originalArr, index) => {
//need to slice at least 1 element out
if (index < 1) index = 1
newArr = newArr.slice(0,index)
originalArr = originalArr.slice(0, index)
for (let i=0; i < newArr.length; i++) {
//check that the original array contains the value
const insertionSort = (nums) => {
for (let i = 1; i < nums.length; i++) {
let j = i - 1
let tmp = nums[i]
while (j >= 0 && nums[j] > tmp) {
nums[j + 1] = nums[j]
j--
}
nums[j+1] = tmp
}
const selectionSort = (nums) => {
for (let i = 0; i < nums.length - 1; i++) {
let smallest = nums[i]
let swapIndex = i
for (let j = i + 1; j < nums.length; j++) {
if (nums[j] < smallest) {
smallest = nums[j];
swapIndex = j
}
}
const checkLoopInvariant = (newArray, originalArray, index) => {
newArray = newArray.slice(0, index)
originalArray = originalArray.sort((a,b) => a > b ? 1 : - 1).slice(0,index)
if (index === 0) return true //no elements sorted yet
for (let i = 0; i < newArray.length; i++) {
if (!originalArray.includes(newArray[i])) {
console.warn(`Error! ${newArray[i]} not one of the ${index} smallest elements`)
}
function identity (value) {
return value;
}
console.log(identity(1)) // 1
function identity (value) {
return value;
}
console.log(identity(1)) // 1
function identity (value: Number) : Number {
return value;
}
console.log(identity(1)) // 1