Skip to content

Instantly share code, notes, and snippets.

View sumerman's full-sized avatar
🔮
DATABASE, DATABASE, JUST LIVING IN A DATABASE

Valery Meleshkin sumerman

🔮
DATABASE, DATABASE, JUST LIVING IN A DATABASE
View GitHub Profile
%% delta(x speed), -//-y, px (lim=px*x),-//- py
{Scale, Sdurat} = gen_scale(linear(1), linear(1), 2, 2),
{Irotate, Rdurat} = gen_rotate(linear(2), 4.5), %% delta(speed), p (lim = p*360)
Rotate = delay(Sdurat, Irotate),
{Itrans, Tdurat} = gen_translate(pow(2), 3.7),
Trans = delay(Sdurat + Rdurat, Itrans),
Trigger = delay(Sdurat + Rdurat + Tdurat, gen_trigger(TrigFunc)),
(gdb) p x < 1
$7 = true
(gdb) p x < (bx + block()->size())
$8 = false
(gdb) p (bx + block()->size())
$9 = 1
(gdb)
-------
@sumerman
sumerman / shared_ptr.hpp
Created December 4, 2010 12:22
Simple non-intrusive refc-smart-pointer
/*
* shared_ptr.h
*
* Created by Valeryi Meleshkin.
*
*/
#ifndef __SHARED_PTR__
#define __SHARED_PTR__
@sumerman
sumerman / flatten.hs
Created January 19, 2011 07:44
Test Pastie
data BiTree a = Leaf a | BiTree a (BiTree a) (BiTree a) deriving Show
{-flatten :: BiTree a -> [a]-}
{-flatten (BiTree v l r)= [v] ++ flatten l ++ flatten r-}
{-flatten (Leaf v) = [v]-}
flatten' :: BiTree a -> [a] -> [a]
flatten' (Leaf v) res = v:res
flatten' (BiTree v l r) res = v:flatten' l (flatten' r res)
@sumerman
sumerman / static_dispatch_tmpr.cpp
Created February 15, 2011 12:11
Static dispatch with C++ templates
#include <cstdlib>
#include <iostream>
using namespace std;
struct Functor {
inline int operator () (int i, char c) {
return i+c;
}
};
-module(head_srv).
-compile(export_all).
%-export([start/1, benchmark/1, console_start/0, loop/1]).
-include("jsonerl/jsonerl.hrl").
-record(command, {action, error, login, desc}).
-record(logic_state, {ies = none}).
-define(INTERNAL_TIMEOUT, 10000).
-define(LISTEN_PORT, 6070).
@sumerman
sumerman / cpp_meta_type_enc_n_conv.cpp
Created April 29, 2011 16:47
Type encoding and conversion of encoded types through metaprogramming
#include <cstdlib>
#include <cstdio>
#include <iostream>
using namespace std;
template <typename T1, typename T2>
class Cast {
private:
struct BigType {
@sumerman
sumerman / refal_matching.hs
Created May 25, 2011 12:38
Refal-expression mathcing implementation for one of CS courses. Comments in russian.
-- | Задание практикума №2
-- Вариант №2 "Отождествление Рефал-выражений"
module Main where
import Debug.Trace
import Data.Maybe
import Control.Monad
import Text.ParserCombinators.Parsec as Parsec
-- * Вспомогательные функции и типы
@sumerman
sumerman / NSInvocationOperation+multipleObject.m
Created June 1, 2011 07:25
initWithTarget:selector:objects: (multiple objects, until nil) cathegory for NSInvocationOperation
@interface NSInvocationOperation (mutipleObject)
- (id)initWithTarget:(id)target selector:(SEL) objects:(id)first, ...;
@end
@implementation NSInvocationOperation (multipleObjects)
- (id)initWithTarget:(id)target selector:(SEL)sel objects:(id)first, ... {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
NSMethodSignature *signature = [target methodSignatureForSelector:sel];
@sumerman
sumerman / MVStateStorage.h
Created September 4, 2011 10:00
Intent of this code is to guide protected concurrent access to collection of states.
#import <Foundation/Foundation.h>
typedef id (^MVGetterBlock)(void);
typedef void (^MVSetterBlock)(id);
typedef id (^MVStateOpBlock)(id);
typedef NSOperation * (^MVOpSetupBlock)(MVGetterBlock, MVSetterBlock);
@interface MVStateStorage : NSObject {
__block NSMutableDictionary *data;