Skip to content

Instantly share code, notes, and snippets.

@wojteklu
wojteklu / clean_code.md
Last active May 4, 2024 14:50
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@AndruC
AndruC / Roll20 Macros.md
Last active May 4, 2024 14:50
Macros that I use to improve my D&D games

Macro Must-Haves

These are my must-have macros for running games online. I make full use of the compendium, which gives these macros access to common actions and rolls, saving me time.

Remember to add /w gm or @{selected|wtype} to hide sensitive info from your players. WTYPE is an attribute used in the 5th Edition OGL character sheet, a prerequisite for most of these.

Here's what my bar looks like.

Macro Quickbar

@munrocket
munrocket / wgsl_noise.md
Last active May 4, 2024 14:50
WGSL Noise Algorithms

WGSL Noise Algorithms

Operator % has changed, probably current code with it need a fix

Good and fast integer hash

// https://www.pcg-random.org/
fn pcg(n: u32) -> u32 {
    var h = n * 747796405u + 2891336453u;
    h = ((h >> ((h >> 28u) + 4u)) ^ h) * 277803737u;
@jclosure
jclosure / docker_reverting
Created June 5, 2015 08:07
How to revert a docker container to a previous commit
$ docker history imagename
IMAGE CREATED CREATED BY SIZE
f770fc671f11 12 seconds ago apt-get install -y curl 21.3 MB
28445c70c2b3 39 seconds ago apt-get install ping 11.57 MB
8dbd9e392a96 7 months ago 131.5 MB
$ docker tag 2844 imagename # <-- that's the secret right there
$ docker history imagename
IMAGE CREATED CREATED BY SIZE
@e-desouza
e-desouza / vlc-osx-delete.lua
Created August 23, 2020 04:12
Delete current file on disk and playlist in VLC (OSX only)
--[[
Copyright 2020 wizard
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
using System;
using System.Buffers;
using System.Reflection;
using System.Runtime.InteropServices;
public static unsafe class MbcsStringMarshaller
{
private static byte[]? s_buffer;
private static readonly GetAnsiStringByteCount s_getAnsiStringByteCount;
@karansinghgit
karansinghgit / del_vscode_mac.md
Last active May 4, 2024 14:40
How to completely uninstall VSCode on Mac
  1. Close and Quit VSCode

  2. Remove VScode from Applications (just go to Finder -> Applications and move VSCode to Bin)

  3. Execute these commands in any order. The paths might be slightly different for you.

rm -fr ~/.vscode*
rm -fr ~/Library/Application\ Support/Code/

rm -fr ~/Library/Saved\ Application\ State/com.microsoft.VSCode.savedState/
rm -fr ~/Library/Preferences/com.microsoft.VSCode.helper.plist 
@bmaupin
bmaupin / free-database-hosting.md
Last active May 4, 2024 14:38
Free database hosting
@ibireme
ibireme / kpc_demo.c
Last active May 4, 2024 14:37
A demo shows how to read Intel or Apple M1 CPU performance counter in macOS.
// =============================================================================
// XNU kperf/kpc demo
// Available for 64-bit Intel/Apple Silicon, macOS/iOS, with root privileges
//
//
// Demo 1 (profile a function in current thread):
// 1. Open directory '/usr/share/kpep/', find your CPU PMC database.
// M1 (Pro/Max/Ultra): /usr/share/kpep/a14.plist
// M2 (Pro/Max): /usr/share/kpep/a15.plist
// M3: /usr/share/kpep/as1.plist
@shunchu
shunchu / convert-seconds-into-hh-mm-ss-in-ruby.rb
Created July 25, 2012 07:58
Convert seconds into HH:MM:SS in Ruby
t = 236 # seconds
Time.at(t).utc.strftime("%H:%M:%S")
=> "00:03:56"
# Reference
# http://stackoverflow.com/questions/3963930/ruby-rails-how-to-convert-seconds-to-time