Skip to content

Instantly share code, notes, and snippets.

View mzumi's full-sized avatar
🏠
Working from home

mzumi

🏠
Working from home
View GitHub Profile
@mzumi
mzumi / .envrc
Last active March 20, 2018 12:00
# xxxx は ~/.aws/credentials に記述されている profile
export AWS_DEFAULT_PROFILE=xxxx
export AWS_ACCESS_KEY_ID=`aws configure get aws_access_key_id`
export AWS_SECRET_ACCESS_KEY=`aws configure get aws_secret_access_key`
export AWS_DEFAULT_REGION=`aws configure get region`
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
fn response(&self, buf: &String) -> Result<SearchResponse<Self::I>, GitHubClientError> {
let result = json::decode(&buf)?;
Ok(result)
}
extension Dictionary where Key : ExpressibleByStringLiteral {
func extractValue<T>(key: String) throws -> T {
let keyStr = key as! Key
if let r = self[keyStr] as? T {
return r
}
throw JSONDecodeError.missingValue(key: key, actualValue: self[keyStr])
}
extension Dictionary where Key : ExpressibleByStringLiteral {
func extractValue<T>(key: String) throws -> T {
let keyStr = key as! Key
if let r = self[keyStr] as? T {
return r
} else {
throw JSONDecodeError.missingValue(key: key, actualValue: self[keyStr])
}
}
@mzumi
mzumi / lib.rs
Last active November 2, 2016 11:50
#![feature(libc)]
extern crate libc;
use libc::*;
use std::ffi::{CStr, CString};
#[repr(C)]
pub struct SampleStruct {
i: i32,
b: bool,
require 'ffi'
module FFISample
extend FFI::Library
ffi_lib 'target/release/libffi_sample.dylib'
class SampleStruct < FFI::Struct
layout :i, :int,
:b, :bool,
@mzumi
mzumi / lib.rs
Last active November 2, 2016 03:45
#![feature(libc)]
extern crate libc;
use libc::*;
use std::ffi::{CStr, CString};
#[repr(C)]
pub struct SampleStruct {
i: i32,
b: bool,
require 'ffi'
module FFISample
extend FFI::Library
ffi_lib 'target/release/libffi_sample.dylib'
# ガベージコレクタに回収される際に、Rust 側で確保されたメモリ領域を
# 開放するため、ManagedStruct を継承する
class SampleStruct < FFI::ManagedStruct
require 'ffi'
module FFISample
extend FFI::Library
ffi_lib 'target/release/libffi_sample.dylib'
attach_function :perform, [:string], :string
end