Skip to content

Instantly share code, notes, and snippets.

Avatar

Sergey Astanin astanin

View GitHub Profile
@astanin
astanin / shared_getters.cpp
Last active May 28, 2016
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.
View shared_getters.cpp
#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 Mar 23, 2016
xmlize(), a simple function similar to tabulate, to generate xml tables
View table2xml.ipynb
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 Jul 29, 2015
Pipe table in GFM
View pipetable.md

Pipe-table generated by tabulate and rendered by Github:

item qty
spam 42
eggs 451
bacon 0
@astanin
astanin / nbody2.ino
Last active Aug 29, 2015
nbody.ino with correct time measurement
View nbody2.ino
/*
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 Feb 24, 2014
This script demonstrates the overhead of using SyncManager vs Value.
View value_vs_manager.py
"""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 Jan 4, 2016
n-body benchmark on Galileo/Arduino
View nbody.ino
/*
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 Sep 30, 2013
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
View ipython.el
;;; 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 Jul 17, 2013
Generic `head`-like functions implemented with functional dependency.
View HasHeadFD.hs
{-# 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 Dec 19, 2015
Generalizing `head`-like functions with TypeFamilies.
View HasHead.hs
{-# LANGUAGE MultiParamTypeClasses, TypeFamilies, FlexibleInstances #-}
module HasHead where
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as BSC
-- Usage example