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
  • 14:31 (UTC +08:00)
View GitHub Profile
@Washi1337
Washi1337 / TinySharp.cs
Last active June 9, 2024 04:37
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
"
set nocompatible
if &term == "xterm"
let &term = "xterm-256color"
endif
## 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 February 23, 2024 16:46
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
@djfdyuruiry
djfdyuruiry / README.md
Last active April 28, 2024 08:34
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 June 14, 2024 12:39
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.

@ajkaanbal
ajkaanbal / Makefile
Created March 29, 2019 16:41 — forked from saitoha/Makefile
SIXEL color graphics DEMO (xterm pl#301 and gnuplot)
#
# SIXEL color graphics DEMO
#
# xterm pl#301 with --enable-sixel-graphics option
# gnuplot with --with-bitmap-terminals option
#
# Now the color palette of xterm VT-340 mode is limited to 16.
# If you want to change it to 256, apply the following patch.
# https://gist.github.com/saitoha/7822989/raw/20727b88f0f826bfcb9d644907944b29a456b67f/graphics.c.diff
#
@benasher44
benasher44 / kn_gtest_to_junit.sed
Last active February 28, 2023 15:45
K/N GTest Output to JUnit XML using sed
# Escape XML characters
s/&/\&/g
s/"/\"/g
s/'/\'/g
s/</\&lt;/g
s/>/\&gt;/g
s/\[==========\] Running ([0-9]+) tests from [0-9]+ test cases./<testsuites><testsuite tests="\1">/g
s/\[ RUN \] ([[:alnum:]_-]+)\.(.+)/<testcase classname="\1" name="\2">/g
s/\[----------\].+//g