Posts

Showing posts from February, 2011

how to convert a string to an object in Javascript? -

this question has answer here: safely turning json string object 20 answers i know how convert string below object in javascript: var string = '{"id":"50","actor":"1","subject":"1","object":"18","message":"a ajout\u00e9","status":"unseen"}' in fact, after converting string above object, able access element of object. example, if convert string object called "obj" able access value of element "id" (which "50") in such way: obj.id thanks in advance. this string in json . use var obj = json.parse(string);

how to resolve error in sub documents mongoose/express -

i developing web application based on mean stack, have care add , edit operations, particularly sub documents of field "order", console tells me "reference" undefined on line "order.reference" : req.body.order.reference, , don't know how sub documents. when add or modify of "order" fields got error, when add fields without exception works. here mongoose diagram: var mongoose = require('mongoose') , schema = mongoose.schema; var contactschema = new schema({ name: {type: string}, order: { reference : {type : string}, adresse : {type : string} , product : {type : string} } }); var contactmodel = mongoose.model('contact', contactschema); mongoose.connect('mongodb://localhost/contact'); exports.add = function(req, res) { var contact = req.body; contact = new contactmodel({ name: req.body.name, "order.reference" : req.body.order.reference, "orde...

php - List of highest scores- how to differentiate your score in the list -

