Skip to content

Instantly share code, notes, and snippets.

View Tamschi's full-sized avatar
🃏
Increasingly doing a little of everything

Tamme Schichler Tamschi

🃏
Increasingly doing a little of everything
View GitHub Profile
@Tamschi
Tamschi / dyn_allocator.rs
Last active December 2, 2022 17:59
Runtime polymorphic allocator for Rust (i.e. C++-style mixing for supporting smart pointers 😉).
// Works with: nightly-2022-12-02
//! Runtime polymorphic allocator for Rust (i.e. C++-style mixing for supporting smart pointers 😉).
//!
//! Not sure why you'd ever want to use this, but here it is for when you need to.
#![allow(incomplete_features)] // generic_const_exprs
#![feature(allocator_api, ptr_metadata, generic_const_exprs)]
#![no_std]
@Tamschi
Tamschi / 0info.md
Last active November 18, 2022 09:20
Twitter User Info Downloader for Twitter Data Export Files

Twitter User Info Downloader for Twitter Data Export Files

Respects the rate limit nicely, shows a progress bar, handles some errors (you may need to adjust this if it gets stuck) and skips already downloaded valid profiles when re-run.

How to Use

  • Download this gist as zip file and extract it into a new folder somewhere.
  • Move main.rs in a src/ subfolder.
@Tamschi
Tamschi / pretty.rs
Last active March 17, 2022 19:38
Compact JSON Prettifier (MIT-licensed)
//! Formats JSON in a slightly more compact way, by not introducing line breaks between array elements.
//!
//! Any non-coding ASCII-whitespace is removed or replaced with `b' '` (simple space) and/or `b'\n'`.
/**
* MIT License
*
* Copyright (c) 2022 Tamme Schichler <tamme@schichler.dev>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
using System;
using System.Threading;
struct InterlockingLock : IDisposable
{
object _lock;
public InterlockingLock(object @lock)
{
_lock = @lock;
@Tamschi
Tamschi / speedparse-int.cs
Last active March 22, 2017 20:14
Integer Speedparser
public static int Parse(string str)
{
unchecked
{
int n = 0;
int l = str.Length - 1;
for (int i = l, x = 1; i >= 0; i--, x *= 10)
{
switch (str[i])
{
@Tamschi
Tamschi / TERRIBLESORT
Created May 11, 2016 16:22
A very slow sorting algorithm (but at least it's apparently kind of small).
-- HUMAN RESOURCE MACHINE PROGRAM --
COPYFROM 24
COMMENT 0
a:
COPYTO 24
b:
c:
INBOX
COPYTO [24]
@Tamschi
Tamschi / IEnumerable.cs
Last active August 29, 2015 14:19
A compiler bug (I'm fairly sure it doesn't match the specification that is.) in VS 2013 that causes unnecessary boxing:
using System.Collections.Generic;
public interface IEnumerable<T, TEnumerator> : IEnumerable<T>
{ new TEnumerator GetEnumerator(); }
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
namespace Messing_around_with_Async
{
internal class Program
{
[CompilerGenerated]
@Tamschi
Tamschi / RatchetStream.cs
Last active August 29, 2015 13:59
Blocking Stream ratchet thing
/*
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
type tree<'a> (root : 'a, children : 'a tree list) =
new (root, [<System.ParamArray>]children) = tree(root, List.ofArray children)
member this.Root = root
member this.Children = children
let rec lines
format
(t : 'a tree)
: string seq
=