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
using System; | |
using System.Collections.Generic; | |
abstract class Particle { | |
public String name; | |
public List<float> position; | |
public List<float> color; | |
public abstract float positionMassFreqValue(int i); | |
public abstract void update(Particle other); |
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
// What we want is the mouse position to stay the same relative to the zoomable object (it's a map in this example) | |
// To do that we solve the equation "oldMouseRelativePos = newMouseRelativePos" to find the value of newMapOffset. | |
// We know the values of oldZoom, newZoom, oldMapOffset and mousePos | |
// | |
// It is assumed that canvas->screen (something you would use in OpenGL, for example) transform is "(p - offset) / zoom", | |
// meaning screen->canvas (something you would use in Canvas2D) transform is "p / zoom - offset". | |
// mousePos is assumed to be in some kind of screen coordinates | |
// mapZoom is assumed to be zooming relative to the top left corner of the map | |
// | |
// "map relative mouse position" is: |
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
#!/bin/bash | |
sudo tc qdisc del dev lo root netem | |
sudo ifconfig lo mtu 65535 |
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
#!/bin/bash | |
sudo tc qdisc add dev lo root netem loss 10% delay 150ms 100ms distribution normal # tune these numbers to make it less or more terrible | |
sudo ifconfig lo mtu 1500 # like on the internet |
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
#version 300 es | |
precision highp float; | |
uniform sampler2D u_texture_points; | |
uniform highp usampler2D u_texture_indices; | |
in vec2 v_texcoord; | |
in vec3 v_color; | |
flat in float v_thickness; |
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
function rdp_find_max(points, start, end) { | |
const EPS = 0.5; | |
let result = -1; | |
let max_dist = 0; | |
const a = points[start]; | |
const b = points[end]; | |
const dx = b.x - a.x; | |
const dy = b.y - a.y; |
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 <stdio.h> | |
#include <stdint.h> | |
#include <time.h> | |
#include <math.h> | |
#include <stdlib.h> | |
#include <stdbool.h> | |
struct rect { | |
float x, y; | |
float w, h; |
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 <stdint.h> | |
#include <stdio.h> | |
#include <sys/mman.h> | |
struct bc_vm { | |
uint8_t *base; | |
uint64_t size; | |
uint64_t commited; | |
}; |
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
// compile with | |
// gcc -O2 001_ok_cow_initial.c -o 001_ok_cow_initial -pthread -Wall -Wextra | |
#include <stdint.h> // uint8_t | |
#include <string.h> // memcmp | |
#include <pthread.h> // pthread_create, pthread_join, pthread_mutex_lock, pthread_mutex_unlock | |
#include <stdbool.h> // bool, true, false | |
#define xylen 1024 |
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
static void | |
render_line(struct v2 from, struct v2 to, u32 *pixels, int width, int height, u32 color) | |
{ | |
if (from.x >= width) { | |
from.x = width - 1; | |
} | |
if (to.x >= width) { | |
to.x = width - 1; | |
} |
NewerOlder