Posts

Showing posts from February, 2013

file - Eclipse(Android SDK) is showing the error "content not allowed in prolog " -

<application android:icon="@drawable/sudoku111" android:label="@string/app_name" > <activity android:name=".sudokugame1" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <activity android:name=".about" android:label="@string/about_title" android:theme="@android:style/theme.dialog" /> <activity android:name=".prefs" android:label="@string/settings_title" /> <activity android:name=".game" android:label="@string/game_title" /> </application> <uses-sdk android:minsdkversion="8" /> th

php - How can I create a checked listbox of Wordpress categories? -

the first thing tried following <input type="checkbox" id="check1" /> <label for="check1"> <ul id="selectable0"> <li><?php wp_list_cats(); ?></li> </ul> </label> this creates single checkbox. want have listbox checkbox beside each item. <?php $categories = get_categories(); foreach ($categories $category) { ?> <input type="checkbox" name="check" value="<?php echo $category->cat_id; ?>"><?php echo $category->cat_name;?><br> <?php } ?>

iphone - UIScrollView comes over UIImage in simulator -

Image
i'm using storyboard , on storyboard i've put uiscrollview , uiimage , can see in image uiscrollview comes on uiimage if @ storyboard looks fine... idea how can fix or problem is? uiimageview size inspector: uiscrollview size inspector: it's hard tell, looks image taller storyboard allows. is imageview.clipstobounds == true ? if not, may want set scrollview.frame after you've set image.

16 bit - Assembly , Move an 8 bit register to a 16 bit Register , how? -

what want know said on topic. have problem moving 8 bit register 16 bit register . i'm trying , divide number permanently 10 til gets lower 10 , , , within each division time , try move out remained part of division out ah register , add 48 it, have ascii code , try show digit got , on screen . here code : num1 dw 255 division : cmp num1,10 jl divend mov ax,10 div num1 mov num1,al ;* add ah,48 mov dl,ah; mov ah,02h int 21h jmp division but , when im trying assemble , says , operand types not match on line indicated * . im using turbo assembler v4.1 ... should ? did mean that? mov bx, offset num1 mov [bx], al the error because declare word adress byte. if did num1 db works. tested tasm 4.1

php - How to delete duplicates in an array? -

how can delete duplicates in array? for example if had following array: $array = array('1','1','2','3'); i want become $array = array('2','3'); so want delete whole value if 2 of found depending on php version, should work in versions of php >= 4.0.6 doesn't require anonymous functions require php >= 5.3: function morethanone($val) { return $val < 2; } $a1 = array('1','1','2','3'); print_r(array_keys(array_filter(array_count_values($a1), 'morethanone'))); demo (change php version in drop-down select version of php using) this works because: array_count_values go through array , create index each value , increment each time encounters again. array_filter take created array , pass through morethanone function defined earlier, if returns false , key/value pair removed. array_keys discard value portion of array creating array values being keys d

swing - Java how to refresh sql outcome in jlist -

i'm having little problem java application. want show orders of restaurant in left jlist, , details of selected order in right jlist. orders read in through mysql query , printed jlist. however, want make refresh button whitch query has executed again , printed jlist. however, can not make refresh button work. refresh content, opens new jfram window... from gui class: public class barscherm extends javax.swing.jframe { private bedieningsmanager manager; /** * creates new form barscherm */ public barscherm() { manager = new bedieningsmanager(); initcomponents(); } private void opvraagknopactionperformed(java.awt.event.actionevent evt) { // refresh button jpanel1.removeall(); java.awt.eventqueue.invokelater(new runnable() { public void run() { new barscherm().setvisible(true); } }); } from manager class: public class bedieningsmanager { private arraylist<barbestelling>

dart - Observable list not updating from js Callback -