i working on simple game. when user view scores of users want score in different color. how can it? so far have list of scores highest score lowest mysql_connect("$host", "$username", "$password")or die("cannot connect server "); mysql_select_db("$db_name")or die("cannot select db"); $sql="select * $tbl_name order score desc;"; $result=mysql_query($sql); while($rows=mysql_fetch_array($result)){ ?> <html table> <?php } mysql_close(); ?> test whether player in row current player, , set class. use css assign color class. while ($row = mysql_fetch_assoc($result)) { $class = $row['player'] == $current_player ? 'class="highlight"' : ''; echo "<tr $class>"; // code rest of table row echo "</tr>"; }

html - Javascript Undefined -

i'm hoping can assist weird issue. have code below, when open web-page, straight .html, works fine. no problems. when imbed onto sharapoint page 2 errors: 'timeline' undefined unable value of property 'layout': object null or undefined. happening tl.layout(); function way down @ bottom. i've added in 2 comments show errors being tagged in debugger. i'm stumped code works fine on own, , i'm not sure how 'losing' definitions? <class="javascript" style="border: 1px solid #b4d0dc; background-color: #ecf8ff;"> <html> <head> <script type="text/javascript"> timeline_ajax_url="/sites/abc/shared%20documents/timeline_front/timeline_ajax/simile-ajax-api.js"; timeline_urlprefix='sites/abc/shared%20documents/timeline_front/timeline_js/'; timeline_parameters='bundle=true' </script> <script> </scri...

vb.net - Copy information from a Excel file to another Excel file using SSIS VB2010, What wrong with these code -

i making ssis will: copy data sql server sql excel file then excel file preexisting excel file formulas i did first part --copy sql excel1- - works fine. tried copy excel1 file other using script task in visual basic 2010. i want check program , tell me wrong in trying copy information excel1 excel2 . when executed error dts scrip task runtime error , nothing. public sub main() dim oexcel microsoft.office.interop.excel.application, oexel2 microsoft.office.interop.excel.application dim obook microsoft.office.interop.excel.workbook, obook2 microsoft.office.interop.excel.workbook, osheet microsoft.office.interop.excel.worksheet, osheet2 microsoft.office.interop.excel.worksheet 'programing 'from excel spreadsheet oexcel = new microsoft.office.interop.excel.application() oexcel.visible = false obook = new microsoft.office.interop.excel.workbook("c:\documents\at1.xls") osheet = directca...

javascript - scroll left after onclick load() -

i have problem horizontal website. clicking switches div content. if scrolled far right new content out of sight left. i've done: <a href="#" class="img" onclick="$('div.container').hide().load('test.html').fadein(1500);return false;.scrollleft()";><img src="images/1.jpg" / height="200px"></a> is there possibility in on click action? or in test.html load action? .animate({'left':'+=50'}); worked far, no put scrolling 0. added left... thanks in advance! cheers, nico

java - Implementation function inside OnClickListener - Android -

i wanna call method "criarnotificacao" -> createnotification, inside function onclick, error can't implement it, friend tell me create anonymous class, don't understand "too much".. how can it? there simple method this? package br.com.notification; import android.app.activity; import android.app.notification; import android.app.notificationmanager; import android.app.pendingintent; import android.content.context; import android.content.intent; import android.os.bundle; import android.view.view; import android.widget.button; import android.widget.textview; public class createnotificationactivity extends activity { button btnnotifica; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); textview text = new textview(this); text.settext("notificação disparada."); setcontentview(r.layout.main); // texto que aparecerá na barra de status (chamad...

regex - Shorten length of character in R -

i have vector of characters this: sampledata <- c("this see i.r.o not i.r.o", "similar here a.s. a.s.", "one more i.r.o. i.r.o.") i remove after first occurence of i.r.o or .i.r.o . in cases a.s or a.s. . so final version looks this: 1 see i.r.o 2 similar here a.s. 3 1 more i.r.o. edit: corrected gaps between i.r.o , a.s gsub() expressionas identical in each character. see example above. i'm little confused because comments above suggest you've gotten answer, don't see it. this seems work: sampledata <- c("this see i.r.o not i.r.o", "similar here a.s. a.s.", "one more i.r.o. i.r.o.") gsub("(([[:alpha:]]\\.)+[[:alpha:]][.]?) .*$","\\1",sampledata) ## [1] "this see i.r.o" "similar here a.s." ## [3] "one more i.r.o." the regex reads "'(on...

python - Download a file from ftp using ftplib -

i looking specific file within folder on ftp. there several folders , code loops through each folder find file. once, find file download it. import ftplib import os, sys, os.path ftp = ftplib.ftp("xxxxxxxx") ftp.login("dbaxyz", "password123") files = [] try: files = ftp.nlst() except ftplib.error_perm, resp: if str(resp) == "550 no files found": print "no files in directory" else: raise f in files: filess = [], filess=ftp.nlst(f) in filess: if len(i)==34 , i[8:11]=="aco" , i[12:17]=="cclf9" , i[3:7]=="1263" : print local_filename = os.path.join('c:\\users\\zubair.zahiruddin\\desktop\\test', i) file = open(local_filename, 'wb') ftp.retrbinary('retr '+ i, file.write) file.close() ftp.close() #ftp.quit() however, error: perm file not foun...

sql server 2008 - (How) Can I place a with sql query in a table value function? -

i put following query return of table value function. ;with org ( select id org_unit id = @id_org_unit union select parent_id org_unit c join org p on p.id = c.id ) select * org i tried create such function i'm resorting stored procedure in despair... is possible create function return result? create function test_func(@id_org_unit int) returns table return ( org ( select id org_unit id = @id_org_unit union select parent_id org_unit c join org p on p.id = c.id ) select * org ); sqlfiddle

How to start hazelcast client from console -

how run hazelcast client console? i have config in xml : <hazelcast-client xsi:schemalocation="http://www.hazelcast.com/schema/client-config hazelcast-client-config-3.3.xsd" xmlns="http://www.hazelcast.com/schema/client-config" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"> <network> <port auto-increment="true" port-count="100">5701</port> <outbound-ports> <!-- allowed port range when connecting other nodes. 0 or * means use system provided port. --> <ports>0</ports> </outbound-ports> <join> <multicast enabled="true"> <multicast-group>224.2.2.3</multicast-group> <multicast-port>54327</multicast-port> </multicast> </join> </network> </hazelcast-client> and need console when run run....

mysql - Get the latest N results for each person -

i'm trying build personalized query table consists on obtaining latest n records each person. table schema follows: +-----------+---------------------+------+-----+---------+-------+ | field | type | null | key | default | | +-----------+---------------------+------+-----+---------+-------+ | person | varchar(100) | no | pri | null | | | time | bigint(20) unsigned | no | pri | null | | +-----------+---------------------+------+-----+---------+-------+ for example, if had following data: +---------+-------+ | person | time | +---------+-------+ | | 2 | | | 7 | | b | 1 | | b | 6 | | b | 4 | | c | 3 | +---------+-------+ and n = 2 , expected result be: +---------+-------+ | person | time | +---------+-------+ | | 7 | | | 2 | | b | 6 | | b | 4 | | c | 3 | +---------+-------+ (just last 2 results each pe...

fft - Inverse Fourier Transforms in Matlab -

Image
this question exact duplicate of: fft images , inverse 1 answer i've been given magnitude , phase fourier transform , i'm asked use these matrices go backwards , reproduce image again. far here understanding: %here have imaginary part z = mag.*cos(phase) + 1i.*sin(phase); %here real part real = sqrt((mag).^2-(z).^2); image = ifftshift(real); image = ifft(image); imshow(image); i take magnitude , phase , imaginary part. use magnitude formula i.e. mag = sqrt((real)^2+(imaginary)^2) try solve real part. reverse shifts , reverse fourier transform in hopes of getting image... get: i need figuring out, ideas? your computation of real part , imaginary part not correct. i'd this: z = mag.*cos(phase) + 1i*mag.*sin(phase); % full matrix of complex amplitudes %here real part real_part = real(z); imag_part = imag(z); % need @ all?! image = i...

javamail - Resent headers in MIME email -

i want know more resent headers (resent-from, resent-to, resent-date etc) prepended email's header. when these headers added? added server or mail client program? i need write java program using javamail api forward email (without changing or parsing through it's original content). email redirected destination email address on arriving @ server specific recepient. snippet have been able forward / redirect mime mail using resent headers helpful. thank you see section 3.6.6 of rfc 2822 . you should able use javamail add these headers message. if message read folder on mail server, you'll need make copy of message first before can change it. use mimemessage copy constructor . can send whatever address want, ignoring addresses in message, using transport.send method takes array of addresses. if need preserve original message-id (which may not appropriate since you're modifying message), you'll need subclass mimemessage , override updateheaders me...

