Posts

Showing posts from May, 2012

c++ - Save byte pointer to a file -

i'm using protonsdk (www.protonsdk.com) im trying use function byte *pdata = getfilemanager()->get("texturefile.rttex", &filesizebytes, true, true); i want save output file (decompressed rtpack) doesn't want to. i new c++ have background php you can write file c++ standard library. http://www.cplusplus.com/doc/tutorial/files/ or c standard library. write data pdata pointing to. #include <stdio.h> #include <stdlib.h> /* proton sdk header */ /* header byte type (not part of c standard library) */ int main(int argc, char** argv) { int filesizebytes; file* fp; byte *pdata = getfilemanager()->get(getsavepath()+"test.txt", &filesizebytes, true); fp = fopen("put_filename_here", "w"); if(fp == null) { fprintf("cannot open file!\n"); exit(-1); } fwrite(pdata, filesizebytes, sizeof(byte), fp); ...

r - Why are the cp values in plotcp() chart modified from the original table? -

what cp values on rpart plotcp() chart? expect these values match cp column in printcp(), instead following scale calculated (from plotcp code): p.rpart <- x$cptable cp0 <- p.rpart[, 1l] cp <- sqrt(cp0 * c(inf, cp0[-length(cp0)])) so each cp value cv table multiplied against following 1 in same column , square rooted. why? according uwe's answer, can found here: re: [r] different cp values in rpart() using plotcp() , printcp() printcp() gives minimal cp pruning happens. plotcp() plots against geometric mean actual relationship in source code provided below, cp0 cp value used in printcp while cp cp value used in plotcp. cp0 <- p.rpart[, 1l] cp <- sqrt(cp0 * c(inf, cp0[-length(cp0)]))

How do you make NLTK draw() trees that are inline in iPython/Jupyter -

for matplotlib plots in ipython/jupyter can make notebook plot plots inline %matplotlib inline how can 1 same nltk draw() trees? here documentation http://www.nltk.org/api/nltk.draw.html based on this answer: import os ipython.display import image, display nltk.draw import treewidget nltk.draw.util import canvasframe def jupyter_draw_nltk_tree(tree): cf = canvasframe() tc = treewidget(cf.canvas(), tree) tc['node_font'] = 'arial 13 bold' tc['leaf_font'] = 'arial 14' tc['node_color'] = '#005990' tc['leaf_color'] = '#3f8f57' tc['line_color'] = '#175252' cf.add_widget(tc, 10, 10) cf.print_to_file('tmp_tree_output.ps') cf.destroy() os.system('convert tmp_tree_output.ps tmp_tree_output.png') display(image(filename='tmp_tree_output.png')) os.system('rm tmp_tree_output.ps tmp_tree_output.png') little slow, jo...

php - wp_mail() or mail() not working in Wordpress contact form -

this question has answer here: php mail function doesn't complete sending of e-mail 24 answers using wp_mail() instead of mail() in wordpress not work 4 answers i have contact form in website http://dil33pm.in/contact/ send button connected file contact-form.php has basic test code. <?php $to = "dil33pm@gmail.com"; // email subject , body text $subject = 'wp_mail function test'; $message = 'this test of wp_mail function: wp_mail working'; $headers = ''; // load wp components, no themes define('wp_use_themes', false); $parse_uri = explode( 'wp-content', $_server['script_filename'] ); require_once( $parse_uri[0] . 'wp-load.php' ); // send test message using wp_mail function...

Can I add event to calendar without letting user know in android? -

Image
i want add event native calendar using below code. , working fine. simpledateformat formatter = new simpledateformat("yyyy/mm/dd hh:mm"); final calendar cal = calendar.getinstance(); try { cal.settime(formatter.parse(datetime)); eventdate = cal.get(calendar.year)+"/"+cal.get(calendar.month)+"/"+cal.get(calendar.day_of_month)+" "+cal.get(calendar.hour_of_day)+":"+cal.get(calendar.minute); log.e("event date",eventdate); } catch (parseexception e) { e.printstacktrace(); } intent intent = new intent(intent.action_edit); intent.settype("vnd.android.cursor.item/event"); intent.putextra("begintime", cal.gettimeinmillis()); intent.putextra("allday", true); intent...

ember.js - Dynamically setting component tagName -

