Skip to content

Instantly share code, notes, and snippets.

View superMDguy's full-sized avatar

Matthew Dangerfield superMDguy

View GitHub Profile
@superMDguy
superMDguy / solve3x3.py
Last active February 6, 2017 19:12
Solving 3x3 systems of equations using Gaussian Elimination
'''Using Gaussian Elimination Method to solve 3x3 systems of equations.
We'll use numpy arrays to store and manipulate the equations. For a video demonstrating the process,
I found https://youtu.be/Dj84vEb4Zko to be helpful.
'''
import numpy as np
A = np.zeros((3, 3)) #This will store the coefficients of the variables as a 3x3 numpy array
x = np.zeros((3, 1)) #This stores the values of the variables as a 3x1 numpy array
b = np.zeros((3, 1)) #This will store what the equations are equal to as a 3x1 numpy array
@superMDguy
superMDguy / dep.js
Last active November 9, 2017 21:50
// See https://github.com/vuejs/vue/blob/be9ac624c81bb698ed75628fe0cbeaba4a2fc991/src/core/observer/dep.js
// for full implementation
class Dep {
constructor() {
this.subs = new Set()
}
addSub(sub) {
this.subs.add(sub)
@superMDguy
superMDguy / dep-2.js
Last active September 25, 2017 20:35
// the current target watcher being evaluated.
// this is globally unique because there could be only one
// watcher being evaluated at any time.
Dep.target = null
const targetStack = []
function pushTarget(_target) {
if (Dep.target) targetStack.push(Dep.target)
Dep.target = _target
}
// See https://github.com/vuejs/vue/blob/be9ac624c81bb698ed75628fe0cbeaba4a2fc991/src/core/observer/watcher.js
// for full implementation
class Watcher {
constructor(getter, cb) {
this.getter = getter // function that returns a value based on reactive properties
this.cb = cb // function that is run on value updates, and is passed value and old value
this.value = this.get()
this.cb(this.value, null)
}
// See https://github.com/vuejs/vue/blob/61187596b9af48f1cb7b1848ad3eccc02ac2509d/src/core/observer/index.js
// for full implementation
/* Walk through each property and convert them into
* getter/setters. This method should only be called when
* value type is Object.
*/
function walk(obj) {
const keys = Object.keys(obj)
for (let i = 0; i < keys.length; i++) {
@superMDguy
superMDguy / final.js
Last active September 27, 2017 23:08
const data = {
name: 'World',
feeling: 'like'
}
walk(data) // adds reactivity to the data object
new Watcher(
() => `Hello, ${data.name}. I ${data.feeling} Vue.js.`, // the value getter we're watching
(val, oldVal) => console.log(val) // the callback, fired on changes to dependencies of the value getter
) // logs 'Hello, World. I like Vue.js'
@superMDguy
superMDguy / simple-reactive.html
Last active September 28, 2017 13:33
A minimalist reactive web app
<html>
<head>
<title>
Reactivity
</title>
<style>
div {
background: #989898;
color: #00FF11;

Keybase proof

I hereby claim:

  • I am supermdguy on github.
  • I am supermdguy (https://keybase.io/supermdguy) on keybase.
  • I have a public key whose fingerprint is 8069 BAAD 1C45 FA27 0E40 43C1 006E 6DD7 CDBA 456B

To claim this, I am signing this object:

Undercover at Amazon warehouse - brutal reality of working for online giant

Alone in a locked metal cage, 10 feet from my nearest colleague, a robot approaches from the shadows and thrusts a tower of shelves towards me. I have nine seconds to grab and process an item to be sent for packing – a target of 300 items an hour, for hour after relentless hour. As I bend to the floor then reach high above my head to fulfil a never-ending stream of orders, my body screams at me. Welcome to Amazon’s picking floor. Here, while cameras watch my every move, a screen in front of me offers constant reminders of my “units per hour” and exactly how long each has taken. This is the online giant’s biggest European packing plant, set to be shipping 1.2 million items a year. As the UK’s top retailer, it made £7.3billion last year alone. But a Sunday Mirro
<script>
const code = '(print (+ 1 (* 2 3) 3))'
const parsed = parse(code)
console.debug('Parsed AST', parsed)
evaluate(parsed[0])
function parse(phrase) {
let seek = 0
const parsed = []