c# - Mono 3.4.1 isn't compiling correctly on the raspberry pi -

i m trying compile latest mono source git (3.4.1) on raspberry pi, can make, , make install, if go /usr/local/lib/mono “2.0 compat-2.0 gac” folders , none other frameworks. when try run: pi@raspberrypi ~/testemono $ mcs hello.cs pi@raspberrypi ~/testemono $ mono hello.exe assembly mscorlib.dll not found or not loaded. should have been installed in `/usr/local/lib/mono/4.5/mscorlib.dll' directory. i have initial mono installation got doing "sudo apt-get install mono-complete" (since need mono build mono) it's on /usr/lib/mono i did 'make check' , here failed tests 420 test(s) passed. 6 test(s) did not pass. failed tests: block_guard_restore_aligment_on_exit.exe bug-10127.exe finally_block_ending_in_dead_bb.exe pinvoke2.exe pinvoke3.exe winx64structs.exe make[5]: *** [runtest] error 1 make[5]: leaving directory `/home/pi/mono/mono/tests' make[4]: *** [testjit] error 2 make[4]: leaving directory `/home/pi/mono/mono/tests' make[3]: *** ...

java - Center JLabel within JPopupMenu -

Image
i know me being ocd, having issue centering jlabel text within jpopupmenu. i've tried popup.add(new jlabel("menu",jlabel.center)); , label.sethorizontalalignment(swingconstants.center); label.sethorizontaltextposition(swingconstants.center)); no luck. anyone know fix? set proper layout of jpopupmenu such boxlayout , flowlayout etc. , add jlabel positioned based on layout manager. sample code: jpopupmenu popup = new jpopupmenu(); popup.setlayout(new flowlayout(flowlayout.center)); popup.add(new jlabel("menu")); read more a visual guide layout managers each layout explained in details along sample code.

android - Start MapFragment from fragment? -

is there way start mapfragment inside fragment, way can start activity inside activity? i'm trying using code below doesn't work. doing wrong or not possible do? intent mymapintent = new intent(this, mymapfragment.class); startmymapfragment(mymapintent);

list - Need help to find with dictionary objects in python -

i have dictionary object say: d = { '25478329': ['17647430', '376088951', '32416061', '43096205'], '43096205': '17647430', '376088951': ['17647430', '25478329', '32416061'], '32416061': ['17647430', '25478329'] } i need finding key maximum numbers of data. data here mean string values inside list. your question clearer, if want suggested in comments, work: def keyfunc(item): key, value = item if isinstance(key, str): return 1 else: return len(key) max(d.items(), key=keyfunc)[0] here, define key function takes key/value 2-tuple returned dict.items() , and: if value string, returns 1. otherwise, returns length of list of strings. that key function used builtin max() function return item largest number of strings, , use [0] key item.

ios - Different Collisions -

