Skip to content

Instantly share code, notes, and snippets.

class TokenBucket:
def __init__(self, rate=5.0, per=1.0):
self.rate = rate # unit: messages
self.per = per # unit: seconds
self.allowance = rate # unit: messages
self.last_check = time() # floating-point, e.g. usec accuracy. Unit: seconds
def getToken(self):
current = time()
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/foreach.hpp>
#include "boost/filesystem.hpp"
#include "boost/regex.hpp"
#include <iostream>
#include <string>
using namespace boost::filesystem;
{-# LANGUAGE OverloadedStrings #-}
module Main where
import RecursiveContents
import Data.Aeson
import qualified Data.Aeson.Types as T
import Data.Attoparsec (parse, Result(..), IResult(..))
import Data.Text (Text)
import Control.Applicative ((<$>), (<*>))
import Control.Monad (mzero, liftM)
import qualified Data.ByteString.Char8 as BS
for(int i=0; i<COLOR_COUNT_MAX; i++){
myLUTp[i] = (big_originalColorsHist[i] != 0) ? floor(color_sum[i]/(big_originalColorsHist[i]) + 0.5) : 0;
constareaLUTp[i] = (big_constareaColorsHist[i] == 0) ? 0 : floor(constarea_color_sum[i]/(big_constareaColorsHist[i]) + 0.5) ;
}
@hmax
hmax / asm
Created June 17, 2012 09:23
asm vs c
cmp dword ptr [rbp+r15*4+0x1b70], 0x0
jnz 0x14000c06d
pxor xmm0, xmm0
jmp 0x14000c090
xor edx, edx
mov eax, dword ptr [rbp+r15*4+0xb70]
mov ecx, dword ptr [rbp+r15*4+0x1b70]
div ecx
cvtsi2sd xmm0, rax
addsd xmm0, xmm6
def read_word(file_object):
buf = ""
data = file_object.read(1)
while True:
if data in stopsymbols:
if len(buf)>0:
break
else:
buf = buf + data
handle_event {erlyvideo_event,user_play,undefined,<0.155.0>,undefined,
undefined,<0.171.0>,undefined,
[{stream_id,1}],
undefined}
debug 2011-09-08 14:37:15 [main] ems_media:593 {"No decoder config in stream, waiting",<<"vlc.ts">>}
error 2011-09-08 14:37:15 Error in process <0.179.0> on node 'ev@localhost' with exit value: {undef,[{erlywatcher_server,logshit,[]}]}
stream started <0.171.0> [{1,<0.179.0>}]
info 2011-09-08 14:37:19 PLAY 127.0.0.1 undefined 1315478234025626 vlc.ts 1
%%We need to store stream_id, because we have to dispatch frames to right loggers
handle_cast({stream_started, _Host, _StreamName, Stream, _Options}, #online_streams{streams = Streams}) ->
LoggerPid = spawn(?MODULE, logshit,[]),
StreamsList = dict:to_list(Streams),
NewStreamId = case length(StreamsList) of
N when N>0 -> lists:max([Key ||{Key, Value} <- dict:to_list(Streams)])+1;
_ -> 1
end,
ems_media:play(Stream, [stream_id, NewStreamId]),
NewStreams = dict:store(NewStreamId, LoggerPid, Streams),
handle_call({subscribe, Client, Options}, _From, #ems_media{module = M, clients = Clients, audio_config = A, media_info = MediaInfo, last_dts = DTS}
= Media) ->
StreamId = proplists:get_value(stream_id, Options),
DefaultSubscribe = fun(Reply, #ems_media{} = Media1) ->
Ref = erlang:monitor(process,Client),
RequireTicker = case Reply of
tick -> true;
notick -> false;
_ -> proplists:get_value(start, Options) =/= undefined
hmax@hwork /media/portable/Projects/CV/local_morphological_diff_cmake/build $ make sparse_benchmark
[ 50%] Building CXX object src/CMakeFiles/sparse_benchmark.dir/sparse.cpp.o
[100%] Building CXX object src/CMakeFiles/sparse_benchmark.dir/sparse_methods.cpp.o
Linking CXX executable sparse_benchmark
CMakeFiles/sparse_benchmark.dir/sparse.cpp.o: In function `main':
sparse.cpp:(.text+0x1e5): undefined reference to `void cv::sparse_methods::bitwise_and<unsigned char>(cv::SparseMat_<unsigned char>&, cv::SparseMat_<unsigned char>&, cv::SparseMat_<unsigned char>&)'
collect2: выполнение ld завершилось с кодом возврата 1
make[3]: *** [src/sparse_benchmark] Ошибка 1
make[2]: *** [src/CMakeFiles/sparse_benchmark.dir/all] Ошибка 2
make[1]: *** [src/CMakeFiles/sparse_benchmark.dir/rule] Ошибка 2