Skip to content

Instantly share code, notes, and snippets.

@mdmaas
mdmaas / vector_vs_stack_array.cpp
Created April 5, 2023 06:44
Simple performance benchmark of stack, heap, and pre-allocated arrays and std::vector
// g++ vector_vs_stack_array.cpp -O3 -o vector
#include <numeric>
#include <vector>
#include <chrono>
#include <iostream>
#include <cmath>
using namespace std::chrono;
double sumNewArray( int N ) {
@madelinegannon
madelinegannon / jetson-nano_openFrameworks_setup_tutorial.md
Last active February 4, 2024 16:41
How to Set Up the NVIDIA Jetson Nano for openFrameworks
@GrabYourPitchforks
GrabYourPitchforks / memory_guidelines.md
Last active April 21, 2024 07:45
Memory usage guidelines

Memory<T> usage guidelines

This document describes the relationship between Memory<T> and its related classes (MemoryPool<T>, IMemoryOwner<T>, etc.). It also describes best practices when accepting Memory<T> instances in public API surface. Following these guidelines will help developers write clear, bug-free code.

First, a tour of the basic exchange types

  • Span<T> is the basic exchange type that represents contiguous buffers. These buffers may be backed by managed memory (such as T[] or System.String). They may also be backed by unmanaged memory (such as via stackalloc or a raw void*). The Span<T> type is not heapable, meaning that it cannot appear as a field in classes, and it cannot be used across yield or await boundaries.

  • Memory is a wrapper around an object that can generate a Span. For instance, Memory instances can be backed by T[], System.String (readonly), and even SafeHandle instances. Memory cannot be backed by "transient" unmanaged me

@jvcleave
jvcleave / build_cross_gcc.sh
Last active November 1, 2019 07:18
Stretch build
#! /bin/bash
set -e
trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG
trap 'echo FAILED COMMAND: $previous_command' EXIT
#-------------------------------------------------------------------------------------------
# This script will download packages for, configure, build and install a GCC cross-compiler.
# Customize the variables (INSTALL_PATH, TARGET, etc.) to your liking before running.
# If you get an error and need to resume the script from some point in the middle,
# just delete/comment the preceding lines before running it again.
@joshbernfeld
joshbernfeld / CMTime+Codable.swift
Created January 11, 2018 05:07
Swift encoding/decoding support for CMTime
extension CMTime: Codable {
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.value = try container.decode(CMTimeValue.self, forKey: .value)
self.timescale = try container.decode(CMTimeScale.self, forKey: .timescale)
self.flags = CMTimeFlags(rawValue: try container.decode(UInt32.self, forKey: .flags))
self.epoch = try container.decode(CMTimeEpoch.self, forKey: .epoch)
}
@kashimAstro
kashimAstro / ofwpaconfig.cpp
Last active November 12, 2016 13:32
configure wpa_supplicant.conf
#include "ofMain.h"
#include "ofAppNoWindow.h"
#define WPA_PATH "/etc/wpa_supplicant/wpa_supplicant.conf"
class ofApp : public ofBaseApp
{
public:
string essid;
string passwd;
@JoshuaSullivan
JoshuaSullivan / ColorCubeHelper-swift2.swift
Last active April 17, 2024 10:48
Here are the Swift 2.3 and Swift 3.0 versions of the ColorCubeHelper class.
//
// ColorCubeHelper.swift
//
// Created by Joshua Sullivan on 10/01/16.
// Copyright © 2016 Joshua Sullivan. All rights reserved.
//
import UIKit
import Accelerate
@Vanlalhriata
Vanlalhriata / GameHost.cs
Created August 23, 2016 14:39
Host Unity game in WPF
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Interop;
namespace KinectRun.Host.Controls
{
// GameHost is a FrameworkElement and can be added to controls like so:
// var gameHost = new GameHost(container.ActualWidth, container.ActualHeight);
@alirobe
alirobe / reclaimWindows10.ps1
Last active April 26, 2024 17:59
This Windows 10 Setup Script turns off a bunch of unnecessary Windows 10 telemetery, bloatware, & privacy things. Not guaranteed to catch everything. Review and tweak before running. Reboot after running. Scripts for reversing are included and commented. Fork of https://github.com/Disassembler0/Win10-Initial-Setup-Script (different defaults). N.…
###
###
### UPDATE: For Win 11, I recommend using this tool in place of this script:
### https://christitus.com/windows-tool/
### https://github.com/ChrisTitusTech/winutil
### https://www.youtube.com/watch?v=6UQZ5oQg8XA
### iwr -useb https://christitus.com/win | iex
###
###
@timonsku
timonsku / Cross compiler for RPi, Jessie, openFrameworks 0.9
Last active October 30, 2015 21:53 — forked from jvcleave/ Cross compiler for RPi, Jessie, openFrameworks 0.9
Instructions for building a Jessie VM to cross-compile openFrameworks 0.9 applications for the Raspberry Pi 1 (arm7)
#ON THE RPI (if you haven't downloaded openFrameworks)
cd
curl -O http://192.237.185.151/versions/nightly/of_v20151008_linuxarmv6l_nightly.tar.gz
mkdir openFrameworks
tar vxfz of_v20151008_linuxarmv6l_nightly.tar.gz -C openFrameworks --strip-components 1
cd /home/pi/openFrameworks/scripts/linux/debian
sudo ./install_dependencies.sh
#INSTALL SMB WITH / ACCESS