Skip to content

Instantly share code, notes, and snippets.

@ranma42
ranma42 / LazyStream.cs
Created May 16, 2024 11:16
Partial response hack
public class LazyStream(
long length,
Func<Task<Stream>> factory
) : Stream {
public override long Position {
get => _position;
set {
if (value < 0 || value > length) {
throw new ArgumentOutOfRangeException(nameof(value), value, "Position must be between 0 and the length of the stream.");
}
@ranma42
ranma42 / Makefile
Created March 24, 2017 08:01
Experiments with the compression of rust tarballs
TARGETS = \
files.bsd.tar.gz \
files.bsd.tar.gz9 \
files.bsd.tar.bz2 \
files.bsd.tar.xz \
files.bsd.tar.xz9 \
files.gnu.tar.gz \
files.gnu.tar.gz9 \
files.gnu.tar.bz2 \
files.gnu.tar.xz \
@ranma42
ranma42 / my-cairo-hack.patch
Created January 26, 2017 18:01
Hack to (force-)enable cairo Xlib backend on Tiger
diff --git a/Library/Formula/cairo.rb b/Library/Formula/cairo.rb
index 0d4d2aa..a0cfe01 100644
--- a/Library/Formula/cairo.rb
+++ b/Library/Formula/cairo.rb
@@ -8,11 +8,8 @@ class Cairo < Formula
keg_only :provided_pre_mountain_lion
option :universal
- # Tiger's X11 is simply way too old
- option 'without-x', 'Build without X11 support' if MacOS.version > :tiger
@ranma42
ranma42 / HOMEBREW_MAKE_JOBS=1 VERBOSE=1 brew install cairo
Created January 19, 2017 11:21
Tigerbrew successfully installing cairo (from the fix_cairo PR)
==> Downloading https://cairographics.org/releases/cairo-1.14.8.tar.xz
/usr/local/opt/curl/bin/curl -fLA Tigerbrew 0.9.5 (Ruby 1.8.2; OS X 10.4.11) https://cairographics.org/releases/cairo-1.14.8.tar.xz -C 0 -o /Library/Caches/Homebrew/cairo-1.14.8.tar.xz.incomplete
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 33.7M 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 33.7M 0 224k 0 0 132k 0 0:04:21 0:00:01 0:04:20 132k
4 33.7M 4 1680k 0 0 616k 0 0:00:56 0:00:02 0:00:54 616k
6 33.7M 6 2080k 0 0 551k 0 0:01:02 0:00:03 0:00:59 551k
@ranma42
ranma42 / HOMEBREW_MAKE_JOBS=1 VERBOSE=1 brew install cairo
Created January 19, 2017 11:16
Installing cairo on tigerbrew (without python 2.5)
==> Installing dependencies for cairo: glib
==> Installing cairo dependency: glib
==> Downloading https://download.gnome.org/sources/glib/2.50/glib-2.50.1.tar.xz
Already downloaded: /Library/Caches/Homebrew/glib-2.50.1.tar.xz
==> Verifying glib-2.50.1.tar.xz checksum
==> Downloading https://raw.githubusercontent.com/Homebrew/patches/59e4d327791d4fe3423c2c871adb98e3f3f07633/glib/hardcoded-paths.diff
Already downloaded: /Library/Caches/Homebrew/glib--patch-a4cb96b5861672ec0750cb30ecebe1d417d38052cac12fbb8a77dbf04a886fcb.diff
==> Verifying glib--patch-a4cb96b5861672ec0750cb30ecebe1d417d38052cac12fbb8a77dbf04a886fcb.diff checksum
==> Downloading https://raw.githubusercontent.com/Homebrew/formula-patches/a39dec26/glib/gio.patch
Already downloaded: /Library/Caches/Homebrew/glib--patch-284cbf626f814c21f30167699e6e59dcc0d31000d71151f25862b997a8c8493d.patch
@ranma42
ranma42 / bluss.s
Created December 3, 2016 10:10
Assembly output of the original example for https://github.com/rust-lang/rust/pull/37921
.text
.file "bluss.cgu-0.rs"
.section .text._ZN5bluss16round_trip_slice17h8927e0fb49da9351E,"ax",@progbits
.globl _ZN5bluss16round_trip_slice17h8927e0fb49da9351E
.p2align 4, 0x90
.type _ZN5bluss16round_trip_slice17h8927e0fb49da9351E,@function
_ZN5bluss16round_trip_slice17h8927e0fb49da9351E:
.cfi_startproc
movq %rdi, %rax
movq %rsi, %rdx
@ranma42
ranma42 / 0001-Combine-GEPs.patch
Last active December 2, 2016 15:50
Patch to combine GEPs
From fe155df2fd7778c6602696055f7ebd0ddf433c3d Mon Sep 17 00:00:00 2001
From: Andrea Canciani <ranma42@gmail.com>
Date: Fri, 2 Dec 2016 16:21:02 +0100
Subject: [PATCH] Combine GEPs
---
lib/Transforms/InstCombine/InstructionCombining.cpp | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/lib/Transforms/InstCombine/InstructionCombining.cpp b/lib/Transforms/InstCombine/InstructionCombining.cpp
test.o: file format elf32-i386
Disassembly of section .text:
00000000 <add>:
0: 83 ec 0c sub $0xc,%esp
3: f2 0f 10 44 24 10 movsd 0x10(%esp),%xmm0
9: f2 0f 58 44 24 18 addsd 0x18(%esp),%xmm0
@ranma42
ranma42 / enum4.ll
Created September 30, 2015 09:30
Experiments with removal of identical code blocks
; ModuleID = 'enum4.0.rs'
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-darwin"
%E32 = type { i32, [0 x i32], [1 x i32] }
; Function Attrs: inlinehint nounwind readonly uwtable
define zeroext i1 @_ZN25E32...std..cmp..PartialEq2eq20h5da5b35084c7cd82taaE(%E32* noalias nocapture readonly dereferenceable(8), %E32* noalias nocapture readonly dereferenceable(8)) unnamed_addr #0 {
entry-block:
%2 = getelementptr inbounds %E32, %E32* %0, i64 0, i32 0
@ranma42
ranma42 / bench-slice-cmp.rs
Created September 16, 2015 07:26
Benchmark for slice comparison in Rust
#![feature(iter_order)]
#![feature(test)]
extern crate test;
macro_rules! gen_bench {
($name:ident, $x: expr, $y: expr) => {
#[bench]
fn $name(b: &mut Bencher) {
b.iter(|| { black_box($x).$name(black_box($y)) })
}