Posts

Showing posts from June, 2014

javascript setinterval with random time -

i have setinterval function alert: setinterval(function(){ alert('oo'); }, 5000); but change (5000) interval each time interval runs alert() - i'd have randomly selected between 5 - 10 seconds. idea how it? you should use settimeout set interval after function should executed. function myfunction() { var min = 5, max = 10; var rand = math.floor(math.random() * (max - min + 1) + min); //generate random number between 5 - 10 alert('wait ' + rand + ' seconds'); settimeout(myfunction, rand * 1000); } myfunction()

java - Listing all devices on a network - Android -

i trying display devices fro network according tutorial: http://android-er.blogspot.ro/2015/12/lookup-manufacturer-info-by-mac-address.html no reason router ip , mac ... (weird part).. when scan fing (other android app) , after scan app results.. my code scanwifi.jar: package com.nliplace.nli.unealta; import android.os.asynctask; import android.os.bundle; import android.support.v7.app.appcompatactivity; import android.view.view; import android.widget.adapterview; import android.widget.arrayadapter; import android.widget.button; import android.widget.listview; import android.widget.textview; import android.widget.toast; import org.json.jsonarray; import org.json.jsonexception; import org.json.jsonobject; import java.io.bufferedreader; import java.io.filenotfoundexception; import java.io.filereader; import java.io.ioexception; import java.io.inputstreamreader; import java.net.httpurlconnection;

generics - swift protocol init func error with SpriteKit -

