This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"you": | |
{ | |
"taunt": "", | |
"object": "snake", | |
"name": "My snake", | |
"length": 3, | |
"id": "7433f0fe-cdb8-46e1-9b3b-a4a43d483579", | |
"health": 100, | |
"body": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; MELPA | |
(require 'package) | |
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/")) | |
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/")) | |
(add-to-list 'package-archives '("melpa-stable" . "http://stable.melpa.org/packages/")) | |
(setq package-enable-at-startup nil) | |
(package-initialize) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Javascript | |
navigator.mediaDevices.getUserMedia({ | |
video: { | |
width: ..., | |
height: ..., | |
frameRate: ... | |
} | |
} | |
).then(function(stream) { | |
let video = document.querySelector('video'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//javascript | |
var canvas = document.querySelector('canvas'); | |
canvas.width = ...; | |
canvas.height = ...; | |
var context = canvas.getContext('2d'); | |
context.drawImage(video, 0, 0, canvas.width, canvas.height); | |
// video 'play' event listener |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function draw(video, canvas, context, frameRate) { | |
context.drawImage(video, 0, 0, canvas.width, canvas.height); | |
setTimeout(draw, 1/frameRate, video, canvas, context, frameRate); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function.pixelate(image, canvas, context, pixelSize) { | |
let wScaled, hScaled, scale; | |
scale = 1/pixelSize; | |
wScaled = canvas.width*scale; | |
hScaled = canvas.height*scale; | |
context.drawImage(image, 0, 0, wScaled, hScaled); | |
context.mozImageSmoothingEnabled = false; | |
context.imageSmoothingEnabled = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function(context, threshold, width, height) { | |
let image, data, r, g, b, color; | |
image = context.getImageData(0, 0, width, height); | |
data = image.data; | |
for (let i = 0; i< data.length; i = i+4) { | |
r = data[i]; | |
g = data[i+1]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct OptionSetHash: OptionSet, Hashable { | |
let rawValue: Int | |
var hashValue: Int { | |
return self.rawValue | |
} | |
static let first = OptionSetHash(rawValue: 1 << 0) | |
static let second = OptionSetHash(rawValue: 1 << 1) | |
static let third = OptionSetHash(rawValue: 1 << 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let DictionaryLookUp : [OptionSetHash: Bool] = [ | |
.first: true, | |
.second: false, | |
.third: true | |
] | |
// Example: cycling through options in a dictionary | |
var options = OptionSetHash.init(rawValue: 0) | |
for (key, value) in DictionaryLookUp { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Canidae | |
Felidae | |
Cat | |
Cattle | |
Dog | |
Donkey | |
Goat | |
Guinea pig | |
Horse | |
Pig |