Skip to content

Instantly share code, notes, and snippets.

Vincent Foley gnuvince

Block or report user

Report or block gnuvince

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:832be1134f69aa29742f0c0f64183f27
Seeded DCSS version 0.23.2 (console) character file.
Game seed: 18127138284784505733
1676291 gotm the Invulnerable (level 27, 271/271 HPs)
Began as a Minotaur Gladiator on July 28, 2019.
Was a High Priest of Trog.
Escaped with the Orb
... and 3 runes on July 30, 2019!
View deals.rs
fn deserialize_deals<'de, D>(de: D) -> ::std::result::Result<HashMap<u8, BTreeSet<String>>, D::Error>
where D: Deserializer<'de>
{
struct DealsVisitor;
impl<'de> Visitor<'de> for DealsVisitor {
type Value = HashMap<u8, BTreeSet<String>>;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
View sob.c
#include <err.h>
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#define CACHE_LINES 64
View gist:212fc4f54e61fe7a5e813c7e2bf5eeeb
/* C code */
int add(int x, int y) {
return x+y;
}
void caller() {
int a = add(3, 4);
}
View gist:2ce9d214a1411d7bad998ad913498b9e
iload_0 ; [a]
iconst_1 ; [a, 1]
ieq ; [a==1]
dup ; [a==1, a==1]
jmp_nonzero OR ; [a==1]
drop ; []
iload_1 ; [b]
OR:
istore_2 ; []
iload_2 ; [c]
View gist:273dd71a293b8a24de0da3478e5bed4f
extern crate rayon;
use rayon::prelude::*;
use std::time::Instant;
fn collatz(mut x: u64) -> usize {
let mut steps = 0;
while x != 1 {
if x % 2 == 0 {
x /= 2;
View gist:fe9e2b7850b3be146e3ae8871bd1f565
impl <'a> IntoIterator for &'a Bitmap {
type Item = u16;
type IntoIter = SharedBitmapIterator<'a>;
fn into_iter(self) -> Self::IntoIter {
return SharedBitmapIterator { offset: 0, bitmap: &self };
}
}
impl IntoIterator for Bitmap {
type Item = u16;
View gist:13bdcaaac028e6cce98da4ed3edda569
use std::io;
use std::collections::HashMap;
use std::collections::VecDeque;
#[derive(Debug, PartialEq, Copy, Clone)]
enum Command {
Assign { bot: usize, value: usize },
Give {
src: usize, // from which bot?
dst1: usize, // to which bot/bin?
@gnuvince
gnuvince / binsearch.org
Last active May 6, 2017
Literate programming in Org-mode + Rust: binary search
View binsearch.org

Introduction

In the fourth chapter of “Programming Pearls”, Jon Bentley discusses program correctness and tells us that as part of some of his programming classes, he asks the attendees to implement the binary search algorithm. Although simple in appearance (“look at the middle element, if it’s the target terminate, if it’s smaller look in the upper half, otherwise look in the lower half”), it can be a surprisingly tricky algorithm to implement. He cites TAoCP Vol. 3 wherein Don Knuth mentions that although the first paper on binary

View insertionsort.rs
fn insertion_sort<T: PartialOrd>(xs: &mut Vec<T>) {
for i in 1..(xs.len() - 1) {
let mut j = i;
while j > 0 && xs[j-1] > xs[j] {
xs.swap(j, j-1);
j -= 1;
}
}
}
You can’t perform that action at this time.