View 1 shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export esver=1.4.0 | |
sudo apt-get update && sudo apt-get install openjdk-7-jre-headless nginx unzip apache2-utils -y && sudo mkdir /etc/elasticsearch && cd /etc/elasticsearch && sudo wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-$esver.zip && sudo unzip elasticsearch-$esver.zip && sudo mv elasticsearch-$esver $esver && echo "" && echo "---" && echo "vi into /etc/elasticsearch/$esver/config/elasticsearch.yml disable 'zen discovery' and enable 'unicast discovery'. Don't worry about the hosts array" && echo "---" && echo "" && sudo touch /etc/init.d/elasticsearch && sudo chmod +x /etc/init.d/elasticsearch && sudo touch /etc/gethosts && sudo chmod +x /etc/gethosts && sudo rm /etc/nginx/sites-enabled/default && sudo touch /etc/nginx/sites-available/elasticsearch && sudo ln -L /etc/nginx/sites-available/elasticsearch /etc/nginx/sites-enabled/elasticsearch && sudo touch /var/log/nginx/kibana.access.log && echo "" && echo "---" && echo "vi into /etc/init.d/elasticsearch and add the c |
View Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Net; | |
using Orleans; | |
using Orleans.Runtime.Host; | |
using OrleansDemo.GrainInterfaces; | |
using OrleansDemo.GrainCollection; | |
namespace OrleansDemo.Host |
View Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Entity Framework has a problem: there is 1 object graph to rule them all, and that object graph is available | |
to anybody, whether or not they actually want/need it. This makes things ambiguous and leads to errors and | |
crap code. | |
It's saner to be able to constrain the data you read/write to exactly what you expect to work with. But | |
this fragments your entities. The idea here is to try and get the best of both worlds; a single base definition | |
of a given entity, but only exposing the bits that are relevant to a particular projection. |
View playground.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
println!("Hello, World!"); | |
} |
View playground.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Person { | |
id: i32, | |
title: String | |
} | |
impl Person { | |
fn new(id: i32, title: &str) -> Person { | |
Person { | |
id: id, | |
title: title.to_string() |
View playground.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(Debug)] | |
struct Person<T> { | |
id: T, | |
title: String | |
} | |
impl <T> Person<T> { | |
fn new<I: Into<String>>(id: T, title: I) -> Self { | |
Person { | |
id: id, |
View playground.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Lifetimes are generic parameters | |
//'a and 'b are lifetimes | |
//'static is a special lifetime for static memory | |
struct Person<'a> { | |
pub id: i32, | |
//Question: can we mutate parent.unwrap().id? | |
pub parent: Option<&'a Person<'a>> | |
} | |
fn main() { |
View playground.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Person { | |
pub id: i32, | |
pub title: String | |
} | |
fn main() { | |
//structs are constructed inline. We could use a static method | |
//Rust structures have completely separate data and functionality blocks | |
let person = Person { | |
id: 1, |
View playground.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mod entities { | |
//This module is public to anyone outside entities | |
pub mod traits { | |
pub trait Entity { | |
fn id(&self) -> i32; | |
fn title(&self) -> &str; | |
} | |
} | |
//This module is private to anyone outside entities |
View playground.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
//The vec! macro is sugar for inline Vec<T> building | |
let vec1 = vec!["a", "b", "c"]; | |
let vec2 = vec![1, 2, 3]; | |
//Rust has iterators, which are usually cheaper than looping | |
for (&x, &y) in vec1.iter().zip(vec2.iter()) { | |
println!("{}, {}", x, y); | |
} | |
OlderNewer