Skip to content

Instantly share code, notes, and snippets.

View aldanor's full-sized avatar

Ivan Smirnov aldanor

  • Dublin, Ireland
View GitHub Profile
@aldanor
aldanor / playground.rs
Created October 29, 2018 00:57 — forked from rust-play/playground.rs
Code shared from the Rust Playground
#![allow(dead_code)]
use std::cell::RefCell;
use std::rc::Rc;
trait Stream<'a> {
type Item: 'a + ?Sized;
fn subscribe<F>(self, f: F) where F: FnMut(&Self::Item) + 'a;
@aldanor
aldanor / playground.rs
Created October 26, 2018 01:45 — forked from rust-play/playground.rs
Code shared from the Rust Playground
use std::cell::RefCell;
use std::rc::Rc;
trait Observer<T> {
fn on_next(&mut self, item: T);
}
impl<T, F> Observer<T> for F where F: FnMut(T) -> () {
fn on_next(&mut self, item: T) {
self(item)
@aldanor
aldanor / playground.rs
Created October 26, 2018 01:16 — forked from rust-play/playground.rs
Code shared from the Rust Playground
use std::cell::RefCell;
use std::rc::Rc;
trait Observer<T> {
fn on_next(&mut self, item: T);
}
impl<T, F> Observer<T> for F where F: FnMut(T) -> () {
fn on_next(&mut self, item: T) {
self(item)
@aldanor
aldanor / playground.rs
Created October 23, 2018 01:15 — forked from rust-play/playground.rs
Code shared from the Rust Playground
trait Observer<T> {
fn on_next(&mut self, item: Option<T>);
}
impl<T, F> Observer<T> for F where F: FnMut(Option<T>) {
fn on_next(&mut self, item: Option<T>) {
self(item)
}
}
import json
import os
import shlex
import sys
def extract_includes():
cwd = os.getcwd()
cc1 = os.path.join(cwd, 'cmake', 'compile_commands.json')
cc2 = os.path.join(cwd, 'compile_commands.json')
@aldanor
aldanor / libpcap_versions.py
Last active March 20, 2017 21:51
libpcap versions
import collections
import fnmatch
import git
import os
import pprint
import pycparser
import subprocess
import tempfile
repo = git.Repo()
@aldanor
aldanor / graphsearch.hs
Created May 22, 2013 21:57
obscure graph hackage
import Data.List (unfoldr, minimumBy)
import Data.Char (isSpace)
import Data.Function (on)
import Data.Maybe (mapMaybe, fromMaybe)
import System.Environment (getArgs)
import qualified Data.ByteString.Char8 as L
import qualified Data.IntMap as IM
type GraphData = (IM.IntMap (IM.IntMap [(Int, Int)]), Int)

#Node

##single

Size Heap New Small Node Array Stack
256*1 19,000 19,000 31,000 18,000 42,000 12,000
256*4 19,000 19,000 31,000 18,000 42,000 12,000
256*8 19,000 19,000 31,000 18,000 41,000 12,000
256*256 26,000 29,000 28,000 15,000 39,000 12,000
#include <iostream>
#include <pybind11/pybind11.h>
namespace py = pybind11;
struct Foo { int v; Foo(int v) : v(v) {} };
PYBIND11_PLUGIN(test_untracked) {
py::module m("test_untracked");
py::class_<Foo>(m, "Foo")
.def(py::init<int>());
@aldanor
aldanor / bench_any_view.cpp
Created August 17, 2016 22:20
ranges::any_view bench
#include <iostream>
#include <chrono>
#include "range-v3/include/range/v3/all.hpp"
using namespace std::chrono;
template<typename T, CONCEPT_REQUIRES_(ranges::Integral<T>())>
class odd : public ranges::view_facade<odd<T>> {
friend ranges::range_access;