Posts

Showing posts from August, 2014

How to disable the close button of window using Qt? -

i want disable close button on window (main application window) when operation starts user can't exit application , enable again when operation complete. how can in qt application? platform windows 7. alternatively show message if user press close button , exiting application process running in background , abort closing application. how can either? if want disable button, can use next: auto flags = windowflags();//save current configuration //your main configuration trick setwindowflags(qt::customizewindowhint | qt::windowtitlehint | qt::windowminmaxbuttonshint ); //... setwindowflags(flags);//restore if sure such "feature" not irritate users, can use this, in case use link comment.

mysql - Querying for dates listed in another table -

i want select rows of table between 2 dates (which found in seperate table). details of tables , query can found in previous question here (i interested in how in hive/hiveql). current query stands, runs long time seems hang indefinitely, whereas when hardcode in dates runs completion quickly. tables , query reference: visit_info, these columns: pers_key - unique identifyer each person pers_name - name of person visit_date - date @ visited business valid_dates, these columns: condition - string start_date - date end_date - date and query itself: select pers_key, pers_name visit_info cross join (select start_date, end_date valid_dates condition = 'condition1') b (a.visit_date >= b.start_date , a.visit_date <= b.end_date) group a.pers_key its worth noting im using hive 0.12, getting rid of join , putting select statement in clause out of question. i'm wondering wrong query, or causing fail. suggestions how improve appreciated. try: select ...

java - Android: NullPointerException when the application attempts to encrypt .txt file -

