Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Stuff is happening.

Florian Gilcher skade

💭
Stuff is happening.
View GitHub Profile
View async-std-timings
time: 0.002; rss: 50MB parse_crate
time: 0.000; rss: 50MB attributes_injection
time: 0.000; rss: 50MB recursion_limit
time: 0.000; rss: 50MB plugin_loading
time: 0.000; rss: 50MB plugin_registration
time: 0.000; rss: 50MB pre_AST_expansion_lint_checks
time: 0.000; rss: 53MB crate_injection
time: 1.046; rss: 101MB expand_crate
time: 0.000; rss: 101MB check_unused_macros
time: 1.046; rss: 101MB macro_expand_crate
@skade
skade / playground.rs
Created May 27, 2019 — forked from rust-play/playground.rs
Code shared from the Rust Playground
View playground.rs
fn main() {
let mut buffer = String::new();
for i in 1..100 {
buffer = fizzbuzz(i, buffer);
println!("{}", buffer);
buffer.clear();
}
}
fn fizzbuzz(i: u32, mut buffer: String) -> String {
@skade
skade / code_demo.rs
Created Sep 8, 2018
Code demo of an API experiment for a database mapper.
View code_demo.rs
let mut changeset = BlogRepository::change().inserts::<Posts>();
for id in 1..=3 {
let post = Post { id: id, content: format!("Post number {}", id) };
changeset.push(post);
}
let mut changeset = changeset.inserts::<Comments>();
View executing_threads.rs
#![feature(rust_2018_preview, async_await, await_macro, futures_api, pin, arbitrary_self_types)]
use std::future::{Future, FutureObj};
use std::mem::PinMut;
use std::marker::Unpin;
use std::sync::{Arc, Mutex};
use std::sync::mpsc::{sync_channel, SyncSender, SendError, Receiver};
use std::task::{
self,
View fast_buzz.rs
extern crate itoa;
use std::io::Write;
use std::io::BufWriter;
pub fn main() {
let stdout = std::io::stdout();
let mut stdout = BufWriter::new(stdout);
let mut acc = 810092048;
View export_index.py
import http.client
import json
conn = http.client.HTTPConnection("localhost:9200")
conn.request("GET", "/my_index/_search?size=10000")
r1 = conn.getresponse()
result = json.loads(r1.read().decode('utf-8'))
for hit in result["hits"]["hits"]:
print(json.dumps({ "index" : { "_type": hit["_type"], "_id" : hit["_id"] }}))
View gnihihi.rs
use std::fmt::Debug;
fn wrap<A, B>(item: A, f: fn(A) -> B) -> B {
f(item)
}
fn main() {
println!("{:?}", wrap(1, Hoge::Fuga));
println!("{:?}", wrap(1, Foo::Bar));
}
@skade
skade / maniac_mansion.rs
Last active Dec 12, 2017
Passing data between a reactor and a thread pool, back and forth. Playground link: https://play.rust-lang.org/?gist=25f9b0c87b1d5bd39d9fc6ffe0d1840a
View maniac_mansion.rs
extern crate tokio_core;
extern crate futures_cpupool;
extern crate futures;
use futures::future::lazy;
use std::sync::Arc;
// Make sure data is not copy
#[derive(Debug)]
struct Data {
@skade
skade / links.md
Created Nov 26, 2014
Link list elasticsearch UG 2014/11
View links.md
@skade
skade / topics.md
Last active Aug 11, 2017
Topics for Explain Me Like I'm New
View topics.md
  • Boolean Logic
  • Side effects
  • OO Design patterns
  • TDD (Test Driven Development)
  • Stack
  • Threading
  • Concurrency
  • References
  • Information Hiding/Encapsulation
  • Single Responsibility Principle
You can’t perform that action at this time.