Posts

Showing posts from August, 2013

semantic web - How to describe a property including inverseOf to an instance in OWL-RDF/XML syntax? -

i have object properties named employ , employedby inverse of each other. how give these properties instance? employ property: <owl:objectproperty rdf:id="employ"> <rdf:type rdf:resource="http://rdf.pozitron.com/organizations/" /> <rdfs:domain rdf:resource="http://rdf.pozitron.com/organizations/"/> <rdfs:range rdf:resource="http://rdf.pozitron.com/people/"/> </owl:objectproperty> my employedby property: <owl:objectproperty rdf:id="employedby"> <rdf:type rdf:resource="http://rdf.pozitron.com/people/" /> <owl:inverseof rdf:resource="#employ" /> <rdfs:domain rdf:resource="http://rdf.pozitron.com/people/"/> <rdfs:range rdf:resource="http://rdf.pozitron.com/organizations/"/> </owl:objectproperty> now how describe employ , employedby in instance? assume pozitron employs john , john employed pozitron. ...

php array map on nested -

situation i have array result returned database call. in example below, fetches many genres can have many books. using join, query pulls books each genre @ same time. here hypothetical result set: array( [0] => array ( 'id' => 1, 'title' => 'ficton' 'modules' => array( [0] => array( 'other_id' => 1 'other_title' => 'james clavell' ), [1] => array( 'other_id' => 2 'other_title' => 'terry pratchett' ), [2] => array( 'other_id' => 3 'other_title' => 'robert ludlum' ), ), [1] => array ( 'id' => 2, 'title' => 'non-ficton' 'modules' => array( [1] => array(...

java - Getting reources path creates weird path (in jar works) -

i've got weird problem. access resources files this: file xmlfile = new file(getclass().getresource(xmlpath).getpath()); where xmlpath "/meta-inf/file.xml". when run eclipse, works fine. unfortunately, when pack jnlp file, upload web app on tomcat (from download jar's jnlp) stops work. when run jnlp, downloads jar's should , fails start. throwing exception: java.io.filenotfoundexception: c:\users\a050868\desktop\http:\address:port\webapp\downloads\lib\package.jar!\meta-inf\componentcontext.xml (the filename, directory name, or volume label syntax incorrect) how can access file, in resources/meta-inf folder, in cached locale jar copy? seems, java try access jar on server side - no local, downloaded jnlp. any ideas? all files packed in jnlp file. don't exist individual files on filesystem when port package. that said, available on classpath . can access content of package using appropriate classloader . getclass().getclassloade...

asp.net web api - webapi route with controller and action -

default webapi route - api/{controller}/{id} in realtime scenrios may require more , post methods is recommended change default routing - api/{controller}/{action}/{id} usually default values recommended values. don't need change unless have special requirements. api/{controller}/{controller}/{id} non-sense because don't have display 2 times name of controller in url. {action} not everytime needed (if use of get/put...). may want create api/{controller}/{action}/{id} second route or specify {action} in default route urlparameter.optional .

json - How to support jQuery Mobile Offline version? -

i making app using jquery-mobile , phonegap. parse json data show content. {"system": { "name": "staci", "thumb": "image.png" } } i want app first time user download jsondata internet. , store images , information in device. next time user dont have use internet see app. there way that. thanks you can store data in device, , next time load data device don't have use internet load data. ( built app phonegap in android , use sqlife store data). phonegap have api support that. http://docs.phonegap.com/en/edge/cordova_storage_storage.md.html#opendatabase

google maps - click on placemark kml file not the exact position of the placemark -

i've added click handler kmllayer places marker on location clicked on 1 of lines (placemarkers) google.maps.event.addlistener(kmllayer, 'click', function (kmlevent) { if (kmlevent.featuredata.description != undefined) { var data = kmlevent.featuredata; var text = data.description; var latlong = kmlevent.latlng; var gid = data.id; var roadid = data.name; var roadname = roadid.split(",")[0]; resetmarker(selectedmarker); shownewmarker(latlong, gid, roadid, roadname); } }); i place marker based on latlng received kmlevent. looks marker placed on line, when zoom in further marker stands further line. i think latlng in event exact location clicked on map, not coordinates of placemark itself. are there solutions exact latlng of placemark?so position of marker on placemark, no matter how zoomed in.

python - Error on using pybing -

i have written script generate urls using pybing. from pybing import bing bing = bing('mykey') response = bing.search_web('python bing') print response['searchresponse']['web']['total'] results = response['searchresponse']['web']['results'] print len(results) result in results[:3]: print repr(result['title']) the error is traceback (most recent call last): file "c:\python27\project\yql.py", line 4, in <module> print response['searchresponse']['web']['total'] keyerror: 'web' on printing response variable get {u'searchresponse': {u'errors': [{u'helpurl': u'http://msdn.microsoft.com/en- us/library/dd251042.aspx', u'message': u'parameter has invalid value.', u'code': 1002, u'parameter': u'searchrequest.appid', u'value': u'mykey'}], u'query': {u'sea...

css - How to center the divs that float: left in responsive layout? -

i need center divs float: left in responsive layout. mean center them in small layout, if moves new line. http://jsfiddle.net/allegrissimo123/njpce/ <div class="buttonwrapper"> <div class="buttons"> <a href="">button 1</a> <a href="">button 2</a> <a href="">button 3</a> <a href="">button 4</a> </div> </div> .buttons a, .buttons button{ display:block; float:left; margin:0 7px 0 0; background-color:#f5f5f5; border:1px solid #dedede; border-top:1px solid #eee; border-left:1px solid #eee; font-size:100%; line-height:130%; text-decoration:none; font-weight:bold; color:#565656; cursor:pointer; padding:5px 10px 6px 7px; } .buttons { text-align:center; margin: 0 auto; position:relative; float:left; left:-50%; } .buttonwrapper...

pharo - Ask "Save or Discard edits" to user that has manipulated a Glamour Text or Smalltalk code presentation -

if show a text presentation or a smalltalk code presentation in glamour browser , can make sure user not inadvertently loose her/his edits asking "save or discard edits" dialog when user leaves presentation? unfortunately, not possible @ point in time.

Access to raw arguments of Node.js script on Windows -

node.js substitute argument looked path complete path in windows environment. $ node -e 'console.log(process.argv)' /arg1 output: [ 'c:\\program files\\nodejs\\node.exe', 'c:/program files (x86)/git/arg1' ] this substitution doesn't occur in osx , linux environments. how can actual content of cli argument on windows?

Using a variable to set an object array in java -

when set object array such as: player[] player = new player[amountofplayers]; i use: amountofplayers = br.read(); to variable amountofplayers . whenever run program type in 3 when asked set amountofplayers output says there 51 players. though when set new player array to: new player[3] ; works. anyone know why be? the problem read char , interpret integer. character 3 has ascii code 51 . it easier use scanner bufferedreader read input, suggested prasad .

android - EditText is not showing virtual keyboard -

i have created dynamic screen edittext in it..but after click not showing virtual keyboard.i have added these following codes..but still ot worked. getwindow().setsoftinputmode(windowmanager.layoutparams.soft_input_state_always_visible); and dint worked inputmethodmanager im = (inputmethodmanager)getsystemservice(context.input_method_service); im.showsoftinput(edittext, 0); my code here... runonuithread(new runnable() { public void run() { linearlayout findviewbyid = (linearlayout) findviewbyid(r.id.dynamicinputs); //textview textview = (textview) findviewbyid(r.id.name); textview textview = new textview(activity_userinput.this); textview.settext(" " + map.get(key_name) + " :"); textview.settextcolor(color.black); textview.settextsize(typedvalue.complex_unit_sp, 17); //textview.setlayoutparams(new layoutparams(layout.dir_left...

audio - How to set the frequency and amplitude values in android device? -

i new android, , need work audio of android device. have table of pairs(frequency - amplitude) , need set each frequency appropriate amplitude, , apply these values equalizer of device, when music file being played, these values applied it. for example, frequency 1000 hz, amplitude should 0.5. frequency 16000 hz, amplitude should 0.8. etc... i need apply these values android device equalizer each frequency in music file have appropriate amplitude. thanks in advance :)

java - How to display histogram of RGB values of an image? -

my application captures image , applies filter modify image rgb values. once modified, wish display histogram of each colour (red, green, blue) on top of image itself. i know how rgb values , know how bitmap, dont know how plot them. code rgb values: int[] pixels = new int[width*height]; int index = 0; image.getpixels(pixels, 0, width, 0, 0, width, height); bitmap returnbitmap = bitmap.createbitmap(width, height, bitmap.config.argb_8888); (int x = 0; x < width; x++) { (int y = 0; y < height; y++) { = (pixels[index] >> 24) & 0xff; r = (pixels[index] >> 16) & 0xff; g = (pixels[index] >> 8) & 0xff; b = pixels[index] & 0xff; ++index; } } we had done similar. got bitmap of image with: bitmap bmp = bitmapfactory.decoderesource(<youimageview>.getresources(), r.drawable.some_dr...

cordova - PhoneGap for Windows Store Apps -

can use phonegap windows store apps developed using c# , xaml? if so, can handle device , resolution dependencies? i'm not quite sure you're asking here. if question "can use phonegap develop app windows 8" answer yes : http://docs.phonegap.com/en/edge/guide_platforms_win8_index.md.html#windows%208%20platform%20guide if you're question "can write code phonegap application using c#" answer no. whole point of phonegap allows write applications various different platforms in html , javascript.

jquery - Return json callback data when they are available? -

i using amd , requirejs implementing following module: define({ callweatherservice: function(x, y){ //var url = 'http://www.webservicex.net/currencyconvertor.asmx/conversionrate?fromcurrency=inr&tocurrency=aud'; // website want scrape var url = 'http://www.webservicex.net/globalweather.asmx/getweather?cityname=' + x + '&countryname=' + y; var yql = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeuricomponent('select * xml url="' + url + '"') + '&format=json&callback=?'; $.getjson(yql,displaydata); function displaydata(data){ if(data.query.results){ result = data.query.results.string.content.replace(/<script[^>]*>[\s\s]*?<\/script>/gi, ''); document.getelementbyid("asmxresult").innerhtml = result; // return result; } } } }); i not want modify html document in code rather ret...

Layout Inflater in Android -

there 3 xml files. main.xml has linear layout. button.xml contains button. txt.xml contains edit text. inflate button.xml main.xml . looks fine. button has same size in button.xml . next inflate edit text main.xml has ems=10( android:ems="10" ). when run, button changes size same of edit text. how happen , how overcome problem. code pasted. main.xml <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/hello_world" tools:context=".first" /> <linearlayout android:id="@+id/ll" android:orien...

ide - automate preferences for projects in RAD 7.5.4 -

Image
i have scenario have multiple projects, have import projects team project " psf " file (every , then). the thing have configure preferences again, adding 1 "jar",adding "jre library" , server library again... is there way automate this? if eclipse project metadata (mentioned in previous answer ) versioned @ same level source in clearcase, should to: update snapshot view (one or many) projects import project workspace if working (meaning find jar, , jre settings after importing 1 project sources), then can try importing psf. importing "project set file" (psf) , means referencing vcs (see " structure of project set file "), clearcase sources in case. first try importing project, psf.

Strange SQL Server Error/Warning -

Image
i have created stored procedure in sql server 2012. procedure works fine , execute, i'm curious, why showing squiggly line below procedure name? below image showing stored procedure: unfortunately, intellisense in ssms isn't greatest. stored proc must new , ssms hasn't "learned" yet, though exists. if close ssms , reopen it, wouldn't have issue. have been frustrated intellisense in ssms i've been tempted turn off. you can press ctrl + shift + r refresh local intellisense cache, , should take care of it.

json - Rabl / Will Paginate setting name of root child -

i wonder if can help. i'm trying migrate our old rails model#to_json our api make versioning easier in longer term. i'm struggling @ first hurdle because of rabl , paginate. we override willpaginate::collection#as_json module willpaginate class collection alias :as_json_without_paginate :as_json def as_json(options = {}) # rabl seemingly passing json::ext::generator::state as_json unless options.is_a?(hash) options = {} end json = { :page => current_page :per_page => per_page, :total_entries => total_entries, :entries => as_json_without_paginate(options) } end end end so @collection.to_json return like { "total_entries": 1, "page": 1, "entries": [ { "follow": { "id": 1, "name": "test" } } ], "per_page": 10 } however when try following in ra...

iphone - Unable to debug in ipad -

i using xcode 4.6.x , ipad ios version 6.1.3 . have added device in provisioning profile. when connect not allow me debug. i have checked base sdk, 6.1 , deployment target 6.1 . have tried switch off , restart ipad, it's not working yet. can me ? first clean project [alt + clean] i.e. clean build folder, quit xcode, remove app device. build project , run. delete data derived data folder. make sure not using distribution profile. hopefully work.

c# - Getting the name of the variable during whose processing an exception has occurred? -

i have function use validation public void validate() { action<list<field>> validatefields = (field) => { if (field != null && field.any()) { field.foreach(x => x.validate()); } }; new list<list<field>> { this.personelements, this.contactelements, this.miscelements }.foreach(x => { try { validatefields(x); } catch (exception e) { log.errorformat("an exception has occurred while validation of {1} : {0}", e, x.tostring()); // print x.name.tostring()); throw; } }); } the problem line: new list<list<field>> { this.personelements, this.contactelements, this.miscelements }.foreach(x => i need (in case exception has oc...

mysql - ruby mysql2 gem install error -

i having problems installing mysql2 gem on windows machine, worked, failed build native extension. googled around, there lot of linux fixes. know not best thing work on windows ruby. problem, used gem install mysql2 -- --with-mysql-dir=c:\wamp\bin\mysql\mysql5.6.12\bin --with-mysql-lib=c:\wamp\bin\mysql\mysql5.6.12\lib install mysql2, works mysql, rails requires mysql2. thank you. mysql2 can tricky install. got dev box working ruby 2.0.0p247, windows 64bit , mysql 0.3.13. here suggestions: make sure have latest devkit installed ( http://rubyinstaller.org/downloads/ ). on right column of page, tells version of devkit you'll need particular version of ruby. we've found easiest install c:\devkit now try , run gem install mysql2 .. . command listed in question. alternatively, 32bit installs do: subst x: "c:\program files (x86)\mysql\mysql server 5.6" gem install mysql2 -v=0.3.13 --platform=ruby -- --with-mysql-include=x:\include --with-mysql-li...

mysql - How to delete duplicate records but except one for Int? -

under table records mysql, have these: select * dbo.online; +-------+ | id | +-------+ | 10128 | | 10240 | | 6576 | | 32 | | 10240 | | 10128 | | 10128 | | 12352 | +-------+ 8 rows in set (0.00 sec) how make to: select * dbo.online; +-------+ | id | +-------+ | 10128 | | 10240 | | 6576 | | 32 | | 12352 | +-------+ 8 rows in set (0.00 sec) in other words, want is, using delete command instead of select * dbo.online group id.. so, idea how? copy data table distinct , steop eliminates duplicates create table backup_online select distinct * online; clear source table truncate table online copy data source table without duplicates insert online select * backup_online

apache - Excluding filename using RewriteRule -

i want pipe uris index.php unless specific file exists in root. i'm little stumped when comes excluding index.php of course won't match last catch rule options +followsymlinks -indexes rewriteengine on rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewritecond %{request_filename} != "index/.php" // i'm not sure on syntax here rewriterule ^(.*)$ $1.php [l] rewriterule ^([^/]*)(.*)$ index.php?category=$1&post=$2 [l,qsa] solved adding additional conditions last rule rewritecond %{request_filename}\.php -f rewriterule ^([^\.]+)$ $1.php [l] rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^([^/]*)(.*)$ index.php?category=$1&post=$2 [l,qsa]

asp.net - Find a repeater inside a unordered list inside a master page? -

i have loaded html template master page , bind category database. have used coding. <ul class="categories"> <li id="categoryitem"> <h4>categories</h4> <ul class="categories" id="categorylist"> <asp:repeater id="repcategories" runat="server"> <headertemplate><ul></headertemplate> <itemtemplate> <li> <asp:hyperlink id="hypercategories" runat="server"><%#eval("categoryname")%></asp:hyperlink> </li> </itemtemplate> <footertemplate></ul></footertemplate> </asp:repeater> </ul> ...

c# - Get checkbox.checked value programmatically from cycling through winform controls -

for winforms program, have options dialog box, , when closes, cycle throught dialog box control names (textboxes, checkboxes, etc.) , values , store them in database can read in program. can see below, can access text property control group, there's no property access checked value of textbox. need convert c , in instance, checkbox first? conn.open(); foreach (control c in grp_invother.controls) { string query = "insert tbl_appoptions (controlname, value) values (@control, @value)"; command = new sqlitecommand(query, conn); command.parameters.add(new sqliteparameter("control",c.name.tostring())); string controlval = ""; if (c.gettype() == typeof(textbox)) controlval = c.text; else if (c.gettype() == typeof(checkbox)) controlval = c.checked; ***no such property exists!!*** command.parameters.add(new sqliteparameter("value", controlval)); command.executenonquery(); } conn.close(); if n...

xml - Two problems with this java code, one fatal one not as fatal what are they? -

here code. program made interview, told code had 1 fatal flaw, , 1 smaller problem. not find either. wrong program? i've tested , seems work fine. know fileexists() method kind of bad , need more checks... other not sure else wrong... import java.io.bufferedwriter; import java.io.file; import java.io.filenotfoundexception; import java.io.filereader; import java.io.filewriter; import java.io.ioexception; import java.util.arraylist; import java.util.scanner; import java.util.regex.matcher; import java.util.regex.pattern; //i chose use library since offers solution performing operations on csv files, better 1 can provide scratch. import au.com.bytecode.opencsv.csvreader; public class csv2xml { //main program loop public static void main(string[] args) { string csvfilename; string xmlfilename; arraylist<arraylist<string>> data; //raw unformatted data boolean exists; string xml; //formated xml da...

android - Stop an animation and start again -

i want stop objectanimation while it's running, when click on animated imageview. then, want play frameanimation on imageview. after that, first animation starts again. here onclicklistener: onclicklistener click = new onclicklistener() { @override public void onclick(view arg0) { try { animator.wait(1000); } catch (interruptedexception e) { // todo auto-generated catch block e.printstacktrace(); } setframeanimation(view); } }; view.setonclicklistener(click); animator objectanimator animation. view imageview my setframeanimation-method: animationdrawable frameanimation = (animationdrawable)view.background(); frameanimation.start(); this code doesn't work. illegalmonitorstateexception when call wait(). use int duration = 150; img = (imageview)findviewbyid(r.i...

python - Why nested list indexing gets swapped with list comprehensions? -

i expected following 2 code-segments equivalent. return tuple(tuple( false if (i,j) in neighborhood else avail[i][j] in range(len(avail))) j in range(len(avail[i]))) (false, false, true, true, true) (false, false, true, true, true) (false, false, true, true, true) (false, false, true, true, true) (true, true, true, true, true) ls = [[val val in row] row in avail] in range(len(avail)): j in range(len(avail[i])): if (i,j) in neighborhood: ls[i][j] = false return ls [false, false, false, false, true] [false, false, false, false, true] [true, true, true, true, true] [true, true, true, true, true] [true, true, true, true, true] the 1 for-loops "correct" (thats wanted). why did list comprehension-version swap indexes? you have loops inverted in first version. creating inner tuples looping on range(len(avail)) , outer tuples loop on range(len(avail[i])) . your code equivalent (with lists instead of tuples) of instead: out...

c# - Convert two UInt16 Values to one UInt32 Value consider least and most significant word -

i have 2 uint16 values private uint16 leastsignificantword; private uint16 mostsignificantword; the 2 words (uint16 values) come component divides uint32 status / error value 2 words , returns 2 words. need uint32 value. sum 2 words wouldn't trick because of disregard if , least significant. for example: private uint16 leastsignificantword = 1; private uint16 mostsignificantword = 1; //result contains value 2 after sum both words //which can not correct because have take note of , least significant uint32 result = leastsignificantword + mostsignificantword; is there way solve this? honest have never worked bits / bytes in c# had never faced such problem. in advance private uint16 leastsignificantword = 1; private uint16 mostsignificantword = 1; uint32 result = (leastsignificantword << 16) + mostsignificantword; you have 2 uint16 (16 bit , 16 bit) 1 0010 1011 1010 1110 , second 1001 0111 0100 0110 if read 2 uin16 1 uint32 have 0010 1011 1010 11...

node.js - Closing out Dropbox Datastore API in NodeJS -

i'm trying use dropbox datastore api nodejs. can connect , use fine, can't seem stop , let program exit gracefully. pulled file https://www.dropbox.com/static/api/1/dropbox-datastores-0.1.0-b3.js , put in local directory. so if run following (with valid creds) never exits. var dropbox = new require('./dropbox.js') var client = new dropbox.client ({ key:'apikey', secret:'apisecret', token:'useroauthtoken', uid:'useruid' }); var datastoremanager = client.getdatastoremanager(); datastoremanager.opendefaultdatastore(function(error,datastore){ if(error) console.log(error); var table = datastore.gettable('exampletable'); table.insert({hello:'newman',inthepool:true}); }); have tried process.exit() (see http://nodejs.org/api/process.html#process_process_exit_code )? this should shutdown program gracefully.

workflow foundation 4 - Using OutArgument in Definition of another Activity -

i'm creating workflow can call custom activity called post webrequest , return response xmldoc. tried return dynamic didn't work. want take specific value in xml doc , add post dada of next post call chain calls together. can't figure out how response data first post post data of second post. appreciated. variable<xmldocument> output1 = new variable<xmldocument>(); activitybuilder ab1 = new activitybuilder(); ab1.name = "customworkflow"; ab1.implementation = new sequence { activities = { new post() { postdata = "<xml></xml>", endpoint = "www.test.co...

doctrine2 - ZF2 - set selected value on Select Element -

i've problem dropdown list zend framework 2 & doctrine. put "selected" attribute on dropdown list options pass selected my code : controller : public function editaction() { // error message during addaction $this->layout()->setvariable("messageerror", $this->flashmessenger()->geterrormessages()); $auth = $this->getauthservice(); if ($auth->hasidentity()){ $builder = new annotationbuilder(); // id of staticcontent $id = (int)$this->getevent()->getroutematch()->getparam('id'); if (!$id) { $this->flashmessenger()->adderrormessage("aucun plan choisi !"); return $this->redirect()->toroute('admin/plans'); } $plan = $this->getentitymanager()->getrepository("admin\entity\plan")->find((int)$id); $form = $builder->createform($plan); // find options localite list (<...

symfony - filters in twig call -

how call function function filter filter? eg public function getfilters()      {          return array (              'test' => new \ twig_filter_method ($this, 'test'),              'test1' => new \ twig_filter_method ($this, 'test1', array('is_safe' => array('html')))          );      } public function test($test) { return; } public function test1($test) { // how test call? } thanks , sorry english from twig template can this: {{ 'some string'|test|test1('argument')}} inside twig extension class can call test function regular php object function: public function test1($test) { // code $testresult = $this->test($test); }

c# - ASP.net WebApi Parameter Binding to complex type from URI -

i want create rest webservice using asp.net webapi on .net 4.5 urls should of format this: /values?age=55&height=176&race=1&weight=80&gender=male&id=800001 the associated controller looks this: [httpget] public string get(int id, [fromuri]demographics demographics) { // etc.} where demographics custom object dto properties. however, contains 1 property has type of custom enum: enum gender { female = 0, male } the default mapping works fine if url of above format. however, of course need check whether parameters provided url correct. asp.net webapi (afaik) per default tries map each parameter based on assumed type (or if can converted type). if can't find matching value in uri appears assume 0. now takes me unfortunate situation 0 definition still valid value gender demographics.gender (0 ~ gender.female). the simplest solution change enum 0 "indeterminate" state check for. however, can not change enum. create own overload demo...

c++ - glm translate matrix does not translate the vector -

i have crossed simple error while started using glm (in vs2010). have got short code: glm::mat4 translate = glm::translate(glm::mat4(1.f), glm::vec3(2.f, 0.f, 0.f)); glm::vec4 vector(1.f,1.f,1.f,0.f); glm::vec4 transformedvector = translate * vector; the result of transformedvector same original value (1.f, 1.f, 1.f, 0.f). not know missing here. have tried rotation matrix , working fine, point transformated correctly. glm::mat4 rotate = glm::rotate(glm::mat4(1.f), 90.f, glm::vec3(0.f, 0.f, 1.f)); glm::vec4 vector(1.f, 1.f, 1.f, 0.f); glm::vec4 transformedvector = rotate * vector; ok, have found out problem. translate vertex not vector, in case had set w value 1. you're forgetting projective coordinates. last component of glm::vec4 vector should 1. correction doing this: glm::mat4 translate = glm::translate(glm::mat4(1.f), glm::vec3(2.f, 0.f, 0.f)); glm::vec4 vector(1.f,1.f,1.f,1.f); glm::vec4 transformedvector = translate * vector; this due way project...

How do I Design and Interface (OOP kind) in Java so that I can either use direct database access or use web services? -

at moment have query database not own has web service, provide get. since in house (sort of), might able direct access in future can better data in query. i don't want have write again , again. if did in java write interface (programming kind, think implements interface, oop)? how this? or write whole new class , "plug in." this regular client/server architecture. http request, server calls servlet or jsp, returns data. i'm not sure if idea correct design or not. definitely sounds should use interface different implementations here. like: public interface dataaccess { data getdata(); } then can code against api , plugin/inject different implementation needed. have this: public class directdataaccess implements dataaccess { public data getdata() { //use jdbc, orm, or similar } } or this: public class webservicedataaccess implements dataaccess { public data getdata() { //call web service } } but lon...

Using PHP file_get_contents with xml -

i'm not sure if xampp setup causing issue have got php page creating sample xml data seen below: $xml = new simplexmlelement('<product/>'); $xml->addchild("price", "us dollars"); $xml->addchild("test","123123"); header("content-type: text/xml; charset=utf-8"); echo $xml->asxml(); this renders xml onscreen perfectly. when come read page using following: $xml = simplexml_load_file("api.xml"); echo $xml->price; so have checked file firstly using file_get_contents("xml.php"); but returns php code rather output of code. have resolved using xml.php write file called feed.xml works fine wondering why file_get_contents("xml.php"); returned code rather parsed output. have used wrong method check file contents or setup issue xampp? thank in advance. the reason isn't working file_get_contents is: ...the preferred way read contents of file string. it d...

java - JAAS - How to authenticate user in web tier? -

i'm trying understand how secure java ee applications using jaas. actually understand how work rules in ejbs, however, don't understand how authenticate user in web tier, example create simple jsf page login form, check given user name & password using db , in case of success how set principal user inside application. what common way doing this? i'd have as-independent solution possible. jaas not universal standard this. in fact, jaas login modules little ill-suited java ee authentication. full jaas model created java applications running locally, shielding code bases each other (e.g. specific jar allowed read file system). it's rare java ee server run untrusted code, of functionality jaas offers not used. two articles topic following: jaas in enterprise whatever happened jaas? what common way doing this? unfortunately common using specific thing. terminology "thing" specific too. can called "realm", "securi...

How to query for the number of shares of a Facebook event URL? -

one of facebook apps allows users share url facebook event using default facebook sharer. under impression can query number of times such url got shared on facebook. however, when query graph api popular events on facebook results show me 0 shares, likes , comments. e.g. select click_count, comment_count, comments_fbid, commentsbox_count, like_count, normalized_url, share_count, total_count, url link_stat url = 'http://www.facebook.com/events/385623724876261' returns { "data": [ { "click_count": 0, "comment_count": 0, "comments_fbid": null, "commentsbox_count": 0, "like_count": 0, "normalized_url": "http://www.facebook.com/events/385623724876261", "share_count": 0, "total_count": 0, "url": "http://www.facebook.com/events/385623724876261" } ] } how can query facebook real nu...

c# - ASP.NET Mvc Best Way to get List<SelectListItem> From EntityContext? -

i using entityframework dataaccess view dropdownlist of countries enduser in asp.net mvc webapplication. it not hard thing achieve have little struggle find looking way. but first of code: <td> @html.dropdownlistfor(x => x.parentid, repos.getparents(@model.parentid) </td> somewhere deep in real code: class dummy { public string text { get; set; } public int value { get; set; } } private selectlist _parents; public selectlist parents { { if (_parents == null) { var parents = entities.instance.partners.select(x => new dummy() { text = x.name, value = x.id }).orderby(x => x.text).tolist(); parents.insert(0, new dummy()); _parents = new selectlist(parents, "value", "text"); } return _parents; } } public selectlist getparents(int? parentid) { if (parentid ...

Cell arrays in MATLAB -

i know cell array is. came following line: cell_array = cell([], 1); what mean? how can read above line? thanks. so makes 0x1 empty cell array. in literally 0 rows , 1 column. make 0x0 cell array this: cell_array = {} which makes sense me. if can't preallocate before loop, it's useful concatenate onto or go cell_array(end) = ... in loop. i don't know why you'd prefer 0x1 this question shows how differs 0x0. mean, if weird reason running loop on empty array know run @ least once :/ that's scraping barrel reason. think stick = {} . edit: as @radarhead points out, 1 way preset number of columns if plan on concatenating new rows in loop.

sql server - Cannot get hours to total over 24, eg 48 hours in hh:mm:ss output -

i running query find out total amount of time user has been browsing for. each browsing session stored in db seconds , sum total seconds , convert hh:mm:ss. problem when i'm converting seconds hh:mm:ss . want display example '78:20:00' dont know how code total this. when gets past 24 hrs hrs column goes 00 because day. the query run convert time can seen below: select username, convert(varchar(12),dateadd(second,totaltimeinseconds,0),108) totalhours #totalsessiontime select username, cast(totaltimeinseconds / (60 * 60) varchar) + ':' + cast(totaltimeinseconds % (60 * 60) / 60 varchar) + ':' + cast(totaltimeinseconds % (60) varchar) totalhours #totalsessiontime if want minutes , seconds 2 digits, you'll have left pad them, make ugly example, work fine.

graph - Using findpeaks and minpeakdistance in MATLAB to find peaks separated by distance rather than index -

Image
i'm trying x-coordinates of peaks in matlab figure (example attached). i've been using findpeaks , doesn't seem fact i'm plotting points rather lines. i won't have 2 peaks. i'll have three, i'll have one. multiple peaks separated @ least 1/4 of range of x, , peaks @ least twice noise level. here's expect work: [pks,locs] = findpeaks(ydata,... 'sortstr','descend',... 'minpeakdistance',floor(range(xdata)/4),... 'minpeakheight',floor(max(ydata)/2)... ) instead of getting 2 peaks, 4 bundled around first peak: >> locs locs = 6774 166785 326792 486799 >> xdata(locs) ans = -96780.787939025 -96770.1800919265 -96770.8959353367 -96771.6117787468 i assume minpeakdistance working on in xdata indices rather data itself. how use distances between peaks instead of distance betwe...

java - Adjust Fairness in Multithreading -

how can adjust fairness between given k threads generate output? in other words imagine have k threads printing "1" , n threads printing "2". how can put fairness between threads each thread print(for example "1") as other (k - 1) print(for example "1").and same n thread printing "2". before create threads, create array[0..numthreads-1] of empty semaphores, 1 each thread going create. signal each thread on creation incrementing semaphore index, 0..numthreads-1. in thread function, have wait on semaphore[index], print something, signal [(index+1) mod numthreads] semaphore, loop round wait on semaphore[index] again. once have done that, nothing should happen @ all. throw in 1 semaphore unit, anywhere.

web crawler - Google Apps Script Bot repeatedly crawling website each minute -

just hour ago, started tailing apache log file (access logs), , since then, ve noticed weird user agent, (couldnt find google's official docs). i m feeling suspicious it, since couldnt find on google's site user agent, ("mozilla/5.0 (compatible; googleapps script; +http://script.google.com/bot.html)) it has crawling login page of our site, every minute, whole day. here's log snippet: 72.14.199.55 - - [07/aug/2013:16:06:28 +0000] "get / http/1.1" 302 639 "-" "mozilla/5.0 (compatible; googleapps script; +http://script.google.com/bot.html)" 72.14.199.55 - - [07/aug/2013:16:06:28 +0000] "get /accounts/login/ http/1.1" 200 3780 "-" "mozilla/5.0 (compatible; googleapps script; +http://script.google.com/bot.html)" and has been same ip. , still is, is common see pattern of crawling? google apps scripts allow users write javascript based code , set them run @ specified intervals google'...

xslt - Wmic /format switch invalid XSL? -

Image
i have quick question, should relatively simple have more experience in wmi-command processor (and since i'm absolute beginner thats not hard :-) ) i fail understand why wmic /format switch works way does. open cmd.exe , type wmic process list brief /format:htable > processlist.html this want , no bothers further on. whereas if go wmic processor, , try execute same command above... wmic:root\cli>process list brief /format:htable > processlist.html i receive error tag: "invalid xsl format (or) file name." here goes screenshot. note have copied xsl files wbem sys32 dir can explain me why these 2 commands me same, difference 1 executed outside wmic environment , other 1 inside, latter 1 doesn't work? fail understand it. please advise can comprehend bit better! :-) you attempting use cmd.exe > redirection while within interactive wmic context. can't work. you can use wmic /output:filename switch while in interactive mode....

c++ - virtual member functions are good or bad for locality in modern CPUs? -

considering new cpus new instructions moving , new memory controllers, if in c++ have vector of derived objects derived composed of virtual member functions, or bad thing locality ? and if have vector of pointers base class base* store references derived objects 1-2-3 level base ? basically dynamic typing applies both cases, 1 better caching , memory access ? i have preference between 2 see complete answer on subject. there new consider ground-braking hardware industry in last 2-3 years ? storing derived rather base * in vector better because eliminates 1 level of indirection , have objects laid out «together» in continuous memory, in turn makes life easier hardware prefetcher, helps paging, tlb misses, etc. however, if this, make sure don't introduce slicing problem. as virtual dispatch in case, not matter exception of adjustment required «this» pointer. example, if derived overrides virtual function calling , have pointer devied * , «this» adjustmen...

ruby on rails - Displaying Png image using Barby Barcode generator -

i using barby , png outputter. have gotten compile fine, not sure how can display image. here code.. controller: @barcode = barby::code128b.new(@num) @blob = barby::pngoutputter.new(@barcode).to_png #raw png data file.open('barcode.png', 'w'){|f| f.write @blob } application helper: require 'barby' require 'barby/barcode/code_128' require 'barby/outputter/png_outputter' view: <%= @blob %> since @blob image data, can't "print" regular string. need use image_tag instead, , give path image. like: <%= image_tag("barcode.png") %>

need to create multiple dynamic arrays in c++ -

i need create number of arrays of object number need dependent on separate variable best way explain psudo code example: int num = 4; for(int i=0;i<num;i++){ object_type arrayi [dynamic size]; } so need 4 arrays each names array0,array1,array2, , array3 , must dynamic arrays. there anyway in c++? std::array<std::vector<object_type>, 4> array; (auto & v : array) v.resize(dynamic_size); the names array[0] , array[1] , etc... instead of array1 , array2 , etc... cares? if absolutely must have names, cassio's answer best bet. pre c++11 alternative: std::vector<object_type> array[4]; (size_t i=0; i<4; ++i) array[i].resize(dynamic_size); if want variable number of arrays, can use vector of vectors, , actually, initialization easier. doesn't require loop, can in constructor. std::vector<std::vector<object_type>> array(num, std::vector<object_type>(dynamic_size));

ruby - Kernel# gets stuck and Kernel#system does not when issuing gzip without any options -

long story short, i've been working on project , noticed when use: 1.9.3p392 :001 > `gzip` irb::abort: abort interrupt! (irb):1:in `call' (irb):1:in ``' (irb):1 /usr/local/rvm/rubies/ruby-1.9.3-p392/bin/irb:16:in `<main>' it wait indefinitely until ctrl + c. although, when use: 1.9.3p392 :047 > system('gzip') gzip: compressed data not written terminal. use -f force compression. help, type: gzip -h => false it continue without me using ctrl + c why using backticks stop process continuing? the backticks operator implicitly redirects standard output of resulting subshell (which capture subshell's output) while system doesn't. can observe same hang using system follows: system('gzip > /tmp/foo') this explicitly captures standard output , hang in same way. when gzip has output redirected wait input until eof or other signal received. without output redirection issue error message me...

matlab - segmenting human point cloud into 6 main parts -

i have point cloud of human , want segemnt 6 main parts including: hands, feet, head, ... how can using opencv or pcl library or matlab? segmentation or clustring algurithm can use? i think, graph cut algorithms may intresting you, try search phrase: "graph cut mesh segmentation". , here: http://people.cs.umass.edu/~kalo/papers/labelmeshes/

android - changed closed error while doing git push -

i trying push changes git project , had amend changes local commits, rebased onto merged change 400918 (otherwise wouldn’t allow me set edit option, not sure if there other way) ,made changes , when try push running following error,i tried rebase on changes,its still not working,any inputs here? user{90}> git push ssh://company.com:29418/project head:refs/for/branch counting objects: 43020, done. delta compression using 32 threads. compressing objects: 100% (4374/4374), done. writing objects: 100% (5359/5359), 6.22 mib | 8.17 mib/s, done. total 5359 (delta 1534), reused 2435 (delta 863) remote: resolving deltas: 100% (1534/1534) remote: processing changes: refs: 1, done ssh://company.com:29418/project ! [remote rejected] head -> refs/for/branch (change 400918 closed) use $git stash to reset code previous head. please take backup of code somewhere else because undo changes since last commit. after running git stash; repo ...

python - Dictionaries containing the biggest values -

i have scipy csr_matrix: (0, 12114) 0.272571581001 (0, 12001) 0.0598986479579 (0, 11998) 0.137415042369 (0, 11132) 0.0681428952502 (0, 10412) 0.0681428952502 (1, 10096) 0.0990242494495 (1, 10085) 0.216197045661 (1, 9105) 0.1362857905 (1, 8925) 0.042670696769 (1, 8660) 0.0598986479579 (2, 6577) 0.119797295916 (2, 6491) 0.0985172979468 (3, 6178) 0.1362857905 (3, 5286) 0.119797295916 (3, 5147) 0.270246307076 (3, 4466) 0.0540492614153 (4, 3810) 0.0540492614153 (4, 3773) 0.0495121247248 and find way create (in case 4) dictionaries each dictionary contains 2 biggest values each row.. so example, row 0 dictionary be: dict0 = {12114: '0.27257158100111998', 11998: '0.137415042369'} and row 1: dict1 = {10085: '0.216197045661', 9105: '0.1362857905'} since csr_matrix not have sort() method, convenient transform row need array first: a = m[i,:].toarray().flatten() to positions of sorted columns: arg...