Skip to content

Instantly share code, notes, and snippets.

Avatar

κeen KeenS

View GitHub Profile
View optic.ml
module Either = struct
type ('a, 'b) t = Left of 'a | Right of 'b
let left v = Left v
let right v = Right v
let fold ~left ~right = function
| Left v -> left v
| Right v -> right v
end
View play_music.html
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<title>Document</title>
</head>
<body>
<div class="controls">
<div class="left">
<div id="playButton" class="button">
View extract_sqrt.rs
fn extract_sqrt(mut n: u64) -> (u64, u64) {
let mut blocks = [0u8; 32];
let mut i = 0;
let mut ret = 0u64;
while n != 0 {
blocks[i] = (n & 0b11) as u8;
n >>= 2;
i += 1;
}
let mut q = 0;
View fizzbuzz_semigroup.rs
//! rust port of this
//! https://twitter.com/gakuzzzz/status/1314499876969881602
//! requires nightly
// just for ease
#![feature(bool_to_option)]
// mandatory
#![feature(type_alias_impl_trait)]
// code
View COPYING
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
View Cargo.toml
[package]
name = "so-actix-web-reqwest"
version = "0.1.0"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
actix-web = "2.0"
reqwest = "0.10"
@KeenS
KeenS / qsort.smi
Last active Jan 3, 2020
An example of SML#'s MassiveThreads support
View qsort.smi
_require "basis.smi"
_require "thread.smi"
@KeenS
KeenS / memo.txt
Last active Dec 21, 2019
Rustの並列コンパイラを試してみた See also https://qiita.com/qnighy/items/b0aa66749ad7a31ecbf9
View memo.txt
手元のコード(4万行くらい)をThreadripper 1950x(16コア32スレッド)でビルドしてみた
# 並列化してないやつ
cargo +nightly-2019-12-17 build 882.25s user 49.92s system 468% cpu 3:19.16 total
cargo +nightly-2019-12-17 build --release 2988.11s user 52.70s system 1149% cpu 4:24.54 total
cargo +nightly-2019-12-17 check 199.58s user 14.22s system 413% cpu 51.731 total
# 並列化したやつ
cargo +nightly-2019-12-18 build 1061.89s user 75.08s system 618% cpu 3:03.70 total
cargo +nightly-2019-12-18 build --release 3135.03s user 74.32s system 1247% cpu 4:17.21 total
View Hamt.sml
functor Hamt(X:
sig
eqtype k
val hash: k -> Int32.int
end
): sig
type 'v t
exception HashConflict
val empty: 'v t
View struct_index.rs
use std::ops::{Index, IndexMut};
pub struct User {
id: u64,
name: String,
}
impl User {
pub fn new(id_var: u64, name_var: String) -> Self {
User {