Skip to content

Instantly share code, notes, and snippets.

@nicowilliams
nicowilliams / bisect-rebase.sh
Last active April 28, 2024 01:46
Bisection, but for git rebase, to quickly rebase across thousands of upstream commits
# Viktor Dukhovni's (@vdukhovni) slow rebase, made faster by bisecting, sort of
#
# fastrebase BRANCH_TO_REBASE ONTO
function fastrebase {
typeset b N
if (($# > 0)) && [[ $1 = -h || $1 = --help ]]; then
printf 'Usage: fastrebase BRANCH_TO_REBASE ONTO_HEAD\n'
printf ' fastrebase # to continue after resolving conflicts\n'
printf '\n\tfastrebase is a shell function that uses the following\n'
#!/usr/bin/env python
# Takes the output of `cargo +nightly build -Z unstable-options --build-plan` and produces
# a graphviz .dot file.
from __future__ import print_function, unicode_literals
import sys
import json
with open(sys.argv[1]) as f:
@withoutboats
withoutboats / constraint-kinds.md
Last active January 9, 2023 17:14
Constraint Kinds in Rust

Notes on adding Constraint Kinds to Rust

Background: Constraint Kinds

a trait can be thought of as a type operator generating a "constraint" - what in Rust would usually be called a bound. For example:

// Declares a new item `Foo` with kind `type -> constraint`
trait Foo { }
@ErikAugust
ErikAugust / spectre.c
Last active May 22, 2024 23:07
Spectre example code
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#ifdef _MSC_VER
#include <intrin.h> /* for rdtscp and clflush */
#pragma optimize("gt",on)
#else
#include <x86intrin.h> /* for rdtscp and clflush */
#endif
@petermolnar
petermolnar / unfix-all-the-toolbars.user.js
Last active June 29, 2022 07:25 — forked from vbuaraujo/unfix-all-the-toolbars.user.js
GreaseMonkey script to remove "position: fixed" from webpages
// ==UserScript==
// @name unfix-all-the-toolbars
// @description Removes "position: fixed" style from elements, unfixing "toolbars" and the such.
// @namespace http://inf.ufrgs.br/~vbuaraujo/
// @include *
// @version 1.2
// @grant none
// ==/UserScript==
anonymous
anonymous / Cargo.toml
Created December 23, 2017 16:23
LazyArc
[dependencies]
parking_lot_core = "0.1"
@Kimundi
Kimundi / client.rs
Last active December 18, 2017 17:14
extern {
fn magic() -> i32;
}
#[no_mangle]
pub extern fn calc(a: i32, b: i32) -> i32 {
a + b + unsafe{magic()} + 10000
}
#![feature(lang_items)]
#![no_std]
#[no_mangle]
pub fn add_one(x: i32) -> i32 {
x + 1
}
// needed for no_std
anonymous
anonymous / playground.rs
Created November 5, 2017 21:10
Rust code shared from the playground
// Did you ever want to have a compile-time evaluated string and didn't
// want to use so called "procedural macros" because it's too easy to
// have that with those? Well, now you can.
//
// ... Oh, right, there is a small catch. The computation has to be in
// Brainfuck. But I mean, it's Turing complete, so you can do any
// computation you like, so it's not a big deal, is it?
//
// Scroll down to the end to see usage, but essentially this file
// defines `bf!` macro to which you can pass whatever Brainfuck code
@ddresselhaus
ddresselhaus / .vimrc
Last active January 21, 2021 18:05
run Elixir tests in a separate tmux pane
" when triggering this command, vim will grab your path and line location and pass it along
map <Leader>el :call RemoteSendCommand(TestLineCommand(expand("%:p"), line(".")))<CR>
" because I'm mostly writing Elixir and making heavy use of the REPL while writing my tests,
" I made a specific command to user with Mix, the Elixir task utility
" But I'm sure you could get this to work with vim-test or something like that
function! TestLineCommand(path, line_number)
let cmd = join(["mix test --only", " line:", a:line_number, " ", a:path], "")
return cmd
endfunction