Posts

Featured post

ios6 - keep track of connected users on ios application -

i have ios app, users can login , logout whenever want. in server side, want know wich users online. set user online when login webservice called, , set offline when logout webservice called. but, cant sure logout done, maybe cellphone turn off, server keep user online, , when try login again error "sorry, logged in" maybe can feedback server (my app uses push notifications) dont know how fast detect user has gone offline... in these cases think best think app should ping server every x seconds , update kind of "last_online" field. then in logic, can consider example user last seen online more 3 minutes ago considered offline. like said, can't trust user click "logout" can't assume that's time logged out. of course can still let user click logout manually.

c++ - QTest dosnt compile -

/usr/include/qt5/qttest/qtestmouse.h:161: undefined reference `qtest::defaultmousedelay()' /usr/include/qt5/qttest/qtestmouse.h:206: undefined reference `qtest::qwarn(char const*, char const*, int)' collect2: error: ld returned 1 exit status im create simple test: #include <qttest/qtest> #include "testhuff.h" #include "huffmancode.h" void testhuff::simpletest() {} if remove #include <qttest/qtest> compiles well.

algorithm - Order of computation on parallel processing -

given unsorted array, have read in article n-square processors can used maximum element of array in o(1) complexity. can explain mechanics behind it? the mechanics behind algorithm based on can call dirty trick. namely, allow processors write simultaneously same shared memory location. if write same value, result considered well-defined. this can used implement parallel-and , parallel-or operators. here's example parallel-or: result := false in 0 n-1 parallel if a[i] result := a[i] we allow simultaneous reads. here's max algorithm: n := a.length in 0 n-1 parallel m[i] := true in 0 n-1 parallel j in 0 n-1 parallel if a[i] < a[j] /* dirty trick: simultaneous read many processors */ m[i] := false /* dirty trick: many processors write m[i] @ once */ in 0 n-1 parallel if m[i] max := a[i] /* dirty trick: many processors write max @ once */ return max the abstract architecture allows these

oop - Data Abstraction in C -

what understood data abstraction hiding technical details user , showing necessary details. data abstraction oop feature. question is: c support data abstraction? if so, why data abstraction object oriented programming language feature , not procedural language feature? if answer question no , structures, enums in c? hide details users. it's possible object oriented programming in c. remember e.g. first c++ compiler c++ c transpiler, python vm written in c etc. thing sets called oop languages apart other better support these constructs, instance in syntax. one common way provide abstraction function pointers. @ struct linux kernel source below (from include/linux/virtio.h). /** * virtio_driver - operations virtio i/o driver * @driver: underlying device driver (populate name , owner). * @id_table: ids serviced driver. * @feature_table: array of feature numbers supported driver. * @feature_table_size: number of entries in feature table array. * @probe: fun

node.js - Time based javascript functions with setInterval -

i'm using node.js question strictly javascript related. i'm interfacing i2c board fade lights , i'd fade them @ specific rate, 1 second. setinterval, in theory should work like... if wanted fade them 100 steps in 1 second like... var fader = setinterval(function(){ //will fade light 100 steps in 1 second dofade(something,something); },10) but depending on code inside of interval loop, may take longer 1 second (i tested , application 2.5 seconds). i'm sure fact function dofade taking set amount of time happen causing issue i'm curious if there real way make happen within 1 second. the closest you'll ever get, afaik, relying entirely on js this: var fader = (function(now) { var timeleft, end = + 1000,//aim 1000 ms stepsremaining = 100, callback = function() {//define here, avoid redefining function objects dosomething(foo, bar); setter(); }, setter = function() {//re

batch file - FORFILES less than 4 days old -

so i'm having trouble trying figure out forfiles. i'm trying files no more 4 days old. less 4 days. not seem quite possible since /d -4 gets items 4 days or older. below have far. forfiles /p t:\downloads /m *.exe /c "cmd /c copy @path t:\downloads\applications | echo copying @path" /d +4 anyone know if possible? or maybe better alternative? this might work you: @echo off &setlocal cd /d "t:\downloads" (for %%a in (*.exe) @echo "%%~a")>dir.txt /f "delims=" %%a in ('forfiles /d -4 /m *.exe ^|findstr /vig:/ dir.txt') echo copying %%a&copy "%%~a" "t:\downloads\applications" del dir.txt unfortunately doesn't work in xp.

flash - How do you get the files type/extension based on the file content in ActionScript? -

how file type/extension based on file content in actionscript? example have jpg image following file name: niceimage. based on file name, won't know whats files extension me it's important know exact type of image. you have read in binary data ( https://www.google.com/search?q=read+binary+file+in+as3 ) , parse image header yourself. there libraries out there (such http://www.greensock.com/loadermax/ ) can if care loading content scene.