Skip to content

Instantly share code, notes, and snippets.

View rpavlik's full-sized avatar

Rylie Pavlik rpavlik

View GitHub Profile
@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active April 16, 2024 01:02
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

@xoseperez
xoseperez / rpi3_iot_server.md
Last active February 11, 2024 15:05
Raspberry Pi 3 with Mosquitto, Node-RED, InfluxDB, Grafana and Nginx (as a reverse proxy)
@mbinna
mbinna / effective_modern_cmake.md
Last active April 18, 2024 19: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

@d235j
d235j / makerbot_rep2x_1st.def.json
Created November 26, 2017 22:52
Replicator 2X Cura definition
{
"id": "makerbot_rep2x_1st",
"version": 2,
"name": "1st Extruder",
"inherits": "fdmextruder",
"metadata": {
"machine": "makerbot_replicator_2x",
"position": "0"
},
Cheef's Grand APDU List Smartcard Selected Information APDU list
Reference: http://web.archive.org/web/20090630004017/http://cheef.ru/docs/HowTo/APDU.info
#------------+------------------------+------------------------+----------------------+--------------------------------+
|ClaIns P1 P2|Lc Send Data |Le Recv Data | Specification | Description |
+------------+------------------------+------------------------+----------------------+--------------------------------+
| 04 | ISO 7816-9 6.3 | DEACTIVATE FILE |
| A0 04 00 00 00 | 3GPP TS 11.11 | INVALIDATE |
| A0 04 00 00 00 | SAGEM SCT U34 6.15 | INVALIDATE |
+------------+------------------------+------------------------+----------------------+--------------------------------+
@qlyoung
qlyoung / linux-clang-format
Created July 17, 2017 18:37
Linux kernel style .clang-format
---
BasedOnStyle: LLVM
Language: Cpp
IndentWidth: 8
UseTab: Always
BreakBeforeBraces: Linux
AlwaysBreakBeforeMultilineStrings: true
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
@vermorel
vermorel / Half.cs
Last active November 26, 2023 22:43
C# Half-precision data type
/// ================ Half.cs ====================
/// The code is free to use for any reason without any restrictions.
/// Ladislav Lang (2009), Joannes Vermorel (2017)
using System;
using System.Diagnostics;
using System.Globalization;
namespace SystemHalf
{
@JPvRiel
JPvRiel / journalctl_enable_persistent_storage.md
Last active January 24, 2024 20:23
Enable persistent storage for the systemd journal log

Enable persistent storage for the systemd journal log

Overview

The assumed default setting in /etc/systemd/journald.conf is Storage=auto which implies that systemd journaling will only persist the journal if the expected storage location is available. Otherwise, the journal data is stored in memory and lost between reboots. On Ubuntu 16.04, /var/log/journal does not exist by default. Create it to keep and query events from previous boots.

Considerations:

  • Syslog still provides the persistant log records for Ubuntu 16.04, so enabling persistant systemd journal logging does cause a level of duplicaiton.
  • There are sane defaults:
@ageis
ageis / systemd_service_hardening.md
Last active April 19, 2024 23:47
Options for hardening systemd service units

security and hardening options for systemd service units

A common and reliable pattern in service unit files is thus:

NoNewPrivileges=yes
PrivateTmp=yes
PrivateDevices=yes
DevicePolicy=closed
ProtectSystem=strict
@Robyer
Robyer / maven-publish-helper-usage.gradle
Last active June 15, 2023 04:22
Gradle script for publishing Android library with sources and javadoc to Maven repository using maven-publish plugin.
// You can use maven-publish-helper.gradle script without changes and even share it between multiple
// modules. Just place the maven-publish-helper.gradle file in the root directory of your project,
// then apply it at the bottom of your module's build.gradle file like this:
// ...content of module's build.gradle file...
apply from: '../maven-publish-helper.gradle'
publishing {
publications {