- In QuickJS
dst.push.apply(dst, ext)
is faster by a 200% margin over others. - In V8
concat
is better for few extensions specially for big arrays, otherwisepush
wins for more than a few extensions of small sized arrays. Somewhat depends of GC frequency.
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
// | |
// Dungeons and diagrams like puzzle generator | |
// 2bam.com 2024 | |
// | |
// There's room for improvement (in C): | |
// - Fit board into int64 masks | |
// - Use "&" + popcount intrinsics to count walls | |
const STOP_ON_FIRST_FOUND = false; | |
const PRINT_EACH_BOARD = true; |
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
/* | |
This is a great question! | |
For me the breakthrough was not to focus on the Model or the View but the line | |
in between them: Queues. | |
The most important part of abstractions is the communication. | |
By enqueuing you don't infer the animation from a state diff, you rather encode | |
the diff patch into an event message (aka Command pattern) which commits a game |
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
# | |
# gnuplot script to show energy and cpu by time from batlog.sh | |
# | |
# To run: | |
# gnuplot -persist batlog.gnuplot | |
# | |
set datafile separator "," | |
set xdata time | |
my_fmt = "%a %b %d %H:%M:%S %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
// | |
// Thx https://www.measurethat.net/Benchmarks/Show/3549/0/javascript-sorting-algorithms | |
// | |
// 1000x random ordered: https://www.measurethat.net/Benchmarks/Show/3549/0/javascript-sorting-algorithms | |
// 1000x almost ordered: https://www.measurethat.net/Benchmarks/Show/25092/0/javascript-sorting-algorithms-best-case-almost-ordered | |
// | |
function swap(ary, a, b) { | |
var t = ary[a]; | |
ary[a] = ary[b]; |
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
VideoCapture cap("libcamerasrc ! video/x-raw,width=640,height=480 ! appsink", CAP_GSTREAMER); |
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
void SetupGitAuthentication() | |
{ | |
// Set the path so git's ssh executables are called instead of Windows' | |
Environment.SetEnvironmentVariable("PATH", "C:\\Program Files\\Git\\usr\\bin;" + Environment.GetEnvironmentVariable("PATH")); | |
// This duplicates what "start-ssh-agent.cmd" does to find the agent PID and socket file, | |
// in order to set SSH_AGENT_PID, SSH_AUTH_SOCK so git works. | |
// We heuristically take the first we find, as the script does. This seems to work, as | |
// possibly the PID is not even necessary. | |
var tmpPath = Path.GetTempPath(); |
If you:
- are using PowerShell or CMD directly
- don't want to be forced to use
id_rsa
- don't want to input a passphrase on each call to
git
- don't want to use Git Bash because you want to use it from CMD/PowerShell directly you need some troubleshooting to use git installation executables and a prior setup:
1. Start or get currently running agent into env vars (PID and socket/pipe file)
start-ssh-agent.cmd
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
internal class CInteropProxy { | |
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] | |
unsafe delegate int C_stepDelegate(World.Pinned* world); | |
C_stepDelegate? c_step; // Set with kernel32.dll GetProcAddress() | |
public void Step(in World world) | |
{ | |
unsafe | |
{ |