Skip to content

Instantly share code, notes, and snippets.

View Pan-Maciek's full-sized avatar
🤫

Maciej Kozieja Pan-Maciek

🤫
  • Qualtrics
  • Kraków
View GitHub Profile
@Pan-Maciek
Pan-Maciek / grid.js
Created October 16, 2019 20:06
Simple grid system colisions.
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++) {
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'
const tuple = (string, ...values) => values
tuple `(${1}, ${"foo"}, ${[1, 2]})` // [1, "foo", [1, 2]]
#include <cstdio>
#include <stack>
using std::stack;
using std::scanf;
using std::printf;
unsigned int operatorPriority(char c) {
switch (c) {
case '+': case '-': return 1;
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'}`
public class Server : IDisposable {
private static JavaScriptSerializer JSON = new JavaScriptSerializer();
class Message {
public string Content;
}
class Client : IDisposable {
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) {
const __size__ = {
vec2: 2,
vec3: 3,
vec4: 4,
mat3: 9,
mat4: 16
}
const typeSize = (type) => __size__[type]
module Eval
open System
type Operator =
| Add
| Subtract
| Multiply
| Divide
type token =
| Number of Double
#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