Skip to content

Instantly share code, notes, and snippets.

View 335g's full-sized avatar

Yoshiki Kudo 335g

View GitHub Profile
@335g
335g / main.rs
Last active March 31, 2018 09:58
type erasure (closure type) in rust
trait AnimalExt {
type Food;
fn eat(&self, food: Self::Food);
}
struct Dog;
impl AnimalExt for Dog {
type Food = String;
@335g
335g / main.rs
Created March 31, 2018 09:42
type erasure in rust
trait AnimalExt {
fn eat(&self, food: String);
}
struct Dog;
impl AnimalExt for Dog {
fn eat(&self, food: String) {
println!("dog: {:?}", food);
}
@335g
335g / a.rs
Created November 25, 2017 02:38
memo
let numbers = ["1", "2", "3", "a", "5"];
let only_numbers = numbers.iter()
.scan((), |_, &item| item.parse::<i32>().ok())
.collect::<Vec<i32>>(); // [1, 2, 3]

Keybase proof

I hereby claim:

  • I am 335g on github.
  • I am 335g (https://keybase.io/335g) on keybase.
  • I have a public key whose fingerprint is 2D21 CD31 B835 5682 589C 5FE1 A760 69C1 58BD 5D40

To claim this, I am signing this object:

@335g
335g / FunctionAttr.swift
Last active August 29, 2015 14:25
引数のタプル受け取りはジェネリクス使った関数だとNG
/// Xcode7 beta4
struct MyInt {
var a: Int
}
struct MyGenerics<T> {
var a: T
}
@335g
335g / sample.swift
Created May 17, 2015 13:38
Ex. Use Tween
var alpha: CGFloat = 0.0
State(alpha)
>>> wait(1.0)
>>> to(1.0, .InCubic, 0.8, toFloatValue())
>>> to(0.0, .OutCubic, 0.8, toFloatValue())
>>> wait(1.0)
>>> to(1.0, .InCubic, 0.8, toFloatValue())
>>> to(0.0, .OutCubic, 0.8, toFloatValue())
@335g
335g / UIView+GRBLSpringAdditions.m
Created January 3, 2015 15:29
減衰振動(1次元)
@implementation UIView (GRBLSpringAdditions)
+ (void)dampedOscillationAlongXAxis:(UIView *)view
toX:(CGFloat)toX
k:(CGFloat)k
omega:(CGFloat)omega
minimumDuration:(CGFloat)minimumDuration
completionBlock:(void (^)(BOOL))completionBlock {
/*******************
UICollectionViewController *toVC;
UINavigationController *nav;
toVC.useLayoutToLayoutNavigationTransitions = YES;
[nav pushViewController:toVC animated:YES];