i'm trying update template within js.callback . when cities.add("test") main() works fine , updates template string, doing same within callback template not updating. i'm trying use javascript api parse.com . login works , getting objects querys well. started out learning dart, maybe it's obvious i'm missing? update: problem solved calling js.retain(parse) , dispatch() working solution below. mydart.html : <template iterate="city in cities"> {{city}} </template> mydart.dart : import 'dart:html'; import 'package:web_ui/web_ui.dart'; import 'package:js/js.dart' js; var parse = js.context.parse; list<string> cities = new list(); void main() { js.retain(parse); //solution problem (1/2) parse.initialize("id", "key"); if(parse.user.current() == null) { parse.user.login("user", "password", js.map({ "success": new

ruby on rails - Setting business name and header images with adaptive payments on paypal -

Image
in order ensure consistent experience want set header image , business on paypal's page, view items names , description , ask customer select shipping address. i'm using active_paypal_adaptive_payment gem ( https://github.com/jpablobr/active_paypal_adaptive_payment ) , option set_payment_options: response = adaptive_gateway.setup_purchase( :action_type => 'create', :receiver_list => recipients, ... ) adaptive_gateway.set_payment_options( :display_options => { :business_name => 'big business', :header_image_url => 'url goes here' }, :sender_options => { :require_shipping_address_selection => true }, :receiver_options => [{ :description => _description, :invoice_data => { :item => [{ :name => _title, :item_count => 1, }], :total_shipping => 10.0, :total_tax => 10 }, :receiver => { :email => email } }

Android - JAVA Denial of Service: Parse Double -

there vulnerability in implementations of java.lang.double.parsedouble() , related methods can cause thread hang when parsing number in range [2^(-1022) - 2^(-1075) : 2^(-1022) - 2^(-1076)] this not issue when using java version 6 update 24 or later. so in order develop secure android application, enough make sure apk built on using jdk version 1.6u24 , above? or, issue related android dalvik vm? please in clarifying might have misconceptions. the buid version of java byte code irrelevant, long execution done on jvm new parsedouble, or on dalvik vm, not know of having flaw. is, parsedouble code runtime library, not part of code. the bug hangs app (critical), not security risk such.

css - HTML with icon on left and right side -

i want create un-order list in html. each of list item, there icon on left side , icon on right side. text among 2 icons , should auto occupy available screen width. in case of long text, ellipsis. list item should this: ++++++ ++++++++++++++++++++++++++ ++++++ +icon+ + short text + +icon+ ++++++ ++++++++++++++++++++++++++ ++++++ ++++++ ++++++++++++++++++++++++++ ++++++ +icon+ + long text long text ...+ +icon+ ++++++ ++++++++++++++++++++++++++ ++++++ ++++++ ++++++++++++++++++++++++++ ++++++ +icon+ + short text + +icon+ ++++++ ++++++++++++++++++++++++++ ++++++ i tried many ways create list didn't success. please help! solution or recommends welcome. update: need icons on separated tags, such div or img in advance. you can use floats: demo 1 and can use position absolute: demo 2 ignore if it's not after.

php - Sending an email verification after registering -

i want, users register on site, have activate account first, before using it. problem is, don't email email test account. before start posting code, problem be, i'm working on local machine xampp? otherwise, here code snippet $random = substr(number_format(time() * rand(),0,'',''),0,10); $insertmailverify = $this->db->prepare("insert mailverify (mailaddress, token, datetime) values (:mailaddress, :token, :date)"); $insertmailverify->execute(array(':mailaddress'=>$emailaddress, ':token'=>$random, ':date'=>$date)); $to = $emailaddress; $subject = "activating account"; $body = "hi, in order activate account please visit http://localhost/finalyear/activation.php?email=".$emailaddress." , fill in verification code $random"; if(mail($to, $subject, $body)) { echo ("

mysql - create trigger to alter multiple tables -

i have n tables, and each table share common column 'colx'. , each table's colx column can have independent values in column, when alters value in main table t's colx, each table's corresponding colx value must updated new value in t's colx. i can write trigger 1 table only, how write n tables? colxcascade triggers through tables, table1 trigger updates table2, table2 can run triggers affect table3 create table table1 (colx int not null, primary key (id) ); create table table2 (id int, colx int, index par_ind (parent_id), foreign key (colx) references table1(colx) on update cascade )

iphone - ALAsset thumbnail without inward black translucent border -

i have find photos in gallery, [alasset thumbnail] return thumbnail inward black translucent border. my question is, how can obtain thumbnail without border? you have lot of options. if need display on screen fake 1 pixel of thumbnail isn't visible. can put uiimageview inside uiview clips bounds. uiview* view = [[uiview alloc] initwithframe:cgrectmake(0, 0, 200, 200)]; view.backgroundcolor = [uicolor clearcolor]; view.clipstobounds = yes; uiimageview* imgview = [[uiimageview alloc] initwithframe:cgrectmake(-1, -1, 202, 202)]; imgview.image = [asset thumbnail]; [view addsubview:imgview]; or better yet, make uiview subclass , override drawrect. -(void)drawrect:(cgrect)rect { uiimage* thumb = [asset thumbnail]; [thumb drawinrect:cgrectmake(rect.origin.x-1, rect.origin.y-1, rect.size.width+2, rect.size.height+2)]; } or can use aspectratiothumbnail instead , make squared yourself. uiimageview* imgview = [[uiimageview alloc] initwithframe:cgrectmake(0, 0

layout - Most popular screen resolutions / ratios among android tablets and smarthphones -

i looking site offer statistics/graphs providing popular resolutions / screen ratios on android smartphones , tablets. need design ui , plan how scale. cool if shared data. is you're looking for? http://developer.android.com/about/dashboards/index.html http://developer.android.com/guide/practices/screens_support.html#testing

Raising event when the checkbox of a webbrowser is checked in C# -

i want raise event when checkbox checked in web browser. here have come with: public class htmlcheckboxargs : eventargs { public guid elementguid; } public delegate void checkboxchangeeventhandler(object sender, htmlcheckboxargs e); public event checkboxchangeeventhandler checkpressed; void oncheckpressed(htmlcheckboxargs args) { if (checkpressed != null) checkpressed(this, args); } protected void checkboxevents() { htmlelementcollection elements = webbrowser1.document.getelementsbytagname("input"); foreach (htmlelement el in elements) { htmlcheckboxargs checkbargs = new htmlcheckboxargs(); if (el.getattribute("type") == "checkbox") { checkbargs.elementguid = guid.parse(el.id); el.attacheventhandler("onclick", (sender, args) => oncheckboxclicked(el, checkbargs));

c++ - cannot convert parameter 2 from 'mxArray **' to 'mwArray &' -

i want create c++ shared library matlab using deloytool , use in mvs. compile function name 'foo.m', result got list of files (.h,.cpp,.lib,...) , found function in 'foocpplib.h' follow: extern lib_foocpplib_cpp_api void mw_call_conv foo(int nargout, mwarray& y, const mwarray& x); then create mvs project (2010), window form application, 2 textbox , 2 click button, 1 textbox named inbox, , named outbox. code inside button_click follow: private: system::void button1_click(system::object^ sender, system::eventargs^ e) { double input = system::double::parse(inbox->text); mxarray *x_ptr; mxarray *y_ptr=null; double *y; // create mxarray input mlffoo x_ptr = mxcreatedoublescalar(input); // call implementation function // note second input argument should &y_ptr instead of y_ptr. foo(1,&y_ptr,x_ptr); // return value mlffoo mxarray. // use mxgetpr pointer data contains. y = (double*)mxgetpr(y_ptr); // display result in form outbox->text

Winapi c++: DialogBox hangs when breaking a loop -

i've created s simple w32 application cicle through 2 applications(hard coded window classes atm). when call start button (idc_start) works fine, when change focus hwnd application hangs cannot closed. need simple , clean method stop loop, start when calling idc_start. apreciated! #include <stdio.h> #include <stdlib.h> #include <conio.h> #include <windows.h> #include <resource.h> #include <iostream> using namespace std; bool callback dlgproc(hwnd hwnd, uint message, wparam wparam, lparam lparam) { hwnd hwnd1,hwnd2; hwnd1 = findwindow("notepad++",0); hwnd2 = findwindow("notepad",0); bool bdone; switch(message) { case wm_initdialog: // set dialog box, , initialise default values { setdlgitemint(hwnd, idc_number, 5, false); hicon hicon, hiconsm; hicon = (hicon)loadimage(null, "e32.ico", image_icon, 32, 32, lr_loadfromfile); if(hicon) se

c# - PHP Mail using HTTP POST Attachments -

i developing php service windows phone based client application. invoking service through client(wp7) , want service send attachment sent part of email. hence using http post, set $to, $message, $subject , $from inside php, , use same logic attachments, after invoking service email on mailbox, corrupt attachment. attachment contains garbage value. here php code $filenames = $_post['attachment']; $to = $_post['to']; $subject = $_post['subject']; $messagetxt = $_post['message']; $headers = "from: " . $_post['from']; $attachmentname = $_post['attachmentname']; $rand_seed = md5(time()); $mime_boundary = "==multipart_boundary_x{$rand_seed}x"; $headers .= " \r\nmime-version: 1.0\r\n" ."content-type: multipart/mixed;\r\n" ." boundary=\"{$mime_boundary}\"\r\n"; $message .= "this multi-part message in mime format.\n\n" ."--{$mime_boundary}\n\n"

C++ htonll and back -

i have found following code capable of converting int64_t network byte order. need opposite code, such network byte order converted little endian machine. code this. int64_t decode(void* value){ int64_t vv = *((int64_t*) value); int num = 42; if(*(char *)&num == 42) //test big/little endian return (((uint64)htonl(vv)) << 32) + htonl(vv >> 32); else return vv; } thanks lot! the code htonll #define htonll(x) ((((uint64_t)htonl(x)) << 32) + htonl((x) >> 32)) flips bytes end end. if apply twice, restores value original state. same function can used ntohll .

java - Programmatically capture compiler errors from Eclipse -

i trying write program can extract compiler errors (or other things bad build paths) eclipse's "problems" view. i have not been able find documentation on how might done. i've got 3 possible solutions you: don't use eclipse this easiest way go. eclipse producing visual presentation of build errors, , want structured presentation, they're bad match. on other hand, if run javac command-line, output easy capture , relatively easy parse right there. if need more precise in parsing errors, @ running javacompiler in code , providing custom diagnosticlistener it. if it's important capture nuances of eclipse compiler, can run command line (in batch mode). there's nice blog post describes process here: ecj - eclipse compiler java . here's short version: find ecj jar in eclipse distribution (mine in plugins/org.eclipse.jdt.core_3.8.3.v20130121-145325.jar ) , run on command line java -jar <ecj.jar> <sourcefiles>

c# - Get generic method definition of implemented generic class -

public class target3<t,t2> { t gettgenerictest(t2 obj); } in above code, gettgenerictest not genericmethod, makegenericmethod can of course not used. so, when have methodinfo belonging object of iinterfacetarget3<string,int> , can work it's non-defined version? can't use makegenerictype because have no way link current methodinfo non-defined one. (pseudo code keep short) list<methodinfo> undefs = new list<methodinfo>(); void x() { type t = typeof(target3<,>); methodinfo undefmi = t.getmethod("gettgenerictest"); undefs.add(undefmi); } void y() { var obj = new target3<string,int>(); methodinfo defmi = obj.gettype().getmethod("gettgenerictest"); //how this? methodinfo undefmi = undefs.firstordefault(u=> defmi.undefinedversion() == u); } if have non-generic method in generic class, not easy "convert" non-generic method in generic class definition. trick:

opengl - default uniform (array) values -

rather explicitly setting uniform data gl program, set 'defaults' in simple test (fragment) shader with: uniform vec3 face_rgb[] = vec3[] ( vec3(0.0, 0.0, 1.0), vec3(0.0, 1.0, 0.0), vec3(1.0, 0.0, 0.0), vec3(1.0, 0.0, 1.0), vec3(0.0, 1.0, 1.0), vec3(1.0, 1.0, 0.0), vec3(0.2, 0.2, 0.2), vec3(0.0, 0.0, 0.0) ); depending on fragment's texture coordinates, index value formulated rgb value. (the actual rgb values immaterial) this works os x (gl 3.2 core profile). in fact, far better using index const array. question - valid glsl syntax, , not implementation-dependent hack? (i have no 4+ access @ moment, assume answer still applies). also, ideas why uniform might outperform constant array? yes, uniform arrays allowed have default values in gl 3.2. syntax valid. that doesn't mean work , it's valid. driver bugs can still you.

c# - Assembly compiled in older .NET version running in newer .NET version, will behavior change? -

i have assembly compiled .net 3.5. cannot recompile in .net 4.5 since used in other applications still running .net 3.5. when use assembly in apps running .net 4.5 assembly treated if running in .net 4.5 instead of .net 3.5? have winforms app , webforms app both in .net 4.5. if there changes in behavior between .net 3.5 , .net 4.5, assembly return 4.5 results? usually .net frameworks backward-compatible, executing assembly developed in .net 3.5 shouldn't problem on 4.5. you should see: version compatibility in .net framework the .net framework 4.5 backward-compatible applications built .net framework versions 1.1, 2.0, 3.0, 3.5, , 4. in other words, applications , components built previous versions of .net framework work on .net framework 4.5. but there problems 1 mentioned in article : however, in practice, compatibility can broken seemingly inconsequential changes in .net framework , changes in programming techniques. example, performance

c# - Ignore whitespace while reading XML -

i have xml format following format <tag> value </tag> this comes external datasource cannot change. when using xmlreader content has linebreaks , whitepace . xmlreadersettings xmlsettings = new xmlreadersettings(); xmlsettings.schemas = new system.xml.schema.xmlschemaset(); xmlreader schemareader = xmlreader.create(xsdstream); xmlsettings.schemas.add("", schemareader); xmlsettings.validationtype = validationtype.schema; reader = xmlreader.create(xmlfilename, xmlsettings); // parse xml file. while (reader.read()) { if (reader.isstartelement()) { switch (reader.name) { case "tag": string value = reader.readelementcontentasstring(); console.writeline(value); break; } } } how can avoid this? not working answer this answer doesn't seem work, i'm leaving moment avoid else suggesting it. i'll delete if posts better a

c++ - How should I conceal helper classes from the rest of the world? -

i have few classes. 1 class supposed visible needs it, , rest helper classes (well, of them structs) should accessible principal class. had implemented nested class inside principal class, starting make header file cumbersome added more helper classes. i've put helper classes in separate namespace forbidding kind of name, suspect there's better way. i'd use anonymous namespace, can't take helper classes out of header, because appear member variables in principal class. here's simplified version of construction that's in header file now, minus include guards: namespace __topsecretvisiblenamespace { class invisible{ }; } using namespace __topsecretvisiblenamespace; class visible { public: visible(); private: invisible sneaky; }; any thoughts? you can't literally 'conceal' them, can make them inaccessible other class using protected modifier. if, reason, don't want use protected on class members,

javascript - Cross Domain Request in IE -

i have cross domain js request working firefox , chrome not ie have found following code (just beggining time saving) jquery.ajaxtransport('text html xml json', function(options, useroptions, jqxhr){.... that adds transport ie, , works fine the problem have xdomainrequest object doesn't allow me change content type, it's being sent plain/text , need application/json i'm using java jersey rest container, there way can intercept calls in plain/text content-type , switch application/json ? or other thoughs on how might work thanks in advance here resource @post @path("/register") @produces(mediatype.application_json) @consumes(mediatype.application_json) public statusresult register(userregistrationrequest urr) { //calls controller register producer, , returns result statusresult result = usercontroller.register(urr); return result; } i tried adding consumes mediatype.plain_text, doesn't work i can see server being call

java - SWT: Get system image for "settings" (cog?) -

i make native possible. need possibility system icons. the thing can find on how dialog icons swt.icon_error , on. there chance other system icons open, save, copy, , on? this not possible swt. there bug report here . what can however, use eclipse icons can found here . there related question here . hope helps.

mysql NOW() with defined time -

i need perform mysql select query date time field in table less todays date time of 2am. how structure this select * tbl datetimefield < (date(now()) , time 2am) thank assistance. this worked: select * tbl datetimefield < date_add(curdate(), interval 2 hour) fiddle - in fiddle used hard coded date '2013-05-04', work correctly later.

php - Not Displaying The map and the multiple markers -

i trying display many markers on google map.all works fine in cases i display 1 marker i write gps localisations of different markers i have data base contains longitude,latitude values want dispaly values markers on map here try not working,plz me spend day :/ <!doctype html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>multi-marqueurs</title> <script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script> </head> <body> <? php $connexion=mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("project",$connexion) or die(mysql_error()); $result = mysql_query("select lattitude,longitude intervenantconn "); $listedespoints=''; while($row = mysql_fetch_array($result)){ if($listedespoints!=

iphone - Import images and text into RTF file -

i need import images , text rtf file. there easy way or should use finished code/example. thanks. help! this post explains how can it: ios objective c: display rtf document you can use uiwebview present different types of documents, such pdf, doc, rtf or xls

Can we use Android YouTube API to develop Google TV applications? -

i have develop android application using youtube android api. need application able run in google tv devices. application not work in google tv device/emulator. try sample application comes youtube library. not working in google tv. is youtube android api compatible google tv ? if why not working in google tv ? my logcat out put says media player error during playback. youtubeandroidplayerapi : mediaplayer error during playback [what=1, extra=-2147483648] youtubeandroidplayerapi : retrying mediaplayer error [retry=3, max=3] awesomeplayer : setdatasource_l('http://redirector.c.youtube.com/videoplayback?id=7b25376d1cb6c78e&itag=22&source=youtube&uaopt=no-save&upn=drkvzj2mxoc&el=videos&devkey=awmuqlksgtkk9uumjngotugo88hsqjpe1a8d1gxqngdm&app=youtube_gdata&ip=0.0.0.0&ipbits=0&expire=1367719435&sparams=id,itag,source,uaopt,upn,ip,ipbits,expire&signature=5ac58e1e3d89eb15227c062654cba43017c92f4a.46152aca146cc324100bbed7dc2

python - why is my function not always returning the correct list? -

i have function takes 2 inputs, , return array of tuples 2 numbers in given tuple have exact same ratio 2 numbers given function! so working fine, reason in instances, not picking every tuple. here example of it, , don't know why: in [52]: def find_r(num1,num2): ....: ratio = num1/float(num2) ....: ratio = 1/ratio ....: my_list = [(a,int(a * ratio)) in range(1,num1) if float(a * ratio).is_integer()] #and * 1/float(ratio) + <= num1] ....: return my_list ....: in [53]: find_r(100,364) out[53]: [(75, 273)] so returned 1 tuple, if divide both 75 , 273 3, tuple of 25 , 91, have same ratio! why did function not pick instance? if helps, suspect has is_integer() method, not sure. thanks! it due imprecision of floating point arithmetic: >>> ((100/364)*364).is_integer() false >>> ((25/91)*91).is_integer() false instead of doing you're doing, should check equivalence of fractions cross-multip

c# - Unable to fetch number of selected Columns or Rows in DataGridView -

i have following piece of code: public double[] extractgriddata(datagridview grid) { numcells = grid.selectedcells.count; numberofrows = grid.selectedrows.count; numberofcolumns = grid.selectedcolumns.count; double[] cellsdata = new double[numcells]; foreach (datagridviewcell cell in grid.selectedcells) { if (cell.value != null) cellsdata[cell.rowindex] = convert.todouble(cell.value); } messagebox.show(numberofrows.tostring()); return cellsdata; } i tried using following code: int32 selectedrowcount = grid.rows.getrowcount(datagridviewelementstates.selected); i number of total cells, nut not number or selected rows or columns. might problem be? if you're not getting selectedrows populated, may not have correct selectionmode set (been there, done that); the selectionmode property must set fullrowselect or rowheaderselect sel

javascript - How to create a multi colored circle in html and css -

Image
i want create circle divided 6 sectors based on values, angle of sector dependent on parameter. bigger value of parameter, larger radians of circle. the way understand can built making circle has 6 different portions, , put div on top, creates white ring effect. know how create circle, not able understand how dynamically divide different colored sectors. is possible css, solution exist using javascript. appreciated. try this: http://html5.litten.com/graphing-data-in-the-html5-canvas-element-part-iv-simple-pie-charts/ it should noted found once using google find question/answer: html5 canvas pie chart

real time updates - Facebook realtime.. How are different objects batched together -

facebook realtime docs specify callback data of following format { "object": "user", "entry": [ { "uid": 1335845740, "changed_fields": [ "name", "picture" ], "time": 232323 }, { "uid": 1234, "changed_fields": [ "friends" ], "time": 232325 }]} if 2 different objects, 'user' , 'page' sent back, facebook batch them together? send them separately? different objects sent in different requests. if there many user requests batch user requests , send it. , can have different end points user , page. format of page request different. looks this { "object": "page", "entry": [ { "id": "408518775908252", "time": 1360643280, "changes": [

geolocation - fastest way to find geo points within a range in mysql -

i query possible streetnames within radius of 500 meters of given point. multiple posts reffering google store locator example using haversine formula or version of it. came across posts have much more simplified solution . they treat points x,y coordinates adding lat , long variables seen below. i wandering if fastest way query mysql without getting complicated , still result. don't have lot of data yet, want know if on right track. there disadvantages or inaccuracy's using method? what don't how can radius range, looks more 1 directional query? distance = 0.1; // range in degrees (0.1 degrees close 11km) latn = lat + distance; lats = lat - distance; lone = lon + distance; lonw = lon - distance; ...query db following: select * table_name (store_lat between latn , lats) , (store_lon between lone , lonw) ithink can use spatial indexes in mysql in case, read more this: http://dev.mysql.com/doc/refman/5.5/en/functions-for-testing-spatial-relations

android - "Inject" predexed libraries into project before building -

i'm maintaining framework lets users write own android applications compiled on web server. each user has own project structure created upon opening page. every project created way uses custom libraries. building first time faster if place dexed version of these libraries project. there way how predex them, recognized when copied other projects?

java - Lighting in Box2D and Box2DLighting not working when used with a texture -

i'm having problem textures , using lighting in small prototype i'm working on. understand how implement lighting using rayhandlers , whatnot, when place texture on top of body, texture constant visibility (e.g. not effected light). @ moment i've tried using spritebatch render texture object. there different way when using lighting? thanks, lewis. if want textures affected lighting, you'll have draw textures first , render lights, this: public void render(spritebatch batch) { super.render(batch); sprite sprite = (sprite) body.getuserdata(); sprite.setposition(body.getposition().x, body.getposition().y); sprite.setorigin(texture.getwidth()/2, texture.getheight()/2); sprite.setrotation(body.getangle() * mathutils.radianstodegrees); sprite.draw(batch); rayhandler.setcombinedmatrix(getcamera().combined); rayhandler.updateandrender(); }

java - App crashes with url.openStream() on android 4.0.3 -

try{ string stringurl = ""; ///some url url url = new url(stringurl); reader reader = new inputstreamreader(url.openstream()); user = new gson().fromjson(reader, user.class); } catch (malformedurlexception e) { } catch (ioexception e) { } when tried parse json response on android 4.0.3 url.openstream() crashes. but, on 2.3.3 it's works. stacktrace 05-05 02:43:07.259: d/websettings(2172): mdatapath: /data/data/com.example.myvk 05-05 02:43:07.560: w/dalvikvm(2172): threadid=1: thread exiting uncaught exception (group=0x40c661f8) 05-05 02:43:07.580: e/androidruntime(2172): fatal exception: main 05-05 02:43:07.580: e/androidruntime(2172): java.lang.runtimeexception: unable start activity componentinfo{com.example.myvk/com.example.myvk.wallactivity}: android.os.networkonmainthreadexception 05-05 02:43:07.580: e/androidruntime(2172): @ android.app.activitythread.performlaun

flash - Cannot unload previous swf while loading the new ones -

i have made main navigation page in adobe flash , 3 buttons in it. have used code in order call external swf's according button pressed. problem when press button load 1 swf want previous 1 unloaded. how can have tried everything var myloader:loader = new loader(); var myloadermain:urlrequest = new urlrequest("main1.swf"); var myloaderquiz:urlrequest = new urlrequest("quiz.swf"); var myloaderanimation:urlrequest = new urlrequest("athens_animation.swf"); var myloadervideo:urlrequest = new urlrequest("videogallery.swf"); videogallerybtn.addeventlistener(mouseevent.click, videofunc); function videofunc(curevt:mouseevent) { myloader.load(myloadervideo); addchild(myloader); } quizbtn.addeventlistener(mouseevent.click, quizfunc); function quizfunc(curevt:mouseevent) { myloader.load(myloaderquiz); addchild(myloader); } animationbtn.addeventlistener(mouseevent.click, animationfunc); function animationfunc(curevt:mouseevent

Controlling jQuery Cycle with jQuery UI slider widget? -

i'm wondering whether there's easy way control image slideshow have working jquery cycle ui slider widget. cycle code is: $(window).load(function(){ $('.foo').cycle({ timeout : 80, speed : 80 , startingslide : 0, }); }); and widget such: $(function() { $( "#slider-vertical" ).slider({ orientation: "vertical", range: "min", min: 0, max: 300, value: 300, slide: function( event, ui ) { $( "#amount" ).val( ui.value ); console.log(ui.value); } }); $( "#amount" ).val( $( "#slider-vertical" ).slider( "value" )); }); any ideas on cycle options might manipulated values ui widget spitting out? thank you! sorry, usual solved right after posting. jquery cycle code remains same: $(window).load(function(){ $('.foo').cycle({ timeout : 80, speed : 80 , startingslide : 0,

c - Template function to print a Thrust vector -

i'm writing matrix template class prints both file , std::cout , i.e.: matrix<float> mymat; ... mymat.cout(...) // print std::cout mymat.write("out.txt") // print file both share common underlying printing function i'm trying implement template too, since i've seen different examples use thrust::copy write data both std::cout , files. below skeleton of i've done, is outputting garbage. point errors may have made? example, allowed pass std::cout around this? template <typename data_t> matrix { ... template <typename out_t> int printto(out_t &out, ...) { data_t *start = ..., *end = ...; ... thrust::copy(start, end, std::ostream_iterator<data_t>(out, " ")); ... } int cout(...) { ... printto(std::cout, ...); ... } int write(char* path, ...) { ... std::ofstream file; file.open(path); print

php - $_GET with MySQL query -

here code: if ($_get['u'] == $userid) { $query = mysql_query("select * table uuserid='$userid'"); } the $userid variable defined in rest of script , works properly. script script.php , works correctly (it's table shows rows table toondb). however, there column in table called uuserid. userid '1'. so, if type... script.php?u=1 i need show rows in database uuserid='$userid' working when type script.php?u=1 however, user 620 has rows in db , when type script.php?u=620 blank results. help, please? maybe it's problem query above :) -- update: variable own userid $userid = ($vbulletin->userinfo['userid']); therefore, $userid 1 me because userid 1. ugh, doofus right now. how can make so, if type script.php?u=620.. plugs 620 clause , show rows in table uuserid=620 thanks! that if means query executed if url param == current logged in user, i'd rid of that. <?php //... if (ctype_digit($_g

jquery - Hover any link then hide certain div -

i summarize issue: http://jsfiddle.net/marciano/bszan/ i have links <a href="">some text 1</a> <a href="">some text 2</a> <a href="">some text 3</a> <a id="menu" href="">menu</a> <a id="submenu" href="">submenu</a> and js $(function() { $('#submenu').hide(); $('#menu').hover( function() { $('#submenu').show(); } ); }); when hover menu, submenu shows up. what need hide 'submenu' when hover of other links 'menu'. thank you try this:- demo $(function () { $('#submenu').hide(); $('#menu').hover(function () { $('#submenu').show(); }); $('a:not(#menu,#submenu)').hover(function () { $('#submenu').hide(); }) });

mod autoindex - How to get PHP to execute when using it as the header/readme for mod_autoindex -

apache mod_autoindex allows not have directories automatically generated, customize them many degrees, including custom header , readme (footer) files. however, when using php files, php fails execute. resulting page has php code throughout it, rather dynamic content said code should have produce. something simple writing out name of directory fails, because php not execute. i have searched, , found adding following .htaccess should fix this: addtype text/html .php addhandler application/x-httpd-php .php however, seems make no difference. without further information hard debug... suggest going through of steps in this answer , if not yield results, post more details current setup.

python - Basic Pygame Graphics -

i starting learn pygame graphics. drew circle in pygame , wondering how program change colors. example: changes colors blue red. i need keep changing colors until close pygame , nice if colors gradually changed 1 instead of instant change? ideas how this? import pygame pygame.init() red = (255, 0, 0) blue = ( 0, 0,255) black = ( 0, 0, 0) size = (1000,1000) screen = pygame.display.set_mode(size) pygame.draw.circle(screen,red,(500,500),200) pygame.display.flip() pygame.time.wait(3000) pygame.quit() i shall progress simple harder, , more complex.. simplest : loop changes color 3 times, simplest: import pygame pygame.init() red = (255,0,0) blue = (0,0,255) black = (0,0,0) size = (1000,1000) screen = pygame.display.set_mode(size) colors = (red, black, blue) # tho allow iterate on colors c in colors: pygame.draw.circle(screen,c,(500,500),200) pygame.display.flip() pygame.time.wait(1000) pygame.quit() medium : infinite loop, ends when close w

sql - "The markup in the document preceding the root element must be well-formed" error while validating xml -

i'm new xml, pls forgive me dumb question. have such schema <?xml version="1.0" encoding="utf-8" ?> <xs:schema xmlns:xs="http://www.w3.org/2001/xmlschema" elementformdefault="qualified"> <xs:element name="product"> <xs:complextype> <xs:sequence> <xs:element name= "name" type = "xs:string"/> <xs:element name= "price" type = "xs:decimal"/> <xs:element name= "fish"> <xs:complextype> <xs:sequence> <xs:element name= "type"> <xs:simpletype> <xs:restriction base="xs:string"> <xs:enumeration value="herbivourus"/> <xs:enumeration value="predator"/>