Skip to content

Instantly share code, notes, and snippets.

View umurgdk's full-sized avatar

Umur Gedik umurgdk

View GitHub Profile
pub fn run(conn: PooledConnection) -> Result<(), Box<Error>> {
let tweets = get_tweets()?;
let cells = tweets.into_iter()
.filter_map(|tweet| tweet.coordinates)
.filter_map(|(latitude, longitude)| {
let cell_result = Cell::find_containing_core(&*conn, &Point::new(longitude, latitude, Some(4326))).ok();
cell_result.and_then(|cell| cell).map(|mut cell| {
cell.sns += 1;
cell
})
@umurgdk
umurgdk / objects.rs
Last active August 6, 2017 12:30 — forked from anonymous/playground.rs
Rust code shared from the playground
use std::borrow::Cow;
use std::fmt::Debug;
use specs::Entity;
use Tile;
use TileRef;
use TileRefMut;
use TileMap;
pub struct TileRefMut<'a, T: Tile + 'a> {
pub tile: &'a mut T,
pub x: usize,
pub y: usize
}
pub struct IterMut<'a, T: Tile + 'a> {
tile_map: &'a mut TileMap<T>,
x: usize,
y: usize
extern crate cgmath;
extern crate specs;
#[macro_use]
extern crate gfx;
extern crate gfx_window_glutin;
extern crate glutin;
// Logging
#[macro_use]
for event in self.events.poll_iter() {
match event {
Event::Quit { .. } => self.running = false,
event => self.input.update(&self.events, event)
}
}
#![feature(prelude_import)]
#![no_std]
#![feature(plugin)]
#![plugin(slave_codegen)]
#[prelude_import]
use std::prelude::v1::*;
#[macro_use]
extern crate std as std;
extern crate slave;
#![crate_type="dylib"]
#![feature(quote, plugin_registrar, rustc_private)]
extern crate slave;
extern crate proc_macro;
extern crate rustc_plugin;
extern crate syntax;
use rustc_plugin::Registry;
#[derive(Worker)]
struct StatsWorker;
impl StatsWorker {
#![command]
fn write(&mut self) {
// Write some data to redis
}
#![command]
pub mod container;
pub mod stack_view;
pub mod label;
pub use self::container::Container;
pub use self::stack_view::StackView;
pub use self::label::Label;
use ui::geom::*;
use ui::renderer::Renderer;
use std::sync::{Arc, Mutex};
use std::sync::mpsc::SyncSender;
use std::marker::PhantomData;
use iron::prelude::*;
use iron::{BeforeMiddleware, typemap, Request};
use workers::MetricWriterCommand;