Skip to content

Instantly share code, notes, and snippets.

View ubnt-intrepid's full-sized avatar
🦀
I may be slow to respond.

Yusuke Sasaki ubnt-intrepid

🦀
I may be slow to respond.
View GitHub Profile
@ubnt-intrepid
ubnt-intrepid / playground.rs
Created November 21, 2016 08:24 — forked from anonymous/playground.rs
Shared via Rust Playground
trait SwapCarriable {
type Out;
fn swap_carry(self) -> Self::Out;
}
impl<T> SwapCarriable for Vec<Option<T>> {
type Out = Option<Vec<T>>;
fn swap_carry(self) -> Option<Vec<T>> {
let mut buf = Vec::with_capacity(self.len());
for e in self {
@ubnt-intrepid
ubnt-intrepid / channel.cxx
Created September 20, 2016 20:03
C++でチャンネル
#include <condition_variable>
#include <memory>
#include <mutex>
#include <queue>
#include <tuple>
template <typename T>
class channel {
std::queue<T> queue;
std::mutex m;
@ubnt-intrepid
ubnt-intrepid / highlevel.rs
Last active August 28, 2016 10:23 — forked from anonymous/playground.rs
Shared via Rust Playground
fn main() {
let env = Env::new("highlevel.log").unwrap();
let model = define_model! {
env,
Find: {
"x" @ x => Binary,
"y" @ y => Continuous(1.0, 2.0),
"z" @ z => Integer(100, 200)
#!/bin/sh
# vim: ft=sh ts=2 sw=2 et :
set -ex
# set hostname
echo arch-localhost > /etc/hostname
# set locale settings
ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
sed -i.bak -e 's/#\(en_US.UTF-8.*\)/\1/' /etc/locale.gen
#[derive(Clone)]
struct Tensor<T, Index> {
body: Vec<T>,
size: Index,
}
impl<T, Index> Tensor<T, Index> {
// size :: (usize,usize,...)
// f :: (usize,usize,...) -> T
fn new<F>(size: Index, f:F) -> Tensor<T, Index> where F: Fn(Index) -> T {
#!/bin/bash -e
if [[ "x$MINGW_PREFIX" == "x" ]]; then
echo "use MinGW-w64 shell." > /dev/stderr
exit 1
fi
# instal dependencies
zlib_package="${MINGW_PACKAGE_PREFIX}-zlib"
pacman -Qs $zlib_package > /dev/null
@ubnt-intrepid
ubnt-intrepid / Invoke-Batchfile.ps1
Created May 31, 2016 04:33
PowerShell サンプル集
<#
.synopsis
Invoke batch file and apply the changes of all environment variables.
#>
param (
[string]
$batch
)
#!/usr/bin/zsh
# 目的
# * 起動している環境の情報を特定する
# * 環境ごとの動作の違いを吸収する
# 識別対象
# * $OSTYPE : OS
# * $TERM : ターミナル
# * $HOME/.hostname : ホスト名 (/etc/hostname などは書き換えが難しいため)

MSYS2の使い方の備忘録 (2016年度3月版)

MSYS2の情報自体は調べれば出てくるのですがいちいち調べるのが面倒なので, ここに使用する際の注意点なども含めてメモっておきます.

MSYS2とは

Windows上でUnix-likeなコマンドライン開発環境を構築するためのツール群

  • MinGW (Windows向けのgccツールチェイン) のために開発されていた MSYS というプロジェクトの後継
  • Arch Linux のパッケージマネージャ (pacman) を移植したことでパッケージの導入・管理が飛躍的に容易になった
  • フォーク元のCygwinとは異なり,ネイティブ向けのアプリケーションの充実を目指しているらしい

MINGW用のライブラリ作成手順

  1. 開発者コマンドプロンプトでシンボル名を出力する
> dumpbin /export hogehoge.dll
  1. 以下の.defファイルを作成する