Skip to content

Instantly share code, notes, and snippets.

@tnn4
tnn4 / decisive.framework.md
Last active January 6, 2024 16:19
decisive framework

WRAP Framework for making better decisions.

Helps avoid common decision-making biases.

WRAP

  • Widen your options
  • Reality-test assumptions
  • Attain distance
  • Prepare to be wrong
@tnn4
tnn4 / c#-tips.md
Last active March 16, 2023 17:09
C# tips

C# inlining

using System.Runtime.CompilerServices; 

public class inliningExample{
  [MethodImpl(MethodImplOptions.AggressiveInlining)]
  public void methodToInline(){
    System.Console.WriteLine("I got inlined");  
  }
@tnn4
tnn4 / closures.md
Last active March 6, 2023 22:52
closure notes

Closures

  • The function closes over its outer environment.
  • The function is "bound" to the outer scope variables.
  • Closures are about data persistence.
  • Allow functions to keep track of local state

What would happen if there were no closure?

Look at the following example.

@tnn4
tnn4 / minimize-screen-tearing-fps-hz.md
Last active April 23, 2023 21:53
Screen Tearing Interaction between fps and Hz (Harmonic Frequencies) and how to minimize it

How to minimize screen tearing if not using v-sync

What causes screen tearing?

The monitor and screen buffer(that the GPU writes to) are out of sync.

If the GPU sends a new image to the monitor while it's in the middle of rendering an image, the monitor will continue to render the image but with the latest data sent from the GPU (so it's not the same image at the top and the bottom of the tearing). 1

Screen tearing is maximized when the GPU is rendering max frames that is a harmonic of the refresh rate.

@tnn4
tnn4 / vs-create-installer.ps1
Last active March 6, 2023 22:33
Visual Studio offline install scripts for C++ Desktop
# e.g. vs_enterprise.exe --layout c:\VSLayout --all
$LAYOUT_PATH="vs-layout-all"
$BOOTSTRAPPER="vs_Community.exe"
$WORKLOAD_DOTNET="Microsoft.VisualStudio.Workload.ManagedDesktop"
$WORKLOAD_CPP=""
# create installer with all components
./vs_Community.exe --layout $LAYOUT_PATH --lang en-us --all
@tnn4
tnn4 / power-shell-examples.md
Last active March 16, 2023 16:50
set environment variable

Powershell Examples

Check if environment variables exist

if ($null -eq $env:FOO) {echo "it's null"}

Allow scripts

If you get an error that running scripts on the system is disabled:

Set-ExecutionPolicy -executionPolicy RemoteSigned -Scope CurrentUser

@tnn4
tnn4 / git-example.md
Last active May 29, 2023 20:45
git examples

git-examples

Init git repo

# GIT INIT
# create repo on Github, requires https://cli.github.com/
gh repo create

## initialize directory for git
git init
@tnn4
tnn4 / install-wsl.ps1
Created March 3, 2023 23:02
install wsl with powershell script
# Install wsl
# this script requires administrator privileges
# check if running as administrator
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
$is_running_as_admin = $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if($is_running_as_admin) {
# continue
}
@tnn4
tnn4 / path.md
Last active March 16, 2023 16:44
paths in different languages

Paths in different languages

Python

import sys
import os

print("\n")
print("sys.path[0] = ", sys.path[0])
print("os.path.dirnam(__file__) = ", os.path.dirname(__file__))
@tnn4
tnn4 / README.md
Last active September 27, 2023 16:03
linux ssh setup

SSH setup

ssh help: man ssh

Install ssh server

sudo apt install openssh-server

Start ssh server