Skip to content

Instantly share code, notes, and snippets.

View 0xfeeddeadbeef's full-sized avatar

Giorgi Chakhidze 0xfeeddeadbeef

View GitHub Profile
@thesamesam
thesamesam / xz-backdoor.md
Last active May 22, 2024 14:41
xz-utils backdoor situation (CVE-2024-3094)

FAQ on the xz-utils backdoor (CVE-2024-3094)

This is a living document. Everything in this document is made in good faith of being accurate, but like I just said; we don't yet know everything about what's going on.

Background

On March 29th, 2024, a backdoor was discovered in xz-utils, a suite of software that

@bennadel
bennadel / api-client.js
Created January 9, 2022 14:18
Building An API Client With The fetch() API In JavaScript
// Regular expression patterns for testing content-type response headers.
var RE_CONTENT_TYPE_JSON = new RegExp( "^application/(x-)?json", "i" );
var RE_CONTENT_TYPE_TEXT = new RegExp( "^text/", "i" );
// Static strings.
var UNEXPECTED_ERROR_MESSAGE = "An unexpected error occurred while processing your request.";
export class ApiClient {
/**
* I initialize the API client.
// Copyright (c) 2019-2020 James M. Curran/Novel Theory LLC. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
namespace NovelTheory.Common
{
@ilyakurdyukov
ilyakurdyukov / faster_lzma_decoder_x86.patch
Last active June 18, 2023 17:04
Faster LZMA decoder for x86 CPUs (patch for XZ Utils).
From 387fd25f57f41009fc317f7922e957de9f370ff2 Mon Sep 17 00:00:00 2001
From: Ilya Kurdyukov <jpegqs@gmail.com>
Date: Tue, 14 Dec 2021 21:54:32 +0700
Subject: [PATCH] faster lzma_decoder for x86
Notice: Uses inline assembly with CMOV instruction.
Another change that removes the comparison with in_size can give a few
percent speedup for architectures with a small number of registers.
---
@0xfeeddeadbeef
0xfeeddeadbeef / Test-ProcessElevated.ps1
Last active November 30, 2023 04:02
Test whether or not a process is elevated (UAC run as admin)
function Test-ProcessElevated
{
[CmdletBinding()]
[OutputType([bool])]
param (
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
[System.Diagnostics.Process] $Process
)
begin {
// Copyright (c) 2019-2020 James M. Curran/Novel Theory LLC. All rights reserved.
// Licensed under the Apache License, Version 2.0.
// See License.txt in the project root for license information.
using System;
using System.Diagnostics;
using Microsoft.Extensions.Logging;
namespace NovelTheory.Common
{
@EgorBo
EgorBo / Dynamic PGO in .NET 6.0.md
Last active January 25, 2024 15:15
Dynamic PGO in .NET 6.0.md

Dynamic PGO in .NET 6.0

Dynamic PGO (Profile-guided optimization) is a JIT-compiler optimization technique that allows JIT to collect additional information about surroundings (aka profile) in tier0 codegen in order to rely on it later during promotion from tier0 to tier1 for hot methods to make them even more efficient.

What exactly PGO can optimize for us?

  1. Profile-driving inlining - inliner relies on PGO data and can be very aggressive for hot paths and care less about cold ones, see dotnet/runtime#52708 and dotnet/runtime#55478. A good example where it has visible effects is this StringBuilder benchmark:

  2. Guarded devirtualization - most monomorphic virtual/interface calls can be devirtualized using PGO data, e.g.:

void DisposeMe(IDisposable d)
@cezarypiatek
cezarypiatek / SigningAssembly.md
Last active January 28, 2024 16:37
Signing assembly
  1. Generate SNK file (you need to run console as admin)
& "C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64\sn.exe" -k ./MyKeys.snk
  1. Converting SNK file to base64 text file using PowerShell
@richlander
richlander / modernizing-csharp9.md
Last active April 26, 2024 17:14
Modernizing a codebase for C# 9

Modernizing a codebase for C# 9

There are lots of cases that you can improve. The examples use nullable reference types, but only the WhenNotNull example requires it.

Use the property pattern to replace IsNullorEmpty

Consider adopting the new property pattern, wherever you use IsNullOrEmpty.

string? hello = "hello world";
using System;
using System.Collections.Generic;
using System.Linq;
namespace [YOURNAMESPACEHERE]
{
public static class TypeExtensions
{
public static bool IsDerivingFrom(this Type type, Type searchType)