i trying encrypt/decrypt file virtual device (genymotion). show code , exceptions have. guess nullpointerexception comes line declare view v = null in onactivityresult method not know how fix it. exceptions 07-22 13:34:10.241 10419-10419/? e/androidruntime﹕ fatal exception: main process: application.nikola.com.encryptdecrypt, pid: 10419 java.lang.runtimeexception: failure delivering result resultinfo{who=null, request=1, result=-1, data=intent { dat=file:///storage/emulated/0/nikola.txt }} activity {application.nikola.com.encryptdecrypt/application.nikola.com.encryptdecrypt.mainactivity}: java.lang.nullpointerexception: attempt invoke virtual method 'int android.view.view.getid()' on null object reference @ android.app.activitythread.deliverresults(activitythread.java:3539) @ android.app.activitythread.handlesendresult(activitythread.java:3582) @ android.app.activitythread.access$1300(activitythread.java:144) @ ...

hadoop - Loading XML to PIG : Error 2998 -

i'm using piggybank-0.12.0.jar , , pig version 0.12 (cdh) pig --version apache pig version 0.12.0-cdh5.3.2 (rexported) i trying load xml file using xmlloader of piggybank jar . during getting below error: register piggybank-0.12.0.jar; define xmlloader org.apache.pig.piggybank.storage.xmlloader(); define regexextractall org.apache.pig.piggybank.evaluation.string.regexextractall(); revisionxml = load 'test3.xml' using xmlloader('rev') (revision:chararray); error: error org.apache.pig.tools.grunt.grunt - error 2998: unhandled internal error. found interface org.apache.hadoop.mapreduce.jobcontext, class expected any idea why coming up. got solution above error 2998. to resolve it, either can build piggybank jar source. link: https://cwiki.apache.org/confluence/display/pig/piggybank in case, had used in built piggybank jar cdh distribution (since, didn't had privilege bypass proxy online download). worked fine me. thanks, ...

Convert a black or white only rgb array into a 1 or 0 array in Python -

i relatively new python , working image containing 'hits' particle detector totally black , white. in order count number of hits (and later separate hits different particles) need group adjacent white pixels. my code ensures image black or white , tries use scipy label function group white pixels (this should work groups none 0 values , made black pixels have 0's , white pixels hold 1. returns 0 labels , unsure why. think may fact not 1's , 0's still tuples of lists working with. is there way create array of 1's or 0's based on whether pixel black or white? def analyseimage(self, impath): img = image.open(impath) grey = img.convert('l') bw = np.asarray(grey).copy() #switches black , white label effective bw[bw < 128] = 255 # white bw[bw >= 128] = 0 # black lbl, nlbls = label(bw) labels = range(1, nlbls + 1) coords = [np.column_stack(np.where(lbl == k)) k in labels] imfile = image.froma...

ios - How do I set the initial scene in a sprite kit project? -

i have 2 skscenes gamescene , menuscene , default scene appears when open app gamescene want menuscene appear first i tried change code in gameviewcontroller: import uikit import spritekit extension sknode { class func unarchivefromfile(file : string) -> sknode? { if let path = nsbundle.mainbundle().pathforresource(file, oftype: "sks") { var scenedata = nsdata(contentsoffile: path, options: .datareadingmappedifsafe, error: nil)! var archiver = nskeyedunarchiver(forreadingwithdata: scenedata) archiver.setclass(self.classforkeyedunarchiver(), forclassname: "skscene") let scene = archiver.decodeobjectforkey(nskeyedarchiverootobjectkey) as! menuscene archiver.finishdecoding() return scene } else { return nil } } } class gameviewcontroller: uiviewcontroller { override func viewdidload() { super.viewdidload() if let sce...

asp.net mvc 5 - Randomize loading order of products -

i working on site friend site can sell goods. got index view loading of ef 6, mvc 5 , people on here. wondering if there way randomize loading order it's different each time. here's code products control index method: private accessorizeforlessentities entities = new accessorizeforlessentities(); // get: /products/ public actionresult index() { var products = entities.products.include(p => p.productimage); ienumerable<displayproductsviewmodel> model = products.select(p => new displayproductsviewmodel() { id = p.productid, name = p.productname, image = p.productimage, price = p.productprice.tostring() }).tolist(); return view(model); } is there way can alter code randomize loading order? just order random. example: entities.products.include(p => p.productimage).orderby(o => guid.newguid())

gruntjs - How to `uglyfy` all files from a folder to dest folder using grunt? -

i have grunt file. @ present have set 1 file src , dest. works well. how set js file folder dest folder? here config file : module.exports = function(grunt) { grunt.initconfig({ pkg: grunt.file.readjson('package.json'), uglify: { options: { banner: '/*\n <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> \n*/\n' }, build: { files: { 'dist/js/newmagic.min.js' : 'js/script/helloworld.js' //instead how set dest/js : js/script/alljsfiles? } } } }); grunt.loadnpmtasks('grunt-contrib-uglify'); //this 1 runs. grunt.loadnpmtasks('grunt-contrib-watch'); how run both? }; my command: grunt uglify the frequent use of uglify reduce many input files 1 output file: uglify: { options: { banner: '/*\n <%= pkg.name %> <%= grunt.template.today...

javascript - Jquery file with variable id as selector with Ajax -

i want change micropost list element using ajax request. there several microposts in page. html file looks this. <div class="load-more-<%= micropost.id %>" > <ol class="answers" > <%= render answers %> </ol> <%= link_to "more",more_micropost_path(micropost),remote: true %> </div> ` i want load _all_answers.html.erb when more link clicked using ajax. js file is $(".load-more-<%= escape_javascript(micropost.id) %>").html("<%= escape_javascript(render('answers/all_answers')) %>"); and controller action def more micropost=micropost.find_by(id: params[:id]) @answers=micropost.answers respond_to |format| format.html {redirect_to micropost} format.js end end but when press more nothing happens. in console error nameerror in micropostscontroller#more undefined local variable or method `micropost' #<#:0x007f08be826c48> m...

HTML5 <input> required attribute but not inside <form> -

this question has answer here: html5 input type required without form. work? 3 answers the required attribute works great inside form tags: <form> <input type="text" name="user" required> </form> but can use required attribute if cannot wrap form? outside of form input required not work me: <input type="text" name="user" required> i can replicate javascript id know if outside form possible the "required" attribute works on form submit , since input has no form browser not know validate on submit. what w3c says "required": when present, specifies input field must filled out before submitting form . this possible js like: document.getelementbyid('your_input_id').validity.valid already discussed here 4 years ago: html5 input type required without form....

javascript - then Promise doesn't work -

i have code statistic report on db. exports.calculate = function(req, res, next) { models.quiz.count() .then(function(questions) { statistics.questions = questions; models.comment.count().then(function(comments) { statistics.comments = comments; statistics.average_comments = (statistics.comments / statistics.questions).tofixed(2); models.quiz.findall({ include: [{model: models.comment}]}) .then(function(quizes) { (index in quizes) { if (quizes[index].comment.length) { statistics.commented_questions++; } else {statistics.no_commented++;} }; }) }) }) .catch(function(error) {next(error)}) .finally(function() {next()}); }; it works until sql statement, never makes loop for, never can statistics.commented_questions or statistics.no_commented tha...

angularjs - Angular Factory Injection not working -

im trying angular work @ basic level. dont it. im doing tutorial , everything. kills me. here im doing: 1.) html <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>document</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"></script> <script src="js/app.js"></script> <script src="js/controller.js"></script> <script src="js/friendsfactory.js"></script> </head> <body> <div ng-app="friendsapp"> <div ng-controller="friendscontroller"> <h3>{{girlfriendname}}</h3> </div> </div> </body> </html> 2.) app.js var friendsapp = angular.module('friendsapp',[]); 3.) controller.js friendsapp.controller('friendscontroller', ['$scope','...

linux - objdump full of zeroes -

the objdump of binary returns lot of functions seem correct, there field of functions this: 08c0ee1c <qglmateriali>: 8c0ee1c: 00 00 add %al,(%eax) ... 08c0ee20 <qglevalcoord1f>: 8c0ee20: 00 00 add %al,(%eax) ... 08c0ee24 <qglnormal3i>: 8c0ee24: 00 00 add %al,(%eax) ... 08c0ee28 <qgldeletetextures>: 8c0ee28: 00 00 add %al,(%eax) ... 08c0ee2c <qgltexsubimage1d>: 8c0ee2c: 00 00 add %al,(%eax) ... 08c0ee30 <qglmap2d>: 8c0ee30: 00 00 add %al,(%eax) ... it of course makes no sense functions have 2 bytes zeroes. looking @ addresses gameconqueror there actual content these functions. why objdump have zeroes? can fix this?

excel - Why does `Empty` not work in this VBA code? -

the code below supposed check if cell empty and, if empty, paste contents of b26 cell. if cell not empty, moves on check cell below it. tried using isempty didn't work, figured excel defaulting empty cells 0. tried using empty (as shown in code below) doesn't work either. sub part1_component_1_foam_color() ' ' transfers component 1 data if foam or color ' ' windows("transfer template.xlsm").activate range("b26").select selection.copy windows("protected_jd_form.xls").activate if range("b27:c27") = empty range("b27:c27").select selection.pastespecial paste:=xlpastevaluesandnumberformats, operation:= _ xlnone, skipblanks:=false, transpose:=false exit sub elseif range("b28:c28") = empty range("b28:c28").select selection.pastespecial paste:=xlpastevaluesandnumberformats, operation:= _ xlnone, skipblanks:=false, tran...

c# - Using AnimateWindow() at Form_Load -

i have borderless form , use animatewindow() method create animations opening, closing, etc form. use code: [flags] enum animatewindowflags { aw_hor_positive = 0x0000000 aw_hor_negative = 0x00000002, aw_ver_positive = 0x00000004, aw_ver_negative = 0x00000008, aw_center = 0x00000010, aw_hide = 0x00010000, aw_activate = 0x00020000, aw_slide = 0x00040000, aw_blend = 0x00080000 } [dllimport("user32.dll")] static extern bool animatewindow(intptr hwnd, int time, animatewindowflags flags); when comes closing form, code seems work: private void form1_formclosing(object sender, formclosingeventargs e) { animatewindow(this.handle, 100, animatewindowflags.aw_blend | animatewindowflags.aw_hide); } however, when opening form code: private void form1_load(object sender, eventargs e) { animatewindow(this.handle, 100, animatewindowflags.aw_blend); } nothing seems happen. after doing guesses , tests figured using animatewindow() me...

How I add a CSS class to first element of an array in PHP? -

i trying select images mysql , need store result in array. this while loop far: // fetch records: while ($stmt->fetch()) { $result = "<div class='item'>\n"; $result .= " <div class='gallery_image'>\n"; $result .= " <a class='thumbnail lightbox' title='{$db_restaurant_name}' rel='gal' target='_blank' href='{$image_path}{$image}'>\n"; $result .= " <div class='img-holder' style='background-image:url({$image_path}{$image})'></div>\n"; $result .= " </a>\n"; $result .= " </div>\n"; $result .= "</div>\n"; $gallery[] = $result; } } my question is, want add css class named active first element of $gallery array. class need add line <div class='item'>\n"; class="i...

windows phone 8.1 - OnsenUI ons-pull-hook not working in IE11 on WP8.1 -

i've been trying make ons-pull-hook work phonegap/cordova on wp8.1 device haven't had luck it. i'm using official example can found here: ons.bootstrap() .controller('democontroller', function($scope, $timeout, $http) { $scope.items = []; $scope.load = function($done) { $timeout(function() { $http.jsonp('http://numbersapi.com/random/year?callback=json_callback') .success(function(data) { $scope.items.unshift({ desc: data, rand: math.random() }); }) .error(function() { $scope.items.unshift({ desc: 'no data', rand: math.random() }); }) .finally(function() { $done(); }); }, 1000); }; $scope.reset = function(){ ...

Replacing loop in dplyr R -

so trying program function dplyr withou loop , here not know how do say have tv stations (x,y,z) , months (2,3). if group output summarised numeric value tv months value x 2 52 y 2 87 z 2 65 x 3 180 y 3 36 z 3 99 this evaluated brand. then have many brands need filter value >=0.8*value of evaluated brand & <=1.2*value of evaluated brand so example down want filter first two, , should done months&tv combinations brand tv month value sdg x 2 60 sdfg x 2 55 shs x 2 120 sdg x 2 11 sdga x 2 5000 as @akrun said, need use combination of merging , subsetting. here's base r solution. m <- merge(df, data, by.x=c("tv", "month"), by.y=c("tv", "months")) m[m$value.x >= m$value.y*0.8 & m$value.x <= m$value.y*1.2,][,-5] # tv month brand value.x #1 x 2 sdg 60 #2 x 2 sdfg 55 data da...

jquery - No scroll on angular element in iPhone 5s -

i embedding website dom element using angularjs, jquery, html5.see code below: digibin_app.directive("displayfile", function () { var updateelem = function (element) { return function (displayfile) { element.empty(); var objectelem = {} if (displayfile && displayfile.type !== "") { if (displayfile.type === "pdf") { objectelem = angular.element(document.createelement("object")); objectelem.attr("data", displayfile.fileurl); objectelem.attr("type", "application/pdf"); } else if (displayfile.type === "html" ) { objectelem = angular.element(document.createelement("object")); var childheight = parseint(window.innerheight); ...

C# FileInfo move foreach -

i have code: fileinfo finfo = new fileinfo(path.combine(directory.getcurrentdirectory(), "backup", file.key)); var fsize = finfo.length; if (fsize != file.value) { dialogresult modifiedcleofiles = messagebox.show("oops! modified files found! click ok move them!", "error", messageboxbuttons.okcancel, messageboxicon.warning); if(modifiedcleofiles == dialogresult.ok) { foreach (fileinfo filemove in finfo) { finfo.moveto(path.combine(directory.getcurrentdirectory(), "backup", filemove.name)); } } return; } but it's error foreach, how can fix it? p.s i'm error: foreach statement not work variables of type system.io.fileinfo if iterate multiple items in directory, need directoryinfo , not fileinfo , object. assuming want files in finfo 's directory, code should this: foreach (fileinfo filemove in finfo.directory.enumeratefiles()) { ... } finfo.di...

c# - Convert set of numbers to date -

i have string has format 20150622 yyyymmdd but need convert following format year-month-date 2015-06-22 is there way in c# need? don't see anyway treat strings arrays in c# there? you can parse string datetime yyyymmdd format (there no dd specifier) , generate it's string representation yyyy-mm-dd format like; string s = "20150622"; datetime dt = datetime.parseexact(s, "yyyymmdd", cultureinfo.invariantculture) console.writeline(dt.tostring("yyyy-mm-dd", cultureinfo.invariantculture)); output; 2015-06-22 but if string parts doesn't range in year, month , day of gregorian calendar , solution won't work. in such case, can use string.substring method parts of string , format them - delimiter like; var s = "20150622"; var result = string.format("{0}-{1}-{2}", s.substring(0,4), s.substring(4,2), s.substring...

Accessing the Azure Graph API using Application Identity -

i'm working azure graph api, , notice can't read directories have signed via consent framework. everything works user-level permissions. is, with private async task<string> acquiregraphapitokenasync(string objectid, authenticationcontext authcontext) { var result = await authcontext.acquiretokensilentasync( graphurl, _clientcredential, new useridentifier(objectid, useridentifiertype.uniqueid)); return result.accesstoken; } i can read client data follows: var authority = string.format(cultureinfo.invariantculture, aadinstance, tenantid); var authcontext = new authenticationcontext(authority, new tokendbcache(userobjectid)); var graphserviceroot = graphurl + '/' + tenantid; var graphclient = new activedirectoryclient(new uri(graphserviceroot), async () => await acquiregraphapitokenasync(userobjectid, authcontext)); try { var aduser = await graphclient.me.executeasync(); ... } sometimes, however, want run similar process in d...

PHP @var annotation for array element -

i know in $foo , in $array['foo'] have got stored class bar instance. i expected same result of using @var annotation in both cases. it works correctly: /* @var $foo bar */ $foo->| // [i see tips correctly] but how that: /* @var $array['foo'] bar */ $array['foo']->| // [i want see tips here, nothing happens] p.s. sign | shows text cursor position. p.s.2. tested annotation on phpstorm 7. not ide ready feature? this worked me in phpstorm 9. maybe should try upgrading: https://www.jetbrains.com/phpstorm/download/

predict - time series prediction using neural network encog library java -

i read example of workbench time-series example. little confused. think in order use neural network should have both training , evaluation dataset if predict future value don't have? example suppose have dataset contains ten numbers , make first 5 numbers training data set , rest evaluation data set , need predict 5 numbers in future after ten number how can this? hope clear in advance. most ten numbers not enough making generalization. training data should representative in order make generalization. can compared situation, if want make conclusions weather situation on planet while taking account temperature in 1 city during 3 months. need enlarge time period @ least 5 years , take account more cities around world.

javascript - Pay With Amazon Open in Popup Window -

i using pay amazon express integration . in have create custom pay amazon button described here : everything working smoothly, when click on pay amazon button, opens window in same page. want window open in popup . is there way, can make pay amazon button open window in popup . here code: <script type="text/javascript"> offamazonpayments.button("amazonpaybutton", app.conf.amazonpaysellerid, { type: "hostedpayment", hostedparametersprovider: function(done) { $.getjson(app.conf.siteurl + 'generatepaymentrequestsignature', { amount: $("#depositamount").val() ? $("#depositamount").val() : 10, currencycode: 'usd', sellernote: "deposit app", returnurl : window.location.href, sellerorderid : localstorage.getitem("useraccesstoken") }, function(data) { if(data.status && data.code == 200) { done(jso...

order - Drupal commerce save personnal field -

i'm new drupal commerce ... i added 2 fields in order table : field_date_de_livraison (text) , field_info_comp_cmde (long text). in personalized pane , try save entered values ​​with code : function pane_date_livraison_checkout_form_submit($form, &$form_state, $checkout_pane, $order) { if (!empty($form_state['values'][$checkout_pane['pane_id']])) { $date_saisie = $form_state['values'][$checkout_pane['pane_id']]; if (!empty($date_saisie['date_livraison'])) { $date_sauvegarde = new datetime($date_saisie['date_livraison']); $date_sauvegarde = $date_sauvegarde->format('d/m/y'); $order->field_date_de_livraison = $date_sauvegarde; } if (!empty($date_saisie['info_comp'])) { $order->field_info_comp_cmde = $date_saisie['info_comp']; } } dpm($order, "return_submit", $type = '...

java - How to process a line that has 2 same words -

i have line follows: abcde, def, efgh, mnop, mno, pqr, abc, abcde, abcde, mnop, efg in this, abcde , mnop occur more once. want change names of occurrences of abcde , mnop represented different. how can without changing order of sequence? please note words appear more once (more twice in cases) not known. need figure out words appears more once done. the line string , want end result string processing. thanks in advance. public class stringmod { public static void main(string[] args) { string text = "abcde, def, efgh, mnop, mno, pqr, abc, abcde, mnop, efg, abcde"; string[] sp = text.split(", "); int count = 1; for(int i=0;i<sp.length;i++){ count = 1; for(int j=i+1;j<sp.length;j++){ if(sp[i].equals(sp[j])){ count++; sp[j]=sp[j]+" "+count; } } } string returnstring = ""; for(int i=0;i<sp.length-1;i++) ...

c# - Which Design Pattern I should follow when passing different data type to a library? -

i creating csv export library input data come different source can have user data exported csv , can have orders data exported csv. i thinking of creating feedcsvprocesser prepare csv input data. the input data of defined type users userfeed, orders of ordersfeed , share common interface ifeedtype. can use di principle , have csv extract data ifeedtype using reflection , prepare csv. approach right, not sure kind of design pattern following or should there. please guide ? it seems doing well. don't seek design pattern if don't have problem yet. respect kiss , yagni principles. keep following ood principles you've mentioned. the important thing in case making "feedcsvprocesser" decoupled files should work on. don't want change class each time have new class exported. as mentioned, dependency inversion principle specific form of doing so. high-level module "feedcsvprocesser" should not depend on low-level modules ("orders...

Javascript calling a function from another javascript file -

file 1 var m = function (speech) { "use strict"; document.getelementbyid("speech").innerhtml = speech.tostring(); }; file 2 $("#test").click(function () { m("hello"); }); js lint probelms v http://puu.sh/j8aoo/a24a88825b.png 'm' used before defined. this error because you're defining m global variable in 1 file, , attempting invoke in another. because global variables sign of code-smell, jslint makes declare them. there few options this. one, prepend file 2 /*global m*/ , , should stop complaining. missing 'new'. this based on variable conventions. in javascript, typically name constructor functions using camelcase. because constructor functions intended called new keyword, it's detecting error. in case, best option rename m m . for more information on configuration , other jslint topics, see this page . alternatively, if have @ in matter, strongly suggest checking out js...

javascript - How to make a screenshot of a < div > , and within that there is a div tag < iframe>? -

i've used various frameworks ( html2image , iframe2image , feedback.js ... ) without success. have idea of how generate image of < div > tag within page body ? check out question answered here . niklas provided solutions html2canvas , examples here

jqgrid: subgrid toolbar does not display -

Image
i'm using jqgrid 4.8.2. i'm trying follow along examples on demo site. i've created parent grid , need show subgrid (as grid). reason, toolbar pager subgrid won't display. rownum, width , height options working, though. i've looked @ demo , can't see i'm doing wrong. take @ following code, please? var lastselection; $(document).ready(function () { $("#jqgrid").jqgrid({ url: 'servlet/getdata', datatype: "json", editurl: "servlet/updateproduct", page: 1, colmodel: [ { label: 'id', name: 'productid', width: 75, key: true }, { label: 'category', name: 'categoryname', width: 90 }, { label: 'name', name: 'productname', width: 100 }, { label: 'country', name: 'country', width: 80 }, { label: 'price', name: 'price', width: 80 }, { label: 'qty', name: 'quan...

c++ - Getting "QFile::rename: Empty or null file name" when dropping file to QTreeView -

i have qsplitter of : left side qtreeview showing local system file using qfilesystemmodel right side have qwebview html page showing directory , file name line line returned api. i want make drag , drop application. have enable drag , drop required functions working internally on own view. but want drag , drop between these 2 views, , when doing this, it's showing plus icon correctly, when dropping file, showing in console : qfile::rename: empty or null file name here's code : qstringlistmodel *model1 = new qstringlistmodel(); qstringlist *stringlist = new qstringlist(); view2->setupdatesenabled(true); view2->setacceptdrops(true); if(oldname == "" || cpe == "") { oldname = cpe; } else { oldname = oldname + " / " + cpe; } view2->page()->mainframe()->addtojavascriptwindowobject("mainwindow",newmyjavascriptoperations); qstring mypage; qtextstream p(&mypage); p << "<!doctyp...

c# - Enterprise Library Logging Block Get Configuration From web.config -

i've web api application. in solution of application, there several projects. and api's in 1 single project. , there 1 project business layer. we want write 1 logging class containing relevant methods in business layer project , going use "enterprise library logging block". what correct procedure related configuration web.config in class of business layer project. thanks in advance. if configuration contained in web.config , business layer assembly executes in same appdomain web api application thing need bootstrap blocks using (in case sounds logging). you @ application startup (e.g. app_start): logger.setlogwriter(new logwriterfactory().create()); in approach business layer use static facade logger.write write logentries. a better approach create small wrapper around logwriter bootstrap block , expose logwriter use in business layer (and anywhere needs logging). bit more friendly dependency injection since it's easy register in c...

javascript - Issue reading JSON file with AJAX request -

i have json file containing this: {"users":["john","peter"]} i tried ajax request, , returns 2 names in users array, until working fine, however, when try edit json file, whether using php or manually, lets add 2 more names users array, this: {"users":["john","peter","george","robert"]} i save json file, reload page , try ajax request once again, reason returns 2 names had prior adding 2 new ones. instead of returning ["john","peter","george","robert"] return ["john","peter"] any ideas why happening? here ajax request: var request = new xmlhttprequest(); request.open("get","../file/data.json",true); request.send(); request.onload = function(){ var data = json.parse(request.responsetext); console.log(data); } use jquery <script type="text/javascript...

javascript - jQuery .load, with specific class not working -

Image
i'd use .load add button, exists on page, each cell on website. let's looks this: lalalala videooooo here wop wop wop wop and of links. if go each link, example "lalalala", you'd go page looking this: info here, blabla. lala so, tried use: $(".mainpart").append("magnet: <div id='magneturl'>loading download buttons..</div>"); $("#magneturl").load("zoo-s01e04-hdtv-x264-lol-ettv-t10975316.html"); and loads fine; but if use: $(".mainpart").append("magnet: <div id='magneturl'>loading download buttons..</div>"); $("#magneturl").load("zoo-s01e04-hdtv-x264-lol-ettv-t10975316.html .magnetlinkbutton"); it print magnet: i hope make kind of sense post. the line $("#magneturl").load("zoo-s01e04-hdtv-x264-lol-ettv-t10975316.html .magnetlinkbutton"); is trying fetch content of page , filter applying jqu...

classloader - Uniquely identify a Java class implementation -

i have been dealing poorly branched projects left me dependiencies include several classes exact same qualified name. consequently, have been getting abstractmethoderror calling methods on wrong implementations. solution rename class packages worked fine. however, wonder whether there better way - can uniquely identify java class implementation? you can check if 2 classes (or classes of 2 objects) identical: o1.getclass() == o2.getclass() this expression true when classes identical (i.e. loaded same class loader). afaik there no way determine if class @ runtime got created specific file.

onclick - Can't dismiss a custom DialogFragment Android -

i implemented own dialogfragment custom layout, 2 simple buttons. problem not able dismiss it. here there code of layout: <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:l ayout_width="match_parent" android:layout_height="match_parent" android:weightsum="1"> <imageview android:layout_width="100dp" android:layout_height="100dp" android:id="@+id/imgprofilequestionsender" android:layout_gravity="center_horizontal" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textappearance="?android:attr/textappearancemedium" android:text="medium text" android:id="@+id/q...

How to close MySQL workbench without killing the running query? -

i running long procedure mysql workbench 6.1 , has been running quite while (so can't drop , restart later) , calculations run long while more. set "connection drop" variable big time, have turn off computer before end of (so can't wait time out). procedure doesn't return anything, don't care not receiving result. there way close workbench without having stop procedure running? thanks lot! simply said: no, it's not possible. the running query bound specific context: connection client server, includes states (e.g. transaction, sql mode , others). killing client means kill connection. ultimatively kill processing server doing client connection.

Eliminate combination duplicates in google spreadsheet -

i'm still on combination business on google spreadsheet, have 2 columns, , b, representing currency , code , want "conversion" combinations, in both ways. i succeeded in writing code, but, want eliminate duplicates : mean, in result, have "convert dollar euro", "convert euro dollar", "convert dollar eur", "euro usd", "eur usd" , "usd eur". but, have, example, "euro euro". how can solve in code : function matrix() { var sheet = spreadsheetapp.getactivesheet(); var range = 'sheet1!b4:c19'; var destid = '1kvhutwvr80ascne9ijtlws9yldf5ykixifvvbpjox5e'; var destcell = 'sheet1!d27'; var curr = spreadsheetapp.getactivespreadsheet().getrange(range).getvalues(); var currconv = []; (var = 0; < curr.length; i++) { ( var j = 0; j < curr.length; j++) { currconv.push(['convert ' + curr[i][0] + ' ' + ' ' + curr[j][0]]); c...

validation - jQuery Validate On Remote response based -

remote: { url: "/pages/", complete: function (status) { return !status; } } i have applied jquery validation , remote parameter, call returns true , false depending on data sent, need validation if true returned should considered false , vice versa. tried returning opposite response in complete callback, validations not work way guess. not sure may status returned remote not considered bool here. try this. remote: { url: "/pages/", complete: function (status) { if(status=="true") return false; return true; //no need of else } }

python - Lingua with Pyramids and Chameleon -

i want use lingua 3.10 i18n in pyramids 1.6 app, uses chameleon templates. far know, lingua helper script should work out of box, whereby path-variables of script have edited. unfortunately nothing happens. answered in this post , cookbook out of date. ... there small how-to? thx solved: had non-valid html-file!

c++ - How to change the characters output by hline/vline? -

Image
i trying create border around window hline/vline. desired output follows but instead letters such q , m being used border. here code far: mvwhline(white_space, 0, 3, acs_hline, 10); how use lines instead of letters? thanks! the usual problem using terminal descriptions using vt100 line-drawing terminals not support feature. if question showed complete program, simple test , see if there other issue. ncurses makes checks "linux" , "screen", not everything. putty example, ncurses provides environment variable handle these cases: ncurses_no_utf8_acs . feature added in late 2011 (some old distributions before ncurses 5.6 may not work, example). note ssh drops unusual environment variables, (again using putty example), may not possible preset variable in client setting connection. for programs not support vt100 line-drawing, ncurses may use ascii graphics (non-letter characters such | , - ) draw lines noted in waddch manual page. i...

javascript - With Knockout.JS how to attach an event handler using custom binding handler -

my binding handler adds hyperlink list item tag. know how attach click event hyperlink through binding handler. click event should call function within view model. you can see code in this jsfiddle . so question is: how attach event handler call showsectionname view model? maybe using ko.bindinghandlers.click(...) ? $(function () { ko.bindinghandlers.bootstraphyperlink = { init: function (element, valueaccessor, allbindings, viewmodel, bindingcontext) { var elt = "<a href='#'>" + viewmodel.name + "</a>"; $(element).append(elt); } }; var section = function (id, name) { var self = this; self.id = id, self.name = name }; self.showsectionname = function (data) { alert("you clicked section " + data.name); } function viewmodel() { var self = this; self.sections = ko.observablearray([ ...

javascript - RegEx: non-consecutive special characters only allowed in the middle -

i using following ng-pattern="/^[a-za-z][a-za-z0-9._](.*[a-za-z0-9])?$/" the matching string should not start special character, not end special character, and not include consecutive symbols except . (dot) , _ (underscore). but not working. please, suggestion. try using word character class start ( [\w] = [a-za-z0-9_] ): i'm not sure mean consecutive symbols. might help: /^[a-za-z]([\w.]*[a-za-z0-9])?$/ maybe, have @ javascript regexp reference