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 datasize = 65536 | |
var framework = "Darwin" | |
#if os(Linux) | |
framework = "Glibc" | |
#endif | |
let bf2swift:[Character:String] = [ | |
">": "sp += 1", | |
"<": "sp -= 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
#!/bin/bash | |
if [ ! -p /dev/stdin ]; then | |
echo "no stdin data" 1>&2 | |
exit 1 | |
fi | |
# ... | |
exit 0 |
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
#!/usr/bin/python | |
import RPi.GPIO as GPIO | |
import time | |
port = 2 | |
GPIO.setwarnings(False) | |
GPIO.setmode(GPIO.BCM) | |
GPIO.setup(port, GPIO.OUT) |
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
(defvar *db* nil) | |
(defun dump-db () | |
(dolist (cd *db*) | |
(format t "~{~a:~10t~a~%~}~%" cd))) | |
(defun save-db (filename) | |
(with-open-file (out filename | |
:direction :output |
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
(setf *random-state* (make-random-state t)) | |
(defun main() | |
(defvar height 20) | |
(defvar width 40) | |
(defvar field (make-array `(,height ,width) :initial-contents | |
(loop for i from 0 below height collecting | |
(loop for j from 0 below width collecting (random 2))))) | |
(loop |
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
// Resolve promise when document onload | |
function awaitDOMContentLoaded() { | |
return new Promise(function (resolve) { | |
if (document.readyState === "complete") { | |
resolve(); | |
} else { | |
document.addEventListener("DOMContentLoaded", resolve); | |
} | |
}); |
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
'use strict'; | |
window.addEventListener("gamepadconnected", function(e) { | |
var gp = e.gamepad; | |
console.log("gamepad" + gp.index + " is connected!"); | |
}, false); | |
window.addEventListener("gamepaddisconnected", function(e) { | |
var gp = e.gamepad; | |
console.log("gamepad" + gp.index + " is disconnected!"); |
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
// turns 9999999 into 9,999,999 | |
function beautify(num) { | |
var str = ''; | |
if (!isFinite(num)) return 'Infinity'; | |
if (num.toString().indexOf('e') != -1) return num.toString(); | |
num = Math.round(num * 10000000) / 10000000; // get rid of weird rounding errors | |
num = Math.floor(num); | |
num = (num + '').split('').reverse(); | |
for (var i in num) { |
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 rand(min, max) { | |
if (max === undefined) { max = min; min = 0; } | |
return Math.floor(Math.random() * (max - min + 1)) + min; | |
} |
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 rand(min, max) { | |
if (max === undefined) { max = min; min = 0; } | |
return Math.floor(Math.random() * (max - min + 1)) + min; | |
} | |
function shuffle(array) { | |
var sample = array.slice(0); | |
var length = sample.length; | |
var last = length - 1; |