Posts

c++ - OpenGL fixed spot map glitch -

i developed game using opengl , c++, works fine glitch need fix: when move camera around (using mouse) map not remain in fixed spot. square (gl_quad) draw in front of me. this example of glitch: video this drawing code of square if needed texture = scene->gettexture("map_papyrus.png"); glblendfunc(gl_src_alpha, gl_one_minus_src_alpha); glenable(gl_blend); gluseprogram(this->shader->getres()); glactivetexture(gl_texture0); glint texture_location = glgetuniformlocation(this->shader- >getfragment(), "color_texture"); gluniform1i(texture_location, texture_location); glbindtexture(gl_texture_2d, this->texture->getres()); glbegin(gl_quads); float size = .5f; float offsetx = 0.0f; float offsety = 0.0f; if (set->easymode) { size = .2f; offsetx = 0.8f; offsety = 0.35f; } gltexcoord2f(0,0); glvertex2f(-size + offsetx, -size + offsety); gltexcoord2f(1, 0); glvertex2f(size + offsetx, -size +offsety);...

c - Calling readline()'s Tab Completion Directly -

i know if want tab completion can use char *readline (const char *prompt); and i'll tab completion while it's running, if have string want completed? there specific function in readline library can call directly , send string parameter have run tab completion on it? i've read through lot of source code of complete.c find main function send string no luck. i don't know c side api lives, bash side calling of stuff, compgen can accept "partial" input. the main problem "partial" input typically provided shell scripts located in /usr/share/bash-completion/completions/"program", there chance seek not "c api" output of 1 or more bash scripts.

SIP Publish event -

i'm newbie sip. i send whole address book of registered sip user using sip message ( publish ) i not understand event package should use. --> event package list can me? riccardo nb: i'm writing handle sip messages... i not aware of standardized event package purpose. sip publish used publish event state (like presence or dialog state) entity in turn composes state , possibly maintains subscriptions other entities. is necessary use sip purpose? sip not meant content delivery protocol. sounds more job http or webdav me.

collections - Scala unFlatMap -

i perform unflatmap. lets have stream: stream("|","a","d","a","m","|","j","o","h","n", ...) stream infinite. convert to: stream("adam", "john", ...) ofcourse example. in general perform operation on elements separated delimiter, generic signature be: def unflatmap[b](isseparator:a => boolean)(group:seq[a] => b):traversableonce[b] how in clean , memory efficient way? you this: def groupstream[a, b](s: stream[a])(isseparator: => boolean)(group: seq[a] => b): stream[b] = group(s.takewhile(!isseparator(_)).tolist) #:: groupstream(s.dropwhile(!isseparator(_)).drop(1))(isseparator)(group) or if want easier read more verbose version: def groupstream[a, b](s: stream[a])(isseparator: => boolean)(group: seq[a] => b): stream[b] = { def isnotseparator(i: a): boolean = ! isseparator(i) def dogroupstream(s: stream[a]): stream...

datetime - Algorithm to estimate total active time from timestamps -

say have a series of timestamps (from visitor impressions), , looks (omitting dates): 01:02:13 01:03:29 01:04:34 02:19:29 09:45:10 09:46:20 ..... in above case, i'd want sum time passed first 4 timestamps (1 2am), , separate them 9am events. is there clever way estimate combined active time, other utilizing timeout (say 300+ seconds timeout indicates new session). if not, what's standard / timeout use?

javascript - Lodash get repetition count with the object itself -

i have array of objects like: [ { "username": "user1", "profile_picture": "testjpg", "id": "123123", "full_name": "user 1" }, { "username": "user2", "profile_picture": "testjpg", "id": "43679144425", "full_name": "user 2" }, { "username": "user2", "profile_picture": "testjpg", "id": "43679144425", "full_name": "user 2" } ] i want get: [ { "username": "user1", "profile_picture": "testjpg", "id": "123123", "full_name": "user 1", "count": 1 }, { "username": "user2", "profile_picture": "testjpg", "id": "43679144425", "full_name": "user 2", "count": 2 } ] i've ...

the output of re.split in python doesn't make sense to me -

print (re.split(r'[a-fa-f]','finqwenlaskdjriewasfsdfddsafsafasa',re.i|re.m)) print (re.split(r'[a-fa-z]','finqwenlaskdjriewasfsdfddsafsafasa',re.i|re.m)) print (re.split(r'\d*','sdfsfdsfds123212fdsf2')) print (re.split(r'\d','sdfsfdsfds123212fdsf2')) print (re.split(r'\w+','dsfsf sdfdsf sdfsdf sfsfd')) ['', 'inqw', 'nl', 'sk', 'jri', 'w', 's', 's', '', '', 'dsafsafasa'] ['', 'inqw', 'nl', 'sk', 'jri', 'w', 's', '', '', '', 'ddsafsafasa'] ['sdfsfdsfds', 'fdsf', ''] ['sdfsfdsfds', '', '', '', '', '', 'fdsf', ''] ['', ' ', ' ', ' ', ''] i think output here weird. pattern split string turned '' in ...