Skip to content

Instantly share code, notes, and snippets.

View algon-320's full-sized avatar
😎

Jun Ishiguro algon-320

😎
  • Google
  • Tokyo, Japan
  • 18:22 (UTC +09:00)
View GitHub Profile
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
# set -x
KEYTIMEOUT=1
HISTFILE=~/.zsh_history
HISTSIZE=1000000
SAVEHIST=1000000
setopt EXTENDED_HISTORY
setopt PROMPT_SUBST
//# lazy_static = "1.4.0"
#![allow(dead_code, unused_variables)]
#![feature(scoped_threads)]
#![feature(negative_impls)]
use std::rc::Rc;
use std::sync::Arc;
struct T;
@algon-320
algon-320 / actix-tcp-echo.rs
Created April 22, 2022 10:43
TCP echo server implemented with actix
//# actix = "0.13.0"
//# tokio = { version = "1.17.0", features = ["net"] }
//# tokio-util = { version = "0.7.1", features = ["codec"] }
//# bytes = "1.1.0"
use actix::prelude::*;
use std::net::SocketAddr;
use tokio::net::{
tcp::{OwnedReadHalf, OwnedWriteHalf},
@algon-320
algon-320 / Makefile
Last active January 15, 2022 11:22
a test program for `sgx_report_attestation_status`
main: main.c
gcc main.c $(shell pkg-config --cflags --libs libsgx_epid) -o main
@algon-320
algon-320 / 01_get_access_token.rs
Last active September 6, 2021 04:05
Get a OAuth 2.0 access token in Rust (Google APIs)
// [dependencies]
// jwt = { version = "0.14.0", features = ["openssl"] }
// openssl = "0.10.32"
// serde_json = "1"
// Docs:
// https://developers.google.com/identity/protocols/oauth2/service-account
use openssl::pkey::{PKey, Private};
@algon-320
algon-320 / Dockerfile
Created February 12, 2021 09:08
a docker image for "Advanced Compilers" course (Cornell Univ. CS 6120, https://www.cs.cornell.edu/courses/cs6120/2020fa/self-guided/)
FROM ubuntu:latest
WORKDIR /root
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get clean
RUN apt-get update
RUN apt-get upgrade -y
# install misc prerequisites
RUN apt-get install -y git
RUN apt-get install -y curl
#![allow(unused_macros)]
#![allow(clippy::inconsistent_digit_grouping)]
macro_rules! bitpack_internal {
($type:ty; []; ) => {
(0 as $type, 0)
};
($type:ty; [$num:literal]; $arg:expr) => {{
let (mut val, mut width) = bitpack_internal!($type; []; );
val |= $arg & (1 as $type).checked_shl($num).unwrap_or(0).wrapping_sub(1);
use core::cell::UnsafeCell;
use core::sync::atomic::{fence, spin_loop_hint, AtomicBool, Ordering};
struct SpinlockMutex<T> {
locked: AtomicBool,
data: UnsafeCell<T>,
}
struct SpinlockMutexGuard<'mtx, T> {
mutex: &'mtx SpinlockMutex<T>,
}
impl<T> SpinlockMutex<T> {
$ ../install/bin/ruby ../test.rb
push / pop:
user system total real
Deque push 0.006660 0.000000 0.006660 ( 0.006663)
Array push 0.007511 0.000000 0.007511 ( 0.007562)
Deque pop 0.005977 0.000034 0.006011 ( 0.006018)
Array pop 0.006018 0.000000 0.006018 ( 0.006022)
Deque push (and write) 0.010819 0.000078 0.010897 ( 0.010912)
Array push (and write) 0.010133 0.000000 0.010133 ( 0.010138)
@algon-320
algon-320 / range_set.cpp
Last active June 22, 2020 11:48
区間の集合を扱うデータ構造
#include <bits/stdc++.h>
struct Range {
// [l, r)
int l;
int r;
Range() : l(-1), r(-1) {}
Range(int l, int r) : l(l), r(r) { fit(); }
void fit() {