In Javascript this
is bound in unexpected ways. Functions, in particular, create a new 'this' and so when you want to keep a reference to an "outer" object you sometimes see the pattern:
var self = this;
as in:
var self = this;
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; | |
var observer = new MutationObserver(function(mutations) { | |
mutations.forEach(function(mutation) { | |
if(mutation.addedNodes.length > 0 && mutation.addedNodes[0].nodeName == "CANVAS"){ | |
// do stuff after the sketch loaded | |
} | |
}); | |
}); | |
var config = { attributes: false, childList: true, characterData: false } | |
target = document.getElementById("myDiv") |
#!/usr/bin/perl | |
# Copyright (c) 2015, Paul Ford, ford@ftrain.com | |
# All rights reserved. | |
# | |
# Redistribution and use in source and binary forms, with or without | |
# modification, are permitted provided that the following conditions | |
# are met: | |
# | |
# 1. Redistributions of source code must retain the above copyright |
// List all files in a directory in Node.js recursively in a synchronous fashion | |
var walkSync = function(dir, filelist) { | |
if( dir[dir.length-1] != '/') dir=dir.concat('/') | |
var fs = fs || require('fs'), | |
files = fs.readdirSync(dir); | |
filelist = filelist || []; | |
files.forEach(function(file) { | |
if (fs.statSync(dir + file).isDirectory()) { |
// by dave @ beesandbombs.tumblr.com >:) | |
void setup() { | |
setup_(); | |
result = new int[width*height][3]; | |
result_ = new int[width*height][3]; | |
} | |
int[][] result, result_; | |
float time; |
#!/usr/bin/perl -w | |
use strict; | |
use Getopt::Std qw/ getopts /; | |
sub HELP_MESSAGE { | |
my $fh = shift || *STDOUT; | |
print $fh qq% | |
Usage: $0 IMG_IN IMG_OUT | |
Cause deliberate errors in an image file (or any file). |
# Towards a Taxonomy of Twitter Bots | |
## Intro | |
- towards a definition - autonomous non-human agents on Twitter | |
- critical thinking - MECE, rabbit rule, holding hands | |
- patterns of behaviour, rather than content | |
- Twitter largely a textual medium | |
- crossover between two broadest categories (automated/event-driven), but largely one or the other (maybe?) | |
- some bots will exhibit both behaviours (active/reactive), but tend to favour one (most commonly, tweeters will also exhibit conversationalist behaviours) |
module.exports = function(grunt) { | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
browserify: { | |
dist: { | |
files: { | |
'build/module.js': ['js/**/*.js'] | |
} | |
} |
#Node - Build Automation
##Setup
Jake is the JavaScript equivilent of the Ruby Rake tool. It prefers to be installed globally but for build purposes it is better to install it into node_modules. For more info see http://howtonode.org/intro-to-jake
npm install jake