Skip to content

Instantly share code, notes, and snippets.

@nuta
nuta / cache disabled
Created June 13, 2021 12:54
Cache memory experiment on Resea IPC on Raspberry Pi 3B+
Booting Resea v0.9.0 (dc57ce1)...
[kernel] Booted CPU #0
[vm] ready
[benchmark_server] starting benchmark server...
[benchmark] starting IPC benchmark...
{"type":"metric","key":"reading cycle counter","value":30}
[benchmark] reading cycle counter: cycles: avg=31, min=30, max=376
[benchmark] reading cycle counter: l1d_cache_access: avg=0, min=0, max=0
[benchmark] reading cycle counter: l2d_cache_access: avg=0, min=0, max=0
[benchmark] reading cycle counter: mem_access: avg=10, min=10, max=174
@mike-myers-tob
mike-myers-tob / Working GDB on macOS 11.md
Last active November 11, 2024 19:42
Steps to get GDB actually working in April 2021 on macOS (Intel x86-64 only)

Debug with GDB on macOS 11

The big reason to do this is that LLDB has no ability to "follow-fork-mode child", in other words, a multi-process target that doesn't have a single-process mode (or, a bug that only manifests when in multi-process mode) is going to be difficult or impossible to debug, especially if you have to run the target over and over in order to make the bug manifest. If you have a repeatable bug, no big deal, break on the fork from the parent process and attach to the child in a second lldb instance. Otherwise, read on.

Install GDB

Don't make the mistake of thinking you can just brew install gdb. Currently this is version 10.2 and it's mostly broken, with at least two annoying bugs as of April 29th 2021, but the big one is https://sourceware.org/bugzilla/show_bug.cgi?id=24069

$ xcode-select install  # install the XCode command-line tools
@geerlingguy
geerlingguy / increase-pci-bar-space.sh
Last active November 10, 2024 20:47
Increase the BAR memory address space for PCIe devices on the Raspberry Pi Compute Module 4
#!/bin/bash
# The default BAR address space available on the CM4 may be too small to allow
# some devices to initialize correctly. To avoid 'failed to assign memory'
# errors on boot, you can increase the range of the PCIe bus in the Raspberry
# Pi's Device Tree (a .dtb file specific to each Pi model).
#
# You should probably read up on Device Trees if you don't know what they are:
# https://www.raspberrypi.org/documentation/configuration/device-tree.md
#
@abey79
abey79 / axy.py
Created May 4, 2020 15:42
My pen is leaking (generative stop-motion animation with the axidraw)
import time
from pyaxidraw import axidraw
from gpiozero import LED
CM_TO_INCH = 1.0 / 2.54
trigger = LED(26)
ad = axidraw.AxiDraw()
ad.plot_setup()
@by12380
by12380 / amazon-lp-from-leetcode.txt
Last active September 30, 2024 14:07
Amazon LP Questions from LeetCode Interview Experiences
1.https://interviewgenie.com/blog-1/category/Amazon+interviews
2.https://www.youtube.com/channel/UCw0uQHve23oMWgQcTTpgQsQ/playlists
3.https://medium.com/@scarletinked/are-you-the-leader-were-looking-for-interviewing-at-amazon-8301d787815d
Tell me about a situation where you had a conflict with someone on your team. What was it about? What did you do? How did they react? What was the outcome?
Give an example of when you saw a peer struggling and decided to step in and help. What was the situation and what actions did you take? What was the outcome?
Tell me about a time you committed a mistake?
Tell me about a time when your earned your teammate's trust?
;K Line Test created by Sebastianv650
; kevinh change to run faster, to force a bigger/more ovious acceleration change
M107
M83 ; extruder relative mode
M104 S200 ; set extruder temp
M140 S75 ; set bed temp
M190 S75 ; wait for bed temp
M109 S200 ; wait for extruder temp
G28 W ; home all without mesh bed level
@shafik
shafik / WhatIsStrictAliasingAndWhyDoWeCare.md
Last active November 8, 2024 20:02
What is Strict Aliasing and Why do we Care?

What is the Strict Aliasing Rule and Why do we care?

(OR Type Punning, Undefined Behavior and Alignment, Oh My!)

What is strict aliasing? First we will describe what is aliasing and then we can learn what being strict about it means.

In C and C++ aliasing has to do with what expression types we are allowed to access stored values through. In both C and C++ the standard specifies which expression types are allowed to alias which types. The compiler and optimizer are allowed to assume we follow the aliasing rules strictly, hence the term strict aliasing rule. If we attempt to access a value using a type not allowed it is classified as undefined behavior(UB). Once we have undefined behavior all bets are off, the results of our program are no longer reliable.

Unfortunately with strict aliasing violations, we will often obtain the results we expect, leaving the possibility the a future version of a compiler with a new optimization will break code we th

@mbinna
mbinna / effective_modern_cmake.md
Last active November 13, 2024 23:24
Effective Modern CMake

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft

@Zammy
Zammy / DrawRect.frag
Last active April 12, 2024 10:52
Rectangle drawing function GLSL
//all params in normalized units
vec3 drawRect(in vec2 st,
in vec2 center,
in float width,
in float height,
in float thickness,
in vec3 fillColor,
in vec3 strokeColor)
{
vec3 color = vec3(0);