Posts

Showing posts from June, 2010

java - Day light saving issue -

using following : public static void main(string[] args) throws parseexception { system.out.println(convertdate("2017-03-12 02:00", true)); } public static date convertdate(final string datestr, final boolean isdatetime) throws parseexception{ date tmpdate = null; if ( datestr == null || datestr.isempty() ) { return tmpdate; } string dateformat = "yyyy-mm-dd"; // logger.debug("input date string: " + datestr); if (isdatetime) { dateformat = "yyyy-mm-dd hh:mm"; // timezone frtimezone = timezone.gettimezone("utc"); // sdf.settimezone(frtimezone); } simpledateformat sdf = new simpledateformat(dateformat); try { tmpdate = sdf.parse(datestr); } catch (parseexception e) { } return tmpdate; } output getting : sun mar 12 0

webserver - What's the difference between a web server and a real(physical) server? -

so,i rookie web development , things servers keep disturbing me.according understanding,a web server application used interact browser.a physical server hardware,is equipment.i don't reallt see connections between these two.would right me understand web server application designed run on physical server? it would. physical server computer. not sure else :)

mysql - How to handle jdbc.queryForObject if it doesn't return a row -

i know how use jdbc in case. the savelinkhistory column bit(1) type in mysql. public boolean getissavedlinkhistory(string name) { string sql = "select savelinkhistory users name = ?"; boolean istracked = jdbctemplateobject.queryforobject(sql, new object[] { name }, boolean.class); return istracked; } the query worked until got error of incorrect result size: expected 1, actual 0 because name didn't exist, queryforobject method expects 1 row result. how can handle case, throw exception says "name" doesn't exist ? , way, boolean ok here ? because didn't see such code before. queryforobject method of jdbctemplate expects query should return 1 row else throw emptyresultdataaccessexception. can use query method resultsetextractor instead of queryforobject. resultsetextractor - extractdata(resultset rs) method return arbitrary result object, or null if no data returned. can throw relevant exception if returns

Why notification text is not shown in Android 7.0(Nougat) -

i displaying notification in app working fine in os versions except android 7.0 ( nougat ) here code intent notificationintent = new intent(context, homescreenactivity.class); // set intent not start new activity notificationintent.setflags(intent.flag_activity_clear_top | intent.flag_activity_single_top); pendingintent intent = pendingintent.getactivity(context, 0, new intent(), pendingintent.flag_update_current | notification.flag_auto_cancel | notification.flag_show_lights); notification.builder builder = new notification.builder(context); builder.setcontentintent(intent) .setautocancel(true) .setpriority(notification.priority_max) .setcontenttitle(title) .setstyle(new notification.bigtextstyle().bigtext(message)) .setcontenttext(message); if (build.version.sdk_int >= 21) builder.setvibrate(new long[0]); notification.flags

android - findLastCompletelyVisibleItemPosition() method of recylerview not working for variable size item -

i used following code private boolean islastitemdisplaying(recyclerview recyclerview){ if (recyclerview.getadapter().getitemcount() != 0) { int lastvisibleitemposition = ((linearlayoutmanager) recyclerview.getlayoutmanager()).findlastcompletelyvisibleitemposition(); if (lastvisibleitemposition != recyclerview.no_position && lastvisibleitemposition == recyclerview.getadapter().getitemcount() - 1) return true; } return false; } private final recyclerview.onscrolllistener onscrolllistener = new recyclerview.onscrolllistener() { @override public void onscrollstatechanged(final recyclerview recyclerview, final int newstate) { // code if (islastitemdisplaying(recyclerview)) { if (loadallow){ if (postproviderlist.size()<20 && postproviderlist.size()>=1) { loadallow = false; }else{ loadallow = false;

r - Partially update row in data.table -

let's assume have following data.table: > dt <- as.data.table(mtcars) > head(dt) mpg cyl disp hp drat wt qsec vs gear carb 1: 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4 2: 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4 3: 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1 4: 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1 5: 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2 6: 18.1 6 225 105 2.76 3.460 20.22 1 0 3 1 i update columns cyl:wt of first row vector vec <- 1:5 such that: > head(dt) mpg cyl disp hp drat wt qsec vs gear carb 1: 21.0 1 2 3 4 5 16.46 0 1 4 4 2: 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4 3: 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1 4: 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1 5: 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2 6: 18.1 6 225 105 2.76 3.460 20.22 1 0 3 1 i tried: dt[1, .sd := vec, .sdcols = cyl:wt] # fails

sql server - Results of calculating with sum of AVERAGE (expression) give a wrong number in SSRS -

Image
this question exact duplicate of: results of calculating sum (expression) give wrong number in ssrs 2 answers i have column calculated "how many employees work in each departments" , used expr =avg(fields!totalemployees.value) know how many employees work or worked in departments. , used expr =sum(avg(fields!totalemployees.value)) calculate total of sum results of avg. , than, when didn't choose between 2 different dates on top - calculate of sum of avg correct can see in screenshots : but , when choose between 2 different dates on top - calculate of sum of avg not correct , gives wrong number can see in screenshots : body of report : can please point me in right direction? or in ssrs ,do have ! , if did not choose between 2 dates not calculating sum of avg else calculating sum of avg or solved issue ! can't specify default val

Android: Conflict with com.squareup:javawriter -

hello , thank trying i have implemented firebase notifications , today wanted learn how add google maps application. after creating api key , adding compile 'com.google.gms:google-services:2.1.2' compile 'com.google.android.gms:play-services-maps:10.2.1' in build.gradle file when build application following errors error:conflict dependency 'com.squareup:javawriter' in project ':app'. resolved versions app (2.5.0) , test app (2.1.1) differ. see http://g.co/androidstudio/app-test-app-conflict details. there conflict `compile 'com.android.support:appcompat-v7:25.3.0' my full gradle file follows apply plugin: 'com.android.application' android { compilesdkversion 25 buildtoolsversion "25.0.2" defaultconfig { applicationid "com.example.alanauckland.yellowjersey" minsdkversion 16 targetsdkversion 25 versioncode 1 versionname "1.0"

windows - How to stop execution of selenium scripts that is continued to execute event after the jenkins job is aborted -

issue: i've started selenium scripts execution job jenkins when few of selenium scripts executed i've aborted job jenkins manually. but, selenium scripts continued running after aborted job can 1 solution stop selenium scripts execution if job aborted can 1 suggest me windows command stop selenium scripts execution running continuosly you can go " manage jenkins " > " script console " run script on server interrupt hanging thread. get live threads running : thread.getallstacktraces(); you can interupt thread hanged, running : thread.getallstacktraces().keyset().each() { t -> if (t.getname()=="thread name" ) { t.interrupt(); } }

ios - Trying to get response from web-service using JSON error occurs -

Image
i trying response web-service using json following error occurs. please me solve the error json returned web not correctly formatted. suggest extract data in string in order check receiving debugger. i noticed in setter setting userdefaults without synchronize. after change of defaults object need call defaults.synchronize() in order make effective changes. at last suggest never assume data coming web correct , recommend put try in catch user not have crash in case of problems. hope helped.

ios - iPad vs iPadPro Constraints solution -

Image
i'm having problems constraints. i'm working on universal app iphone ... various views correct, have no problems in now, i'm experiencing severe problem costraints when work ipad ipadpro. my problem between 2 spaces ... show picture understand problem .. on left have ipad display right visualization ipadpro now can see on ipad pro have many spaces between various labels , other items , can not understand how should work on constraints modify spaces there. when working iphone ipad easy because use compact compact variables or regular regular etc ... between 2 ipad how can work on this? change spacing of ipadpro constraints. make similar see in picture ipad in short, great if shrink window items ipadpro

javascript - ToDate Should not be Less than FromDate -

i have 2 datepicker 1 fromdate , second todate. want todate should not less fromdate. have tried solve not able solve properly. $(document).on('focus', '.datepicker', function() { // alert(); $(this).datepicker({ format: "mm/dd/yyyy", //startdate: '-90d', //enddate: '+0d', autoclose: true }); $(".datepickerinputto").change(function () { var fromdate = $(".datepickerinputfrom").val; var todate = $(".datepickerinputto").val; if (todate <= fromdate) { alert("end date should greater start date"); $(".datepickerinputto").val = ""; } }); }); <script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha256-zosebrlbnqzlpnkikedrpv7loy9c27hhq+xp8a4mxaq=" crossorigin="anonymous"></s

c++ - How to control value assigned by operator [] -

i know how overload operator[] follows : t& operator [](int idx) { return thearray[idx]; } t operator [](int idx) const { return thearray[idx]; } but want control values assigned arr[i] = value . want control value between 0 , 9. there syntax so? rene has provided answer. in addition this, here full example. note added "user-defined conversion", i.e., operator t , in proxy_t class. #include <iostream> #include <array> #include <stdexcept> template <class t> class myclass { std::array<t, 5> thearray; // array... class proxy_t { t& value; // reference element modified public: proxy_t(t& v) : value(v) {} proxy_t& operator=(t const& i) { if (i >= 0 , <= 9) { value = i; } else { throw std::range_error(std::to_string(i)); } return *

sql - Stored Procedure for multiple inserts with exiting if one fails -

i have eav table, each separate attribute have new row, this: personid atributename atributevalue ----------------------------------- 1 name john 1 gender male 1 height 170 the problem if want insert new person (with id 2, name jack, male, height 180) need 3 more inserts, , there changes 1 ore more fail. thinking of including inserts in stored procedures parameters (id, name, gender, height, etc..). my question is, doing this: create procedure dbo.insersubject @id int, @name varchar(50), @gender varchar(50), @height int insert subjects values (1, 'name', 'john'), (1, 'gender', 'male'), (1, 'height', 170); will fail if 1 of inserts fail? kind of implementation kind of database/table? create procedure dbo.insersubject @id int, @name varchar(50), @gender varchar(50), @ height int begin try insert subjects va

Laravel If Else statement inside foreach -

i'm trying use if/else statement inside foreach loop. domdocument i'm trying find description tag , inside of description tag. this works fine. when there description tag, display's what's inside description tag. if there no description tag displays: no description found no description found no description found no description found . why show error 4 times? how fix this? i'm using domdocument , laravel 5.4 meta tag: $meta = $dom->getelementsbytagname('meta'); my code: @foreach ($meta $node) @if($node->getattribute('name')=='description') {{$node->getattribute('content'), php_eol}} @else {{'no description found'}} @endif @endforeach edit, according muthu17: i have written same code you. problem is: shows "no description found" time. if finds description tag, show's description tag init , "no description found". i've declared $showerrormessage =

Extracting data from table in HTML file using python -

i have following table html file. <table border="0" summary="" width="100%"> <a name="table.header.1"><!-- --></a> <table border="1" cellpadding="3" cellspacing="0" summary="" width="100%"> <tr bgcolor="#ccccff" class="tableheadingcolor"> <th align="left" colspan="3"><font size="+2"> table.header.1</font></th> </tr> <tr bgcolor="#ccccff" class="tablesubheadingcolor"> <th align="left">query fields</th> <th align="left">query orderings</th> </tr> <tr> <td width="50%">row1</td> <td>no</td> </tr> <tr> <td width="50%">row2</td> <td>yes</td> </tr> <tr> <td width="50%">row3</td> <td>no&

java - ArtifactTransferException: Failure to transfer org.springframework.data:spring-data-jpa:jar:1.7.0.RELEASE -

iam getting following compile time error in pom file artifacttransferexception: failure transfer org.springframework.data:spring-data-jpa:jar:1.7.0.release http://repo.maven.apache.org/maven2 cached in local repository, resolution not reattempted until update interval of central has elapsed or updates forced. original error: not transfer artifact org.springframework.data:spring-data-jpa:jar:1.7.0.release from/to central (http://repo.maven.apache.org/maven2): access denied http://repo.maven.apache.org/maven2/org/ springframework/data/spring-data-jpa/1.7.0.release/spring-data-jpa-1.7.0.release.jar. error code 403, forbidden my pom file is: <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelversion>4.0.0</modelversion> <groupid>com.technicalkeeda&l

Webpack 2 compiling but not running javascript -

Image
i have 2 js files index.js const sum = require('./app'); const total = sum(10,5); console.log(total); app.js function sum(a,b){ return a+b; } module.exports = sum; webpack config const path = require('path'); const config ={ entry:"./app/index.js", output:{ path:path.resolve(__dirname,"app/build"), filename:'bundle.js' } } module.exports = config; the bundle.js getting generated , have added bundle index.html, bundle gets loaded when checking in network tab. console.log(total) not working, nothing works. nothing showed in browser console? errors? maybe better show configuration ( eg: webpack command or/and package.json )? your code works fine configuration : app ├── app.js ├── build │   ├── bundle.js │   └── index.html └── index.js webpack.config.js : const path = require('path'); const config ={ entry:"./app/index.js", output:{ path:path.resolve(__dirname,&q

android - Preference perfomance optimization required? -

i have read preference values adapter. sharedpreferences prefs = preferencemanager.getdefaultsharedpreferences(this); boolean value; i call following code in getview() (in adapter): value = prefs.getboolean("key"), false); my question is: better preload value memory , use or can keep code , android itself? when using sharedpreferences in app has multiple modifications value, it's better modify value in memory @ later point. may save sharedpreferences .. for example, application class may have this: public class myapplication extends multidexapplication { public static boolean flag = false; } and in getview method, doing multiple changes counter value, this: public class brandcountriesadapter extends baseadapter { .. @override public view getview(int position, view convertview, viewgroup parent) { //.... myapplication.flag = true; //.... return convertview; } then @ time in app, might save flag value in prefe

Start Service using espresso or ui automation in android -

i want run service class (backgroundsync) loginscreentest using espresso,but not able run service.i have taken link :- https://github.com/googlesamples/android-testing/blob/master/integration/servicetestrulesample/app/src/main/java/com/example/android/testing/servicetestrulesample/localservice.java please me.

JQuery Ajax Post/Get Not Sending Data But Retrieves Data From The Page -

for reason, jquery ajax isnt sending data. yes, similar question has been asked here none of answers works in case, tried both $.get , $.post or $.ajax , specifying post or get , none works, undefined variable error, ajax retrieve data sent page ie. load ajax-user-summary.php page $('#user-menu li:nth-child(1)').click(function(e) { $.post('includes/ajax-user-summary.php', { user_id: 10667546, user: "darlington akogo"}, function(status) { $('.user-record-interface').load("includes/ajax-user-summary.php"); }); }); $('#user-menu li:nth-child(1)').click(function(e) { var data = {user_id: 10667546, user: "darlington akogo"}; $.ajax( { url:'includes/ajax-patient-summary.php', data:data,success:function(status){ $('.patient-record-interface').load("includes/ajax-user-summary.php"); }); });

asp.net ajax - Jquery scroll to element just goes to top of page -

i have jquery updates page content via ajax (paging through sub table content) , want page "jump" (scroll) top of section content has been updated. found code try , perform scroll ever goes right top of page , not specific element : <script type="text/javascript"> $(document).ready(function() { $(".page-number").on("click", function() { var page = parseint($(this).html()); $.ajax({ url: '@url.action("productreview")', datatype: 'html', data: { "id": @model.product.productid, "page": page }, success: function (data) { $("#review-list").html(data); $("#page-number-"+ page).addclass("selected"); //location.hash = "#prodreviews";

angular - How to get back to the app after In App Browser view -

i have implemented in app browser-native feature on app.that feature working fine.now have issue.when user clicks button of device after go web page doesn't show dynamic data on app.i have implemented data fetching part inside constructor() .can tell me how solve issue? app working fine on other use cases.this happens when go browser. this video issue . constructor(public storage: storage) { super(storage); super.gettoken().then((val) => {//get token this.token = val; this.geteventlist(this.token); }); } //get event list geteventlist(data): { this.eventdata.geteventlist(data).subscribe( result => { this.eventlist = this.getmanagedeventlist(result.eventinfo); }, err => { loading.dismiss(); }, () => { loading.dismiss(); } ); } op's feedback: this not issue of code.this issue of "ionic view" app.i have installed .apk on android device , no issues.it's working fin

SAPUI5 upload file and use it as model -

i upload xml file local workspace , use model. can upload files server don't know how retrieve data uploaded object , set or load model here how m uploading file. jquery.ajax({ url: ofileuploader.getuploadurl(), headers: oheaders, type: 'put', cache: false, contenttype: false, processdata: false, data: file }); } i not use standard ofileuploader.upload() because uses http method "post" , wanted "put" thank you it not clear how contents of file variable passing jquery.ajax call. depending on this, have 3 options hat come mind: directly use file variable contents in model. use filereader api read file contents , put them in model. make back-end service return xml content of file response ajax call , store response in model.

mongodb - Correct mongo database is not picked up from the connection parameter, instead have to map it manually -

i having issue need manually map correct database domain instead of being picked connection argument. using grails 3.2.8, plugin "org.grails.plugins:mongodb:6.1.0". have both hibernate , mongodb plugin enabled. i have define connection url as //application.yml mongodb: url: 'mongodb://${mongodb_username}:${mongodb_password}@${mongodb_replica_set}/${mongodb_database}?${mongodb_connection_options}' my domain object defined : class reportdata { string id long somefield static mapwith = "mongo" static mapping = { //database "db-name" doesn't work when commenting out line } } shouldn't database(system property mongodb_database) picked auto-magically connection url? not sure if bug or missing configuration aspect. i realized had not added following in build.gradle file: bootrun { systemproperties = system.properties } so application environment settings not getting applied

Google Maps and D3.js -

i've got working on on previous project i've come across stumbling block replicating new data puzzle. the points rendering not in right place. also, when zoom in , out points change position - i've double checked long , lat same. i think problem in transform function: function transform(d) { d = new google.maps.latlng(+d.latitude, +d.longitude); d = projection.fromlatlngtodivpixel(d); return d3.select(this) .style("left", (d.x - padding) + "px") .style("top", (d.y - padding) + "px"); } is fromlatlngtodivpixel(d) placing points wrong or overriding left , top styles? appreciated. here 'not yet' working example - code on gist.github.com. https://bl.ocks.org/bmpms/36dfbe319f6a6f4cfb56205e95687024 p.p.s i've solved it. css, silly of me not guess. required css follows - hygiene being class of each individual layer : .hygiene, .hygiene

database - SQL request in VBA run time error -

i know there number of threads related this. however, none of them seemed solve problem. putting down exact problem here. can me this? i want execute simple sql query on excel sheet macro seem no recognize datatable object although defined in spreasheet name "tabl11" here code using in macro: sub jointables() dim cn adodb.connection set cn = new adodb.connection dim strmystring string cn .provider = "microsoft.ace.oledb.12.0" .connectionstring = "data source=" & thisworkbook.fullname & ";" & _ "extended properties=excel 8.0" .open end dim rs adodb.recordset set rs = new adodb.recordset strmystring = "65544397" dim sqlstring string sqlstring = "select * [tabl11]" rs.open sqlstring, cn worksheets("sheet3") .cells(2, 1).copyfromrecordset rs end enter code here rs.close cn.close end sub i run time error: 2147217865 (80040e37)

ios - App crashes after purchasing auto renewable purchase with trial -

Image
i have been trying implement auto renewable subscription (ars) trial period. had app ars implemented , working fine. wanted add trial period in these subscriptions. testing purpose created 2 new products trial period of 1 month set in them. now in sandbox environment, when try purchase these 2 new products sandbox id had taken subscription, process goes smoothly without issue. when try purchase them new sandbox account, app crashes after reaching updatedtransaction observer method. in method, have received receipt of product purchase , whole transaction details. app crashes after this. restore purchase same product works fine. below crash log , snapshot: terminating app due uncaught exception 'nsinvalidargumentexception', reason: ' * -[__nsdictionarym removeobjectforkey:]: key cannot nil' * first throw call stack: (0x186c081c0 0x18564055c 0x186b06534 0x100f052a4 0x19362ded8 0x1022e925c 0x1022e921c 0x1022ee284 0x186bb5f2c 0x186bb3b18 0x186ae2048 0x188

Update on join in Hive -

i'm trying understand how update column in hive table, based on id match different table. is, have table 'users', columns 'uid' (string), 'isverified' (boolean) , lot more columns. have second table 'users_verified', 1 column 'uid' (string). i'm trying effect of update users set isverified = 1 uid in (select uid users_verified); however neither nor update on join queries seem supported hive, , seems need use insert overwrite statement instead. can give me example of how might work?

c# - Callbacks how to pass bool -

i have project (wcf, xaml, c#), , in project have mediator class (which follows mediator pattern). allows classes register callbacks when actions have been completed (for example data loading database). the 'register' method mediator looks follows: public void register(action<object> callback, viewmodelmessages message) { internallist.addvalue(message, callback); } then classes register notified @ points, whereby callbacks called. works fine. the problem when attempt pass variable of type bool when action completed. in particular case, want message passed using mediator pattern when edit happening (user input editing of data). should pass along 'true' or 'false'. so, boolean type think. the registration on side of class wants receive message so: mediator.mediator.instance.register( (object o) => { // o boolean if (o == null) return;

Add Service in Custom HTTP service Angular 2 -

i using http interceptor extending http service. needed catch request , fire logout event if user token expired. the logout service defined in authservice uses http service. whenever try create instance of authservice , access functions, return undefined. is there missing? http.interceptor.ts import { injectable, ondestroy } "@angular/core"; import { router } '@angular/router'; import { connectionbackend, requestoptions, request, requestoptionsargs, response, http, headers} "@angular/http"; import { observable } "rxjs/rx"; import { environment } "../environments/environment"; import { authservice } './services/auth.service'; import { sharedservice } './services/shared.service'; import { loaderservice } './factory/loader.service'; import 'rxjs/add/operator/map'; @injectable() export class interceptedhttp extends http { private _router: router; private _auth: authservice; construc

javascript - Why does an array with a variable name of 'names' turn into a string when i put in 'name'? -

i declared array called names. used while loop go on each name , log them console. then, accidentally mistyped 'names' 'name'. normally, gives out reference error , logged different characters of first name. , checked developer tools , looked variable "name" because did not define variable **"name" var names = ['john', 'jane', 'mary', 'mark', 'bob']; var = 0; while (i < names.length) { console.log(name[i]); i++; } what printed out in console j o h n , then looked variable "name" cos did not declare , came out names "john,jane,mary,mark,bob" what reason behind this? first of added simple console.log() see name is. in case did not define variable name , default shorthand variable window.name . explains behaviour, there no reference error . lets take closer it: var names = ['john', 'jane', '

java - Read text file to arrayList and sort -

this snippet of txt file "q.txt". 12.54778255173505 : ^finishedline 15.416218875438748 : ^finishedline 16.245508427720914 : ^finishedline 9.595696051997852 : &^finishedline 11.971100145959943 : ! '^finishedline 11.678678199807727 : " $^finishedline 14.905855346233682 : # %^finishedline 15.98343143372184 : $ "^finishedline 16.053542916378102 : % #^finishedline i need sort text file "q.txt" contains double , string. has been separated using " : " , @ end of each phrase there ("^finishedline"). when run this, coming "numberformatexception: empty string" error. public class sorting { public static void sort() throws ioexception { scanner s = new scanner(new file("q.txt")); arraylist<qpair> set = new arraylist<>(); string line = ""; while (s.hasnext()) { string[] parts = line.split(" : "); set.add(new

php - sending and recieving an ajax call -

i looked ages prevent being duplicate can't seem find answer. on previous jquery page used following ajax call: var daynum1 = $(this).text(); var month1 = $('.ui-datepicker-month').text(); var year1 = $('.ui-datepicker-year').text(); var mydate = daynum1 + " " + month1 + " " + year1; $('#headingcontent').html(mydate); $.ajax({ url: "events.php", type: "post", data: { mydate: mydate }, datatype: "html", success: function(html) { $("#eventcontent").empty(); $("#eventcontent").append(html); } }); this worked absolutely perfectly. events.php able pick variable using: if(isset($_post['mydate'])) however i've come use different ajax call send data different page: var titleevent = $("#dropdowntextbox").val(); $.ajax({ url: "editevents2.php", cache: false, data: { titleevent: titleevent }, datatype: "html",

javascript - How to prevent page refresh before a user has selected a button on a dialog box? -

my web app listening out page refresh. i attempting doing following: window.onbeforeunload = dialogbox; the idea display dialog box in order prevent page refreshing until user has made choice selecting either of 2 buttons determines whether continue refresh or cancel refresh. unfortunately page displays dialog box brief second , continues refresh. there anyway can use 'onbeforeunload' prevent page continuing refresh , show dialog box? is impossible achieve using 'onbeforeunload'? the code dialog box: function dialogbox() { $("#dialog").html(""); $("#dialog").append("there appears unsaved changes"); $( function() { $( "#dialog" ).dialog({ modal: true, buttons: { cancel: function() { $(this).dialog( "close" ); }, "save": function() { }, },

c# - How to select the comma in multidimensional array? -

i have been developing application quite long time now, started using rectangular array: int[,] array = new int[900,800] but after giving higher values turned out caused lot of outofmemoryexception problems, decided replace multidimensional array this: int[][] array /*init stuff*/ but after doing compiler gave me 3000 errors (obviously), require lot of time fix manually, started thinking regular expressions replace ',' ']['. want select , inside array square brackets. far got: (?<=array\[).*, which selects ',' right, selects rest of index like: array[aaa,bbb] ^^^^ array[bbbb,ccc] ^^^^^ is there way select ',' like: array[aaa,bbb] ^ note: doesn't have 100% perfect, want work in of cases. thanks. you can use expression: \[([0-9]+),\s*([0-9]+)\] and replace with: [$1][$2] this expression matches less current attempt, result in less error-prone matching.

angular - get current route component instance or guards -

i have navigation area including logout button next router-outlet. app.component.html: <my-nav-header></my-nav-header> <router-outlet></router-outlet> on every module/component in router have implemented candeactivate method dirty-checking (as described in routing & naviagtion tutorial of angular) called actual candeactivateguard via interface described in tutorial. works expected - when user clicks router link , has unsaved changes asked whether route anyway or not. my-nav-header.component.ts logoutbtnclick(){ // todo: insert call candeactivate here // or find way dirty state of current component in router //console.debug('logout - can deactivate[1]: ', this.activatedroute.routeconfig.candeactivate); //console.debug('logout - can deactivate[2]: ', this.activatedroute.snapshot.routeconfig.candeactivate); this.loginsvc.dologout(); } login.service.ts @injectable() export class loginservice { ... public

java - Multiple index.html in spring boot -

Image
i have simple spring boot application 2 html inside webapp. in controller have written mapping like: @controller public class htmlcontroller { @requestmapping(value = "/", method = requestmethod.get) public string index() { return "index"; } @requestmapping(value = "/anotherindex", method = requestmethod.get) public string anotherindex() { return "anotherindex"; } } also have properties: spring.mvc.view.prefix=/ spring.mvc.view.suffix=.html when pass in browser localhost:8080/ - index.html page when pass localhost:8080/anotherindex have exception: javax.servlet.servletexception: circular view path [/anotherindex.html]: dispatch current handler url [/anotherindex.html] again. check viewresolver setup! (hint: may result of unspecified view, due default view name generation.) @ org.springframework.web.servlet.view.internalresourceview.prepareforrendering(internalresourceview.java:205) [spring-webmvc-4.3.7.release.jar:4.3.7.

javascript - Safari and IE ajax issues with subsequent calls (.then) -

i've got code: var request1 = this.add(prod_id, pack_id_combination, button, pack_qty).then(function(rdata1){ // works this.add(prod_id, case_id_combination, button, case_qty).then(function(rdata2){ // (random) doesn't work }.bind(this), function(req, status, error){ console.log('case error',req, status, error); }); }.bind(this), function(){ console.log('pack error'); }); i omitted rest of code because it's huge class , it's impossible build jsfiddle, things. but here's facts: my js points php file returning data. ajax calls via add() function (see below) it works first call, doesn't work second call. on log, status = 'error', error = '' (empty, no info here) i know sure second add(), if called alone same params, work. furthermore, has these problems in safari , ie, not in chrome, ff, android furthermore, has these problems if tested online, while in local environment works properly. safari says

javascript - Accumulator not initialized when using reduce.call -

why doesn't accumulator initialized? keep getting undefined. var s = "sosstsros"; var radiatedletters = array.prototype.reduce.call(s,function(acc,curr){ if(!curr.match(/[so]/)){ acc++; } },0); console.log(radiatedletters); you need return accumulated value reducer function , not mutate it: var s = "sosstsros"; var radiatedletters = array.prototype.reduce.call(s, function(acc, curr) { if (!curr.match(/[so]/)) { return acc + 1; } else { return acc; } }, 0); console.log(radiatedletters);

design patterns - Workflow System with Azure Table Storage -

i have system need run simple workflow. example: on jan 1st 08:15 trigger task object z when triggered run code (implementation details not important) schedule task b object z run @ jan 3rd 10:25 (and on) the workflow simple, need run 500.000+ instances , that's tricky part. i know windows workflow foundation , same reason have chosen not use that. my initial design use azure table storage , appreciate feedback on design. the system consist of 2 tables table "jobs" partitionkey: objectid rowkey: processon (utc ticks in reverse newest on top) attributes: state (pending, processed, error, skipped), etc... table "timetable" partitionkey: yyyymmdd rowkey: yyyymmddhhmm_<guid> attributes: job_partitionkey, job_rowkey the idea runs table have complete history of jobs per object , timetable have list of jobs run in future. some assumptions: a job never span more 1 object there ever 1 pending job per object the "job&qu

javascript - what is better approach to use slice or splice when remove element from an array? -

because of high data volume have set array $scope.event size limit when reaches bufferlimit remove first item array , add latest item array. best approach use slice or splice in terms of high data volume when remove add item ? ctrl.js $scope.event = []; function safelyadd(element) { if (totalreceived > bufferlimit && $scope.event.length) { $scope.event = $scope.event.slice(1); //delete first element in $scope.event totalreceived -= $scope.event[0].messagesize; //total message size minus deleted message size console.log('totalreceivedbytes', totalreceived); // $scope.event =[];//reset array if max size reached.. console.log('$scope.event', $scope.event) } console.log('$scope.event.length', $scope.event.length); $scope.event.push(element); //then push new item.. } that depends on requirements: the splice() method returns r

python - wsgi user permissions on elastic beanstalk -

i'm using elastic beanstalk , django. 1 of dependencies in requirements.txt file has setup performs when it's imported. part of setup check whether dir exists else create it. i'm getting permissions errors because user ( assume it's wsgi) not have permissions create dir. oserror: [errno 13] permission denied: '/home/wsgi/.newspaper_scraper/memoized' how can setup permissions allow these dirs created in way persistent across instances create in future? this happening because uwsgi worker running under user limited permissions. need create .newspaper_scraper/memoized directory first, , set correct permissions on (allow others r/w). can on deployment making script in .ebextensions eb executes upon deployment. create file in .ebextensions/setup_newspaper.config , add following it: .ebextensions/setup_newspaper.config packages: yum: libxslt-devel: [] libxml2-devel: [] libjpeg-devel: [] zlib1g-devel: [] libpng12-devel: [

python - How to select controls inside a table that is inside a form - mechanize? -

<form method="post" action="/user/user_login_prov.jsp"> <table id="userpass" class="separator"> <tr class="gap"><th>&nbsp;</th><td>&nbsp;</td></tr> <script type="text/javascript"> //<![cdata[ this.onloads.push(function() { redirecttopeerzd(''); document.getelementbyid('username').focus(); }); //]]> </script> <tr><th>user name</th><td><input class="login_input" type="text" name="username" id="username" size="256" maxlength="256" autocomplete=off /></td></tr> <tr><th>password</th><td><input class="login_input" type="password&q

ios - Serve mp4 file through coldfusion and play with jwplayer -

i have web application in coldfusion record videos , serve videos user. the video working fine on android , desktop browsers giving me error "error loading media: file not played" in ios. here jwplayer code working. jwplayer("element").setup({ file: "/video.cfm?token=4514_129_9b2f727d-5056-a85d-6ebe3e48fc2ab9c6", image: "path/to/image", width: 450, height: 360, type: "mp4", logo: { file: 'path/to/logo', link: 'example.com', hide : true } }); here video.cfm server mp4 after verification. <cfset videofile = 'path\to\file'> <cfset fileinfo = getfileinfo(videofile)> <cfset length = fileinfo.size> <cfset start = 0> <cfset end = fileinfo.size - 1> <cfheader name="content-type" value="video/mp4"> <cfheader name="accept-ranges" value="0-#length#"> <cfheader name="content-range" value=&