Posts

Showing posts from August, 2011

algorithm - Generating numbers which follow Normal Distribution in Java -

i want generate numbers(randomly) such numbers follow normal distribution of given mean , variance. how can achieve this? it better if can give in context of java. 1 might in these answers help: not precise. generate random numbers following normal distribution in c/c++ shamelessly googled , taken from: http://www.javapractices.com/topic/topicaction.do?id=62 the 'magic' happend inside random.nextgaussian() import java.util.random; /** generate pseudo-random floating point values, approximately gaussian (normal) distribution. many physical measurements have approximately gaussian distribution; provides way of simulating such values. */ public final class randomgaussian { public static void main(string... aargs){ randomgaussian gaussian = new randomgaussian(); double mean = 100.0f; double variance = 5.0f; (int idx = 1; idx <= 10; ++idx){ log("generated : " + gaussian.getgaussian(mean, variance)); } } pri

boolean - Python True/False for the following code -

how evaluated python code: not not true or false , not true as of myself, have 2 guesses: method 1: step  code 1        not not true or false , not true 2        not false or false , false 3        true or false , false 4        true , false 5        false method 2: step  code 1        not not true or false , not true 2        not false or false , false 3        true or false 4        true from table of python's operators precedence : or has lower precedence than and in turn has lower precedence than not according that: not not true or false , not true is equivalent to ((not (not true)) or (false , (not true))) edit: noticed martijn pieters in comment below, worth mentionning python has short-circuits operators. means and , or guaranteed evaluated left-to-right and that: if left-term of or true right term never evaluated (as result of true or whatever true in boolean logic)

java - Parsing a complex JSON file -