can show me wrong code? code in playground error detail protocol personwithname: class { var personname: string {get set} init(name: string) } class namecard<persontype: skspritenode persontype: personwithname> { var person: persontype init() { self.person = persontype(name: "no name") // line error. } } for shorter explanation replaced skspritenode any because have deal designated init() of skspritenode later in more detail.. more details on initializer requirements in protocols, take @ this section of apple's developer guide protocol personwithname: class { var personname: string {get set} init(name: string) } class namecard<persontype: persontype: personwithname> { var person: persontype init() { self.person = persontype(name: "no name") } } class exampleclass: personwithname { var personname: string = "" required init(name: string) {

c# - How can I modify individual elements of a vector? -

i want read , write individual elements of vectoroffloat . problem there's no setter defined, makes brackets + index way of accessing elements read only. vectoroffloat vector = new vectoroffloat(5); // vector[2] = 2.5f; // not work there's workaround: convert array toarray() modify array desired write array clear() , push() float[] array = vector.toarray(); array[2] = 2.5f; vector.clear(); vector.push(array); // work retarded console.writeline(vector[2]); this seems cumbersome write 1 element is there more direct approach this? also, missing setter worth if can work around it? the comments correct. way gain access unmanaged array trough startaddress property returning intptr . lock(vector) { var ptr_array=(float*)vector.startaddress.topointer(); ptr_array[4]=1.0f; }

php - How do I create a function to add to existing information? -

i have existing code has string of words. need able create function add existing string of words. struggling how in php. new , have looked has gotten me nowhere. when said , done, like: a function add new word existing variable contains string of words. (below existing code of words) $words = 'apple sauce, tasty chicken, new monkey, left right'; below can come with: function newword($word){ $newalpha = 'time table'; if ($newalpha > 0){ echo $newalpha => $words; } } i know that's not right i'm new php , mysql. may worth noting need function inserted database $words housed, bonus if me that. just concatenate string: function newword($word, $words){ if($word != ''){//or other check want return "$words, $word"; } return $words; } usage: $newalpha = 'time table'; $words = newword($newalpha,$words);//now $words has $newalpha appended onto end comma , space you can see in a

c# - Cross thread error despite setting ApartmentState -

i trying display content of loop ui. first off, i'm not sure i'm approaching correct way (using winforms) i'm doing: foreach (string item in stringarray) { thread thread = new thread(delegate() { updatedresultevent(item); }); thread.setapartmentstate(apartmentstate.sta); thread.start(); } i hope enough information, if isn't i'll go more detail here. i have 2 classes, program.cs (winform) , class called logicclass. pass instance of program object logicclass. logicclass has delegate signature matches method in program class. method passed delegate public void updateresultsonscreen(string newcontent) { txtresults.text += newcontent; } the error message is cross-thread operation not valid: control accessed thread other thread created on edit the goal is, similar way progress bar works, see control getting updated in real time. c

Outlook add in not registering for all users -

i have created outlook add in , setup project add in using vs setup. have changed properties of setup project "installallusers" true. it generates .msi , .exe file. run .exe file or .msi admin add in registered single user only. registry entry visible in hkcu hive not in hklm hive. i on windows 8.1 , office 2013. cheers, saurav i have changed properties of setup project "installallusers" true. the installallusers property doesn't affect registry hive add-in registered. need choose appropriate windows registry hive manually. the deploying office solution using windows installer article describes required steps creating msi installed office add-ins (including per-machine).

linux - Extract information from RTF file in shell script -

we have many rtf files need upload in oracle ebs respective category. need read info stored in document properties of rtf file. these fields title, subject, author, company , category. when open rtf file in notepad, can see info not sure how extract using linux command. using grep wasn't successful. i pasting here part of rtf file holds info \mwrapindent1440\mintlim0\mnarylim1}{\info**{\title ^xxsls_gbl_ordack^}****{\subject xxsls}****{\author ^es_es,es_fr,es_it,es_de^}**{\doccomm $header: xxsls_gbl_ordack_es_es.rtf $} {\operator }{\creatim\yr2012\mo11\dy11\hr14\min3}{\revtim\yr2013\mo3\dy2\hr10\min43}{\version24}{\edmins361}{\nofpages4}{\nofwords725}{\nofchars14202}{\*\manager }{\*\company }**{\*\category ^bd^}**{\nofcharsws14898} {\vern32773}}{\*\userprops {\propname _dochome}\proptype3{\staticval -974575144}}{\*\xmlnstbl {\xmlns1 http://schemas.microsoft.com/office/word/2003/wordml}}\paperw11850\paperh18144\margl851\margr851\margt851\margb0\gutter0\ltrsect can please

ios - AVPlayer override video controls -

i need notified when control button (on video) pressed. example if tap on "pause" or on "full scren" button need implement logic. can override methods of avplayerviewcontroller ? found avplayerviewcontrollerdelegate can't find methods override. i tried add observer avplayer player.addobserver(self, forkeypath: "status", options:nskeyvalueobservingoptions(), context: nil) and used: override func observevalueforkeypath(keypath: string, ofobject object: anyobject, change: [string : anyobject], context: unsafemutablepointer<void>) { ... } but notification when video played: method isn't called if tap on control button. thanks keypaths different, swift, check play/pause after clicked: player .addobserver(self, forkeypath: "rate", options: nskeyvalueobservingoptions.new, context: nil) and in observevalueforkeypath check this if ((change!["new"] as! int) == 1) ^ returns if video played or p

Persistent socket/connection PHP for SMPP/SMS -

i need set persistent socket connection in php , not sure how achieve this. when send sms message a) open socket connection b) send message (via sms/smpp) , c) close socket connection however need not open , close connection time. rather, require - 2 persistent connections maintains connectivity smsc (sms centre) , reconnects when timeout occurs. - 1 persistent connection reading sms , 1 sending sms. - automatic restart/recovery (i.e. when memory issues arise) - automatic looping act listener incoming events such receiving incoming delivery receipts , sms messages, 'ping' (enquire link) keep smpp connection alive. update: wondering if had achieved above using following: https://github.com/shaneharter/php-daemon function pfsockopen seems have capabilities looking for. check out question - php pfsockopen in session . === a personal observation on implementation. assuming php code triggered incoming request , other times, smpp client inactive. may not qui

html - Bootstrap collapse expanding too far when first clicked -

the following jsfiddle has 2 collapse panels. however, when each window expanded , collapsed, animation awkward , not fluid--it expands larger needs @ first, input fields contained therein not visible, , input fields appear suddenly. https://jsfiddle.net/6pmsp9ou/ this appears happen when window above width. if viewing window made less wide, expands normally. can seen in jsfiddle, appears expand , collapse @ default width, if widen viewing window, behavior described above observed. how can expand , collapse normally? <div id='ah-body'> <div style='max-height:500px;overflow-y:auto;'> <a href='#section1' class='collapse-header col-sm-12' data-toggle='collapse'>section 1</a> <div id='section1' class='collapse'> <div class='input-wrapper required col-sm-12 col-md-6'> <label for='field1'>field 1</label> <input id='field1&#

html - Check if link is clicked in JavaScript -

edit: question different 'supposedly duplicate' because mine checking how not trigger off event when link clicked, other question how detect changes in form. i using function ( taken here ) detect changes made form before leaving page, works fine triggers off when click save button using onbeforeunload event fire of function , want prevent happening when click save button. here event: window.onbeforeunload = function (e) { e = e || window.event; if (formisdirty(document.forms[0])) { // ie , firefox if (e) { e.returnvalue = "you have unsaved changes."; alert("you have unsaved changes."); } // safari return "you have unsaved changes."; alert("you have unsaved changes."); } }; how can prevent event firing when particular save link clicked? link: <a id="ctl00_contentplaceholder1_lbtnsave" href='/save'> <img id="

Perl - Script working in Padre, Windows. But not in Linux Ubuntu -

i've tried transfer script on i've been working on in windows. fails @ first hurdle. use strict; use warnings; $keywordfile = 'keyword.txt'; open(keywords, $keywordfile) or die "$keywordfile not found\n"; @keywordarray; while ( $line = <keywords> ) { chomp $line; push @keywordarray, $line; } close(keywords); it keeps on dying, though in same destination there file called 'keyword.txt'. issue coming ubuntu, or perl wrong? it keeps on dying, though in same destination there file called 'keyword.txt' relative paths resolved against working directory (i.e. directory script run from), not directory in script located. you should either run script directory contains needed files use findbin module script location , use path refer file names: eg. use finbin; $keywordfile = "$findbin::bin/keyword.txt";

c++ - virtual functions with compile time constants -

i put question first , add longer explanation below. have following class design not working c++ not support virtual template methods. happy learn alternatives , workarounds implement behaviour. class localparametersbase { public: template<unsigned int target> virtual double get() const = 0; //<--- not allowed c++ }; template<unsigned int... params> class localparameters : public localparametersbase { public: template<unsigned int target> double get() const; //<--- function should called }; using simple function argument instead of template parameter @ moment no alternative following reasons: the implementation of method in derived class relies on template meta-programming (using variadic class template arguments). far know not possible use function arguments (even if of constant integral type) template arguments. the method called compile-time constants. performance crucial in application , therefore want benefit calculation

android - How to use less drawable resources as possible? -

i'm trying make kind of quiz-app relative music field keep on showing random images , user takes answers. each answer check in database whether right or not. can see examples of mean here , here . problem should put in android project great number of images, suppose not good. i'm wondering if there way doing that, maybe using sample-images each element (a single note, single sharp, treble clef etc.) , fixing them toghether in way in order "build" final image.. don't know. , also, there way verify answers without internet connection? in advance. you can make customview or views http://developer.android.com/training/custom-views/index.html , have draw differently, depending on you're trying convey. use background images, , draw lines. adding custom view , imageview single layout explains how include images in customview .

xml - Oracle Data source configuration in MULE -

i've created project using apikit-with-munit example project. i mavenized project , have 1 app file called api.xml , 1 api-test-suite.xml file. i'm trying add db reference in test , i'm coming across following error when launching tests when launching test maven only. when launching tests anypoint studio, munit works fine. i dont't know wrong config... suspect problem related namespaces can point out i'm doing wrong? failed execute goal com.mulesoft.munit.tools:munit-maven-plugin:1.1.0:test (test) on project testing-apikit-with-munit_1.3.3-1: execution test of goal com.mulesoft.munit.tools:munit-maven-plugin:1.1.0:test failed: org.mule.api.config.configurationexception: configuration problem: failed import bean definitions url location [classpath:api.xml] [error] offending resource: url [file:/c:/workspaces/coverage1/testing-apikit-with-munit_1.3.3-1/target/test-classes/api-test-suite.xml]; nested exception org.springframework.beans.factory.xm

c# - Linq select returning string instead of object -

Image
i have following code: var languages = _languageservice .getall() .select(x => (((languageviewmodel) new languageviewmodel().injectfrom(x)))) .tolist(); when executing this, languages becomes, expected, collection of languageviewmodel objects: what trying is, when selecting, convert object's code property uppercase, so: var languages = _languageservice .getall() .select(x => (((languageviewmodel) new languageviewmodel().injectfrom(x)).code = x.code.toupper())) .tolist(); i'm expecting languages object have multiple languageviewmodel s in looks this: my guess fact i'm using statement select(x => (new object().property = value)) selects property . then, how can return object 1 of properties changed? using object initializer before inject not option gets overriden, using after inject not possible, not casted yet, got solution here not seem work. advice appreciated.

PHP mysqli select by group and random -

not sure if possible. trying mysqli query work group results , inside each group display results randomly. here current code produces results in random order. select * swt_counties_members county_id=".$scounty[1]." , status=1 or county_id=0 , status=1 order rand() what need group service_id , display random records in each group. this select * swt_counties_members county_id=".$scounty[1]." , status=1 or county_id=0 , status=1 group service_id order rand() where group results first service_id , display results in each of group randomly hope makes sense :) many thanks you want order by, not group by select * swt_counties_members county_id=".$scounty[1]." , status=1 or county_id=0 , status=1 order service_id,rand()

Have intellij use different python SDKs for subdirectories in project -

i have python project this: project/ project/code project/code/requirements.txt project/fabfile project/fabfile/requirements.txt project/code python3 project, need use sdk. project/fabfile has python2, because fabric doesn't support python3. on command line have 2 virtualenvs manage this, inside intellij (with python plugin), have sdk set python3 virtualenv project sdk. result, isn't detecting different requirements in fabfile/, , marking python2 syntax errors. how can use different sdks these? if you're using intellij idea, can set multi-module project, , assign different interpreter each module. create 1 module 'code' content root, , 'fabfile' content root.

c# - GC.GetGeneration method gives unexpected results -

i have sample code jeffrey richter's book, shown below. object o = new object(); console.writeline("gen " + gc.getgeneration(o)); // 0. gc.collect(); console.writeline("gen " + gc.getgeneration(o)); // 1. gc.collect(); console.writeline("gen " + gc.getgeneration(o)); // 2 (expected) 0 gc.collect(); console.writeline("gen " + gc.getgeneration(o)); // 2 (expected) 1 can explain why 3rd , 4th calls getgeneration showed 0 , 1 generations instead of 2? i found out answer. current .net framework of console app 3.5. when changed 4 client profile achieved expected results. have question - differences in garbage collection in .net 3.5 , 4.0 / 4.5?

swift - NSURLSession validation -

i'm trying o work out correct (or @ least good) way handle data request using swift 2. what want achieve to: check if data connection available, if no alert user if connection available make request check request response, if invalid alert user if valid, check response code , display 1 of 2 messages what have far let requesturl: string = ********************** let url = nsurl(string: requesturl)! let request = nsmutableurlrequest(url: url) let session = nsurlsession.sharedsession() let postparams: nsdictionary = ["id":newid!] request.httpmethod = "post" { let jsondata = try nsjsonserialization.datawithjsonobject(postparams, options: []) let jsonstring = nsstring(data: jsondata, encoding: nsutf8stringencoding)! string let utf8str = jsonstring.datausingencoding(nsutf8stringencoding) let base64encoded = utf8str?.base64encodedstringwithoptions(nsdatabase64encodingoptions(rawvalue: 0))

sdk - Android studio can't see my phone (Vodafone Smart Prime 6) -

i trying test app phone vodafone smart prime 6 one. unfortunately,android studio can't see it. used adb techniques plus restarting phone multiple times,but still no result. don't have problems old samsung s3 phone. any ideas? thanks you have enable "usb debugging mode" after enabling "developer options check post more details :: enabling usb debugging mode

Generate SCORM for moodle from PHP -

we have instructions (text/image/videos) , trainings build on php. have moodle working , wanted generate scorms php application. is there library, or instruction achieve that? any or clue? look @ resource http://www.adlnet.gov , @ document: http://www.adlnet.gov/resources/scorm-users-guide-for-programmers?type=technical_documentation it contains information building , embedding resources scorm package.

c++ - DeleteInterpProc called with active evals -

i writing program executes tcl scripts. when script has exit command, program crashes error deleteinterpproc called active evals aborted i calling tcl_evalfile(m_interpreter, script.c_str()) script file name. have tried tcl_eval arguments interpreter , "source filename". result same. other tcl comands (eg. puts) interpreter executes normally. how can fixed? #include <tcl.h> #include <iostream> int main() { tcl_interp *interp = tcl_createinterp(); //tcl_preserve(interp); tcl_eval (interp, "exit"); //tcl_release(interp); std::cout << "11111111111" << std::endl; return 0; } this simple case. "11111111111" not printed. understand whole program exited when calling tcl_eval (interp, "exit"); . result same after adding tcl_preserve , tcl_release . the problem interpreter, execution context tcl code, getting feet deleted out under itself; makes confused! @ least you

ruby - Rails Time.now - 1.month not working -

i trying write simple script rails 2.3 application, encountering problem. when start rails console , type time.now - 1.month gives correct output: >> time.now - 1.month => mon dec 07 17:05:50 +0100 2015 when use same piece of code inside file (script/foo.rb) error undefined method 'month' 1:fixnum (nomethoderror) i not able require files "lib" directory. in rails 2.3 "lib" directory inside $load_path . problem has given me headache. can me. here details system: $ -a ruby /usr/bin/ruby /users/rakesh/.rvm/rubies/ruby-1.8.7-p374/bin/ruby the same script works fine on friend's machine guessing wrong in computer. 1.month comes active support, not ruby stdlib, need load dependency script context. so, if want run custom script under whole rails environment (with dependencies loaded), should use rails runner : runner runs ruby code in context of rails non-interactively $ bin/rails runner path_to_your_script.rb

testing - Salesforce/Apex, Why is TestDataFactory class included on code-coverage percentage? -

now i'm making apex test case clearing code-coverage. used normal code following like, https://developer.salesforce.com/docs/atlas.en-us.198.0.apexcode.meta/apexcode/apex_testing_utility_classes.htm testdatafactory @istest public class testdatafactory{ public list<account> createaccounts(){ // data create... return accounts; } // data create methods... . . . } mytestclass @istest private class mytestclass { static testmethod void test1() { testdatafactory.createaccounts(); // run tests } // other testmethods . . . } number of lines of testdatafactory class 100lines, , mytestclass 100lines test case logic completed code cover. therefore, 100 lines / 200 lines. code coverage 50%. because code coverage of testdatafactory class 0%. how can solve it? i'm sorry poor english. thank reading it. it works expected. shortly, including code other test methods in @

W3C xml get element with namespace and without namespace -

i have xml below, <?xml version="1.0" encoding="utf-8" standalone="no" ?> <entities xmlns="sample"> <entity> sample value </entity> <ns1:entity xmlns:ns1="sample"> sample value </ns1:entity> </entities> when use nodeelement.getnodename(); , can able <entity> not <ns1:entity> . verified this post , tried getlocalname() instead of getnodename() . not working. when tried using getelementbytagnamens("entity","sample") , getlength() method returned 0. updated: as mentioned in below answer interchanged parameters of getelementbytagnamens . see option use getelementbytagnamens("*","entity") allows me not hardcode namespace in code. wanted know, there disadvantage of using * . getelementbytagnamens("entity","sample") should getelementsbytagnamens("sample","entity&quo

javascript - Table with dynamic number of columns -

Image
i have table in display in first line current month , want change number of td in second line whith ng-click function. (if click next button next month , number of td in second tr become number of day of month(next month) what ve done : $scope.nextmonth=function(month){ var months = ["january","february","march","april","may","june","july","august","september","october","november","december"]; var nummonth = months.indexof(month); console.log(nummonth); if(nummois == 11){ $scope.month= months[0]; } else { $scope.month=months[nummonth+1]; } $scope.nbrjrs = nbjourbymonth(nummonth,2016); }; this screenshot of have : edit and when click next button : as can see month change number of td refers number of day in month doesn't change !! :( in view have : <table> <thead> <th><a href="#&q

magic numbers - Java's checkstyle, MagicNumberCheck -

i using checkstyle reportings source-code. question magicnumbercheck . i using date/(org.joda.)datetime in source code this: datetime datetime = new datetime(2013, 2, 27, 23, 0): datetime.plushours(57); is there way suppress magicnumbercheck notifications if magic number within date or datetime? you can use suppressioncommentfilter check this. configure properties values (in checkstyle configuration file) <module name="suppressioncommentfilter"> <property name="offcommentformat" value="check\:off\: ([\w\|]+)"/> <property name="oncommentformat" value="check\:on\: ([\w\|]+)"/> <property name="checkformat" value="$1"/> </module> now required lines, can like //check:off: magicnumber datetime datetime = new datetime(2013, 2, 27, 23, 0): datetime.plushours(57); //check:on: magicnumber this suppress magicnumber checks , rest checks work here. you can su

Convert null values to empty array in Spark DataFrame -

i have spark data frame 1 column array of integers. column nullable because coming left outer join. want convert null values empty array don't have deal nulls later. i thought so: val mycol = df("mycol") df.withcolumn( "mycol", when(mycol.isnull, array[int]()).otherwise(mycol) ) however, results in following exception: java.lang.runtimeexception: unsupported literal type class [i [i@5ed25612 @ org.apache.spark.sql.catalyst.expressions.literal$.apply(literals.scala:49) @ org.apache.spark.sql.functions$.lit(functions.scala:89) @ org.apache.spark.sql.functions$.when(functions.scala:778) apparently array types not supported when function. there other easy way convert null values? in case relevant, here schema column: |-- mycol: array (nullable = true) | |-- element: integer (containsnull = false) you can use udf: import org.apache.spark.sql.functions.udf val array_ = udf(() => array.empty[int]) combined when or coalesce : df

version control - Delete a pushed old git commit -

we working on single branch 20 developers. yesterday accidentally messed auto merge commit. he had pull taken 24 hours(span-1) before committing. after committing , taking pull accidentally reverted files shown in auto merge commit believing shouldn't committed had not changed files. after committed auto merge , pushed it. after 24 hours(span-2) of push recognized issue. now problem is, in span-1 have around 25 commits 10 developers , similar in span-2. changes on same/different files same/different developers. we tried cherry picking asks conflict resolution not possible in our case many developers involved. is there way solve problem. want delete merge commit. if required can delete actual commit done developer between span-1 , span-2. having these changes in history not problem. want clean repository. note: question here doesn't address specific problem. general question on deleting git commits. not interested in deleting/rewriting history. want rolled changes

java - Moving one object data to another -

so basically, want move object data object (queue jockeying). let's have int counter1,counter2 and have methods void enqueue1(object data) void enqueue2(object data) void dequeue1() void dequeue2() and, example, this obj1.enqueue1("data 1") obj2.enqueue2("data 2") obj2.enqueue2("data 3") obj2.enqueue2("data 4") what wanna when difference between counter1 , counter2 >1, want move data larger counter have balanced counter1 , counter2 so, how can move "data 4" obj2 obj1? i wrote pseudocode this: if (counter1 - counter2) == -2 obj2.dequeue2 obj1.enqueue(obj2.enqueue("data 4")) how can achieve in java code? appreciated thanks! have dequeue methods return last inserted object, , remove current class : object dequeue() then obj1.enqueue(obj2.dequeue());

How to ensure non-null duplicate values are not inserted in SQL Server 2005 -

i have history database in sql server 2005 used archive data live database. need add column in history database named rowid int. column cannot made identity since need store values live database. note: in live database rowid identity column. column added me in live database recently. i need make sure in history database, non-null values inserted column unique. understand in sql server, cannot make nullable column unique. so, in sql server 2005, efficient way make sure insertion of non-null duplicate values rowid columns throws error? this long comment. time upgrade more recent version of sql server. microsoft discontinuing support in april (2016) (see here ). starting in sql server 2008, can trivially want filtered unique index: create unique index unq_history_rowid on history(rowid) col not null;

html - Filling overlapping child divs to parent div content area -

i have parent div element has padding , defined border-box styling. trying nest multiple, overlapping child divs inside parent element , have child divs fill parent container, content part of parent container's box model. the problem having top , left absolute positioning of child divs being calculated browser correctly, height , width remains same total height , width of parent div, not height , width of content portion. this css have tried not working: * { -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; } .container { width: 300px; height: 60px; padding: 25px 12px 12px; border: thin solid red; position: absolute; } .layer { width: 100%; height: 100%; position: absolute; float: left; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; } please see jsfiddle example of trying do: http://jsfiddle.net/dwp1v0uu/ if inspect "container"

javascript - Is there a way to check if an array holds more than one value? -

for example, if needed code have set of numbers in array list happen? example array [1,3,4,5,9]. there way check , see if array contained these integers @ once , in same order? var arraysearch = function (subarray,array ) { var = -1; return subarray.every(function (v) { if(i != -1) { i++; return (array.indexof(v) === i) } = array.indexof(v); return >= 0; }); }; var arr = [1,3,4,5,9]; console.log(arraysearch([4,5],arr))

c# - Return Parameter From SQL Query -

i trying run sql stored procedure , return value query. syntax throws error of: cannot implicitly convert type 'system.data.sqlclient.sqlparameter' 'decimal' this syntax, should alter in order have run properly? public decimal returnvaluefromquery(string connectionstring, string sqlquery, int blah, datetime d1, datetime d2) { string cs = system.configuration.configurationmanager.appsettings[connectionstring].tostring(); try { using (sqlconnection conn = new sqlconnection(cs)) using (sqlcommand cmd = conn.createcommand()) { cmd.commandtext = sqlquery; cmd.connection = conn; cmd.commandtype = commandtype.storedprocedure; cmd.parameters.add("@blah", sqldbtype.int).value = blah; cmd.parameters.add("@startdate", sqldbtype.date).value = d1; cmd.parameters.add("@enddate", sqldbtype.date).value = d2; var returnparameter = cmd.parameters.add("@returnval", sq

javascript - Inconsistent loading time for JS and PHP -

i have php script being loaded js through jquery's $.ajax . measured execution time of php script using: $start = microtime(); // top part of code // other processes includes aes decryption $end = microtime(); // bottom part of code file_put_contents('log.txt','time took: '.($end-$start)."\n",file_append); it measured somewhere less 1 second. there no prepend/append php scripts. in js $.ajax code, have measured execution time by: success: function(response) { console.log(date('g:i:s a') + ' time received\n'); // other processes including aes decryption console.log(date('g:i:s a') + ' time processed\n'); } the time same time received , time processed. however, when check chrome developer tools, it claims php script loaded 8 seconds . what wrong in how measured these things? i'm php loading fast how come chrome reports took more 8 seconds? i'm using localhost , web server fast , time e