Skip to content

Instantly share code, notes, and snippets.

Seivan Heidari seivan

Block or report user

Report or block seivan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@seivan
seivan / dense.rs
Created Jul 30, 2019
Dense and Sparse vector for faster O(1) lookup, insert and removal (no order)
View dense.rs
#[derive(Debug)]
pub struct DenseVecStorage<T>
where
T: Component,
{
components: Vec<T>,
entity_ids: Vec<usize>,
component_ids: Vec<usize>,
}
@seivan
seivan / main.rs
Last active Nov 20, 2018
gfx-rs. 3.2
View main.rs
#[macro_use]
extern crate gfx;
extern crate gfx_window_sdl;
extern crate sdl2;
use gfx::Device;
pub type ColorFormat = gfx::format::Srgba8;
pub type DepthFormat = gfx::format::DepthStencil;
@seivan
seivan / mod.rs
Created Oct 11, 2018
Events on UIViewController
View mod.rs
//! iOS support
//!
//! # Building app
//! To build ios app you will need rustc built for this targets:
//!
//! - armv7-apple-ios
//! - armv7s-apple-ios
//! - i386-apple-ios
//! - aarch64-apple-ios
//! - x86_64-apple-ios
@seivan
seivan / mod.rs
Created Oct 11, 2018
Sans UIApplication & UIApplicationDelegate
View mod.rs
//! iOS support
//!
//! # Building app
//! To build ios app you will need rustc built for this targets:
//!
//! - armv7-apple-ios
//! - armv7s-apple-ios
//! - i386-apple-ios
//! - aarch64-apple-ios
//! - x86_64-apple-ios
View erasedensevector.cpp
template size_t handle_map::erase(Id_T handle)
{
if (!isValid(handle)) { return 0; }
m_fragmented = 1;
Id_T innerId = m_sparseIds[handle.index];
uint32_t innerIndex = innerId.index;
// push this slot to the back of the freelist
innerId.free = 1;
View rants.md

The borrow checker is solid. The communication with it, is a UX fail. As indicative by the tutorials that write pseudo code to try to teach you how it works using named scopes.
By now, I get how it works but it's hard to predict in a when you're not exactly sure how to solve certain technical issues, or even how the final design of an API of several modules will look like. Forcing you go back and forth between lifetimes, implementations and what not. two steps forward, eleven back. It's a failure that the borrow checker does not adapt to what I am trying to achieve instead of telling me it's impossible - when I am very much aware, it's possible.

Ideas: Figure out what variations of smart pointers and mutexes will work in combination to do what I am trying to achieve and make it happen - this essentially gets rid of the borrow checker as your code becomes reference counted instead of compile error. Performance and execution becomes unpredictable as you have no idea what's going to happen once you execu

@seivan
seivan / CustomFileHandler.swift
Created Sep 24, 2018
Long running Swift process (for running under BeamVM through ports)
View CustomFileHandler.swift
////
//// CustomFileHandler.swift
//// StatefulProcess
////
//// Created by Seivan Heidari on 18/07/03.
////
//
import Foundation
#if os(Linux)
import Glibc
@seivan
seivan / world.cpp
Created Sep 22, 2018
C++ ECS prototype
View world.cpp
#include <map>
#include <memory>
#include <set>
#include <typeindex>
#include <vector>
// ────────────────────────────────────────────────────────────────────────────────
struct Position {};
struct Weapon {};
@seivan
seivan / world.cpp
Created Sep 22, 2018
N variadic tuple
View world.cpp
#include <iostream>
#include <string>
#include <type_traits>
class Frombler {
public:
virtual void fromble() = 0;
};
class Foo : public Frombler {
@seivan
seivan / UndefinedBehaviour.swift
Created Aug 31, 2018
This shouldn't work, but it works. Thus undefined behaviour.
View UndefinedBehaviour.swift
func update(_ arg: inout String) {
arg = "UPDATED \(arg)"
}
public class SystemWork {
let mainQueue = DispatchQueue.init(label: "mainQueue", qos: .userInitiated, attributes: [], autoreleaseFrequency: .inherit, target: nil)
let workerQueue = DispatchQueue.init(label: "workerQueue", qos: .userInitiated, attributes: [.concurrent], autoreleaseFrequency: .inherit, target: nil)
let systemQueue = DispatchQueue.init(label: "systemQueue", qos: .userInitiated, attributes: [.concurrent], autoreleaseFrequency: .inherit, target: nil)
You can’t perform that action at this time.