Skip to content

Instantly share code, notes, and snippets.

View Kerollmops's full-sized avatar
🍼
Meilisearch needs care

Clément Renault Kerollmops

🍼
Meilisearch needs care
View GitHub Profile
#[macro_use]
extern crate glium;
extern crate opencl;
extern crate libc;
pub mod particle;
pub mod particles;
mod cgl;
use particles::Particles;
//! Systems to specifically deal with entities.
use std::collections::HashMap;
use std::ops::{Deref, DerefMut};
use ecs::Aspect;
use ecs::DataHelper;
use ecs::{Entity, IndexedEntity};
use ecs::EntityData;
use ecs::EntityIter;
@Kerollmops
Kerollmops / gist:d33e665c42c884e3c66d2c3f41bfd7b8
Last active July 23, 2016 19:40 — forked from tomaka/gist:623781c5af6ebbc5dcfe
Gfx vs glium comparison table

Gfx and glium are Rust libraries that aim to provide a "rusty" abstraction over graphics programming APIs. Both may look similar, and one of the questions that gets asked frequently on IRC is "what are the differences between gfx and glium?". Here is a comparison table:

                                 |          Gfx                                                                                                      |               Glium            

-------------------------------------|-------------------------------------------------------------------------------------------------------------------|-------------------------------- URL | https://github.com/gfx-rs/gfx-rs | https://github.com/tomaka/glium History | Papers since Oct 2013. Really started in June 2014. | Private/confidential from Feb 201

general {
output_format = "i3bar"
colors = true
interval = 5
}
order += "ipv6"
order += "disk /"
order += "run_watch DHCP"
order += "run_watch VPNC"
@Kerollmops
Kerollmops / basic_example_float.rs
Last active January 5, 2017 10:16
basic example float for the Medium article on Ripin-rs
extern crate ripin;
use ripin::operate::FloatExpression;
let str_expr = "3 4 + 2 *";
let tokens = str_expr.split_whitespace();
let expr = FloatExpression::<f32>::from_iter(tokens).expect("Parsing error!");
assert_eq!(expr.evaluate(), Ok(14.0));
@Kerollmops
Kerollmops / basic_try_from_iterator_impl.rs
Last active January 3, 2017 22:06
Basic example try_from_iterator implementation for the Medium article on Ripin-rs
extern crate ripin;
use ripin::TryFromRef;
use std::marker::PhantomData;
// the "Operand" type
#[derive(Copy, Clone)]
enum MyOperand {
Number1,
Number2,
@Kerollmops
Kerollmops / basic_evaluation.rs
Last active January 3, 2017 22:10
Basic example basic_evaluation implementation for the Medium article on Ripin-rs
use ripin::evaluate::Evaluate;
use ripin::expression::Expression;
use ripin::{Stack, pop_two_operands};
impl Evaluate<MyOperand> for MyEvaluator<MyOperand> {
type Err = ();
fn operands_needed(&self) -> usize {
match *self {
MyEvaluator::Add | MyEvaluator::Sub => 2,
@Kerollmops
Kerollmops / variable_example_float.rs
Last active January 28, 2017 18:11
viariable example float for the Medium article on Ripin-rs
use ripin::evaluate::VariableFloatExpr;
use ripin::variable::IndexVar;
let variables = vec![3.0, 500.0];
let expr = "3 4 + 2 * $0 -"; // (3 + 4) * 2 - $0
let tokens = expr.split_whitespace();
let expr = VariableFloatExpr::<f32, IndexVar>::from_iter(tokens).expect("Parsing error!");
@Kerollmops
Kerollmops / bench_script.sh
Last active August 15, 2018 10:38
A little script made to help making rust benchmarks comparisons using git revisions
#!/bin/sh
# This env variable is here to permit
# to use a custom `cargo bench` command if needed
CARGO_BENCH_CMD=${CARGO_BENCH_CMD:-cargo bench}
if [ $# -eq 0 ]; then
echo "comparing benchmarks of HEAD~1 and HEAD..."
OLD=$(git rev-parse --short 'HEAD~1')
NEW=$(git rev-parse --short 'HEAD')
@Kerollmops
Kerollmops / ray_from_cam.rs
Last active November 4, 2017 12:34
A function that create a ray from a perspective camera
use cgmath::{Point2, Point3, Vector3, Vector4, Matrix4};
use cgmath::{SquareMatrix, InnerSpace};
use collision::{Ray, Ray3};
// http://antongerdelan.net/opengl/raycasting.html
fn ray_from_cam(proj: Matrix4<f32>, view: Matrix4<f32>, point: Point2<f32>) -> Ray3<f32> {
assert!(point.x >= -1.0 && point.x <= 1.0);
assert!(point.y >= -1.0 && point.y <= 1.0);
// 4d Homogeneous Clip Coordinates