View rust-temporary-exec.sh
#!/usr/bin/env sh
# $ ./rust-temporary-exec.sh 'println!("hello world!")'
# => hello world!
set -eu
echo "fn main() { $1 }" | rustc - && ./rust_out
View bench_starts_with.rs
#![feature(test)]
extern crate test;
#[cfg(test)]
mod tests {
use super::*;
use std::str;
use test::Bencher;
View trait_dispatch.rs
trait Foo {
fn method(&self) -> String;
}
impl Foo for u8 {
fn method(&self) -> String {
format!("u8: {}", *self)
}
}
View builder.rs
#[derive(Clone, Debug)]
struct AnyOption {
a: bool,
b: bool,
}
struct AnyBuilder {
option: AnyOption,
}
View copy.rs
use std::io;
use std::fs::File;
fn main() {
let r = io::stdin();
let mut reader = r.lock();
let mut writer = File::create("temp_copy.txt").unwrap();
let _ = io::copy(&mut reader, &mut writer);
View stream.rs
use std::io::{self, Read, Write};
use std::fs::File;
fn copy(reader: &mut Read, writer: &mut Write) {
const BUFFER_SIZE: usize = 32 * 1024;
let mut buf = [0u8; BUFFER_SIZE];
while let Ok(n) = reader.read(&mut buf) {
if n == 0 {
break;
View wscrap.sh
#!/usr/bin/env sh
# Scrap web pages
#
# Usage:
# $ ./wscrap.sh https:xxx/xxx/
set -eu
DEPTH=8
View Vimium-Custom-serarch-engines
g: https://www.google.com/search?q=%s Google
wiki: https://www.wikipedia.org/w/index.php?title=Special:Search&search=%s Wikipedia
youtube: https://www.youtube.com/results?search_query=%s Youtube
twitter: https://twitter.com/search?q=%s Twitter
reddit: https://www.reddit.com/search?q=%s reddit
hackernews: https://hn.algolia.com/?query=%s HackerNews
github: https://github.com/search?q=%s GitHub
qiita: https://qiita.com/search?q=%s Qiita
stack: https://stackoverflow.com/search?q=%s Stack Overflow
View build.sh
#!/bin/sh
# sh build.sh ${target}
set -eu
if [ $# -eq 0 ]; then
echo "target none, exit"
exit 1
fi
View .profile
export SELFBUILD=$HOME/code/build
export PATH=$HOME/local/bin:$PATH
# go
export GOROOT=$HOME/code/build/go
export GOPATH=$HOME/.gopath
export PATH=$SELFBUILD/go/bin:$PATH
export PATH=$GOPATH/bin:$PATH
# rust