Skip to content

Instantly share code, notes, and snippets.

View 0x6675636b796f75676974687562's full-sized avatar

Andrey S. 0x6675636b796f75676974687562

  • ex-@JetBrains, now Umbrella Corp.
  • Shenzhen, China
View GitHub Profile
@Washi1337
Washi1337 / TinySharp.cs
Last active January 5, 2025 18:55
A program to emit a tiny .NET binary program printing Hello World to the standard output. Blog post: https://blog.washi.dev/posts/tinysharp/
using System.Text;
using AsmResolver;
using AsmResolver.DotNet;
using AsmResolver.DotNet.Builder.Metadata.Blob;
using AsmResolver.DotNet.Builder.Metadata.Strings;
using AsmResolver.DotNet.Code.Cil;
using AsmResolver.DotNet.Signatures;
using AsmResolver.IO;
using AsmResolver.PE;
using AsmResolver.PE.DotNet.Builder;
"
" .vimrc
"
" vim:ft=vim
"
" Windows-specific defaults
if (has("win32") || has("win16"))
if filereadable(expand("$VIM/_vimrc"))
source $VIM/_vimrc
@MarioCarrion
MarioCarrion / init.lua
Last active January 18, 2025 07:45
init.vim to init.lua migration
vim.g.mapleader = ","
vim.opt.filetype="on"
vim.opt.filetype.indent="on"
vim.opt.filetype.plugin="on"
vim.opt.encoding="utf-8"
vim.opt.syntax="on"
vim.opt.compatible=false
## Parameter Expansion 1: "$PARAMETER"
i=$(zsh -c "echo {1..100000}"); time (: "$i";: "$i";: "$i";: "$i";: "$i";: "$i";: "$i";: "$i";: "$i";: "$i";: "$i";: "$i";: "$i";: "$i";: "$i";: "$i";: "$i";: "$i";: "$i";: "$i";)
## Parameter Expansion 2: $PARAMETER
i=$(zsh -c "echo {1..100000}"); time (: $i;: $i;: $i;: $i;: $i;: $i;: $i;: $i;: $i;: $i;: $i;: $i;: $i;: $i;: $i;: $i;: $i;: $i;: $i;: $i;)
## Parameter Expansion 3: "${PARAMETER##*/}" (modifier)
path=/foo/bar; time (for i in {1..100000}; do : "${path##*/}";: "${path##*/}";: "${path##*/}";: "${path##*/}";: "${path##*/}";: "${path##*/}";: "${path##*/}";: "${path##*/}";: "${path##*/}";: "${path##*/}"; done)
## Array Parameter Expansion 1: "${ARRAY[1]}" (one element)
i=($(zsh -c "echo {1..1000000}")); time (for j in {1..10000}; do : "${i[1]}";: "${i[20]}";: "${i[300]}";: "${i[4000]}";: "${i[50000]}"; done)
## Array Parameter Expansion 2: "${ARRAY[@]}" (all elements)
i=($(zsh -c "echo {1..1000000}")); time (: "${i[@]}";: "${i[@]}";: "${i[@]}";: "${i[@]}";: "${i[
#!/bin/zsh
set -u
emulate -R ksh
sudo renice -10 $$ >/dev/null
time2sec() {
local time="$1"
shift
@tekin
tekin / .gitattributes
Last active March 10, 2026 16:21
An example .gitattributes file that will configure custom hunk header patterns for some common languages and file formats. See https://tekin.co.uk/2020/10/better-git-diff-output-for-ruby-python-elixir-and-more for more details.
# Stick this in your home directory and point your Global Git config at it by running:
#
# $ git config --global core.attributesfile ~/.gitattributes
#
# See https://tekin.co.uk/2020/10/better-git-diff-output-for-ruby-python-elixir-and-more for more details
*.c diff=cpp
*.h diff=cpp
*.c++ diff=cpp
*.h++ diff=cpp
@ChristopherA
ChristopherA / brew-bundle-brewfile-tips.md
Last active March 13, 2026 19:22
Brew Bundle Brewfile Tips

Brew Bundle Brewfile Tips

Copyright & License

Unless otherwise noted (either in this file or in a file's copyright section) the contents of this gist are Copyright ©️2020 by Christopher Allen, and are shared under spdx:Creative Commons Attribution Share Alike 4.0 International (CC-BY-SA-4.) open-source license.

Sponsor

If you more tips and advice like these, you can become a monthly patron on my GitHub Sponsor Page for as little as $5 a month; and your contributions will be multipled, as GitHub is matching the first $5,000! This gist is all about Homebrew, so if you like it you can support it by donating to them or becoming one of their Github Sponsors.

@djfdyuruiry
djfdyuruiry / README.md
Last active October 8, 2024 04:54
WSL 2 - Enabling systemd

Enable systemd in WSL 2

NOTE: If you have Windows 11 there is now an official way to do this in WSL 2, use it if possible - see MS post here (WINDOWS 11 ONLY)

This guide will enable systemd to run as normal under WSL 2. This will enable services like microk8s, docker and many more to just work during a WSL session. Note: this was tested on Windows 10 Build 2004, running Ubuntu 20.04 LTS in WSL 2.

  • To enable systemd under WSL we require a tool called systemd-genie

  • Copy the contents of install-sg.sh to a new file /tmp/install-sg.sh:

@t27
t27 / linux-oom-killer-fixes.md
Last active March 17, 2026 10:58
Dealing with the Linux OOM Killer

Dealing with the Linux OOM Killer at the program level

Do this in cases when you dont want to change the os-level settings, but only want to disable the OOM killer for a single process. This is useful when youre on a shared machine/server.

The OOM killer uses the process level metric called oom_score_adj to decide if/when to kill a process. This file is present in /proc/$pid/oom_score_adj. The oom_score_adj can vary from -1000 to 1000, by default it is 0.

You can add a large negative score to this file to reduce the probability of your process getting picked and terminated by OOM killer. When you set it to -1000, it can use 100% memory and still avoid getting terminated by OOM killer.