from i've seen isn't possible default, hoping new glimmer engine might able improve this. i'm creating inline edit component within table. default, want component td element, selectively become input element on interaction. // components/inline-edit.js tagname: 'td', click: function() { this.set('tagname', 'input'); this.rerender(); // prolly not necessary, thought i'd give go } unfortunately, not work. missing something? i'm using ember 1.13.3, need opt glimmer work? thanks. why don't render input field hidden, on click unhide , focus? <td> can't become <input> because <input> can't direct child of <tr> nor make sense.

windows services - Decimal value is read as scientific notation in sql server -

i have windows service reads .csv particular folder , puts in sql server. have code shown below: private void updateworkorder(list etchrecord) { object[] objarr = new object[] { convert.toint32(etchrecord[1]), convert.todatetime(etchrecord[2]), convert.todatetime(etchrecord[3]), convert.todecimal(etchrecord[4]), convert.toint32(etchrecord[5]), **convert.todecimal(etchrecord[6])};** --> field dbmanager.execdataset("usp_etchrate_saveworkorderdata", objarr); } and have stored procedure in sql server responsible stroing in sql table. problem shows decimal values in field shown above scientific notation. tried changing text doesn't work

Reading Csv file with chinese characters in php -

i reading csv file chinese characters, , when use print_r() give me type of array array ( [0] => pk!ȣ�4v�[content_types].xml ��(��t�n�0�w�?d�v��cuu]�-�l �irp�h$.�����%�鮲�"�21j�"�{m�*�����h����z������f�����f�$ ) array ( [0] => orb^b�0�?)|��e\ɠ�z��d����b2~�bm [1] => %�;��*y'�����**kre [2] => tn��c2�ear�>�t�b��4�t�4dÌqdl���?�t4�����*f�;+�@{�졗��f��io{s��ma�g�`�2k?ly���&`cwvݙ|��^z��v*u�jw�}�\�y�%����acb$���qsk�mmq6��-<���+ց�����_������ݥ㸋�g�|����g6 �����pk!�u0#�l�_rels/.rels ��(����n�0��h�c���nh���lh�!t�$����$@����jc�����?[���itb/nú(a�3b{�jx��v�b"gi��aw��l_x���b���������#b4o��r��0q�ahѓ�eܔ�=��p-<��j{�>�<���4mox/�}b�n�@�;�v�cf��ۨ�b�i�����"c�&�\o���8q"k��h��<ߊs@��.�h����<⧄�md�a��t_��pk!�>����xl/_rels/workbook.xml.rels �(����j�0����nӮ""��e��j}��l��m2㟾���ۅe���f���2���k�&�wp%�&��w ) array ( [0] => ޚ���[=� ) array ( [0] => &$���w�4�k��h"�xr��㣔d�����nҨ9��ɨ�aw(7ey/���o�� ) array ( [0] =>...

rust - What is the idiomatic lifetime for the "next" pointer in a linked list? -

i'm trying make simple simple linked list type class have pointer next node, running issues. proper way this? what have this: trait base { fn connect<'a, 'b>(&'a self, next: &'b base); } struct mystruct<'b> { next: option<&'b base>, // should swapped out reference base next node } impl<a', b'> base mystruct<'b> { pub fn new() -> mystruct<'b'> { mystruct { next: none, } } pub fn connect<'a, 'b>(&'a self, layer: &'b base) { self.next = some(layer); } } the way picture lifetime struct/node connected should should same initial node (i.e. when deallocate list should entirely) should have 1 lifetime. however, believe causes issues when there self pointer in connect function. you i have pointer next node your code shows reference, not pointer, take mean reference. say when deallocate list sh...

javascript - Node.js Nock simulate request timeout and subsequent success -

i'm trying simulate service request timeouts test node requestretry module, allows specify request max # of attempted retries , retry delay. in order test this, need use nock simulate timeout first x number of requests, respond same request. know there 'socketdelay()' method delay connection, how specify successful response after first delayed response? i have this, simulates timeout on first request //delays first request's response 1500 nock(urlhost) .post('/' + uripath) .socketdelay(1500) .reply(200, 'response body'); but how can make respond faster after simulate service recovering? i'm looking along these lines //delays first 2 request's responses 1500 nock(urlhost) .post('/' + requestidentifier.ttoroutinginfo.uripath) .socketdelay(1500) .reply(200, 'response body') .times(2) //delays third request 300 .then .socketdelay(300) .reply(200, 'response body'); ...

php - How to calculate Due Fees? -

i want calculate due fees, w.r.t current month. session of schools starts apr, , fees starts apr. if student not pay fees in apr, may, jun, , paying fees in aug. due fees must apr + may + jun. but i`m confused how due fees based on current month. my code: $current_month = date('m'); $final = 0; for($i='apr'; $i<$current_month; $i++) { $query_run = mysqli_query($conn,"select amount fees_on_class class = '$class'"); while ($num = mysqli_fetch_assoc ($query_run)) { $temp += $num['amount']; } $final = $final + $temp; } mysqli_query($conn,"insert dues(registration_number, due_fees)values('$registration_number','$final')"); code not working , giving 0 (0). thanks. alphabetic value in loop using not work want. for($i='apr'; $i<$current_month; $i++) { } please make month loop numeric. for($i='4'; $i<$current_month; $i++) { } i have not checked whole code, first e...

javascript - Detect object completely inside another object -

good day everyone, i wondering if there way detect if fabric object inside object? i looking @ object.intersectswithobject(object2) in documentation unfortunately, object inside object2, function doesn't give true anymore false. has else had problem? not know @ how this. have searched function in fabric.js. can help? intersectswithobject: function(other) { // extracts coords function getcoords(ocoords) { return { tl: new fabric.point(ocoords.tl.x, ocoords.tl.y), tr: new fabric.point(ocoords.tr.x, ocoords.tr.y), bl: new fabric.point(ocoords.bl.x, ocoords.bl.y), br: new fabric.point(ocoords.br.x, ocoords.br.y) }; } var thiscoords = getcoords(this.ocoords), othercoords = getcoords(other.ocoords), intersection = fabric.intersection.intersectpolygonpolygon( [thiscoords.tl, thiscoords.tr, thiscoords.br, thiscoords.bl], [othercoords.tl, othercoords.tr, othercoords.br, othercoords.bl] ); return in...

sql - Creating new table vs adding new field -

i having following data : fabric cost time | no fabric|bangloresilk|chanderi|.... <- fabric types -------------------------------------------- 01/15 | 40 | 25 |... 02/15 | 45 | 30 |... ..... | ... | ... |... dyeing cost time | no fabric|bangloresilk|chanderi|.... <- fabric types -------------------------------------------- 01/15 | 40 | 25 |... 02/15 | 45 | 30 |... ..... | ... | ... |... and here list of fabric types same both data. add data created following tables : fabric_type id int fabric_type_name varchar and have 2 approaches . approach 1 : fabric_cost id int fabric_type_id int (foreign key fabric_type) cost int deying_cost id int fabric_type_id int (foreign key fabric_type) cost int approach 2 : fabric_overall_cost id ...

symfony - Symfony2 form.error field not working -

i got problem. created form class , set asserts entitiy. but want render errors. got form_erros global erros, not fields. here code: controller public function addaction(request $request){ $news = new news(); $form = $this->createform(new newstype(),$news); $form->handlerequest($request); if ($form->isvalid()) { echo "yepp"; } return array( 'form' => $form->createview() ); } formclass $builder ->add('unpublic','checkbox',array( 'required' => false)) ->add('unactive','checkbox',array( 'required' => false)) ->add('untitle','text',array( 'required' => true)) view <div class="form-group"> {{ form_label(form.untitle,'titel*',{ 'label_attr': {'class': 'col-sm-2 control-label'}}) }} <strong...

iterating over a deque in two directions efficiently in Python -

i have deque, let's call deq . need iterate on both ends, , not modifying @ during these iterations. naturally, don't want create another deque. i've considered reversed , don't know if creates copies. if, example, write: reversed_deq = reversed(deq) will reference exact same memory locations, iterate on in reverse, without using more memory/time? that seems logical way go double-ended queue, want make sure i'm not missing anything. i can't find code deque (usually have "python equivalent" of these things, couldn't find it), , reason - no matter run - timeit gives me between 15 , 16 ns (for try time, not this) from c source reversed([deque]) returns reverse iterator, no copies or memory allocation. [deque].reverse() reverse in place.

Can SonarQube project administrators delete a project via the API? -

i'm using sonarqube 4.5.4. sonarqube's api documentation says post api/projects/destroy method requires administer system permission. however, users having administer project role can delete projects via web interface selecting deletion option in project configuration menu. why can't "project administrators" use api delete projects administer? or there way? i've tried , got error: $ curl -u user:password -x post "https://sonar.cpqd.com.br/api/projects/destroy?id=123456789" {"err_code":401,"err_msg":"unauthorized"}% the link documentation provide points http://nemo.sonarqube.org/ running sonarqube 5.1, not version using. fortunately, there no change regarding permissions checks on ws /api/projects/destroy between 4.5 , 5.1 , request not implemented: administer system permission required, project administer permission not enough. in 5.2, ws replaced ws /api/project/delete requires 'admini...

php - Randomly executing a branch of code one thirds of the time -

i have question. have following code : protected function definir( $ticketinfos ) { if($ticketinfos->ainfosticket["probabilitegain"]>0) { $ticketinfos->setgainrecup( $this->getgain() ); } else { $ticketinfos->setgainrecup( 0.0 ); } } probabilitegain constant witch equal 100. want make winning match 1/3. 2 times want : $ticketinfos->setgainrecup( $this->getgain() ) , 1 time : $ticketinfos->setgainrecup( 0.0 ); best solution ? thx in advance i approach using php rand() function. something this: protected function definir( $ticketinfos ) { $randomnumber = rand(1, 3); if($randomnumber < 3) { $ticketinfos->setgainrecup( $this->getgain() ); } else { $ticketinfos->setgainrecup( 0.0 ); } } if $randomnumber 1 or 2, execute $this->getgain(); if $randomnumber 3, execute other function. you can find more information php rand function her...

Implementing time delay function in C -

i want implement delay function using null loops. amount of time needed complete loop once compiler , machine dependant. want program determine time on own , delay program specified amount of time. can give me idea how this? n. b. there function named delay() suspends system specified milliseconds. possible suspend system without using function? first of all, should never sit in loop doing nothing. not waste energy (as keeps cpu 100% busy counting loop counter) -- in multitasking system decreases whole system performance, because process getting time slices time appears doing something. next point ... don't know of delay() function. not standard c. in fact, until c11, there no standard @ things this. posix rescue, there usleep(3) (deprecated) , nanosleep(2) . if you're on posix-compliant system, you'll fine those. block (means, scheduler of os knows have nothing , schedules them after end of call), don't waste cpu power. if you're on windows...

Why do i get a ClassNotFoundException on running a simple scala program on IntelliJ 14+? -

Image
i'm unable figure out wrong program? i'm using older verison of scala (2.7) because compatible libraries i'm using here simple program i'm attempting run. the program runs fine using scalac , scala commands. however on intellij 14+ -> when create new project -> select compiler (scala 2.7) , try run above program error below object simpleclass { def main(args: array[string]) { println("this simple class") } } error output. why intellij throw classnotfoundexception ? i've saved program simpleclass.scala /usr/lib/jvm/java-7-openjdk-i386/bin/java -didea.launcher.port=7532 -didea.launcher.bin.path=/home/tejesh/downloads/idea-ic-141.1532.4/bin -dfile.encoding=utf-8 -classpath /usr/lib/jvm/java-7-openjdk-i386/jre/lib/javazic.jar:/usr/lib/jvm/java-7-openjdk-i386/jre/lib/management-agent.jar:/usr/lib/jvm/java-7-openjdk-i386/jre/lib/resources.jar:/usr/lib/jvm/java-7-openjdk-i386/jre/lib/rhino.jar:/usr/lib/jvm/java-7-openjdk-i386...

performance - Why is Python 3 is considerably slower than Python 2? -

this question has answer here: is there reason python 3 enumerates slower python 2? 2 answers i've been trying understand why python 3 taking time compared python 2 in situations, below few cases i've verified python 3.4 python 2.7. note: i've gone through of questions why there no xrange function in python3? , loop in python3 slower python2 , same code slower in python3 compared python2 , feel didn't actual reason behind issue. i've tried piece of code show how making difference: max_num = 3*10**7 # make compatible py3.4. try: xrange except: xrange = range def foo(): = max_num while i> 0: -= 1 def foo_for(): in xrange(max_num): pass when i've tried running programme py3.4 , py2.7 i've got below results. note: these stats came through 64 bit machine 2.6ghz processor , calculated ...

node.js - how to manage nodejs instances selectively -

we want have ability run demo server independently testing env. these purposes use 2 nodejs instances run different options(ports). i trying implement 2 different ci jobs managing these 2 servers independently see no way stop nodejs instances selectively. is there way make named instances stop/start/restart them separately? or way use forever watch file changes(want avoid because of time limit)? you can use forever.js name each application run forever --uid app start app.js forever --uid app1 start app.js then can restart individual apps forever restart app1

angularjs - Drop-down does not show design properly -

drop-down design not showing using bootstrap angular js. in header following js & css included: <script src="template_assets/libraries/jquery-2.1.3.min.js"></script> <script src="template_assets/libraries/jquery-ui.min.js"></script> <script src="template_assets/libraries/angular.min.js"></script> <script src="template_assets/libraries/angular-route.min.js"></script> <script src="template_assets/libraries/angular-resource.min.js"></script> <script src="template_assets/libraries/angular-sanitize.min.js"></script> <script src="template_assets/libraries/angular-animate.min.js"></script> <script src="template_assets/libraries/sortable.js"></script> and @ footer following js & css included: ...

testing - My concateneate in groovy dont work -

i have question, how can concatenate way file import java.util.properties def groovyutils = new com.eviware.soapui.support.groovyutils(context) def path = groovyutils.projectpath properties properties = new properties(); file propertiesfile = (path + jsonconfig.properties); log.info propertiesfile propertiesfile.withinputstream { stream -> properties.load(stream); } iterator = properties.keyset().iterator(); while(iterator.hasnext()) { key = iterator.next(); value = properties[key]; testrunner.testcase.testsuite.project.setpropertyvalue(key, value); } the error: org.codehaus.groovy.runtime.typehandling.groovycastexception: cannot cast object 'e:\jsonconfig.properties' class 'java.lang.string' class 'java.io.file' error @ line: 9 path + jsonconfig.properties appears string . might want call file constructor. replace: file propertiesfile = (path + jsonconfig.properties); with: file propertiesfile = new fi...

java - NoSuchMethodError when using spf4j -

i'm trying use spf4j https://github.com/zolyfarkas/spf4j i've tagged method with: @jmxexport @performancemonitor(warnthresholdmillis=1, errorthresholdmillis=100, recordersource = recordersourceinstance.rs5m.class) and exception on it: exception in thread "awt-eventqueue-0" java.lang.nosuchmethoderror: org.spf4j.perf.aspects.performancemonitoraspect.aspectof()lorg/spf4j/perf/aspects/performancemonitoraspect; i'm starting application eclipse jdk 1.7.0_55 -javaagent:depend/aspectj/1.8.6/lib/aspectjweaver-1.8.6.jar , aop-ajc.xml in src/meta-inf folder <?xml version="1.0" encoding="utf-8"?> <aspectj> <aspects> <aspect name="org.spf4j.perf.aspects.performancemonitoraspect" /> </aspects> <weaver options="-verbose"> <include within="com.*..*" /> </weaver> </aspectj> also jmx beans not visible in visualvm @ point. doing wrong? also logged i...

Convert object string to object(class) in C# using Winforms -

here going tell working on , after there comes question. want tell guys working on.. guys can understand problem better. thanks in advance, i working on project. app grocery calculator. got class called artikel. class base class of other derived classes (vegetables, drinks, warmfood.. etc). i got combobox filled data database. want add price of each product "total cost cart". base class looks this: class artikel { // properties private string naam; private double prijs; private string winkel; // properties public string naam { { return naam; } set { naam = value; } } public double prijs { { return prijs; } set { prijs = value; } } public string winkel { { return winkel; } set { winkel = value; } } // constructor public artikel(string naam, double prijs, string winkel) { this.naam = naam; this.prijs = prijs; this.winkel = w...

python 2.7 - How could i deselect checkbox? -

for pincode tried this: checkbox = webdriver.find_elements_by_xpath('//*[@name="add_in_fld"].onclick()') if checkbox.isselected(): checkbox.click() sample link from selenium import webdriver driver = webdriver.firefox() driver.get("http://www.findlatitudeandlongitude.com/batch-geocode/#.vbshl7oqphz") cb = driver.find_element_by_css_selector(".cb_short input") assert cb.is_selected() cb.click() assert not cb.is_selected()

The dll.config isn't created -

vs 2013 / c#. hi guys. have problem *.dll.config file. choose 1 of configuration solutions in vs , build project. project can't builded becase got error: "error 32 not copy file "obj\myconfig\myproject.dll.config" because not found." i searching in explorer folders doesn't exist. question why dll.config not created? i have set on myconfig build action content , copy output directory copy always . add: full error: c:\program files (x86)\msbuild\12.0\bin\microsoft.common.currentversion.targets(4003,5): error msb3030: not copy file "obj\myconfig\myproject.dll.config" because not found. i have no idea can do. try change sth 2h , nothing ;/ add2: if find dll.config file , copy location of build - when rebuild config file isn't replaced (the date , time arne't changed). looks project doesn't touch file @ all. why happens?

c# - Build succeeded but publish failed in VS 2013 for WCF -

Image
this question asked many times. said solutions did not help. tried publish wcf project. build failed on publish. following message in output window. i tried following things checked vs2013 having administrator rights. folders have permission modify. changed "msbuild project build output verbosity" option "detailed" above things did not give me solution. attached solution explorer reference. how can resolve problem? i've ran issue before, latest while upgrading wcf project visual studio 2013 2015. solution (with multiple projects) build , run fine within vs fail when publishing wcf service. no error in publish step message: ========== publish: 0 succeeded, 1 failed, 0 skipped ========== the solution has been in project properties. in latest case, build > platform target setup x64 default in vs2015, changed "any cpu" , resolved issue. hope helps.

How to continue on keypress OR do something else by entering 1 in batch -

i'm trying make simple text-based game , trying design fighting mechanics. right now, once enter fight have either type "1" attack or "2" enter fightmenu. want change can press space regular attack, still able type "1" open fightmenu. here code far if you're interested: :fighting cls set /a yourhit=%random% %%dmg% set /a theirhit=%random% %%theirdmg% set /a armor = %armor% - %theirhit% if %theirhit% gtr %armor% set /a armor = 0 & set /a hp = %hp% - %theirhit% if %yourhit% geq %theirhp% goto winner if %theirhit% gtr %hp% goto loser set /a theirhp = %theirhp% - %yourhit% echo. call :fightheadsup echo - hit them %yourhit%! echo. echo - hit %theirhit%! echo. echo 1.continue attacking echo 2.return fight menu echo. set /p input12=enter: if %input12% equ 1 goto fighting if %input12% equ 2 goto fightmenu goto fightmenu enclose compared values in pair of " double quotes " follows (get used always value empty or contain bl...

ggplot2 - How to reorder in R -

i using code: z <- data.frame(ins = factor(c("d", "c", "a", "e", "f", "b")), percent = c(2.48, 4.55, 15.16, 16.47, 21.17, 40.17)) ggplot(data=z, aes(x=ins, y=percent)) + geom_bar(stat="identity")+ geom_bar(colour="na", fill="slateblue3", stat="identity") + guides(fill=false) + coord_flip() + xlab("year") + ylab ("procent (%)") + ggtitle("people using computers - 2014 -") + theme(axis.text.x = element_text(angle = 90, hjust = 1, colour='black'))+ theme(panel.background = element_rect(fill = 'white', colour = 'white')) when run plot, r reorders values as: a, b, c, d, e, f , not order gave: d, c, a, e, f, b, corresponds increasing order: 2.48 40.17. can keep order want? 10x since question "how reorder", think answer is z$ins <- reorder( z$ins, z$perce...

Comments Listview in Android -

i have activity contains different items, 1 of item listview. created custom list adapter , sending json array. data list arrives server. the list purpose make comments list. allowed user insert comment , show in listview. when have items in list works, , items shown. problem when listview empty , user post comment. see that data changed don't see item, means list not refreshed.. so tried add listview empty view doesn't work. here updated code: ( update ) if (!s.isempty() && !s.equals("{}")) { try { if (commentslistadapter == null) { commentslist.setemptyview(findviewbyid(r.id.dummy)); commentslistadapter = new commentslistadapter(postview.this); } jsonobject resobj = new jsonobject(s); list.add(resobj); commentslistadapter.setdataset(list); cmnttxt.settext(""); input...

ios - Multidimensional Array [String , UIImage] (Swift) -

i'm new ios programming. i'm trying create array store items have parsed. parse items string(text), , image(pffile). im trying figure out how create array. would declared as: var completearray: [string:[nsdata]] = [] //////////////////////// okay ive updated struct struct brandcollection { var brandtext:[string] = [string]() var brandimage:[uiimage?] = [uiimage]() } you should create struct hold each of entries , create array of these structs - struct branditem { var brandtext:string var brandimage:uiimage } var completearray: [branditem] = []

watchkit - Force Apple Watch Display stay on programmatically -

as notice, apple watch turn display off (meaning call method wkinterfacecontroller.diddeactivate). however, don't want this. there anyway force display stay on within app's life cycle? mine watch os 2 beta 4 check out answer on post: keep apple watch awake no. can tell users use setting inside applewatch app "show session app" instead of "show clock face" (i´m sorry translations, watch on swedish. correct if wrong please.) this activate app whenever wrist raised again.

ruby on rails - How to create a set of Questions and Subquestions with order? -

i have database of questions , subquestions (which belong 1 question). want subquestions ordered inside each question. also, want bunch of main questions ordered among themselves. 1 way add order column in question , subquestion table , fill in manually. but, since db can dynamic, not viable option. so, want is 1. root q1 a. sub1_q1 b. sub1_q2 2. root q2 a. sub2_q1 b. sub2_q2 c. sub2_q3 i have seen gems ancestry , acts_as_tree . while possible create parent child relationship there, there no scope order bunch of siblings. lets assume have question model has many subquestions (subquestion model). , need order questions created_at desc , subquestions created_at asc(in each question). so models like: class question < activerecord::base has_many :subquestions, -> { order("created_at asc") } end class subquestion < activerecord::base belongs_to :question end now do: @questions = question.order("created_at desc...

cqrs - NEventStore get projection which lists all aggregates of a given type -

i using irepository interface neventstore.domain project . create projection list of aggregates of given aggregate type. how go doing this: so if have reportbatch aggregate, looking list report batches have saved. how can accomplish this? barking wrong tree projections? should saving reportbatchlist aggregate when created events reportbatch . should saving reportbatchlist aggregate when created events reportbatch. no. should have projection writes read model each time receives created event. query read model list. read model database (sql or nosql), in-memory construct, text file, etc. note not "a list of aggregates of given aggregate type". it's read model, , while read model may have knowledge of data generated aggregate, not directly represent aggregate. event sourcing advanced form of command query responsibility segregation (cqrs), in writes (aggregates et al) , reads (projections , read models) conceptually separate.

Converting normal sql query into hibernate criteria query -

i need convert sql query hibernate criteria,please guys. select name, count(*) app device group name order app desc limit 3 try code: select device.name, count(device) device device group device.name order count(device) desc this assumes have entity class called device field name along getter method getname() . may have change query depending on actual code (which never showed us). the limit clause had not applicable hql. instead, should doing query.setmaxresults() .

javascript - Cant not get two if else statements to work? checking strings and numbers -

i run these 2 if else statement can not them work ? please help. if input sting fail go beginning , ask again. function table(){ var num = prompt("please enter number"); if (num <= 0 && typeof num != 'string') { alert("invalid number or zero") ; table(); } else { alert("ok") ; } } table(); if not correct text beginning , ask again. function text(){ var txt = prompt("please enter rock or scissors or paper"); if (txt != "rock" || "scissors" || "paper") { alert("failed") ; table(); } else { alert("ok") ; } } text(); thank you. the typeof result prompt always either "string" (the user clicked ok or pressed enter) or "object" (the user clicked cancel or pressed esc), because typeof null "object" , prompt returns typed, or null on cancel. tha...

android - From Html To Native -

i write example html native,but can't jump. here code. h5activity(html) webview = (webview) findviewbyid(r.id.webview); webview.loadurl("file:///android_asset/hello.html"); webview.addjavascriptinterface(new object() { @javascriptinterface public void jump() { intent intent = new intent(h5activity.this, nativebactivity.class); startactivity(intent); } }, "egos"); nativebactivity(native) setcontentview(r.layout.activity_nativea); button = (button) findviewbyid(r.id.text); button.settext("finish"); my hello.html <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/xhtml; charset=utf-8" /> <script type="text/javascript"> ...

c# - Remove Auto-generated Code from SonarLint Analysis -

background i running visual studio 2015 enterprise (rtm) , have enabled sonarlint extension code analysis of multi-project asp.net 4.5 mvc solution. problem sonarlint analysis seems ignoring project setting code analysis "suppress results generated code (managed only)" that is, i'm getting lot of sonar errors reported couple of *.designer.cs files generated .aspx pages. (most of project mvc, it's worth.) don't care these errors, , don't think have decent path fixing them... more details i have sonarqube integrated our tfs 2013 environment, , correctly ignoring these issues on tfs server analysis. problem showing in visual studio, using roslyn analysis. any ideas how can set equivalent of .ignore file or otherwise fix this? there no built-in way of ignoring files in roslyn @ moment, can't it. each analyzer needs decide if analyzed file needs checked or not. sonarlint, i've created issue on github: https://github.com/sonarso...

php - Cakephp 3 - How to retrieve current logged user in a 'Table' class during validation process? -

i'am using cakephp3 website , have inject custom validation logic based on current user id when i'am creating or modifying entity. the basic case "is user allow change field new value" ? if' not, want raise validation error (or unauthorized exception). in cakephp, i'am understanding, of application , businness rules must placed on models or 'modelstable'of orm. but, in classes, authcomponent or current session not available. i don't want call manually method on entity controller each time need check. use validator, : $validator->add('protected_data', 'valid', [ 'rule' => 'canchangeprotecteddata', 'message' => __('you're not able change data !'), 'provider' => 'table', ]); method on modeltable : public function canchangeprotecteddata($value, array $context) { \cake\log\log::debug("canchangeprotecteddata...

asp.net web api - Get bearer token from OWIN Cookie and put it on API Requests -

here scenario: have mvc4.5/webapi2 application uses openidconnectauthentication based on thinktecture.identityserver provider. far can authenticate against mvc. want authenticate webapi using bearer token. here configuration app.usewebapi(configureapi()); app.usecookieauthentication(new cookieauthenticationoptions() { authenticationtype = cookieauthenticationdefaults.authenticationtype, cookiesecure = cookiesecureoption.always, authenticationmode = microsoft.owin.security.authenticationmode.active, cookiehttponly = true }); app.useidentityserverbearertokenauthentication(new identityserverbearertokenauthenticationoptions() { enablevalidationresultcache = false, authority = webconfigurationmanager.appsettings["authority"], authenticationmode = microsoft.owin.security.authenticationmode.passive }); app.useopenidconnectauthentication(new openidconnectauthenticationoptions() {...

java - detect duplicate character in string -

i doing exercises in cracking coding interview book , trying determine if there duplicate character in string. using arraylist data structure. method of return type boolean, returns true if there duplicate , returns false if there no duplicate character. added third return statement program compile returns false. import java.util.*; public class questiononecrackingcode { public static void main(string[] args) { string s = "abcdefga"; arraylist<string> c = new arraylist<string>(); c.add(s); system.out.print(check(c)); } public static boolean check(arraylist<string> g) { (int = 0; < g.size(); i++) { (int j = + 1; j < g.size(); j++) { if (g.get(i) == g.get(j)) { return true; } else { return false; } } } return false; } } you're not separating string ch...

javascript - AngularJs/ngCordova Custom Build in ionic injection module error -

today went brink of insanity. my goal include plugin ngcordova (in example: cordova-plugin-device). , little work. my starting point project ionic tabs, nothing more. following advice received first go website ngcordova, , build custom-ng cordova.js containing need (by device). i integrates project location: /www/lib/ngcordova/dist/ng-cordova.js. i change index.html follows: ... <!-- ionic/angularjs js --> <script src="lib/ionic/js/ionic.bundle.js"></script> <script src="lib/ngcordova/dist/ng-cordova.js"></script> <!-- cordova script (this 404 during development) --> <script src="cordova.js"></script> <!-- app's js --> <script src="js/app.js"></script>... i made dependency injection in application module this: angular.module('starter', ['ionic', 'starter.controllers', 'starter.services', 'ngcordova']) and finall...

Understanding how to read nested lists in R in order to access the data -

here set of list of lists of lists: please see development code read.genbank function here #must connected internet work library(ape) library(plyr) gi_sample<-c(336087836, 336087835, 336087834) #use read.genbank function apply because have more max @ 1 time (400) my_output <- apply(gi_sample, 1, function(x) read.genbank(x)) str(my_output) list of 3 $ :list of 1 ..$ 336087836:class 'dnabin' raw [1:606] 00 00 00 00 ... ..- attr(*, "class")= chr "dnabin" ..- attr(*, "species")= chr "flavobacterium_johnsoniae" ..- attr(*, "references")=list of 1 .. ..$ 336087836:list of 2 .. .. ..$ :list of 4 .. .. .. ..$ pubmedid: chr(0) .. .. .. ..$ authors : chr "rusznyak,a., akob,d.m., nietzsche,s., eusterhues,k., totsche,k.u., neu,t.r., frosch,t., popp,j., keiner,r., geletneky,j., katzs"| __truncated__ .. .. .. ..$ title : chr "calcite mineralization karstic cave bacteria" .. .. .. ..$ j...