Skip to content

Instantly share code, notes, and snippets.

@kindlychung
kindlychung / ffmpeg-install.sh
Last active July 3, 2016 10:08 — forked from clayton/ffmpeg-install.sh
Install FFMPEG on OS X with HomeBrew to convert Mp4 to WebM
# Installation
brew install libvpx
brew install ffmpeg --with-vpx --with-vorbis --with-libvorbis --with-vpx --with-vorbis --with-theora --with-libogg\
--with-libvorbis --with-gpl --with-version3 --with-nonfree --with-postproc --with-libaacplus\
--with-libass --with-libcelt --with-libfaac --with-libfdk-aac --with-libfreetype --with-libmp3lame\
--with-libopencore-amrnb --with-libopencore-amrwb --with-libopenjpeg --with-openssl\
--with-libopus --with-libschroedinger --with-libspeex --with-libtheora --with-libvo-aacenc\
--with-libvorbis --with-libvpx --with-libx264 --with-libxvid --with-libvpx
val pairs = sc.parallelize(List(("aa", 1), ("bb", 2),
("aa", 10), ("bb", 20),
("aa", 100), ("bb", 200)))
/* aggregateByKey is a generalized version of fold, it takes an initial accumulator (here an empty list),
a first lambda function to merge a value to an accumulator, and a
second lambda function to merge two accumulators */
pairs.aggregateByKey(List[Int]())(
(aggr, value) => value +: aggr,
(aggr1, aggr2) => aggr1 ++ aggr2
).foreach(println _)
>> Running: /Users/kaiyin/.multirust/toolchains/nightly/bin/cargo build
Compiling itertools v0.4.13 (file:///Users/kaiyin/EclipseWorkspace/rust-itertools)
src/adaptors.rs:334:23: 346:5 error: mismatched types [E0308]
src/adaptors.rs:334 let get_next_b = || match self.b.next() {
^
src/adaptors.rs:334:23: 346:5 help: run `rustc --explain E0308` to see a detailed explanation
src/adaptors.rs:334:23: 346:5 note: expected type `std::option::Option<_>`
src/adaptors.rs:334:23: 346:5 note: found type `<J as std::iter::Iterator>::Item`
src/adaptors.rs:350:34: 350:46 error: mismatched types [E0308]
src/adaptors.rs:350 Some((a.clone(), get_next_b()))
struct Person<'a> {
car:Option<&'a Car>
}
struct Car {
model : String
}
impl <'a> Person<'a> {
pub trait ArrayMap<X, Y, T> {
fn map<F: Fn(&X) -> Y>(&self, f: F) -> T;
}
impl<U, V> ArrayMap<U, V, [V; 0]> for [U; 0] {
fn map<F: Fn(&U) -> V>(&self, _: F) -> [V; 0] {
[]
}
}
use std::rc::Rc;
use std::cell;
use std::ops::{Deref, DerefMut};
pub struct SCell<T>(Rc<cell::RefCell<T>>);
pub struct Ref<'a, T: 'a>(cell::Ref<'a, T>);
pub struct RefMut<'a, T: 'a>(cell::RefMut<'a, T>);
impl<T> SCell<T> {
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
logo
Click or press ‘S’ to search, ‘?’ for more options…
1
2
3
4
5
6
7
use std::ops::Add;
use std::borrow::Borrow;
#[derive(Clone, Debug)]
struct Point {
x: i32,
y: i32,
}
impl<T> Add<T> for T
use std::ops::Add;
use std::borrow::Borrow;
#[derive(Clone, Debug)]
struct Point {
x: i32,
y: i32,
}
impl<T: Borrow<Point>> Add<T> for Point {