Skip to content

Instantly share code, notes, and snippets.

View astanin's full-sized avatar

Sergey Astanin astanin

View GitHub Profile
@astanin
astanin / shared_getters.cpp
Last active May 28, 2016 18:30
How to share implementation of methods between multiple derived classes in C++ without putting it into the base class. Using the curiously recurring template pattern.
#include <iostream>
/* How to share implementation of methods between multiple derived classes
without putting it into the base class. Using the curiously recurring template
pattern.
Let's assume, that most, but not all of the derived classes are implemented in
a similar way, and have .x and .y members.
It makes sense to write getters and setters only once and share this code
@astanin
astanin / table2xml.ipynb
Last active March 23, 2016 15:03
xmlize(), a simple function similar to tabulate, to generate xml tables
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@astanin
astanin / pipetable.md
Created July 29, 2015 18:06
Pipe table in GFM

Pipe-table generated by tabulate and rendered by Github:

item qty
spam 42
eggs 451
bacon 0
@astanin
astanin / lcov-on-msys-howto.md
Last active August 29, 2015 14:22
How to install LCOV on Windows (in MSYS2)

See

@astanin
astanin / nbody2.ino
Last active August 29, 2015 14:17
nbody.ino with correct time measurement
/*
An implementation of the n-body benchmark for Arduino clones.
Expected output with TIME_STEPS = 50000000:
-0.169075164
-0.169059907
# time: ...
N-body benchmark (Java7 #2 1 Core):
@astanin
astanin / value_vs_manager.py
Created February 24, 2014 16:00
This script demonstrates the overhead of using SyncManager vs Value.
"""This script demonstrates the overhead of using SyncManager vs Value.
Output:
C double: 8.782e-07 sec per assignment
C struct: 8.795e-07 sec per assignment
Python class: 3.346e-07 sec per assignment
AutoProxy: 2.985e-05 sec per assignment
Method calls on AutoProxy seem to be two orders of magnitude slower.
@astanin
astanin / nbody.ino
Last active January 4, 2016 09:29
n-body benchmark on Galileo/Arduino
/*
An implementation of the n-body benchmark for Intel Galileo (Arduino clone)
Expected output with TIME_STEPS = 50000000:
-0.169075164
-0.169059907
# time: ...
Performance of Intel Galileo vs desktop CPUs:
@astanin
astanin / ipython.el
Created September 30, 2013 09:58
ipython.el version 0.11 as taken from https://raw.github.com/ipython/ipython/master/docs/emacs/ipython.el with Version and "ends here" comments added, as required by Marmalade
;;; ipython.el --- Adds support for IPython to python-mode.el
;; Copyright (C) 2002, 2003, 2004, 2005 Alexander Schmolck
;; Author: Alexander Schmolck
;; Keywords: ipython python languages oop
;; URL: http://ipython.org
;; Compatibility: Emacs21, XEmacs21
;; Version: 0.11
;; FIXME: #$@! INPUT RING
@astanin
astanin / HasHeadFD.hs
Created July 17, 2013 15:09
Generic `head`-like functions implemented with functional dependency.
{-# LANGUAGE FunctionalDependencies, FlexibleInstances #-}
module HasHeadFD where
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as BSC
class HasHeadFD c e | c -> e where
@astanin
astanin / HasHead.hs
Last active December 19, 2015 21:19
Generalizing `head`-like functions with TypeFamilies.
{-# LANGUAGE MultiParamTypeClasses, TypeFamilies, FlexibleInstances #-}
module HasHead where
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as BSC
-- Usage example