Skip to content

Instantly share code, notes, and snippets.

View mosmeh's full-sized avatar

Yuta Imazu mosmeh

View GitHub Profile
use std::{
alloc::{GlobalAlloc, Layout, System},
sync::atomic::{AtomicUsize, Ordering},
};
pub struct Allocator {
inner: System,
counter: AtomicUsize,
}
{
"Dahina tabla": [1, 2.89, 4.95, 6.99, 8.01, 9.02],
"Bayan tabla": [1, 2.0, 3.01, 4.01, 4.69, 5.63],
"Red Cedar wood plate": [1, 1.47, 2.09, 2.56],
"Redwood wood plate": [1, 1.47, 2.11, 2.57],
"Douglas Fir wood plate": [1, 1.42, 2.11, 2.47],
"uniform wooden bar": [1, 2.572, 4.644, 6.984, 9.723, 12],
"uniform aluminum bar": [1, 2.756, 5.423, 8.988, 13.448, 18.68],
"Xylophone": [1, 3.932, 9.538, 16.688, 24.566, 31.147],
"Vibraphone 1": [1, 3.984, 10.668, 17.979, 23.679, 33.642],
@mosmeh
mosmeh / main.rs
Created June 27, 2020 09:27
Spinner
use crossterm::{cursor, queue};
use std::io::{self, Write};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::thread::{self, JoinHandle};
use std::time::Duration;
const DEFAULT_FRAMES: &str = "⠙⠹⠸⠼⠴⠦⠧⠇⠏";
const DEFAULT_INTERVAL: Duration = Duration::from_millis(50);
use serde::{Deserialize, Serialize};
use std::env;
use std::fs::File;
use std::io::Write;
use std::io::{BufRead, BufReader, BufWriter};
#[derive(Serialize, Deserialize)]
struct Article {
id: String,
title: String,
unsafe fn slice_from_bytes<T>(bytes: &[u8]) -> &[T] {
assert_eq!(0, std::mem::size_of::<T>() % std::mem::size_of::<u8>());
assert_eq!(0, bytes.len() % std::mem::size_of::<T>());
let ratio = std::mem::size_of::<T>() / std::mem::size_of::<u8>();
let ptr = bytes.as_ptr() as *const T;
let length = bytes.len() / ratio;
std::slice::from_raw_parts(ptr, length)
}
def eulerian_walk(nodes, start):
tour = []
def visit(n):
if n in nodes:
while nodes[n]:
visit(nodes[n].pop())
tour.append(n)
visit(start)
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
vector<int> dd(int y, const vector<int>& x) {
vector<int> ret;
for (int a : x) {
ret.push_back(abs(a - y));
@mosmeh
mosmeh / a.md
Created April 3, 2020 11:27
塩基配列を読むときのテクニック

ASCIIでは

  • A,C,G,Tの値は0x61,0x63,0x67,0x74なので,下位4bitを取り出すと1,3,7,4になり,すべて異なる値となる
  • 大文字と小文字の値は0x20だけ違うため,下位4bitを取り出すと大文字と小文字は同じ値となる

→ 下位4bitだけ読むことでA,C,G,Tをcase-insensitiveに読める

int read_base(char c) {
    switch (c & 0xf) {
 case 'A' &amp; 0xf: // 1
OBJS := foo
VERSION := $(shell cat VERSION 2> /dev/null)
COMMIT := $(shell git describe --always --tags --dirty 2> /dev/null)
CFLAGS := $(if $(VERSION),-DFOO_VERSION=\"$(VERSION)\") $(if $(COMMIT),-DFOO_COMMIT=\"$(COMMIT)\")
.PHONY: all clean
all: $(OBJS)
clean:
code="""spwwz pgpcjzyp! hpwnzxp ez esp hzcwo zq nzxafepc dntpynp!
nzxafepc dntpynp td l mldtd zq esp xzopcy tyqzcxletzy lyo
nzxxfytnletzy epnsyzwzrj dfns ld mtr olel lylwjdtd, lt, lyo lwdz
nzxafepc rlxp. awpldp pyuzj esp hzcwo zq nzxafepc dntpynp. dpp
jzf lrlty le seea://end.n.etepns.ln.ua/ndmzzv/"""
def rot(c, n):
if 'a' <= c and c <= 'z':
return chr((ord(c) - ord('a') - n) % 26 + ord('a'))
else: