Skip to content

Instantly share code, notes, and snippets.

View thundergolfer's full-sized avatar
👟
Loading...

Jonathon Belotti thundergolfer

👟
Loading...
View GitHub Profile

Browserify: Running Node JS in the browser

Prerequisites

  1. Install Node JS
  2. Check installation of NodeJS and NPM (installed with NodeJS): npm -v and node -v

The Problem

If you want to develop some Javascript the needs to run in a browser and want to make use of the NodeJS development and package ecosystem, much of which involves code that is incompatible with a browser, then you'll need a way to transform browser-incompatible code into compatible code.

#
# Solves the 'Jug Problem' from RMIT AI Sem 1 2018 Tutorial 1
#
# The state space graph for this problem contains multiple cycles, so we
# can't rely on a naive search fully exploring the graph without getting stuck in a cycle
#
# In order to combat the cycles, I introduce some randomness into operation choices and
# set a maximum search depth that well exceeds the known depth of the most efficient solution
# NOTE: This is rough code. It's hashed out and it's ugly.
[user]
email = [email protected]
name = Jonathon Belotti
[core]
editor = vim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
excludesfile = ~/.gitignore
[web]
browser = google-chrome

Showing a bit of my code

It's quite hard to look across some code you've written, and pick something out to show; Like most programmers, I really only found in past my work, things to fix and change. Had to pick something though, so I'll show simplegraphdb, which I something I wrote relatively recently (mid November 2017) in preparation for being a Golang programmer at Atlassian.

It's quite small, and self-contained. I had been interested for quite a while in graph databases, as I like the kinds of questions a graph database allows you to ask efficiently about certain kinds of data. They are also not something explored really at university, the relation-model dominating my education thus far.

I approached this project as a thing that could serve as an my introduction to graph database thinking. I wanted to keep things nice, simple, and elegant and found the "Hexastore" indexing model to be exactly this. It can be implemented by building and linking m

@thundergolfer
thundergolfer / atlassian_intern_description.md
Last active November 13, 2017 00:27
Info I received with my offer for Atlassian Sydney.

Job Title: Intern Developer

Commencement Date: 27th November 2017

Reports To: Development Manager

Main Activities (including but not limited to):

  • Developing server-side code for internal and external web applications
  • Writing unit tests, automated regression tests and tracking defects as they occur
  • Supporting and assisting Atlassian customers from around the globe using our products to further
@thundergolfer
thundergolfer / stop_looking_for_a_trick.md
Created October 14, 2017 03:14
A short sheet to print out and check over when you forget how to break down a programming problem

Do you need to SEARCH?..

  • BINARY search

Graph

  • Depth First Search
  • Breadth First Search

Do you need to

LINKED LIST

def coinProblem(coins, total):
dp = [0] * (total + 1)
coins.sort()
for subtotal in range(1, total + 1):
best = float('inf')
for c in coins:
if c <= subtotal:
option = 1 + dp[subtotal - c]
def unbounded_knapsack(items, C):
"""
items List[item], where 'item' is a named tuple -> (val=4, cost=10)
C int, where 'C' stands for capacity
Note: This implementation also stores the optimal group of items at each capacity value
"""
dp = [(0, [])] * (C + 1)
used = []
@thundergolfer
thundergolfer / heap.py
Last active September 28, 2017 11:59
A binary heap implementation that I wrote, and am thus more familiar with.
class Heap():
def __init__(self):
self.data = [None]
self.size = 0
def insert(self, n):
self.size += 1
self.data.append(n)
self._swim(self.size)
class Trie(object):
class Node(object):
def __init__(self):
self.val = 0
self.children = {}
def __init__(self):
"""
Initialize your data structure here.
"""