This file contains hidden or 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
class Grid { | |
constructor(width, height, resolution) { | |
const cols = this.cols = ceil(width / resolution) | |
const rows = this.rows = ceil(height / resolution) | |
this.resolution = resolution | |
this.data = Array.from({ length: rows }, () => Array.from({ length: cols }, () => [])) | |
this.neighbors = function* (obj) { | |
const x = floor(obj.x / this.resolution), y = floor(obj.y / this.resolution) | |
for (var oy = -1; oy <= 1; oy++) { | |
for (var ox = -1; ox <= 1; ox++) { |
This file contains hidden or 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
const { min, cos, sin, PI, sqrt, ceil } = Math | |
const canvas = document.createElement('canvas') | |
const sqrt3 = sqrt(3) | |
const size = min(document.body.clientWidth, document.body.clientHeight * 1.5 / sqrt3) * 4 / 5 | |
canvas.width = size | |
canvas.height = ceil(size * 2 * sqrt3 / 3) | |
document.body.appendChild(canvas) | |
const c = canvas.getContext('2d') | |
c.strokeStyle = '#fff' |
This file contains hidden or 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
const tuple = (string, ...values) => values | |
tuple `(${1}, ${"foo"}, ${[1, 2]})` // [1, "foo", [1, 2]] |
This file contains hidden or 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
#include <cstdio> | |
#include <stack> | |
using std::stack; | |
using std::scanf; | |
using std::printf; | |
unsigned int operatorPriority(char c) { | |
switch (c) { | |
case '+': case '-': return 1; |
This file contains hidden or 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
var XBoxController = require('../src/controller') | |
var USB = require('usb') | |
// searching for an official xBox 360 controller | |
var device = USB.findByIds(1118, 654) | |
var controller = new XBoxController(device) | |
// handling button events and setting the leds to corresponding pattern | |
controller.on('button', function (key, val) { | |
console.log`Button ${key} has been ${val ? 'pressed' : 'released'}` |
This file contains hidden or 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
public class Server : IDisposable { | |
private static JavaScriptSerializer JSON = new JavaScriptSerializer(); | |
class Message { | |
public string Content; | |
} | |
class Client : IDisposable { |
This file contains hidden or 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
import { TYPES } from '../core' | |
/** Class representing a 3 dimensional vector. | |
* @version 0.0.2 | |
*/ | |
export default class Vec3 extends Float32Array { | |
constructor(x = 0, y = 0, z = 0) { | |
super(3) | |
if (Array.isArray(x) || x.type === TYPES.Vec3) { |
This file contains hidden or 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
const __size__ = { | |
vec2: 2, | |
vec3: 3, | |
vec4: 4, | |
mat3: 9, | |
mat4: 16 | |
} | |
const typeSize = (type) => __size__[type] |
This file contains hidden or 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
module Eval | |
open System | |
type Operator = | |
| Add | |
| Subtract | |
| Multiply | |
| Divide | |
type token = | |
| Number of Double |
This file contains hidden or 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
#include <iostream> | |
using namespace std; | |
void join(char tab1[], char tab2[], char out[]) { | |
int i = 0, // indesk w tablisy out | |
i1 = 0, // indeks w tablicy 1 | |
i2 = 0; // indeks w tablicy 2 |