i have 2 collisions in game happen when main characters hits obstacle, game on appears , 1 touches ground , nothing happens. codes -(void)didbegincontact:(skphysicscontact *)contact { if ([contact.bodya.node.name isequaltostring:@"ground"] || [contact.bodyb.node.name isequaltostring:@"ground"]) { [hero land]; } else { [self gameover]; } how can add different main character/hero collision doesn't lead me game on whole different outcome (like different reaction main character) try detecting contact other special cases: -(void)didbegincontact:(skphysicscontact *)contact { bool iscontactwithground = ([contact.bodya.node.name isequaltostring:@"ground"] || [contact.bodyb.node.name isequaltostring:@"ground"]); bool iscontactwithhero = ([contact.bodya.node.name isequaltostring:@"hero"] || [contact.bodyb.node.name isequaltostring:@"hero"]); bool iscontactwithotherthing = (...

lotus notes - Getting values from profile document -

i have problem getting value profile document. creation, followed these instructions: creating profile form 1.create form fields hold values want store in profile documents. 2.choose design - form properties , deselect "include in menu. , "include in search builder" 3.save form. 4.do not include form in view. in form have 1 field computed when composed (a number), computed value "0" but code can't retreive field value: dim session new notessession dim db notesdatabase dim doc notesdocument set db=session.currentdatabase set doc=db.getprofiledocument("nameofprofiledoc") dim number integer number=doc.fieldname(0) isprofile return true, number "". reason never gets value perhaps because haven't saved document database yet. can create action button let's edit document , save it: @command( [editprofile] ; formname );

PHP - print the result of a boolean expression -

i expect following code print "false" <?php $a = 4; $b = 45; echo $a==$b; ?> but prints nothing. it doesn't print because result of $a==$b boolean, , false converted empty string. use var_dump instead (if debugging code): var_dump($a==$b); or alternatively can use echo way: echo ($a==$b) ? 'true' : 'false';

sql - Convertion nvarchar to decimal -

select nom ,sum(cast(solde float)) _solde tab num_client='550322' group nom i have result without comma ,solde 66,11 want result respecting comma . sql server not respect locale settings varchar number conversions, need replace comma decimal first. select nom ,sum(cast(replace(solde,',','.') float)) _solde tab num_client='550322' group nom

javascript - Using a weaker equality test for angular select -

lot's of advice tells me this: // in js $scope.items = [ { id: 1, name: 'foo'}, { id: 2, name: 'bar'}]; // in html <select ng-model="selecteditem" ng-options="item item.name item in items"></select> and works fine. works fine too: $scope.selecteditem = $scope.items[1]; the select initialized bar object. but doesn't work: $scope.selecteditem = { id: 2, name: 'bar'}; the select control not initialized bar object (understandably, think). selecteditem equivalent bar object, not equal it. have problem in app parse back-end. selecteditem pointer 1 object another, , items of (handful) of objects in target class. these in 2 different queries. is there way manipulate angular still select object, use custom equality test, object id? yes, require use of external library or scripting of own. need lookup function take key/value pair (such present in code sample) , return item array. th...

Injection of sub-component in Web Component -

suppose creating component template contains special sub-components. example: <x-audio-player playlist-json="my_js_list"></x-audio-player> with shadow dom <x-playlist> <x-track name="track 1"></xtrack> <x-track name="track 2"></xtrack> <x-track name="track 3"></xtrack> </x-playlist> probably, have need completly change view of tracks. need give possibility change shadow dom into: <x-playlist> <y-track name="track 1"></y-track> <y-track name="track 2"></y-track> <y-track name="track 3"></y-track> </x-playlist> so. best way that? you able define multiple possible selections insertion points. wanna like: <template> <content select="x-track, y-track"></content> </template> hope helps!

visual studio 2013 - Missing Method exception "System.Web.Routing.RouteValueDictionary System.Web.WebPages.TypeHelper.ObjectToDictionaryUncached(System.Object) -

i've created new project in visual studio 2013.2 webapi , mvc enabled. right out of box, compiling generated project , running gives me exception. looking around here, i've come across following 2 questions: mvc 5.1 missingmethodexception system.web.webpages.typehelper.objecttodictionaryuncached system.web.webpages.typehelper.objecttodictionaryuncached both these answers involve assembly redirects; however, in case assembly redirects present , i'm still getting issue. problem gac loading version 3.00.11001.0 listed under assembly version 3.0.0.0 , application wants 3.20.20520.0 listed assembly version 3.0.0.0. (note in diagnosing project installed 5.2 pre-release nuget package, had same problem original versions, don't have readily available) since gac preferred on bin directory, seems development machine pull wrong file. is safe remove these files gac? appears these required visual studio produce razor intellisense removing assemblies gac di...

html - CSS apply gradient to right triangle shape with solid fill -

