Skip to content

Instantly share code, notes, and snippets.

View junkdog's full-sized avatar
🐥

Adrian Papari junkdog

🐥
  • Stockholm
View GitHub Profile
#!/usr/bin/awk -f
# This program is a copy of guff, a plot device. https://github.com/silentbicycle/guff
# My copy here is written in awk instead of C, has no compelling benefit.
# Public domain. @thingskatedid
# Run as awk -v x=xyz ... or env variables for stuff?
# Assumptions: the data is evenly spaced along the x-axis
# TODO: moving average

Here's an example of an algebraic approach to bitwise operations. I'm intentionally choosing something that is obvious from the programmer's point of view to see what it corresponds to algebraically.

We know that bitwise rotation of an n-bit word x can be done with left/shift shifts:

(x << 1) | (x >> (n-1)) = (x << 1) ^ (x >> (n-1)).

Algebraically, this means that the rotation operator C satisfies C = L + R^(n-1). Since C is a rotation it must satisfy C^n = 1, i.e. if we rotate n times we should end up where we started. This corresponds to the identity (L + R^(n-1))^n = 1.

@merikan
merikan / Jenkinsfile
Last active June 13, 2024 03:56
Some Jenkinsfile examples
Some Jenkinsfile examples
@mbinna
mbinna / effective_modern_cmake.md
Last active June 26, 2024 13:26
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

@mplacona
mplacona / gist:614ffdacc7da223f8a6121cd4b7a2eee
Last active October 27, 2023 08:22 — forked from jimbojsb/gist:1630790
Code highlighting for Keynote presentations

Step 0:

Get Homebrew installed on your mac if you don't already have it

Step 1:

Install highlight. "brew install highlight". (This brings down Lua and Boost as well)

Step 2:

#pragma once
#include "IconsFontAwesome.h" // from https://github.com/juliettef/IconFontCppHeaders
namespace ImGui
{
inline void SetupImGuiStyle( bool bStyleDark_, float alpha_ )
{
@Test
public void test_interval_delta_when_world_step_is_bigger_than_system_interval() {
IntervalSystem intervalSystem = new IntervalSystem();
World world = new World(new WorldConfiguration()
.setSystem(intervalSystem));
float worldTotalTime=0;
float intervalSystemTotalIntervalTime=0;
for (int i = 0; i < 4; i++) {
world.delta = 2f;
@hastebrot
hastebrot / README.md
Last active March 6, 2022 06:31
Transducers in Kotlin

Transducers are composable algorithmic transformations. They are independent from the context of their input and output sources and specify only the essence of the transformation in terms of an individual element. Because transducers are decoupled from input or output sources, they can be used in many different processes - collections, streams, channels, observables, etc. Transducers compose directly, without awareness of input or creation of intermediate aggregates.

Original source code (from Oct 12, 2014):

Change notes:

  • Converted to Kotlin 1.0.0-beta-3595 and JUnit 4.12.
@paniq
paniq / ecs.md
Last active July 3, 2024 06:41
Entity Component Systems
@alan-mushi
alan-mushi / scrolling_form.c
Created July 11, 2014 12:38
This is a simple example of "scrolling" form with ncurses. It use "page" to allow forms with more fields than your window can print.
/*
* This is a simple example of "scrolling" form with ncurses.
* It use "page" to allow forms with more fields than your window can print.
*
* It prints a "label" (inactive field) and a regular field and let you
* "scroll" pages of the form.
*
* How to compile:
* gcc -o test scrolling_form.c -lform -lncurses
*/