Skip to content

Instantly share code, notes, and snippets.

Avatar

Thomas Schaller torkleyy

View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am torkleyy on github.
  • I am torkleyy (https://keybase.io/torkleyy) on keybase.
  • I have a public key ASBJCJpHMosVjzd4eE0JLDW2XmLwl_68OSO6JR9-PvbtZwo

To claim this, I am signing this object:

@torkleyy
torkleyy / mapping.json
Created Mar 7, 2019
Mapping from ISO 3166-1 alpha-3 to ISO 639-1 (basic subset)
View mapping.json
{
"DEU": "de",
"CHN": "zh",
"GRC": "el",
"EST": "et",
"HRV": "hr",
"LVA": "lv",
"LTU": "lt",
"ROU": "ro",
"ITA": "it",
@torkleyy
torkleyy / macro.rs
Created May 15, 2018
Macro experiments with Rust
View macro.rs
($num:expr;$($field:ident),*;$($rev:ident),*) => {
impl<$($field,)*> Pop for ($($field,)*)
where
$($field: Pop),*
{
fn tag() -> Ty {
unreachable!()
}
fn pop_tags(stack: &mut Stack) -> Result<()> {
@torkleyy
torkleyy / unsafe_magic.rs
Created Mar 31, 2018
[USE WITH CAUTION, not reviewed] How the compiler drops trait objects in Rust
View unsafe_magic.rs
use std::ptr::write;
#[derive(Clone, Copy, Debug)]
#[repr(C)]
struct FatPtr {
ptr: *mut (),
extra: *const (),
}
trait Foo {
@torkleyy
torkleyy / todo.md
Last active Mar 26, 2018
My TODO list for this week
View todo.md
  • Finish shred setup PR
  • Finish shred MetaTable PR
  • Review https://github.com/omni-viral/chains/pull/4
  • Publish shred
  • Create shred version bump PR for Specs
  • Publish Specs
  • specs_gsf (postponed until Specs is published)
  • Get gsf ready for the first release
  • Test out Amethyst UI code & write together current issues
  • Eventually help out with hal integration
@torkleyy
torkleyy / trait_object.rs
Last active Mar 26, 2018 — forked from rust-play/playground.rs
How to cast a generic `T: O` to a generic trait object `O` in Rust
View trait_object.rs
trait Foo {
fn method(&self);
}
trait Cast<T> {
fn cast(t: &T) -> &Self;
fn cast_mut(t: &mut T) -> &mut Self;
}
View gist:c0b90863f61198e3563a39e860208c6b
use specs::System;
use specs::SystemData;
pub struct InstrumentedSystem<T> {
pub system: T,
}
impl<T> InstrumentedSystem<T> {
pub fn new(system: T) -> Self {
InstrumentedSystem {
@torkleyy
torkleyy / playground.rs
Created Dec 8, 2017 — forked from anonymous/playground.rs
Rust code shared from the playground
View playground.rs
const INPUT: &str = "6169763796227664136644229724736711773811471986347364813198\
2449728688116728695866572989524473392982963976411147683588415878214189996163533\
5845471757941581181487242988327988983333997865614591526441446699598873414819683\
1917298735798978579136673284993278834377211217661472385847495991971385539887695\
6427631354172668133549845585632211935573662181331613137869866693259374322169811\
6836353253215972428893581471233581177749146537873713685747843767216521817923716\
3528837672978496752682491519252674493518798957134774622211362557796347614192318\
7534658445615596987614385911513939292257263723518774888174635963254624769684533\
5314437457293443419737464693268381862484484835874775632858674999564462187752323\
7438343392183599313646338362886111557314285435894329114876629965363319558213593\
@torkleyy
torkleyy / specs-lua.rs
Created Oct 29, 2017
A little snippet showing how Lua could be used together with Specs.
View specs-lua.rs
#[macro_use]
extern crate error_chain;
extern crate hlua;
extern crate specs;
use std::collections::HashMap;
error_chain! {
errors {
NoSuchComponent(name: String) {
@torkleyy
torkleyy / entities.rs
Created Aug 7, 2017
Creating entities in Specs
View entities.rs
impl<'a> System<'a> for EntitiyCreator {
type SystemData = (Entities<'a>, WriteStorage<'a, Pos>);
fn run(&mut self, (entities, pos): Self::SystemData) {
let a = entities.create();
let b = entities.create();
pos.insert(a, Pos::new(2, 4));
pos.insert(b, Pos::new(3, 5));
You can’t perform that action at this time.