Image
i want apply same gradient triangle (class="triangle-right") rectangle (class="fillblue"). have seen other examples not working me. combining both shapes , using single class awesome too! js fiddle here! css: .fillblue { background: rgb(208,228,247); /* old browsers */ background: -moz-linear-gradient(top, rgba(208,228,247,1) 0%, rgba(115,177,231,1) 24%, rgba(10,119,213,1) 50%, rgba(83,159,225,1) 79%, rgba(135,188,234,1) 100%); /* ff3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(208,228,247,1)), color-stop(24%,rgba(115,177,231,1)), color-stop(50%,rgba(10,119,213,1)), color-stop(79%,rgba(83,159,225,1)), color-stop(100%,rgba(135,188,234,1))); /* chrome,safari4+ */ background: -webkit-linear-gradient(top, rgba(208,228,247,1) 0%,rgba(115,177,231,1) 24%,rgba(10,119,213,1) 50%,rgba(83,159,225,1) 79%,rgba(135,188,234,1) 100%); /* chrome10+,safari5.1+ */ background: -o-linear-gradient(top, rgba(208,228,247,1) 0%,rgba(115,...

Docker build takes too long -

certain instructions in dockerfiles taking long. example, adding 3 lines file add instruction or echoing line file takes more minute. what can causing this? here's syslog, not sure if relevant: may 29 18:45:17 mymachine kernel: [97813.649053] ext4-fs (dm-3): mounted filesystem ordered data mode. opts: discard may 29 18:45:54 mymachine kernel: [97850.627286] ext4-fs (dm-3): mounted filesystem ordered data mode. opts: discard may 29 18:45:55 mymachine kernel: [97851.249484] ext4-fs (dm-4): mounted filesystem ordered data mode. opts: discard may 29 18:46:34 mymachine console-kit-daemon[983]: glib-critical: source id 5102 not found when attempting remove may 29 18:46:53 mymachine kernel: [97908.977215] ext4-fs (dm-2): mounted filesystem ordered data mode. opts: discard may 29 18:46:53 mymachine kernel: [97909.217137] ext4-fs (dm-2): mounted filesystem ordered data mode. opts: discard may 29 18:46:53 mymachine kernel: [97909.247252] ext4-fs (dm-3): mounted filesystem ordered ...

Android add RelativeLayout dynamically -

i'm trying insert relativelayout dynamically. method works well, layout placed laterally , not under existing public void add(view v) { edittext et=new edittext(context); relativelayout dynamic_component = new relativelayout(this); dynamic_component.addview(et); relativo.addview(dynamic_component); } if want layout "dynamic_component" auto-magically placed under existing views of parent layout, "relativo" parent should linearlayout vertical orientation.

javascript - Custom Highcharts Context Menu Button Appearing in Every Chart on Page -

i have page several charts, , need able add specific options exporting context menu each chart. code using: mychart.options.exporting.buttons.contextbutton.menuitems.push({ text: "custom option", onclick: somefunction }); unfortunately, adds option every chart, not chart mychart references. i'd able add option , have appear on 1 chart. here fiddle demonstrates: http://jsfiddle.net/4up5y/2/ thanks! to add button use options chart. can set each chart different set of options: http://jsfiddle.net/4up5y/4/ get default buttons: var buttons = highcharts.getoptions().exporting.buttons.contextbutton.menuitems; buttons.push({ text: "tokyo option", onclick: helloworld }); and set them chart: exporting: { buttons: { contextbutton: { menuitems: buttons // or buttons.slice(0,6) } } },

javascript - scrollLeft with JQuery & Wrapper Width doesn't work -

i still have bug here. here got informations sliding horizontally jquery: scrollleft: end of main div not offset().left my site: xxx on index page there 2 divs on print page there 3 divs xxx i set width 6000px can add more blog post automatically display inline. but heres bug, if have 6000px everywhere can scroll right side, blogpost go away. i hope understand. i need still problem! daniel add bottom of css, , should fix issues. .blog { min-height: 382px; } and add script bottom of each page have horizontal scrolling, , when page done loading fix width dynamically. <script type="text/javascript"> var resizewidth = function() { var numitems = $('.items-row').length; var divwidth = $('.items-row').outerwidth(); var offset = ($(window).width() - divwidth) / 2; $("#incontent").css('width', (numitems * divwidth + offset) + 'px'); } $(document).ready(function() { ...

html - Issue with Nested Form rendering -

i have rails 4 app has form looks like: <%= form_for @store, :html => {:multipart => true} |f| %> <%= f.fields_for :products |product| %> <%= render partial: "edit_product_fields", locals: {product:product} %> <% end %> <%= f.submit %> <% end %> and edit_product_fields partial looks like: <select> <option value="textbook" <% if product.type_of == "textbook" %>selected<% end %>>textbook</option> <option value="magazine" <% if product.type_of == "magazine" %>selected<% end %>>magazine</option> <option value="book" <% if product.type_of == "book" %>selected<% end %>>book</option> </select> when have code this, error: undefined method `type_of' #<nestedform::builder:0x00000102304f78> but if change render line (i made less explicit taking out par...

collision - How do you create 2 Rectangle objects that will collide and be detected in Java? -

also, possible collide 2 oval objects? public void paint(graphics g){ g.setcolor(color.green);<br/> g.fillrect(k, l, 100, 100);<br/> g.setcolor(color.blue);<br/> g.fillrect(n, m, 100, 100);<br/> g.setcolor(color.red);<br/> for(int i=0; i<2; i++){<br/> g.filloval((int)x[i],(int)y[i],diameter,diameter);<br/> }<br/> } it appears using swing graphics. although providing code question rather complex task, try guide in correct direction. it might best encapsulate rectangles (or ovals) own classes. give objects method drawself(graphics g) , pass in graphics object. also, give classes fields keep track of current positions , sizes. then, collisions, might try making class along lines of collisiondetector . of shape objects have-a collisiondetector, , everytime shape moves ask shapes check collisiondetector s...

c++ - GLM: function taking degrees as a parameter is deprecated (WHEN USING RADIANS) -

currently using vc++ 11 sdl2, glm, , glew. issue stemming glm when attempt 2 things: create rotation matrix, create perspective camera matrix (3d). the error is: "glm: perspective function taking degrees parameter deprecated" despite fact passing radians (as floats) both functions. says should define "#define glm_force_radians." necessary? personally use degrees everything, opengl, having convert , forth (for ai movement , not) pain , causes spike in cpu when have many npcs moving. #define degreestoradians(x) x*(3.141592f/180.0f) the static part should resolved @ compile time compiler, surround degrees glm stuff macro , done. add #define glm_force_radians before including , glm headers, default use radians instead of degrees

arrays - Need help fixing java.lang.ArrayIndexOutOfBoundsException -

i'm trying implement this word wrap algorithm in java. program takes in number of paragraphs wrap, maximum line length, , input text. example: 1 5 test. however, after takes in input text , runs algorithm, following runtime error: exception in thread "main" java.lang.arrayindexoutofboundsexception: 1 @ dynamicprogramming.main(dynamicprogramming.java:74) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:601) @ com.intellij.rt.execution.application.appmain.main(appmain.java:120) could possible have typo translating above code c++ java, or there kind of error in logic causing exception? thanks. import java.util.scanner; public class dynamicprogramming { static int p; static int m; static string[] inputline; public static...

C++ complex number multiplication -

if have (1+i)^2, answer should 2i but if do std::complex<double> = sqrt(1), 1 = 1; cout << pow(one+i,2) << endl; it outputs (4,0) you initializing i sqrt(1) whereas thought sqrt(-1) . such evaluated double expression (after -1 converted double closest matching sqrt , see mike's comment complete sequence), according cplusplus.com generates domain error negative arguments. instead can initialize i as: std::complex<double> i(0,1); alternatively use complex number argument sqrt described in this answer , or potatoswatter indicated in comments use 1.i c++14 (should have compiler & standard library supports user-defined literals standard library types, part 2 ).

PHP date and time from an xml import -

i have xml file date stored in format: <sun rise="2014-05-30t02:51:30" set="2014-05-30t18:31:22"/> my php process value variable named $sunrise 2014-05-30t02:51:30 but timezone +2 have add 2 more hours. the problem string. dont have idea how convert date. since got time inside element (2014-05-30t02:51:30) use strtotime() or alternatively, use datetime + dateinterval add 2 more hours. consider example: $sunrise = '2014-05-30t02:51:30'; $date = new datetime($sunrise); $date->add(new dateinterval('pt2h')); echo $date->format('y-m-d h:i:s'); // outputs: 2014-05-30 04:51:30 echo date('y-m-d h:i:s', strtotime($sunrise . ' +2 hours')); // outputs: 2014-05-30 04:51:30

how can i set the camera function that anti-shake(image Stabilizer) at android -

i've made camera app. i want add function anti-shake. but never find how setting anti-shake(image stabilizer). plz me!! usually image stabilizer built-in camera feature, while ois (optical-image-stabilization) built-in hardware feature; few devices support them. if device hasn't built-in feature, think cannot anything. android doesn't provide direct api manage image stabilization, may try: if android.hardware.camera.getparameters().getsupportedscenemodes(); contains steadyphoto keyword (see here ), device supports kind of stabilization (usually shots when accelerometer data indicates "stable" situation) check android.hardware.camera.getparameters().flatten(); "ois" or "image-stabilizer" keyword/values or similar use in parameters.set(key, value); . samsung galaxy camera should use parameters.set("image-stabilizer", "ois");//can "ois" or "off" if boring may try reading accele...

html - select all option for dropdown using php -

this question has answer here: how create select option dropdown? 2 answers i totally fed of coding part add select option, have added select all, problem how fetch data, mysql database using, select option. i have 8 tables in ma database , search box have select table query search term show information query term selected table. here code above: <form method="post" action="test3.php" name="search_form"> <input type="text" name="search" size=15 maxlength=15 placeholder = "gene symbol"/> <select name="table[]" id = "table[]" size = "0" multiple> <option selected="selected"></option> <option value="infla_info">inflammation</option> <option value="diet_info"...

Difference between ModuleSpawn and ModuleInvoke in Marklogic? -

i have gone through entire website of marklogic not finding modulespawn , moduleinvoke class , why using them , difference between them. do have idea that? both subclasses of http://docs.marklogic.com/7.0/javadoc/xcc/com/marklogic/xcc/request.html the key difference modulespawn "spawned asynchronously marklogic server" . is, runs on task server instead of xdbc server.

c# - How to create a simple RP in Windows Identity Foundation -

i have done following steps- 1. created website using vs2012. 2. configute authorization in config file show logded in user can access resources. using asp.net defaultmembershipprovider testing purpose. 3. run site & register user & logded in site. 4. added local sts clicking "identity , access" 5. has modified config file use wif federation authentication. now when run site automatically logded in , show 'terry' logded in user. when click on logoff link not happen anything. after lookiing project found 'terry' automatically logded in cliam section of localsts.exe.config. is there practical use of cliam section of localsts.exe.config? simply want create 2 rp site & 1 sts. both rp site authenticated sts & provide sso. each rp site uses own membership data authenticate user. can please provide me steps this. of example have read shows using cliam section of localsts.exe.config. thanks, @sam localsts provides ...

ios - How to measure continues shake in Objective C? -

i have measure continues shake in event application. accelerometer deprecated , using coremotion . using following code application. - (void)motionended:(uieventsubtype)motion withevent:(uievent *)event { if (event.type == uieventtypemotion && event.subtype == uieventsubtypemotionshake) { nslog(@"shaking..."); } } its detect event when stop shake. there way through can detect continues shake event ? thanks in advance. can't use motionbegan method? - (void)motionbegan:(uieventsubtype)motion withevent:(uievent *)event { if (event.type == uieventtypemotion && event.subtype == uieventsubtypemotionshake) { nslog(@"shaking..."); } }

JSON to CSV file conversion -

i have json file { "name": "re2", "count": 1806, "frequency": "realtime", "version": 5, "newdata": true, "lastrunstatus": "success", "lastsuccess": "fri may 30 2014 06:02:41 gmt+0000 (utc)", "results": { "collection1": [ { "title": { "href": "http://www.realestate.com.au/project-spec+property+%e2%80%93+helio+apartments-vic-north+melbourne-600004887", "text": "93 flemington road, north melbourne, vic 3051" }, "image": { "href": "http://www.realestate.com.au/project-spec+property+%e2%80%93+helio+apartments-vic-north+melbourne-600004887", "alt": "93 flemington road, north melbourne, vic 3051", "src": "http://i2.au.reastatic.net/345x200/3a7e58fe...

php - Can't get data attribute value -

am trying fetch data attribute dynamically created table using foreach .currently getting value od data attribute serviceid of first row only. this php code : <?php foreach ($service_arr $service) {?> <tr class="odd gradex"> <td><button id="delete_btn" type="button" data-serviceid="<?=$service->service_id?>" class="btn btn-default" data-toggle="modal" data-target="#servicesdeletemodal">delete</button></td> </tr> <?php }?> i want fetch value serviced table. if have 3 rows generated in foreach loop, getting serviceid of first row ( <tr> ).why that? jquery code: $('#delete_btn').click(function(){ var service_id = $(this).attr("data-serviceid"); console.log(service_id); }); please thanks you have duplicate ids. id selector binding click first element in matched dom. should use .data() set data attribut...

ios - Fast Enumeration with NSMutableDictionary -

i found weird issue 64 bit platform, when tried enumerate nsmutabledictionary.i have code follows, nsmutabledictionary *dictionary = [nsmutabledictionary dictionary]; nsarray *expectedkeysarray = [nsarray arraywithobjects:@"k1", @"k2", @"k3", @"k4", @"k5", nil]; nsarray *expectedvaluesarray = [nsarray arraywithobjects:@"v1", @"v2", @"v3", @"v4", @"v5", nil]; (int = 0; < [expectedkeysarray count]; i++) { [dictionary setobject:[expectedvaluesarray objectatindex:i] forkey:[expectedkeysarray objectatindex:i]]; } (nsstring *key in dictionary) { nslog(@"key %@",key); } when ran above code in 32 bit simulator,line within loop nslog(@"key %@",key); is getting executed , fast enumeration works fine.but when run above code in 64 bit simulator, doesn't enter loop , fast enumeration doesn't work.did face similar issue?.i...

Lotus Notes Database template inheritance not replicating -

i have lotus notes database 5 replicas. i changed template name inheritance "xyzv1" "xyzv2". i expected overnight, template name inheritance update "xyzv2" after servers replication did not. what missing/wrong in db acl? replica: template name xyzv2.ntf replica: template name xyzv1.ntf replica: template name xyzv1.ntf replica: template name xyzv1.ntf replica: template name xyzv1.ntf it not replicate template info if in replication options "send" tab option "send changes in application title , catalog info other replicas" unchecked.

autocomplete - Auto filled Current Password on Change Password page -

i'm testing page "change password". user i've logged in has saved password browser. problem whenever open "change password" page, current password shown filled in already. i'm not sure issue or correct. please me whether issue or correct. you need add attribute below password input. autocomplete="off" please note though latest versions of major browsers not supporting attribute more.

Error on loading Xamarin.Forms sample project -

Image
just playing xamarin.forms, downloaded sample project tipcalc here . when try open solution in xamarin studio getting error. when try build project, error error msb4019: imported project "c:\program files (x86)\msbuild\microsoft\portable\v4.5\microsoft.portable.csharp.targets" not found. confirm path in declaration correct, , file exists on disk. (msb4019) (tipcalc.android) please guide me, should configure in project, make run successfully. using xamarin studio 5, os windows 7 ultimate. i installed portable library tools followed xamarin.android fix this. error occurs if try load pcl project without installing portable library tools, because xamarin checks following file in machine while loading pcl project. c:\program files (x86)\msbuild\microsoft\portable\v4.0microsoft.portable.csharp.targets

jquery - Shift focus to next field when Enter is pressed -

i facing problem in shifting focus next textfield in ipad. scenario : [textfield1] [textfield2] when enter pressed on textfield1 shift focus textfield2. i have googled workarounds , tried them nothing works. please me on this. easiest way set tag property of textfields then - (void)textfieldshouldreturn:(uitextfield *)textfield { uitextfield *nextfield = (uitextfield*)[self.view viewwithtag:textfield.tag + 1]; // if textfield tag exist make first responder if(nextfield) { [nextfield becomefirstresponder]; } else { // hide keyboard [self.view endediting:yes]; } return yes; }

sql - java.lang.UnsatisfiedLinkError: no sqljdbc_auth in java.library.path -

i'm created .jar of java application, , when i'm try run .jar cmd, error. i've been searching , found many examples, no 1 work's me. set java.library.path directory ‘sqljdbc_auth.dll’ saw here error continuous. http://www.linglom.com/images/howto/netbeans/sqlserver/part3/8.png i run java application command : java -djava.library.path= "my dll path" , give this: ps c:\users\user> java -djava.library.path="c:\users\user\desktop\microsoft jdbc driver 4.0 sql server\sqljdbc _4.0\ptb\auth\x64" error: not find or load main class .library.path=c:\users\user\desktop\microsoft jdbc driver 4.0 sql server \sqljdbc_4.0\ptb\auth\x64 i dont no how solve this. i've been searching lot of time, nothing works. please me. thanks warning: failed load sqljdbc_auth.dll cause : no sqljdbc_auth in java.library.path com.microsoft.sqlserver.jdbc.sqlserverexception: driver not configured integrat ectionid:0481a2ee-4ac4-4fd3-89cd-58aad1696fe4 @...

android - java.lang.outofmemoryerror bitmap on a fragment pager -

i have memory leak problem can't find way solve. there many questions in stackoverflow no 1 of them useful me. i have activitiy view pager , action bar tabs navigation. in every fragment load 1 image sort of gallery in end. works nice. after fragment changes, got error: e/androidruntime(19271): java.lang.outofmemoryerror e/androidruntime(19271): @ android.graphics.bitmap.nativecreate(native method) all i've read need of deallocating images, thought about: event @ "fragment lost focus" delete views inside fragment focus has lost but can't find solution that. correct way? if so, can give example? or i'm wrong , solution way? this how add images fragment: imageview img = new imageview(rootview.getcontext()); img.setvisibility(1); img.setimageresource(r.drawable.gallery_image_1); img.setadjustviewbounds(true); img.settag( "gallery_image_1" ); gallery...