Skip to content

Instantly share code, notes, and snippets.

View RadimBaca's full-sized avatar

Radim Bača RadimBaca

View GitHub Profile
@RadimBaca
RadimBaca / gist:98708409a8a653901d79362a9c790b88
Last active February 12, 2024 10:18
Manim pymunk integration. Fluid simulation.
import pymunk
from manim import *
import random
# transform the pymunk position to manim position
def transform_pymunk_to_manim_position(p):
return p[0] / 100.0, p[1] / 100.0, 0
@RadimBaca
RadimBaca / sps.js
Last active November 23, 2023 14:05
Shortest path search
function shortestPathSearch(game_board, y_npc, x_npc, yp, xp) {
const numRows = game_board.length;
const numCols = game_board[0].length;
// Define movement directions (up, down, left, right)
const dx = [-1, 1, 0, 0];
const dy = [0, 0, -1, 1];
// Create a 2D array to mark visited cells and store parent cells
const visited = Array(numRows)
@RadimBaca
RadimBaca / TLB harware effect
Last active April 1, 2019 21:31
Demostrate TLB overflow. The code has much better times for lower `array_count` (1-32) even though the number of processed numbers is constant. This behaviour occurs due to the TLB overflow in the case of large `array_count`.
#include <vector>
#include <array>
#include <algorithm>
#include <chrono>
#include <iostream>
#include <string>
//constexpr int N = 128;
constexpr int SIZE = 1024 * 150;
constexpr int REPEAT = 1024 * 10;
@RadimBaca
RadimBaca / merge.cpp
Last active March 29, 2019 13:39
comparison of merge and concatenation of two vectors in C++
////////////////////////////////////////////////////////
//
// Task : merging two vectors of SortRecords into one vector
// Author: R.Baca
//
/////////////////////////////////////////////////////////
#include <vector>
#include <algorithm>
#include <random>