Skip to content

Instantly share code, notes, and snippets.

View tatsuya6502's full-sized avatar

Tatsuya Kawano tatsuya6502

  • Shanghai, China
  • 20:10 (UTC +08:00)
View GitHub Profile
@tatsuya6502
tatsuya6502 / .gitignore
Last active April 17, 2022 06:20
Rust FFI on Windows MSVC
/target/
**/*.rs.bk
Cargo.lock
*.exe
*.obj
exports.txt
@tatsuya6502
tatsuya6502 / rust-cross-sparc64-linux-different-ld-versions.log
Last active July 14, 2017 01:10
Rust cross compile - Linux x86_64 -> Linux Sparc64 (gcc 5.4.0)
/home/tatsuya% docker run -it ubuntu:trusty
root@1ce8acf4991d:/# cd
root@1ce8acf4991d:~# uname -a
Linux 1ce8acf4991d 4.11.9-1-ARCH #1 SMP PREEMPT Wed Jul 5 18:23:08 CEST 2017 x86_64 x86_64 x86_64 GNU/Linux
root@1ce8acf4991d:~# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.5 LTS"
@tatsuya6502
tatsuya6502 / nonblocking.py
Created June 3, 2017 10:18
check and set nonblocking option to stdin and stdout
import fcntl, sys, os
def get_status(fileno):
fl = fcntl.fcntl(fileno, fcntl.F_GETFL)
if (fl & os.O_NONBLOCK) == os.O_NONBLOCK:
return "nonblocking"
else:
return "blocking"
def set_nonblocking(fileno):
@tatsuya6502
tatsuya6502 / hkt.rs
Created May 31, 2017 15:44 — forked from 14427/hkt.rs
Higher-kinded type trait
use std::rc::Rc;
trait HKT<U> {
type C; // Current type
type T; // Type with C swapped with U
}
macro_rules! derive_hkt {
($t:ident) => {
impl<T, U> HKT<U> for $t<T> {
@tatsuya6502
tatsuya6502 / rust-rls-working-revisions.md
Last active April 14, 2017 02:20
Rust Language Server (RLS) - Working Revisions

Rust Language Server (RLS) - Working Revisions

IMPORTANT (April 14, 2017)

I will not update this table anymore as RLS is now available as a rustup component on a number of platforms (OS + CPU architecture). If you are using rustup to manage Rust toolchains and components, you will no longer need to build RLS by yourself. Here are some examples on Ubuntu 16.04 LTS:

$ source $HOME/.cargo/env
@tatsuya6502
tatsuya6502 / trpl-ja-install.sh
Last active February 27, 2017 14:47
trpl-ja scripts
#!/usr/bin/env bash
# For Ubuntu 14.04 Trusty (Ubuntu certified cloud image) on Joyent Cloud. (Image version: 14.04.5 20170222)
# https://docs.joyent.com/public-cloud/instances/virtual-machines/images/linux/ubuntu-certified#1404-20170222
set -uex -o pipefail
export LC_ALL=C
export TRAVIS_OS_NAME=ubuntu
echo 'apt ==================='
@tatsuya6502
tatsuya6502 / trpl_circleci_rsa.pub
Last active January 24, 2017 08:11
trpl-ja keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDKbUaOCSa1+MtanqkfHGcga0N9UhoXe5CRRBdzug2WnNqY5Eq1nWIpqB6GusC4TQOZ1Za7kaNdmBSY/D7zp1oJ4xMWOmy7EeU0g488J59ofygzHLoHXYYLplWoYDpmDAmF6pwvkzoiXDfbOckp5Nt9S/1+aMgaXO0ybi5PqNqw9Dq/iLMwV2tB49E4FdIMI+FImlUBQJ3lAGt/F17pwi2tonhMbyuIooeNuMb+2rLldRGzf/0Cxk2NdfgmgJ9M3nRdCQ2/asfzT8W0Q/V2iEsIqE7N5DVOFMMlTzy5S27U0zZ40j5tt4TNHyXn6VLE+jQ2uoOyTV5a07TpswXZNz+RDP8ZmtNMR8VG6Cq1wl9lu/QWNTSsE172PBkAye2Y1k4FzbXFjOaSHAXuYYMaD+t2ppYyF8HO8lhUhdU3M9iN0CxT2rIy+z26QhhtrOtj5lU3hS3xIpJRrR0c+h5RiECelTR078yqxj6AuZnf1Ml4VxT4WtSxsa23xwKDEBelsunwihtGKLi52GJP9WakbV+oG5QdbysFimDHNKRDFrRoXgGT6jmnsl/pF1XakWvS8f4S9JxQ6g5xE4tHW1bPXRcxJ1O/TUzdxDFYlgHmGdIT8ljUSm/sg4U/NQnbm2/ZNXXg3O04ZIIYNZqBvJS6AjeMw0WsShR7NZcdM3XvsTHOOQ== trpl-circleci@hibaridb.org
@tatsuya6502
tatsuya6502 / main.rs
Created March 12, 2016 02:19
Zundoko-Kiyoshi with Rust
extern crate rand;
#[derive(Clone, Copy, PartialEq)]
enum Sound {
Zun,
Doko,
}
impl Sound {
fn pick(mut rng: &mut rand::Rng) -> Self {
@tatsuya6502
tatsuya6502 / my_math.ex
Created December 21, 2015 10:44
MyMath, functions that are traced by ReconTrace
defmodule MyMath do
@spec factorial(non_neg_integer()) :: non_neg_integer()
def factorial(0), do: 1
def factorial(n) when n > 0, do: n * factorial(n - 1)
@spec factorial_iter(non_neg_integer()) :: non_neg_integer()
def factorial_iter(n) when n >= 0, do: factorial_iter1(n, 1)
defp factorial_iter1(0, acc), do: 1 # `1` should read `acc`
@tatsuya6502
tatsuya6502 / recon_trace.ex
Created December 21, 2015 10:31
ReconTrace (WIP)
require :recon_trace
defmodule ReconTrace do
@moduledoc """
`ReconTrace` provides functions for tracing events in a safe manner
for single Erlang BEAM VM. It is a wrapper module of `recon_trace`
in the Erlang Recon toolset: http://ferd.github.io/recon/
## Examples