Skip to content

Instantly share code, notes, and snippets.

View kingjbbrooks's full-sized avatar

kingjbbrooks

View GitHub Profile
@kingjbbrooks
kingjbbrooks / node-python-fastai.md
Created November 9, 2020 02:35 — forked from zcaceres/node-python-fastai.md
Starter code to use NodeJS with a Python layer for the model.

Deploying a Deep Learning Image Classification Model with NodeJS, Python, and Fastai

TL|DR: Use this to easily deploy a FastAI Python model using NodeJS.

You've processed your data and trained your model and now it's time to move it to the cloud.

If you've used a Python-based framework like fastai to build your model, there are several excellent solutions for deployment like Django or Starlette. But many web devs prefer to work in NodeJS, especially if your model is only part of a broader application.

My friend Navjot pointed out that NodeJS and Python could run together if we could send remote procedure calls from NodeJS to Python.

/*
* Chemical equation balancer
*
* Copyright (c) 2014 Project Nayuki
* All rights reserved. Contact Nayuki for licensing.
* http://www.nayuki.io/page/chemical-equation-balancer-javascript
*/
"use strict";
var admobid={}
if( /(android)/i.test(navigator.userAgent) ) {
admobid = { // for Android
banner: 'ca-app-pub-xxxxx/xxxxx',
interstitial: 'ca-app-pub-xxxxxx/xxxxxx'
}
}
else if(/(ipod|iphone|ipad)/i.test(navigator.userAgent)) {
admobid = { // for iOS
banner: 'ca-app-pub-xxxxxxx/xxxxxxx',
We can make this file beautiful and searchable if this error is corrected: It looks like row 7 should actually have 28 columns, instead of 24 in line 6.
AtomicNumber,Element,Symbol,AtomicMass,NumberofNeutrons,NumberofProtons,NumberofElectrons,Period,Group,Phase,Radioactive,Natural,Metal,Nonmetal,Metalloid,Type,AtomicRadius,Electronegativity,FirstIonization,Density,MeltingPoint,BoilingPoint,NumberOfIsotopes,Discoverer,Year,SpecificHeat,NumberofShells,NumberofValence
1,Hydrogen,H,1.007,0,1,1,1,1,gas,,yes,,yes,,Nonmetal,0.79,2.2,13.5984,8.99E-05,14.175,20.28,3,Cavendish,1766,14.304,1,1
2,Helium,He,4.002,2,2,2,1,18,gas,,yes,,yes,,Noble Gas,0.49,,24.5874,1.79E-04,,4.22,5,Janssen,1868,5.193,1,
3,Lithium,Li,6.941,4,3,3,2,1,solid,,yes,yes,,,Alkali Metal,2.1,0.98,5.3917,5.34E-01,453.85,1615,5,Arfvedson,1817,3.582,2,1
4,Beryllium,Be,9.012,5,4,4,2,2,solid,,yes,yes,,,Alkaline Earth Metal,1.4,1.57,9.3227,1.85E+00,1560.15,2742,6,Vaulquelin,1798,1.825,2,2
5,Boron,B,10.811,6,5,5,2,13,solid,,yes,,,yes,Metalloid,1.2,2.04,8.298,2.34E+00,2573.15,4200,6,Gay-Lussac,1808,1.026,2,3
6,Carbon,C,12.011,6,6,6,2,14,solid,,yes,,yes,,Nonmetal,0.91,2.55,11.2603,2.27E+00,3948.15,4300,7,Prehi
@kingjbbrooks
kingjbbrooks / GSoC 2018 - Brandon Makin - WebRTC in Godot
Created July 22, 2020 05:23 — forked from BrandonMakin/GSoC 2018 - Brandon Makin - WebRTC in Godot
GSoC 2018 Final Submission - Brandon Makin - WebRTC in Godot
My project was to allow users of the Godot game engine to create multiplayer games by connecting players via WebRTC using Godot's existing multiplayer APIs.
Godot's core can be extended by adding modules - essentially plugins that are compiled with the engine. I created a WebRTC module that can be found here:
https://github.com/BrandonMakin/godot/tree/webrtc_static_final/modules/webrtc
That folder - modules/webrtc/ - represents my work for Google Summer of Code. SConstruct, config.py, are to help the build system compile and were created by my mentor Fabio Alessandrelli. register_types.h and register_types.cpp are there to expose the WebRTCPeer and NetworkedMultiplayerWebRTC classes to Godot's internal scripting and were created by Fabio Alessandrelli and modified by me, Brandon Makin. The rest of the code uses WebRTC's PeerConnectionInterface to implement Godot's multiplayer API. webrtc_peer.h and webrtc_peer.cpp create the WebRTCPeer class, a class that uses Godot's lower-level PacketPeer API.
@kingjbbrooks
kingjbbrooks / gist:6206d5c00992757ae21772a82575eaab
Created May 25, 2020 05:05 — forked from ChickenProp/gist:3194723
The Liang-Barsky algorithm for line-rectangle collisions

The Liang-Barsky algorithm is a cheap way to find the intersection points between a line segment and an axis-aligned rectangle. It's a simple algorithm, but the resources I was pointed to didn't have particularly good explanations, so I tried to write a better one.

Consider a rectangle defined by x_min ≤ x ≤ x_max and y_min ≤ y ≤ y_max, and a line segment from (x_0, y_0) to (x_0 + Δ_x, y_0 + Δ_y). We'll be assuming at least one of Δ_x and Δ_y is nonzero.

Image depicting the situation

(I'm working with Flash, so I'll be using the convention that y increases as you go down.)

We want to distinguish between the following cases:

@kingjbbrooks
kingjbbrooks / Matrix4+Extensions.swift
Created May 13, 2020 09:46 — forked from Bersaelor/Matrix4+Extensions.swift
Applying SCNMatrix4 to SCNVector3 (Couldn't find this in SceneKit)
//
// Matrix4+Extensions.swift
// StARs
//
// Created by Konrad Feiler on 17.12.17.
// Copyright © 2017 Konrad Feiler. All rights reserved.
//
import Foundation
import SceneKit
@kingjbbrooks
kingjbbrooks / Matrix4+Extensions.swift
Created May 13, 2020 09:46 — forked from Bersaelor/Matrix4+Extensions.swift
Applying SCNMatrix4 to SCNVector3 (Couldn't find this in SceneKit)
//
// Matrix4+Extensions.swift
// StARs
//
// Created by Konrad Feiler on 17.12.17.
// Copyright © 2017 Konrad Feiler. All rights reserved.
//
import Foundation
import SceneKit
# Name Type 1 Type 2 Total HP Attack Defense Sp. Atk Sp. Def Speed Generation Legendary
1 Bulbasaur Grass Poison 318 45 49 49 65 65 45 1 False
2 Ivysaur Grass Poison 405 60 62 63 80 80 60 1 False
3 Venusaur Grass Poison 525 80 82 83 100 100 80 1 False
3 VenusaurMega Venusaur Grass Poison 625 80 100 123 122 120 80 1 False
4 Charmander Fire 309 39 52 43 60 50 65 1 False
5 Charmeleon Fire 405 58 64 58 80 65 80 1 False
6 Charizard Fire Flying 534 78 84 78 109 85 100 1 False
6 CharizardMega Charizard X Fire Dragon 634 78 130 111 130 85 100 1 False
6 CharizardMega Charizard Y Fire Flying 634 78 104 78 159 115 100 1 False

Option 1: Command-line download extension as zip and extract

extension_id=jifpbeccnghkjeaalbbjmodiffmgedin   # change this ID
curl -L -o "$extension_id.zip" "https://clients2.google.com/service/update2/crx?response=redirect&os=mac&arch=x86-64&nacl_arch=x86-64&prod=chromecrx&prodchannel=stable&prodversion=44.0.2403.130&x=id%3D$extension_id%26uc" 
unzip -d "$extension_id-source" "$extension_id.zip"

Thx to crxviewer for the magic download URL.