Posts

google play services - get current location of android device -

google play services - get current location of android device - i have taken code google " googleplacelocation " project. trying should give me current nearest location of mobile, using longitude , latitude comparing . right giving me list view of close places through when click on place name shows me address, name , longitude , latitude. i'm trying closest nearby location. has other files such googleplaces , place.java , on. work done here. here code mainactivity.java public class mainactivity extends activity { // flag net connection status boolean isinternetpresent = false; // connection detector class connectiondetector cd; // alert dialog manager alertdialogmanager alert = new alertdialogmanager(); // google places googleplaces googleplaces; // places list placeslist nearplaces; // gps location gpstracker gps; // button button btnshowonmap; // progress dialog progressdialog pdia...

python - Control output of Django Rest Framework -

python - Control output of Django Rest Framework - my rest api functioning correctly, output id numbers. how can 'role_type' display name instead of id number? output: {"count": 2, "next": null, "previous": null, "results": [{"user": {"username": "smithb", "first_name": "bob", "last_name": "smith"}, "role_type": 2, "item": 1}, {"user": {"username": "jjones", "first_name": "jane", "last_name": "jones"}, "role_type": 2, "item": 1}]} serializers.py class roleserializer(serializers.modelserializer): user = personshortserializer(many=false, read_only=true) class meta: model = role fields = 'user', 'role_type', 'item' def get_role_type(self, obj): homecoming obj.name models.py ...

java - Lucene search of two or more words not working on Android -

java - Lucene search of two or more words not working on Android - i using lucene 3.6.2 on android. code used , observations made below. indexing code: public void indexbookcontent(book book, file externalfilesdir) throws exception { indexwriter indexwriter = null; niofsdirectory directory = null; directory = new niofsdirectory(new file(externalfilesdir.getpath() + "/indexfile", book.getbookid())); indexwriterconfig indexwriterconfig = new indexwriterconfig(lucene_36, new standardanalyzer(lucene_36)); indexwriter = new indexwriter(directory, indexwriterconfig); document document = createfieldsforcontent(); string pagecontent = html.fromhtml(decryptedpage).tostring(); ((field) document.getfieldable("content")).setvalue(pagecontent); ((field) document.getfieldable("content")).setvalue(pagecontent); ((field) document.getfieldable("content")).setvalue(pagecontent.tolowercase()); } private document...

Printing Specific Rows in R -

Printing Specific Rows in R - hi guys working big info frame records employee time card info specific months. want print out entire row of employees record maximum of 3 zeros in 3 different months. believe need utilize apply function: apply(employee, 1, ...) employee name of info frame, 1 allows iterate on each row, unsure how select have 3 or fewer zeros in row. appreciate help! you utilize rowsums() . here's illustration false data. > d <- data.frame(x1 = c(0, 1, 0, 0), x2 = c(0, 2, 2, 0), x3 = c(0, 2, 0, 0), x4 = c(3, 0, 0, 0)) > d # x1 x2 x3 x4 # 1 0 0 0 3 # 2 1 2 2 0 # 3 0 2 0 0 # 4 0 0 0 0 the can subset rows logical value of x == 0 sums 3 or less: > d[rowsums(d == 0, na.rm = true) <= 3, ] # x1 x2 x3 x4 # 1 0 0 0 3 # 2 1 2 2 0 # 3 0 2 0 0 r

nginx - Excluding location path from file pathes -

nginx - Excluding location path from file pathes - in config file, location /i/ { root /data/w3; } the /data/w3/i/top.gif file sent in response /i/top.gif request. how can set ignore i in file paths? indeed need /i/top.gif mapped /data/w3/top.gif . location /i/ { alias /data/w3/; } nginx config httpserver

php - Remove nth element from redis's list in thread safe way -

php - Remove nth element from redis's list in thread safe way - in cron job, wish remove nth element redis's list, in thread safe way during iteration. is possible? may know how can so? i'm looking thread safe way. there author process, perform write operation same list time-to-time. while (true) { // elements "mylist" list. $list = $redis->lrange("mylist", 0, -1); // iterate through "mylist" list. ($n = 0; $n < count($list); ++$n) { if ($list[$n] == "dummy") { // wish remove nth element (with "dummy" value) "mylist" // in thread safe fashion. how? } } } thread safe of import such next situation won't happen cron job find out "dummy" element 5th element, , prepare remove it. writer process inserting additional element head of list, pushes "dummy" element 6th position. cron job removed 5th element list, n...

java - What is wrong with my normal calculations? -

java - What is wrong with my normal calculations? - i attempted utilize algorithm described @ opengl - how calculate normals in terrain height grid?. popped in vertex shader , using perlin noise functions test it, , worked charm, when ported java, didn't work well. float nx = 0; float ny = 0; float nz = 0; vector3 p = new vector3(vpx,vpy,vpz); vector3 off = new vector3(1,1,0); float hl = trygetheight(_mempoints2,p.x - off.x,p.z - off.z); float hr = trygetheight(_mempoints2,p.x + off.x,p.z + off.z); float hd = trygetheight(_mempoints2,p.x - off.z,p.z - off.y); float hu = trygetheight(_mempoints2,p.x + off.z,p.z + off.y); nx = hl - hr; ny = hd - hu; nz = 2.0f; vector3 v = new vector3(nx,ny,nz); v = v.nor(); nx = v.x; ny = v.y; nz = v.z; the results algorithm in vertex shader: the results algorithm in buffer setup: (sorry blur, testing depth of field stuff when snapped these.) the results algorithm in vertex shader: normals should not calculated in sha...