Skip to content

Instantly share code, notes, and snippets.

from game import Directions
n = Directions.NORTH
s = Directions.SOUTH
w = Directions.WEST
e = Directions.EAST
fringe = util.Stack()
closed = set()
def makeNode(state, prevActions=[], action=False):
@timkg
timkg / gist:309a6d12741638c486be
Created March 24, 2015 04:07
Map-Reduce a collection of values into a list
[1, 2, 3]
.map(function (num) {
var listItem = document.createElement('li');
listItem.textContent = num;
return listItem;
})
.reduce(function (acc, cur) {
acc.appendChild(cur);
return acc;
}, document.createElement('ul'));
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<p>Most object-oriented languages are actually class-based.</p>
<p>Javascript is object-oriented in the sense that you can create Objects without Classes.</p>
<p>Every Object in JS is created via a Constructor, implicitly or explicitly.</p>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
// Closure - transporting a function outside of another function's scope. The returned function keeps reference to the inner scope, even when it is used somewhere else.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
var myObj = {
@timkg
timkg / README.md
Created March 22, 2014 05:40 — forked from mbostock/.block

A sunburst is similar to the treemap, except it uses a radial layout. The root node of the tree is at the center, with leaves on the circumference. The area (or angle, depending on implementation) of each arc corresponds to its value. Sunburst design by John Stasko. Data courtesy Jeff Heer.

@timkg
timkg / gist:5591004
Created May 16, 2013 11:13
Jade javascript and variables
// rendering the content of a variable
li.tweet
img(src= tweet.profile_image_url)
h5= tweet.from_user_name
p= tweet.text
// executing some JS and conditionally render one line or the other
- var tweets = link._tweets.length || null;
ul.meta
@timkg
timkg / gist:5574889
Created May 14, 2013 09:54
Using jade from inside express.
// tell express where to find our jade templates
app.set('views', path.join(__dirname, '../views'));
// tell express to use jade to compile view files
app.set('view engine', 'jade');
// now we can call response.render(), just like jade.render()
app.get('/', function(request, response) {
response.render('layouts/index.jade');
});
@timkg
timkg / gist:5574709
Created May 14, 2013 09:15
A quick look at Jade extends, block, include.
// file index.jade
html
head
block head
body
block content
// file view.jade
extends index.jade
@timkg
timkg / gist:5574566
Last active December 17, 2015 07:39
A quick look at jade html syntax
h1 This is a heading!
h2.warning This is a warning
p.info this is a paragraph, with an image nested inside, at the end.
img(src='http://some.url')
<h1>This is a heading!</h1>
<h2 class="warning">This is a warning</h2>
<p class="info">this is a paragraph, with an image nested inside, at the end.<img src="http://some.url"></p>