Skip to content

Instantly share code, notes, and snippets.

View e10s's full-sized avatar

Kazuya Takahashi e10s

  • Japan
View GitHub Profile
/* This divides an n-word dividend by an m-word divisor, giving an
n-m+1-word quotient and m-word remainder. The bignums are in arrays of
words. Here a "word" is 32 bits. This routine is designed for a 64-bit
machine which has a 64/64 division instruction. */
import std.stdio;
import std.algorithm : max;
int nlz(uint x) {
int n;
@e10s
e10s / dl.d
Created December 17, 2015 15:46
Highly rangefied dl command (from https://github.com/ueshita/dl-cmd)
/+
The MIT License (MIT)
Copyright (c) 2015 ueshita, e10s
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
@e10s
e10s / get_ejectability_freebsd.c
Created November 2, 2015 12:06
A simple program to print whether a CD tray is ejectable, on FreeBSD.
/*
Copyright electrolysis 2015.
Distributed under the Boost Software License, Version 1.0.
(See copy at http://www.boost.org/LICENSE_1_0.txt)
*/
// A simple program to print whether a CD tray is ejectable, on FreeBSD.
#include <stdio.h>
#include <string.h>
@e10s
e10s / cd_tray_open_or_closed_freebsd.c
Created November 2, 2015 06:52
A simple program to print whether a CD tray is open or closed, on FreeBSD.
/*
Copyright electrolysis 2015.
Distributed under the Boost Software License, Version 1.0.
(See copy at http://www.boost.org/LICENSE_1_0.txt)
*/
// A simple program to print whether a CD tray is open or closed, on FreeBSD.
#include <stdio.h>
#include <string.h>
@e10s
e10s / curry.d
Last active August 29, 2015 14:17
Currying in D
/*
Copyright electrolysis 2015.
Distributed under the Boost Software License, Version 1.0.
(See copy at http://www.boost.org/LICENSE_1_0.txt)
*/
module curry;
import std.traits : arity;