Skip to content

Instantly share code, notes, and snippets.

View KirillOsenkov's full-sized avatar

Kirill Osenkov KirillOsenkov

View GitHub Profile
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
UUIDv7 uuid = new UUIDv7();
Console.WriteLine(uuid.ToString());
public readonly struct UUIDv7 {
@gd3kr
gd3kr / script.js
Created February 15, 2024 06:30
Download a JSON List of twitter bookmarks
/*
the twitter api is stupid. it is stupid and bad and expensive. hence, this.
Literally just paste this in the JS console on the bookmarks tab and the script will automatically scroll to the bottom of your bookmarks and keep a track of them as it goes.
When finished, it downloads a JSON file containing the raw text content of every bookmark.
for now it stores just the text inside the tweet itself, but if you're reading this why don't you go ahead and try to also store other information (author, tweetLink, pictures, everything). come on. do it. please?
*/
@Washi1337
Washi1337 / TinySharp.cs
Last active November 3, 2024 16:00
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;
using System;
using System.Threading.Tasks;
using System.Linq;
Console.WriteLine("yeah true");
class Keywords {
public unsafe dynamic select() {
var var = new int*[] {};
var set = (IGrouping<int*[], IGrouping<int*[], object>>) null;
#nullable disable
#pragma warning disable IDE0004, IDE0049, IDE0052, IDE0055, IDE0060, CS1998, CS0626
using static System.Runtime.CompilerServices.Unsafe;
class A
{
Func<Task<object>> _x;
public object X
{
@sayedihashimi
sayedihashimi / msbuild-error-format.md
Last active May 13, 2024 20:38
MSBuild and Visual Studio Known Error Message Formats

MSBuild and Visual Studio Known Error Message Formats

When a tool is executed that outputs some text, MSBuild will examine the text for errors and warnings. Many tools use a known format to report these messages. By default, MSBuild will examine the text and report errors and/or warnings based on the output. This behavior can be changed or disabled by using these parameters on the Exec task: IgnoreStandardErrorWarningFormat, CustomErrorRegularExpression, and CustomWarningRegularExpression.

NOTE: If you do decide to use your own regular expression to detect error and warnings, then

/// <summary>
/// Export a <see cref="IClassifierProvider"/>
/// </summary>
[Export(typeof(IClassifierProvider))]
[ContentType("code")]
internal class VideoCommentClassifierProvider : IClassifierProvider
{
[Export(typeof(ClassificationTypeDefinition))]
[Name("video comment")]
internal ClassificationTypeDefinition VideoCommentClassificationType = null;
@badamczewski
badamczewski / Morph.cs
Created December 1, 2020 14:11
Text Morphing in WPF
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;
namespace WPFAnimations
<!DOCTYPE html>
<html>
<head>
<style>
.editor { font-family: 'Roboto Mono', monospace; font-size: 12px; outline: none; overflow-y: auto; padding-left: 48px; counter-reset: line; }
.editor div { display: block; position: relative; white-space: pre-wrap; }
.editor div::before { content: counter(line); counter-increment: line; position: absolute; right: calc(100% + 16px); opacity: 0.5; }
</style>
</head>
@KirillOsenkov
KirillOsenkov / AddGeneratedFile.csproj
Last active November 12, 2024 14:46
Sample of generating a .cs file during build and adding it to the compilation
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net472</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<GeneratedText><![CDATA[
using System%3B