i need parse json file , put data html table. using gwt application, data shall read file on server side , passed client on page load. the format jsonobjects in file follows: { "object 1": [ { "value1": [ "subkey1", "subvalue2" ], "value2": "val", "value3": { "key1": val1, "key2": val2, "key3": val3} }, { "value2": [ "subkey1", "subvalue2" ], "value2": "val", "value3": { "key1": val1, "key2": val2, "key3": val3} }, .... .... ], "object 2": [ { "value1": [ "subkey1", "subvalue2" ], "value2": "val", "value3": { "key1": val1, "key2": val2, "key3": val3} }, { "value2": [ "subkey1", "subvalue2" ], "value2": "val", "value3": { "key1

java - my app don't receive a parse notifications -

i can see push notification in table on parse.com. devices cannot receive notifications. permissions manifest <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.access_network_state"/> <uses-permission android:name="android.permission.wake_lock" /> <uses-permission android:name="android.permission.vibrate" /> <uses-permission android:name="android.permission.receive_boot_completed" /> <uses-permission android:name="android.permission.get_accounts" /> <uses-permission android:name="com.google.android.c2dm.permission.receive" /> <permission android:protectionlevel="signature" android:name="com.james.fappsilya.fappsapp.permission.c2d_message" /> <uses-permission android:name="com.james.fappsilya.fappsapp.permission.c2d_message" /> receivers , services <servic

php - checking array point with high score -

my intention check array , setting 1 of point high score , , if in array other 3 same score high score , echo there 2 same point else echo not same. checking point having same point. my code $dpoint =70; $ipoint =70; $hpoint =60; $apoint =60; $score = $dpoint; high score $xdata = array( 'd1' => $dpoint, 'i1' => $ipoint, 'h1' => $hpoint, 'a1' => $apoint ); foreach($xdata $key => $value){ if($score == $value){ echo "there 2 same point"; }else{ echo "not same"; } } but getting werid result , part missed ? fix me if understand well... <?php $dpoint =70; $ipoint =70; $hpoint =60; $apoint =60; $score = $dpoint; $xdata = array( 'd1' => $dpoint, 'i1' => $ipoint, 'h1' => $hpoint, 'a1

php - Multiple actions for checkbox list -

Image
i have list of multiple items having checkbox each row (like gmail list of emails). user selects checkboxes , press action button perform action on selected items ( delete example). list of selected items sent php file background processing. but solution performing multiple actions on selected checkboxes ( instance, in gmail, delete, mark spam, mark read/unread etc..). here have: use different "submit buttons" each actions. give same name different values. check backend for example, html <form action="backend.php" method="post" > <input type="submit" name="action" value="delete" /> <input type="submit" name="action" value="move" /> <input type="submit" name="action" value="copy" /> <input type="checkbox" name="selection[]" value="value 1" > <input type="

android - cordova Update files and reload updated index.html? -

i working in plugin update of html files. the default location cordova fetches files assests directory directory read only, cannot update files in directory. so moved assests directory files(/data/data/packagename/files) directory, whenever there update occurred able download zip bundle server , extract bundle using zip extractor , able show updated index.html updated bundle. the problem how can set start page location programmatically updated bundle when app starts again likewise ios "startpage()" method. i not want achieved updating config.xml or loadurl() in default cordovaapp.java. thanks

xml parsing - A tool to automatically change and save a copy of XML files -

i need tool capable of taking template xml file , replicating several times,each time different values in various fields. bonus points if tool has sort of api , can integrated c# applications. you're looking xslt processor. there several. since want integrate c#, you'd best served using msxml , xslcompiledtransform class: https://msdn.microsoft.com/en-us/library/system.xml.xsl.xslcompiledtransform(v=vs.110).aspx more documentation on xslt msdn: https://msdn.microsoft.com/en-us/library/14689742%28v=vs.110%29.aspx https://msdn.microsoft.com/en-us/library/ms256069%28v=vs.110%29.aspx there other processors available though, such saxon or xalan. these used 'stand alone version' (or write simple console application in .net take in xslt file , xml file(s) parameter , run transformation repeatedly). saxon home , personal use available here: http://saxon.sourceforge.net/ . commercial versions available. xalan can found here: https://xml.apache.org/xa

CakePHP how to use global order with union -

hi combined 2 tables using union order function not work. did is $comment->union($a_commnets); $comment->order(['created' => 'desc']); but seems order function not work because result data shows $comment data locate @ beginning of array , $a_comments locate @ end of $comment data. please help thanks in advance

javascript - Use inputs multiple times -

i have 3 input fields type:number called separately when pushed on button. instance, click on button1 dialog1 appears , on.. want in code behind ( jquery ) value number input , place in <div class="total-price"></div> <div id="dialog1"> <h2>product 1</h2> <input type="number" class="col-md-4 amount" id="amount" min="0" max="10" step="1" value="0"> <div class="total-price">total:</div> </div> <div id="dialog2"> <h2>product 1</h2> <input type="number" class="col-md-4 amount" id="amount" min="0" max="10" step="1" value="0"> <div class="total-price">total:</div> </div> <div id="dialog3"> <h2>product 1</h2> <input type="number&quo

c# - AJAX request for a loaded partial view -MVC -

the concept behind question whenever value shown in id textbox, value id pulls information corresponding id in partial view right of page via ajax , javascript. i have partial view showing on right there error alert chrome cant populate partial view, shows empty partial view (textbox etc). i've tried researching problem cant find relating html.partial() instead has tutorials on views in page don't want. ideas on going wrong? below code regarding issue. im still getting grips ajax apologies silly mistakes. jobscanner.cshtml <div id="qr"> <div id="first"> <p>hold qr code in front of webcam.</p> <video id="camsource" autoplay="" width="320" height="240">webcam has failed, please try another</video> <canvas id="qr-canvas" width="320" height="240" style="display:none"></canvas> @* <div class=

java - Check for Broken Pipe only when IOException is thrown -

when writing outputstream throw ioexception exception if remote machine down, or has disconnected. now, want call specific method when (and only) pipe broken. problem ioexception not have code or errno property check error. , way able achieve by try { stream.write(message.getbytes("utf8")); stream.flush(); } catch (ioexception e) { if (e.getmessage().equals("sendto failed: epipe (broken pipe)")) { // perform specific action } else { e.printstacktrace(); } } obviously not perfect way achieve such thing. suggestion efficient solution? as mentioned here in java, there no brokenpipeexception specifically. type of error found wrapped in different exception, such socketexception or ioexception . so can achieve same using string#contains() method if(e.getmessage().contains("broken pipe")){ // whatever want }

angularjs - Angular Web API $http post exclude list -

i have web api (2) project has departments , employees. employee has department, , department has list of employees. now in frontend, when creating or editing employee, user must select department. when posting api, department contains list of employees (which causes invalid modelstate), how can prevent this? this relevant setup: models: public class employee : ientity, icreatedon, imodifiedon, imappable { [key] public virtual int id { get; set; } public virtual department department { get; set; } // .. other properties } public class department : ientity, imappable { [key] public virtual int id { get; set; } public virtual icollection<employee> employees { get; set; } // .. other properties } web api controller: public class employeescontroller : apicontroller { private readonly iemployeeservice _employeeservice; public employeescontroller(iemployeeservice employeeservice) { this._employeeservice = employe

ios - Launching web url with Session -

i developing html web page. creating session id in that. i want use same session id opening web site through ios app well. nsstring *urlstring = @"http://www.myserver.com:8080/test/testpage"; nsurl *url = [nsurl urlwithstring:urlstring]; nsurlrequest *urlrequest = [nsurlrequest requestwithurl:url]; [webview loadrequest:urlrequest]; is possible launch web url using session id appended in ios? if not understanding in wrong way, want add parameters request, in case sessionid. in case should this: nsurl *url = [nsurl urlwithstring: @"http://www.myserver.com:8080/test/testpage"]; nsstring *body = [nsstring stringwithformat: @"sessionid=%@", @"val1"]; nsmutableurlrequest *request = [[nsmutableurlrequest alloc]initwithurl: url]; [request sethttpmethod: @"post"]; [request sethttpbody: [body datausingencoding: nsutf8stringencoding]]; [webview loadrequest: request]; on other way around, can use example

wpf - windowsformhost cant load a usercontrol from another dll -

so have dll project contains many useful classes , controls me (lets call foo.dll). i'm making wpf app. need use of them in app. created usercontrol windows forms , referenced usercontrolforme foo.dll. it's shown, good. want insert usercontrol wpf form. looks this: <usercontrol x:class="flatrectangular_profile.usercontrol1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:ignorable="d" xmlns:uc="clr-namespace:flatrectangular_profile.uc" height="2093" width="717"> <grid name="grid"> <windowsformshost> <uc:windowsformsprofmanual ></uc:wi

javascript - How to make alerts fade out in Bootstrap 3? -

i'm using bootstrap alerts,i tried multiple ways make them fade out didn't work. code: <div class='col-sm-7 alert alert-success' id='alrt' role='alert'> <i class='fa fa-check fa-fw'></i> <b>etudiant ajouté avec succés</b> </div> the alert show automatically when opening page. you can add '.in' class, alert fade out. <div class="alert alert-info fade in"> <a class="close" data-dismiss="alert" href="#"></a> <p>message inside alert goes here</p> </div>

json - Check if payment was successful via PHP and/or JQuery?(PayPal API) -

i creating website in selling something. website works described: the customers choose product the customers clicks on link buy product redirect directly paypal. what want following, after payment successfull want write paypal-email adress of customer in database this: | id | paypal | approved | | 1 | j@d.com | yes | how can realize that? have have redirect customer "checkout page" afterwards , execute php-code there read data? can me out here? :) thanks! you looking instant payment notifications . instant payment notification (ipn) message service automatically notifies merchants of events related paypal transactions. merchants can use automate back-office , administrative functions, automatically fulfilling orders , providing customers order status. so, after every transaction, paypal send notification server listener file includes buyer,transaction information can use store in database. you can download sample php code here

JQuery add/remove class onClick -

open submenu on click, close on next click - that's achive. example this page (submenu under 'follow' link). opens submenu (adds class 'open'), not closing. stucked... :( my html: <ul id="toggle"><li> <a href="#">menu</a> <ul id="dropdown" class="dropdown-menu" role="menu"> <li><a href="#">2017</a></li> <li><a href="#">2012</a></li> <li><a href="#">2003</a></li> </ul> </li> <li><a href="#">contact</a></li> </ul> javascript: $(document).ready(function(){ $('#toggle li').on('click', function(){ $(this).removeclass('open').addclass('open'); }); }); http://jsfiddle.net/gallex/32pv6xz8/7/ you can use function toggleclass() this: $('#toggle li').on('click', funct

Caught exception:Internal Server Error Soap connection php -

i'm building function in php check if user , password match external database, can extract emailadres. have created soap wsdl me can check this. i can check if user exists, every time try send soapcall request email, error message caught exception:internal server error. i looked around error, , there somehow wrong array send parameter during request. array consist of login / password of user i'm checking. the weird thing is, if send array 1 parameter, don't recieve error, recieve empty string in return cause username , password don't match. i used same structure check if user exists, , not giving error. here code make connection: checkemail('hmichiels','xxxxxxx'); function checkemail($ploginstr,$ppasswordstr){ try{ $client = new soapclient('https://milliarium.gabo-mi.com/forms/generic/security/externalemailservice.asmx?wsdl', array('trace'=>1)); $params = array('ploginstr'=>$ploginstr, 'ppa

node.js - nclosure is not compatible with nodejs 0.12 -

the nclosure ,nodejs server-side google closure lib, not compatible nodejs 0.12 compatible nodejs 0.12 /node_modules/nclosure/lib/settingsloader.js:102 if (!path || !require('path').existssync(path)) return null; ^ typeerror: undefined not function @ nclosure.settingsloader.readargsfromjsonfile (/home/wj/work/transport/node_modules/nclosure/lib/settingsloader.js:102:33) @ nclosure.settingsloader.readsettingsobject (/node_modules/nclosure/lib/settingsloader.js:133:12) @ nclosure.base.loadbasescript_ (/node_modules/nclosure/lib/nclosurebase.js:199:53) @ new nclosure.base (/node_modules/nclosure/lib/nclosurebase.js:69:10) @ object.<anonymous> (/node_modules/nclosure/lib/nclosurebase.js:350:24) @ module._compile (module.js:460:26) @ object.module._extensions..js (module.js:478:10) @ module.load (module.js:355:32) @ function.module._load (module.js:310:12) @ module.require (module.js:365:17) t

php - String to DateTime conversion substracts 1 hour from initial time -

$initialtime = "31.03.2015 17:59"; $timestamp = (new intldateformatter('en_us', intldateformatter::short, intldateformatter::short, 'europe/moscow', intldateformatter::gregorian,'dd.mm.yyyy hh:mm'))->parse($initialtime); $dt = new datetime('@'.$timestamp.' utc'); $dt->settimezone(new datetimezone('europe/moscow')); var_dump($dt); so, $initialtime i'm getting $timestamp using intldateformatter::parse() (timezone 'europe/moscow' ) then parse $timestamp datetime , set timezone same, outputs: class datetime#1 (3) { public $date => string(19) "2015-03-31 16:59:00" public $timezone_type => int(3) public $timezone => string(13) "europe/moscow" } why initial time different output time 1 hour? looks wrond intldateformatter . timestamp datetime object differs parsed one. $initialdate = new datetime(); $initialdate->settimezone(new datetimezone(

android - on button click retrieve first 5 arraylist record and so on -

in application having listview.i want display first 5 records arraylist , when user click button load more 5 . aaraylist size 25. can first 5 records how retrieve next five.any help? final arraylist<hashmap<string,string>> newbrnd=new arraylist<hashmap<string,string>>(authorizedservicecenter); final arraylist<hashmap<string,string>> newbrnd_=new arraylist<hashmap<string,string>>(); if(authorizedservicecenter.size()>5) { for(int i=0;i<5;i++) { newbrnd_.add(newbrnd.get(i)); newbrnd.remove(i); log.e("details..", ""+newbrnd_.tostring()); log.e("remove", ""+newbrnd.get(i)); } } loadmore1.setonclicklistener(new onclicklistener() {

android - Cannot set spinner's selected item -

i want set selected item of spinner : adapter = new arrayadapter<rue>(this, android.r.layout.simple_spinner_item, db.getallrues()); // db.getallrues() has data adapter.setdropdownviewresource(android.r.layout.simple_spinner_dropdown_item); rueppale.setadapter(adapter); rueppale.setselection(adapter.getposition(db.getrue(p.getdec_decoup_terri_code())), true); // p.getdec_decoup_terri_code() has data code of db.getrue : public rue getrue(string decoup_terri_code) { rue r = new rue(); string[] columns = {"decoup_terri_code","decoup_terri_nom"}; cursor c = bd.query(t_decoup_territ, columns, "decoup_terri_code=?", new string[]{decoup_terri_code}, null, null, null); if (c != null && c.getcount() > 0 ) { c.movetofirst(); r.setdecoup_terri_code(c.getstring(0)); r.setdecoup_terri_nom(c.getstring(1)); } return r; } the problem @ runtime spinner not scroll automatically desired item ! bad

vb.net - How to get a list of excel cell 'name' references in vbnet? -

i'm trying copy data 1 excel workbook another. both workbooks have same cell 'name' reference, data contained in cell references identical hence why im trying list references (to later map values) . is there way can list cell references in workbook using vbnet? a loop perhaps?

azure - Best Practice: Calling separate Web-API Service from Single Page Application (SPA) -

hy all we discussing around architecture of following scenario: single page application (javascript driven html5 application asp.net webapi) separate rest service (webapi only) businesslogic, dal, database-connectivity security on azure ad (adal) what the way call rest-service single page application? at moment seeing possibilities: 1) calling rest-service directly client (browser) via cors: client (browser) -> rest-service ...like in example: https://github.com/azureadsamples/singlepageapp-webapi-angularjs-dotnet 2) calling webapi-service single page application, calls rest-service: client (browser) -> webapi spa -> rest-service for first variant, see security questions. save this? if rest-service in internal network , spa in dmz? for second variant, best practices here? because need our controllers: spa controller example: //get /api/models public iqueryable<model> get() { // create httpclient instance var resp = client.getasync(

java - Deleting multiple rows in Excel using Apache POI -

Image
i have excel sheet table of 75 rows. in 76th row have total function of each column =sum(a1:a75) , =sum(b1:b75) in 77th 92th rows have excel chart takes a1:a75 , b1:b75 values if use apache poi populate 75 rows, looks great. (i using xssfworkbook) if use apache poi populate 30 rows, delete rows 31 75. run problems. were delete these rows in excel total functions update, , excel chart updates use a1:a30 , b1:b30, , excel chart moves row 31. i mirror behaviour using apache poi this have tried xlstable.shiftrows(75,91,-45) (rows 75 91 apache row equivalents of excel rows 76 92 , include total function , chart) i have tried for (int = 75; > 30; i--) { row r = cellutil.getrow(i, xlstable); xlstable.removerow(r); } and for (int = 30; < 75; i) { row r = cellutil.getrow(i, xlstable); xlstable.removerow(r); } these cause sheet become messy #ref errors. imagine want may not possible poi, , need build entire sheet requisite amount of rows, , ad

xaml - Why MVVM/WPF ComboBox SelectedItem is null in multibinding to other control's Visibility? -

edit : bound same property (searchtype) combobox binds -> works fine. still know why first solution described here not work. i have public enum searchtype { networkobjects, customers } in viewmodel contructor: public searchviewmodel() { searchtype = panels.searchtype.networkobjects; in xaml: <usercontrol.resources> <xpui:convertsearchtypetovisibility x:key="searchtypetovisibilityconverter" /> </usercontrol.resources> <combobox name="searchtypecombobox" itemssource="{binding path=searchtypes}" selecteditem="{binding path=searchtype, mode=twoway}"> ... <datagrid.visibility> <multibinding converter="{staticresource searchtypetovisibilityconverter}"> <binding relativesource="{relativesource self}" path="name"/> <binding elementname="searchtypecombobox" path="selectedite

c# - Find items in list where word exist and ignor special chars -

i have list of myitems: my item { string name; int age; } list<myitem> list = new list<myitem>(); list.add(new test("name", 2)); list.add(new test("ŚćĄa", 4)); list.add(new test("may nĄmĄa bb" , 7)); list.add(new test("may maa cc" , 7)); for : var newlist = list.where(m => m.name.tolower().contains(texttosearch.tolower())).tolist(); i can ignore lower , upper case, how ignore special chars ĄĆŚ , when set texttosearch = "aa"; item two, 3 , four. but when set texttosearch = "Ąa"; i'd item 2 , four try this: list.where(m => cultureinfo.invariantculture.compareinfo.indexof( m.name, texttosearch, compareoptions.ignorenonspace | compareoptions.ignorecase) > -1 ).tolist(); two, 3 , 4 listed.

owin - Can IdentityServer return claims as part of authenticate request -

i implementing wsfed authentication using wsfederation plugin on top of thinktecture identityserver, got own userservice implemented authenticatelocalasync method below public async task<authenticateresult> authenticatelocalasync(string username, string password, signinmessage message) { var requestviewmodel = new signinrequestviewmodel { emailaddress = username, password = password }; var result = await signinapplicationservice.signinasync(requestviewmodel); var responseviewmodel = result.viewmodel; var claims = claimbuilder.getclaims(responseviewmodel); return new authenticateresult( responseviewmodel.customerid.tostring(), string.format("{0} {1}", responseviewmodel.firstname, responseviewmodel.lastname), claims);

javascript - jQuery dropdown not displaying first option -

so, have dropdown filter on client web page, dropdown should work matching class in hidden div , displaying relevant content. however, in ie9 (and on linked fiddle) can see doesn't work. the second option (iphone) doesn't appear display results. think issue down numbering of 'select.dropdown' function can't figure out is, exactly. snippet: $("select.dropdown").change(function(){ var filters = $.map($("select.dropdown").toarray(), function(e){ return $(e).val(); }); var filter; if(filters[0]=="all") { if(filters[1]=="all") filter = ""; else filter = "." + filters[1]; } else{ if(filters[1]=="all") filter = "." + filters[0]; else filter = "." + filters.join("."); } $("div#filtercontainer > div").hide(); $("div#filtercontainer").find("div" + filter).show(); console.log(filters);

Convert unicode list into python list -

this question has answer here: convert string representation of list list in python 8 answers s = u"['1', '2', '2', '1', '2']" print type(s) # <type 'unicode'> how can convert list here: s = [1,2,2,1,2] you use ast.literal_eval function. >>> import ast >>> s = u"['1', '2', '2', '1', '2']" >>> list(map(int, ast.literal_eval(s))) [1, 2, 2, 1, 2] or >>> [int(i) in ast.literal_eval(s)] [1, 2, 2, 1, 2]

node.js - heroku node js cleardb mysql fail : ER_ACCESS_DENIED_ERROR: Access denied for user -

today i'm pushing app on heroku, create database cleardb, configure using software (navicat premium) create tables. i start program, works on local side, , when try access database error : er_access_denied_error: access denied user 'xxxxxxxx'@'ip-xx-xx-xx-xxx.us-westxxxxxxxxxx' (using password: yes) i have read that's maybe port defined on navicat. this configuration : connection: { port : '3306', host : 'us-westxxxxxxxxxx', user : 'xxxxxxxx', password : 'xxxxxxxx', database : 'xxxxxxxx', charset :'utf8' } my configuration don't know error. thanks helping ! check endpoint data cleardb endpoint url looks dramatically different expect. the host piece after @. cleardb_database_url => mysql://[username]:[password]@[host]/[database name]?reconnect=true one thing notice specify port (i don't , works) , specify port

c++ - Array Equivalent of Bare-String -

i can without issue: const char* foo = "this bare-string"; what want able same thing array: const int* bar = {1, 2, 3}; obviously code doesn't compile, there kind of array equivalent bare-string? you can't this: const int* bar = {1, 2, 3}; but can this: const int bar[] = {1, 2, 3}; reason char* in c (or c++) have added functionality, besides working char pointer, works "c string", added initialization method (special char*): const char* foo = "this bare-string"; best.

date - Displaying the timezone properly in XSLT -

was using below tag displaying timezone working fine until when daylight saving has happened , our server in uk displaying time 01/04/2015 03:43:00 pm + 0100 , have timezone displayed, please advice. tag used previously: date:format-date(date:date-time(), 'dd/mm/yyyy hh:mm:ss z') regards arvind if "properly" mean want displayed "bst" (for british summer time) there isn't enough information in date/time value - time-zone offset of +1 occurs in many different timezones near greenwich meridian. you're using exslt library formatting dates , times. based on java's simpledateformat class, try luck timezone designator z instead of z . alternatively, if you've got access xslt 2.0, can use format-datetime() function. suffers same problem (the datetime value stores offset, doesn't tell name of timezone). can give processor clue setting 5th argument of format-datetime() "europe/london", in case might abl

c - MIPS Code Cycle Time -

i need task of determining number of cycles mips code below. my main issue determining if condition not met, if statement still executed (thus adding number of total cycles) assuming single cycle implementation scheme i.e., each instruction requires 1 clock cycle execute. 1. number of cycles required execute code when a. s==0? b. s==1? this have come myself: a. 9 cycles b. 8 cycles (it not instruction contained in if statement, , not jump endif statement - (goes function) final endif. this sample of mips: main: # evaluate expression. # put final result in a0 prepare syscall. addi $sp, $sp, -4 # make space on stack. sw $ra, 0($sp) # save return address. li $t0, 1 # put 0 in register li $a1, 4 # put 4 in register li $a2, 6 # put 6 in register if: bne $t0, $zero, else # (i == 0) ? add $v0, $a1, $a2 # v0 = a1 + a2 j endif else: jal func endif: add $a0, $v0, $zero li $v0, 1 so need determine number of cycles if a. s = 1

host - Dataset (Sysout) read error after COBOL program execution -

in rexx program, cobol program invoked , it's sysout captured using temporary dataset allocation (tso alloc) , using execio read. works without issues. one of our users (using different machine) reported issue @ execio read. irx0562e abnormal completion of data management macro. irx0565e sg0 ,$logon ,3420,d,sysout ,get ,wrng.len.record,0000003500000 0,qsam. iec020i 001-4,sg0,$logon,sysout,3420,bws858, iec020i sys15089.t170858.ra000.sg0.r0278041 iec020i dcb eropt=abe or invalid code, and/or no synad exit specified irx0250e system abend code 001, reason code 00000004. irx0255e abend in host command execio or address environment routine mvs. i found issue occured when cobol program has outputs on sysout. recreate similar situation in z/os system specifying 'vb' attribute in tso allocation. in case, allocated dataset not viewable in ispf. following error message shown, when trying view in ispf. 'i/o er

Calculate average using XQuery -

i need calculate average of each courses using xquery. here's xml code : <?xml version="1.0" encoding="iso-8859-1" ?> <?xml-stylesheet href="class.xsl" type="text/xsl" ?> <university> <student><sname>charlie parker</name> <course sigle="inf8430" note="69" /> <course sigle="inf1030" note="65" /> <course sigle="inf1230" note="73" /></student> <student><name>miles davis</name> <course sigle="inf8430" note="65" /> <course sigle="inf1030" note="77" /> <course sigle="inf1230" note="83" /></student> <student><name>john coltrane</name> <course sigle="inf9430" note="24" /> <course sigle="inf1030" note="64" /> <course sigle="inf1230" note="

How can PHP see client side cookies? -

how can php see client side cookies? to elaborate: when working php & javascript, understand php gets processed on server side. while javascript happens on client side. in javascript can check , set these client cookies. makes sense. however, php, if check client cookie value part of conditional statement sets , how php able see clients cookie value while php happening on server side? here's example of php conditional lives in php file: <?php if ($_cookie["name"] == “mickey”) { setcookie(“fulsome”, “mickey mouse”, time()+3600); } ?> there no such thing client side cookie. a cookie piece of data associated set of urls in browser. every time browser makes http request 1 of urls, cookie included in request headers. they designed set via http response headers. an api added browsers allows them created , set javascript. these still regular cookies though , included in every request associated urls. it possible mark cookie http_onl

Database: Are there any vendors support column level locking? -

i'm studying database mechanism , see there 2 mechanisms: table level locking , row level locking . don't see column level locking , when google, see no document tell except link: database locking . in link: a column level lock means columns within given row in given table locked. form of locking not commonly used because requires lot of resources enable , release locks @ level. also, there little support column level locking in database vendors. so, vendors support column level locking ? , can tell me more detail, why column level locking requires lot of resources row level locking . thanks :) a lock cannot, in , of itself, require anything. it's abstract verb acting on abstract noun. why should locking column cost more locking byte, or file, or door? wouldn't put lot of stock in link. the answer question lies in why locks exist -- protect -- , how dbmss engineered. one of primary jobs of dbms manage concurrency: give each use

python - Script encrypts, but still saves the plaintext instead of the ciphertext -

i have issue current program supposed take user input, encrypt allowing choose how want shift by, save file. unknown reasons program seems capable of saving file missing out encryption. appreciated. text = "abcdefghijklmnopqrstuvwxyz 1234567890-=!Ãâ€Å¡Ãƒ‚£%^&*" def main(): #if want save file after encrypting if statement ans = input("would save file of read file, press w or r").lower() if ans == "w": text = input("what text want enter").lower() caeser(text) save_file() elif ans == "r": text = input("what file name want enter").lower() caeser(text) # organise loop & function def caeser(text): shift = int(input("how shift?: ")) shifted_list = [] letter in text: character_lower = letter.lower() ascii = ord(character_lower) shift = shift % 26 shifted_letter = ascii + shift shifted_char = chr(shif

When would lambda functions be useful for classes in C++? -

so, see usefulness of lambda functions when used replace functors, when want use them in object oriented programming (with classes) setting in general , why? okay, little more (and less) helpful response comment. closures (that is, functions declared inside other functions, capture outer function's variables) interesting back-channel way implement classes. watch: auto makecounter(int initialcount) { int currentcount = initialcount; struct { std::function<void()> increment = [&]() { currentcount++; }; std::function<int()> getcount = [&]() { return currentcount; }; } thecounter; return thecounter; } now thecounter structure 2 members, 1 increments count , other retrieves current count. notice struct doesn't need store current count; instead implicitly held 2 lambdas, share currentcount between them. there's few problems this. it doesn't compile. not mostly. there ton of things wrong code snippe

ios - UIView scale animation overshoots when changed -

Image
when animate change view's transform, reset change in animation before first animation finishes, everything's great (shown here rotation). animation smoothly switches new target: but when scale, animation overshoots magnificently: here's breaking code: uiview.animatewithduration(1) { self.someview.layer.transform = catransform3dmakescale(0.001, 0.001, 1) } uiview.animatewithduration(1, delay: 0.5, options: nil, animations: { self.someview.layer.transform = catransform3didentity }, completion: nil ) has else seen this? doing wrong? edit: , there workaround? edit 2: believe duplicate of this question , voting close. this blog post provides answer: in ios 8, uiview animations additive, , has unfortunate result scale animations. basically, second animation happens together with first animation. solution explicitly remove original animation before starting new one: view.layer.transform = view.layer.presentationlayer

playframework - Play framework 2.3.8: Static assets not working in Production -

before week upgraded play (2.2.3) project 2.3.8. started app activator run when tried load image public folder in java controller, loaded , did not have issue. when try start app using, activator start it did not loads. seems there no public folder within in universal folder. caused problem. how resolve it? place our static assets in 2.3.8 project? how package production?

javascript - Mailchimp inline form validation not working for JS loaded HTML -

i'm trying create custom mailchimp popup. i'm using embeddable form code loading form html onto page on button click using js (or jquery) separate file. don't want user redirected mailchimp's thank page on completion of form. when don't try load form html separately, , have on main page, inline validation working , you're not redirected mailchimp page. when load same form code file either js or jquery, inline validation not work , you're redirected mailchimp page. there way load form html file , avoid redirect? i using jquery , found lot of articles suggesting issue conflict between mailchimp , jquery, recommended fixes didn't seem work, , switching js not fix it. i've tried lot of different things new js & jquery missing obvious - apologies in advance! here's html i'm using jquery version: <!-- form loaded here on button click --> <div id="mailchimp-popup-outer"></div> <div class="mailchimp-