Skip to content

Instantly share code, notes, and snippets.

extern crate libc;
use libc::*;
use libc::funcs::posix01::signal::signal;
fn main() {
unsafe { signal(SIGINT, goodbye as u64); }
println!("Hello, world!");
@niconii
niconii / diff-fulliter.s-while.s-.diff
Created May 14, 2015 19:41
Iterator chain vs. while loop comparison
2,3c2,3
< .file "fulliter.0.rs"
< .section .text._ZN4main20h34b4fa9d2be136ebeaaE,"ax",@progbits
---
> .file "while.0.rs"
> .section .text._ZN4main20h3118530cba082203eaaE,"ax",@progbits
5,6c5,6
< .type _ZN4main20h34b4fa9d2be136ebeaaE,@function
< _ZN4main20h34b4fa9d2be136ebeaaE:
---
use std::env;
fn main() {
env::set_var("RUST_BACKTRACE", "1");
panic!();
}
@niconii
niconii / try.c
Last active August 29, 2015 14:21
Awful Result/try! implementation in C
#include <stdio.h>
#include <stdbool.h>
#include <assert.h>
enum ResultKind { Kind_Ok, Kind_Err };
typedef struct {
enum ResultKind kind;
union {
struct { int ok; };
@niconii
niconii / keybase.md
Created October 10, 2015 21:58
Keybase verification

Keybase proof

I hereby claim:

  • I am niconii on github.
  • I am niconii (https://keybase.io/niconii) on keybase.
  • I have a public key whose fingerprint is 9C90 5AFA 2637 6CD7 7727 442B B306 692C E33C FE6B

To claim this, I am signing this object:

@niconii
niconii / pipe_codes
Last active November 16, 2016 05:36
[ '['
x exchange bg/fg colors
krygbcmwn dark colors
KRYGBCMW light colors
h00 256-color
i italics
u underline
c clear all formatting
|[bxWu]Test|c
@niconii
niconii / nicode.md
Last active November 16, 2016 05:36

Escape sequences

Sequence Results in
\[ [
\] ]
\\ \

Format characters

@niconii
niconii / bankswitch.rs
Created January 10, 2016 06:42
Messing around with an idea mentioned in https://news.ycombinator.com/item?id=10873525
extern crate sdl2;
use sdl2::pixels::Color;
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use std::sync::mpsc::{Receiver, Sender};
enum Command {
SetBG(u8, u8, u8),
; Goal: to turn controller button samples, incoming on the x register each
; frame, into three variables:
; - cur, which represents the current state of the controller buttons
; - prs, which represents the buttons pressed this frame
; - rls, which represents the buttons released this frame
;
; Example:
; x cur prs rls
; ................ ................ ................ <- initial values
; ...........1.... ...........1.... ...........1.... ................
@niconii
niconii / snescontroller.rs
Created March 22, 2016 16:02
A little SNES controller simulator
trait ControllerPins {
// inputs:
// latch pin (normally low)
fn latch_rising(&mut self);
fn latch_falling(&mut self);
// clock pin (normally high)
fn clock_rising(&mut self);
fn clock_falling(&mut self);
// output: