Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
# Supporting class for demo purposes | |
class DatabaseStub | |
attr_reader :name | |
def self.instances | |
["development", "test", "ci"] | |
end | |
def initialize(databaseName) | |
@name = databaseName |
Don't worry about what anybody else is going to do. The best way to | |
predict the future is to invent it. | |
-- Alan Kay | |
Premature optimization is the root of all evil (or at least most of it) | |
in programming. | |
-- Donald Knuth | |
Lisp has jokingly been called "the most intelligent way to misuse a | |
computer". I think that description is a great compliment because it |
# Author: Pieter Noordhuis | |
# Description: Simple demo to showcase Redis PubSub with EventMachine | |
# | |
# Update 7 Oct 2010: | |
# - This example does *not* appear to work with Chrome >=6.0. Apparently, | |
# the WebSocket protocol implementation in the cramp gem does not work | |
# well with Chrome's (newer) WebSocket implementation. | |
# | |
# Requirements: | |
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby |
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
(function() { | |
// Notes from http://news.ycombinator.com/item?id=1952531 | |
var notes = { | |
"suspended cymbal":"zk", | |
"snare":"bschk", | |
"brush":"pv", | |
"bass":"bk", | |
"flam1":"tk", | |
"roll tap":"vk", | |
"flam2":"kt", |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
function loadCanvasWithInputFile(){ | |
// canvas | |
var canvas = document.getElementById('myCanvas'); | |
var context = canvas.getContext("2d"); | |
var fileinput = document.getElementById('ab'); // input file | |
var img = new Image(); | |
fileinput.onchange = function(evt) { | |
var files = evt.target.files; // FileList object | |
var file = files[0]; |
mix3d asked for some help using this guide with windows so here we go. This was tested with Windows 10. Run all commands in Git Bash once it's installed.
Github will be the main account and bitbucket the secondary.
When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:
const Article = require('../../../../app/models/article');
Those suck for maintenance and they're ugly.