Skip to content

Instantly share code, notes, and snippets.

Avatar

Logan Yang logancyang

View GitHub Profile
@logancyang
logancyang / space-colonization.js
Created Jul 28, 2020
A 2D version of space colonization algorithm in JavaScript
View space-colonization.js
class Leaf {
constructor() {
this.pos = createVector(random(width), random(height));
this.reached = false;
}
show() {
fill(255, 255, 0);
noStroke();
ellipse(this.pos.x, this.pos.y, 8, 8);
View tensor_backward.py
class Tensor:
...
def backward(self):
# topological order all of the parents in the graph
topo = []
visited = set()
def build_topo(v):
if v not in visited:
visited.add(v)
for parent in v._prev:
View tensor_forward.py
class Tensor:
def __init__(self, data, _parents=(), _op=''):
self.data = data
self.grad = 0
self._backward = lambda: None
# A set that contains previous (parent) nodes that produced
# the current node with operation _op
self._prev = set(_parents)
self._op = _op
View tensor_sigmoid.py
class Tensor:
def __init__(self, data, _parents, _op):
...
def sigmoid(self):
sigm = 1.0/(1 + np.exp(-self.data))
out = Tensor(sigm, _parents=(self,), _op="σ")
def _backward():
self.grad = sigm * (1 - sigm)
out._backward = _backward
return out
@logancyang
logancyang / 1-server.md
Created Mar 15, 2018 — forked from dragonjet/1-server.md
Setup Web Server on EC2 Amazon Linux AMI
View 1-server.md

Step 1: Server Credentials

This assumes you are now connected to the server via SSH.

  • sudo -s Enter root mode for admin access
  • groupadd devgroup Create new group to be later granted access to /var/www/html

Creating a new Root User

  • useradd -G root,devgroup masterdev Create new root user. Also add to the devgroup
  • passwd masterdev Change password for the new root user
  • At this point, you'll need to input your new root user's new password
View tmux-cheatsheet.markdown

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@logancyang
logancyang / beautiful_idiomatic_python.md
Last active Aug 29, 2015 — forked from JeffPaine/beautiful_idiomatic_python.md
Transforming Code into Beautiful, Idiomatic Python: notes from Raymond Hettinger's talk at pycon US 2013. The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!
View beautiful_idiomatic_python.md

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:
You can’t perform that action at this time.