Posts

Showing posts from May, 2011

singleton - Use cases of the Signleton pattern -

i doing test, , confused on below question. which type of application benefit using singleton pattern? a. application interacts external systems in serial fashion. b. application interacts external systems in parallel fashion. c. clustered application can support 200 concurrent users. d. application requires remote monitoring capabilities there tests right answer , other tests answer d. correct answer? what (e) - small project not going heavily tested? singleton anti-pattern. should not use in system pollutes global state, more complex , less useful. don't want coupled singleton. moreover, using in multi-threaded environment lead disaster. imagine have several tests each changes singleton's instance. imagine tests concurring. eliminate use of singleton pattern in code-base , start considering better design. suggest taking advantage of dependency inversion principle , using dependency container instead.

python - Function for CodeAcademy course returning absolute value for numbers produces error about maximum recursion depth -

my code should use abs() return absolute value of argument (called distance_from_zero(n) ) when argument either ' int ' or ' float '. if argument else, ' str ' code should return "nope". when run code on codeacademy, error message "oops, try again. looks have error in code. check error message more info! - maximum recursion depth exceeded". can please tell me how following code wrong? def distance_from_zero(n): return distance_from_zero(n) if type(n) == int or type(n) == float: return abs(n) else: return "nope" edit: has been fixed, thank you! you've defined function endlessly calls first action, overflows stack. that's "maximum recursion depth exceeded" means. def distance_from_zero(n): return distance_from_zero(n) # calls calls ... # , doesn't matter else happens in function, it'll never # executed return end point of function....

jquery - Sticky subnav when scrolling past, breaks on resize -

i have main header fixed top , have subnav (which on real site anchor links within page) fixed bottom of window. have hero image height of window minus height of header , minus height of subnav. when user scrolls past subnav @ bottom, sticks top after main navigation. works pretty @ moment. here's extracted version of how works on site that's under development: https://jsfiddle.net/owgvjxdj . however, 1 bug when window resized, subnav's position isn't recalculated , ends positioned either high or low. i can refactor subnav's position binding additional window resize event: // refactor subnav measurements on window resize $( window ).resize(function() { var windowh = $(window).height(); var sticktobot = windowh - $('#subnav').outerheight(true); var scrollval = $(this).scrolltop(); if ( scrollval > sticktobot - $('.navbar').outerheight(true) ) { $('#subnav').css({'position':'fixed','top' :...

Sort XML File using XSLT -

i sorting xml file using xslt , facing small problem here.. my xml file given below: <?xml version="1.0" encoding="iso-8859-1"?> <bulkcmconfigdatafile xmlns="a.xsd" xmlns:xn="b.xsd" xmlns:subs="c.xsd" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="a.xsd a.xsd"> <fileheader fileformatversion="32.615 v5.0"/> <configdata dnprefix="" log="0" mediation="false"> <subs:sumsubscriberprofile id="378466"> <subs:sumsubscriptionprofile id="1"> <subs:imsserviceprofile id="1" modifier="create"> <subs:attributes> <subs:chargingidx>1</subs:chargingidx> </subs:attributes> </subs:imsserviceprofile> </subs:sumsubscriptionprofile> </subs:sumsubscriberprofile> <subs:sumsubscriberprofile i...

jquery - WebAPI - Passing JSON of derived class -

i using kendo ui,entity framework, , angularjs , trying serialize derived class type in kendo grid , send webapi method. have follow model association: class freq_pool<---- base class class pool_faa:freq_pool<----derived class class frequency(contains freq_pool object) i using kendo ui model follows: model: { id: "id", fields: { frequency: { type: "string" }, freq_pool: { $type: 'domainmodelmodule.pool_faa, domainmodelmodule', // type: "object", defaultvalue: {} } } } .... $("#faafreqgrid").kendogrid({ datasource: faads, columns: [ { field: "frequency", editor: categorydropdowneditor, title: "frequen...

scala 2.11 - How to recover from akka.stream.io.Framing$FramingException -

on: akka-stream-experimental_2.11 1.0. we using framing.delimiter in tcp server. when message arrives length greater maximumframelength framingexception thrown , capture onerror of actorsubscriber. server code: def bind(address: string, port: int, target: actorref, maxinflight: int, maxframelength: int) (implicit system: actorsystem, actormaterializer: actormaterializer): future[serverbinding] = { val sink = sink.foreach { conn: tcp.incomingconnection => val targetsubscriber = actorsubscriber[message](system.actorof(props(new targetsubscriber(target, maxinflight)))) val targetsink = flow[bytestring] .via(framing.delimiter(bytestring("\n"), maximumframelength = maxframelength, allowtruncation = true)) .map(raw ⇒ message(raw)) .to(sink(targetsubscriber)) conn.flow.to(targetsink).runwith(source(promise().future)) } val connections = tcp().bind(address, port) connections.to(sink).run() ...

angularjs - Configure angular $http with a value obtained from server -

i'm building (first) angular app have tokens inserted headers (the content shown part taken here ) angular.module('myapp') .factory('sessioninjector', ['sessionservice', function(sessionservice) { var sessioninjector = { request: function(config) { config.headers['x-session-token'] = sessionservice.gettoken(); return config; } }; return sessioninjector; }]) .config(['$httpprovider', function($httpprovider) { $httpprovider.interceptors.push('sessioninjector'); }]) the trouble i'm having sessionservice - how can initialize call server? for example, didn't work: .factory('sessionservice', ['$injector', function($injector){ var token = ""; return { gettoken: function () { var http = $injector.get('$http'); if (token === "") { http.get('http://localhost/a...

Android GraphView library - Scale and Scroll doesn't work on little X Date increments (seconds) -

i'm using graphview library (see: https://github.com/jjoe64/graphview or http://www.jjoe64.com/p/graphview-library.html ). working graphview-demos-master, modify "public class dateasxaxis .." little increments in date seconds , not day increments. seconds increments in x axis, scale , scrolls doesn't function. calendar calendar = calendar.getinstance(); date d1 = calendar.gettime(); datapoint[] datos = new datapoint[50]; (int i=0; i<50; i++){ datos[i]= new datapoint(d1,i%4); // d1.settime(d1.gettime() + 86400000); // 1 day works ok, jumps in scale d1.settime(d1.gettime() + 60000); // 1 min doesn't work scrolling not scaling. } linegraphseries<datapoint> series = new linegraphseries<datapoint>(datos); graph.addseries(series); // set date label formatter graph.getgridlabelrenderer().setlabelformatter(new dateasxaxislabelformatter(getactivity())); graph.getgridl...

Paypal's IPN Simulator using Laravel 5 -

i'm go mental problem, i'm implementing ipn system in app , started doing tests using paypal's ipn simulator. when try send ipn simulation, gives following error: we're sorry, there's http error. please try again. first thought - paypal's service down - tested wrong since if create blank page , send ipn message http://mydns.com/blankpage.php able send it. second thought - problem routes - think it's not problem either: here's ipn listener @ purchasecontroller.php : public function completed() { //fahim's paypal ipn listener $ipn = new paypalipnlistener(); $ipn->use_sandbox = true; $verified = $ipn->processipn(); $report = $ipn->gettextreport(); log::info("-----new payment-----"); log::info($report); if ($verified) { if($_post['address_status'] == 'confirmed'){ //sucess } } } in routes.php : route::post('purchase/compl...

c# - The name 'Directory' does not exist in the current context -

i create music player, because i'm learning how write universal app. i'm trying load list of songs in folder when use getfiles, visual studio shows me error: " the name 'directory' not exist in current context" even though @ beginning of code have "using system.io". doing wrong? using system; using system.collections.generic; using system.io; using system.linq; using system.runtime.interopservices.windowsruntime; using windows.foundation; using windows.foundation.collections; using windows.ui.xaml; using windows.ui.xaml.controls; using windows.ui.xaml.controls.primitives; using windows.ui.xaml.data; using windows.ui.xaml.input; using windows.ui.xaml.media; using windows.ui.xaml.navigation; namespace project_2 { public sealed partial class select : page { private void add_new_song(int song_number) {...} private string[] load_songs() { string[] paths = directory.getfiles(@"c:\...

sql server 2005 - Joins with aggregates doubling, sometimes tripling quantity amounts -

i'm trying join 4 tables several columns of results, 2 of sums/aggregates of respective columns. query returning multiples of true sums should be. here have: select pl.[vendor item no_], bc.[item no_], min(ile.[description]) 'item description', sum(ile.[quantity]) 'quantity on hand', bc.[bin code] 'item location' [live$bin content]bc left outer join [live$purchase line]pl on bc.[item no_] = pl.[no_]left outer join [live$item ledger entry] ile on bc.[item no_] = ile.[item no_] bc.[bin code] 'annex back' , bc.[item no_] 'sk%' group pl.[vendor item no_], bc.[item no_], pl.[description], bc.[bin code] using subquery/inline view may solve problem. assuming else working. know need know pk/fk relationship between 3 tables. select pl.[vendor item no_], bc.[item no_], min(ile.[description]) 'item description', ile.[quantity] 'quantity on hand', bc.[bin code] ...

Cannot install wordpress in XAMPP -

Image
i have installed xampp. apache , mysql server running perfectly. when installing wordpress when progress par filling there no problem. but when progress bar @ end following message in xampp control panel , installation won't complete. status unpacking file. error: apache shutdown unexpectedly. 3:53:49 pm [apache] may due blocked port, missing dependencies, 3:53:49 pm [apache] improper privileges, crash, or shutdown method. 3:53:49 pm [apache] press logs button view error logs , check 3:53:49 pm [apache] windows event viewer more clues 3:53:49 pm [apache] if need more help, copy , post 3:53:49 pm [apache] entire log window on forums so got tips resolve problem? may have change port apache in order install wordpress because may both using same port this link has method on how can change port apache : http://w3guy.com/fix-xampp-error-apache-shutdown-unexpectedly/ i hope :)

ios - Passing userID with photo POST Swift -

i have upload function sends photo server using post method. want include variable userid (currentuser) in service. have following code, when switch let param = ["userid" : "1"] let param = [currentuser] error. currentuser declared string function calls cant figure out whats wrong. func myimageuploadrequest(){ let myurl = nsurl(string: "http://server.com/posttest/imageupload.php"); let request = nsmutableurlrequest(url:myurl!); request.httpmethod = "post"; let param = ["userid" : "1"] let boundary = generateboundarystring() request.setvalue("multipart/form-data; boundary=\(boundary)", forhttpheaderfield: "content-type") let imagedata = uiimagejpegrepresentation(myimageview.image, 1) if(imagedata==nil) { return; } request.httpbody = createbodywithparameters(param, filepathkey: "imagefile", imagedatakey: imagedat...

Knitr: Turning the R chunk figure caption 90 degrees inline Latex -

here code demo cannot do. use r chunk make figure , use out.extra='angle=90' make figure post sideways on page. how caption go sideways too? \documentclass{article} \usepackage{subcaption} \begin{document} <<test-plot,echo=false,fig.cap="i posted sideways under figure, not here",out.extra='angle=90'>>= plot(1) abline(0, 1) plot(rnorm(10)) for(i in 1:10) { abline(v = i, lty = 2) } @ \end{document}

vb.net - Entity Framework Conceptual Clarification -

this question purely conceptual! the code below works fine, can't figure out how . . . the scenario i've begun reading on entity framework concepts, , i'm using information , examples located here build first mvc project. here's code example link: imports system.collections.generic imports system.data.entity namespace mydataaccessdemo module program sub main() using context new productcontext() dim food new category {.categoryid = "food"} context.categories.add(food) dim cheese new product {.name = "cheese"} cheese.category = context.categories.find("food") context.products.add(cheese) context.savechanges() end using end sub end module public class productcontext : inherits dbcontext public prop...

sql - Is having an identity primary key in addition to a composite unique constraint redundant? -

i have table has identity column primary key unique constraint on both identity column + second column: create table variable ( variableid bigint identity(1,1) primary key nonclustered, calcid bigint not null, ) create unique clustered index cl_calcid_variableid on variable(calcid,variableid) i have second table has identity primary key, 2 of same fields first table act foreign keys: create table value ( valueid bigint identity(1,1) primary key nonclustered, calcid bigint not null, variableid bigint not null, foreign key (calcid,variableid) references variable(calcid, variableid) ) create clustered index cl_calcid_variableid_valueid on value(calcid,variableid,valueid) is design redundant? since variableid identity in first table, don't need foreign key have calcid , variableid in second table. thinking of building tables way though because combination of calcid+variableid "makes sense" describe unique record having identity column ma...

c# - How exclude an entity and its properties in Entity Framework Migrations? -

consider have model: // in accounting.dll public class invoice { public int number{ get; set; } public company { get; set; } } public accountingdbcontext : dbcontext { // ... public dbset<invoice> invoices { get; set; } } in model i've used company defined in project // in infrastructure.dll public class company { public string name{ get; set; } } public infrastructuredbcontext : dbcontext { // ... public dbset<company> companies { get; set; } } the company being created via infrastructure migrations. in accounting project, finds company new create table for. question: how can set migrations in accounting leave company alone while scaffolding migrations? i've tried modelbuilder.entity<company>.ignore() . it's not solution whole entity framework ignores it. want migrations ignore it.

java - JavaFX ComboBox shows scrollbars on first click -

i'm doing program in javafx comboboxes, , loading fxml layout. when click first time in combobox few items (only two, example), scrollbar shown @ right side. after open again, scrollbar doesn't appear anymore. i tried solutions. 1 worked apply css directly in fxml, sets cell size fixed value. solution inside code (for example, in initialize function in controller) better case. thanks help. if options stay fixed suggest using choicebox instead of combobox . same, without scrollable option. if insist using combobox can try combobox.setvisiblerowcount()

python - how to render template in flask without using request context -

so there's flask app i'm working on project , need run in loop @ timed variables check status of variables , give output accordingly. however, problem have need render template in flask before loop restarts. in changelog on http://flask.pocoo.org/ it's indicated it's possible render templates without using request context haven't seen real examples of this. there way render templates in flask without having use request context without getting errors? can given appreciated. update: here's code i'm working with from flask import flask, render_template, request, flash, redirect, url_for import flask import time flask.ext.assets import environment, bundle flask_wtf import form wtforms import textfield, textareafield, submitfield wtforms.validators import inputrequired csrf_enabled = true app = flask(__name__) app.secret_key = 'development key' app = flask.flask('my app') assets = environment(app) assets.url = app.static_url_path scss =...

vb.net - How to assign code to a code created button? -

i writing in vb 2010, did form has button "new", shows new form created code on execution time , form contains textbox , 2 more buttons. problem is, how can add code buttons b1 or b2 created? how can store data textbox in variable when click on 1 button or else. i've read post asking somthing similar here they're related vba. wrote whole code below. help. private sub button2_click(byval sender system.object, byval e system.eventargs) handles button2.click dim f new form dim tb new textbox dim b1, b2 new button dim l new label f .size = new system.drawing.size(220, 120) .startposition = formstartposition.centerparent .text = "new" .minimizebox = false .maximizebox = false .controls.add(b1) .controls.add(b2) .controls.add(tb) .controls.add(l) end l .size = new system.drawing.size(180, 20) .location = new point(10, 3) .text = "label...

javascript - Sort Tree Structure of Objects by Class Property -

i have tree structure of objects (javascript/typescript), derived of same class (t). each object may or may not contain children of same object (list). therefore children may or may not contain own children (list), , on... i'm needing sort each of these "levels" of nodes specific property of object. currently i'm handling each parent , children: nodes.sort((a, b) => { return a.id- b.id; }); nodes.foreach(function (node) { node.children.sort((a, b) => { return a.id- b.id; }); }); however, i'm needing method sort children of children, children of children, , etc. imagine involve recursion, i'm not sure best way of handling in terms of efficiency. a) sort nodes. b) go through each node, if node has children, repeat step children. fu...

tiddlywiki5 - Tiddlywiki 5 and InlineJavascriptPlugin -

i'm new on tiddlywiki 5. try use tablesorter.js in tiddler , trying use inlinejavascripplugin that. test followed demo.js of eric shulman, there no output. seems nothing loaded. tagged plugin systemconfig. correct? jspara tiddlywiki5 modern, rewritten version of tiddlywiki , old version (prior 5.0) referred "tiddlywiki classic". plugins inlinejavascriptplugininfo written tiddlywiki classic , incompatible tiddlywiki5.

php - Filtering a MySQL query with multiple conditions -

i have output array named "feed items" (fi): ( [0] => array ( [reg] => 2015-08-03 13:39:00 [id] => fd7ec4107d16b07c1a13cbdd386af8d2cb05ffca [user_id] => de5fd44db1760b006b1909cf1db11a78b38e455c [img] => edee88e88cf6e17732e393b5433cfd894662902e [type] => new_join_ambition ) ) i generate array named "removedfeeditems" (rfi) has following structure: ( [0] => array ( [object_id] => fd7ec4107d16b07c1a13cbdd386af8d2cb05ffca [postee_id] => de5fd44db1760b006b1909cf1db11a78b38e455c [type] => new_join_ambition ) ) my mission not records have following condition: ri.id == rfi.object_id && ri.user_id == rfi.postee_id && ri.type == rfi.type the query use feed items array is: select i.registered reg, a.id, u.id user_id, ...

c++ - How to reset chrono::duration value? -

i want collect runtime of program in pieces of codes(separate functions), current strategy calculate execution time( chrono::duration ) each part , sum them together. have deal 2 different cases(call functions twice different input), , use static variable timer keep separated durations. wan reset variable before second case. how can this? of course can use duration of 2 consecutive system_clock::now(), seems unnecessary. tried timer = 0 or timer(0) , doesn't work. example: class myclass { static std::chrono::milliseconds timer_a; void foo(); void bar(); } in cpp file: std::chrono::milliseconds timer_a(0); foo() { ... // someduration1; timer_a += someduration1; .... } bar() { ... // someduration2; timer_a += someduration2; ... cout << timer_a.count(); } there main() call foo() , bar() twice. i.e., int main() { if(somecondition) { foo(); bar(); } if(othercondition) { // here need reset timer_a 0 s.t. record runtime a...

php - Not showing a picture where table field is empty -

i have mtsql database 25 images can stored, in table fields called picture1 through picture 25. what want check these variables once pulled database see whether should displayed or not. currently if there isn't images still shows , missing image sign. , no matter seem write shows regardless off if there image or not, below current code. <? if(!isset($picture2) || empty($picture2)){ ? <div class="property-slide"> <a href="m/properties/<?php echo $row['picture2']; ?>" class="image-popup"> <img alt="" src="m/properties/<?php echo $row['picture2']; ?>"></a> </div> <? } ?> the value of picture 2 1.jpg located in folder on server @ path m/properties/. i did consider storing images seperatley, easier use query show relevant properties, pre built else , database populated third party api.

python - pyexiv2 get image exif, from_buffer function lead memory leak -

i use pyexiv2 library read image exif info.and found imagemetadata.from_buffer() method lead memory leak when image not intact. imagemetadata() method ok. the code below test code, , when let read file not image, see memory not free. import pyexiv2 import time import sys import os def read_metadata(file_data): try: metadata = pyexiv2.imagemetadata(file_data) metadata = pyexiv2.imagemetadata.from_buffer(file_data) metadata.read() except exception,e: print e filename = sys.argv[1] print filename write_metadata(open(filename).read()) time.sleep(10000)

sql - Combining Data from Two Tables into One Row -

i've read around quite bit solution problem can't seem work. seems simple problem i'm not getting result set want. i'm working on report needs pull 2 tables , create 1 row of data each employee. file needs uploaded healthcare vendor. here example of data table1: employeecheckdeduction employee id deduction amount check date 1234 50.00 6/30/2015 1234 50.00 7/15/2015 4567 100.00 6/30/2015 4567 100.00 7/15/2015 9876 75.00 6/30/2015 9876 75.00 7/15/2015 table2: employercontribution employee id contribution amount check date 1234 25.00 6/30/2015 1234 30.00 7/15/2015 4567 50.00 6/30/2015 4567 60.00 7/15/2015 part of problem not every record in table1 have corresponding match in table 2. if maxed out on contributions, won't receive 1 ...

Flyway sql server on windows xp with windows authentification -

i work on windows xp, sql server 2008 r2(express) installed , jdk 7 i've tried flyway migrate database windows authentification every time run migrate command error message appear grave: l'environnement d'exÚcution java (jre, java runtime environment) version 1.7 n'est pas pris en charge par ce pilote. utilisez la bibliothÞque de classes sqljdbc4.jar, qui permet la prise en charge de jdbc 4.0. error: java.lang.unsupportedoperationexception: l'environnement d'exÚcution java (jre, java runtime environment) version 1.7 n'est pas pris en charge par ce pilote. utilisez la bibliothèque de classes sqljdbc4.jar, qui permet la prise en charge de jdbc 4.0. what should do? i've try flyway oracle , mysql , worksvery well resolved started use jtds instead of microsoft jdbc driver url connection used connect local server windows authentification flyway.url=jdbc:jtds:sqlserver://localhost:1434;databasename=basetest;integratedsecurity=true; and ...

Scheduling asynchronous tasks in Java Play 2.4.2: scala Duration compilation error -

i'm using akka system scheduler in play 2.4.2 execute asynchronous task. docs use scala.concurrent.duration.duration class create unit of time, getting compilation error says cannot create instance of duration because abstract class. this block of code want execute asynchronously: akka.system().scheduler().scheduleonce(no_delay, workerhandler, akka.system().dispatcher()); no_delay defined so: private static final duration no_delay = new duration.create(0, "seconds"); and relevant import statements: import scala.concurrent.duration.*; import java.util.concurrent.timeunit; the error message: scala.concurrent.duration.duration abstract; cannot instantiated [error] new duration(0, "seconds") any ideas how use duration properly? you cannot instanciate duration since abstract class, need drop new keyword. therefore, can do: import scala.concurrent.duration.duration; private static final duration no_delay = duration.create(0, t...

How to add the object values into table using angularjs -

var app = angular.module("myapp", ["ngsanitize"]); app.controller("controller", ['$scope', function($scope) { $scope.tasks = [{ item: "shopping", status: true }, { item: "cleaning", status: false }]; }]); and html <div ng-app="myapp"> <div ng-controller='controller'> <table border=1 ng-repeat='task in tasks'> <tr> <td>{{task.item}}</td> <td>{{task.status}}</td> </tr> </table> </div> </div> i tried above not able attach header table.and @ place of done tring attach checkbox...i mean if status true chexk box must checked or else unchecked. output: item done shopping checkbox ticked cleaning checkbox without ticked see documentation checkbox input not answer, why repeat table in...

android - drawable-w2560dp and drawable-1600dp Do Not Work -

i using new wdp qualifiers in application various phone/tablet sizes. work 600, 720, 800, 1200, not 1600 , 2560. google nexus 10 tablets have 2560 x 1600 resolutions. why drawable-w2560dp , drawable-w1600dp not work? how define assets google nexus 10? these qualifiers not work because google nexus not fall under them. w2560dp stands "width of 2560dp". dp or density-independent pixels different regular pixels. nexus 10 may have resolution of 2560px x 1600px (i.e. pixels) dp dimensions going more 960dp x 720dp (or that. can't give exact numbers). take @ these design guidelines supporting multiple screens feel difference between pixels , dp , how can better design layouts.

fft - Swift vDSP_create_fftsetup deprecated in iOS 8.4? -

i using fft routine wrote application in swift couple of months ago. the line initializing fft setup, i.e. calculating weights of fft, let fft_weights: fftsetup = vdsp_create_fftsetup(17, fftradix(kfftradix2)) does not seem work anymore ios 8.4, whereas former app works fine on ios 8.3. when try type function, doesn't appear anymore. deprecated? if yes, since it's relevant function, substitute? thank you! i ran similar issues several fft functions online. turns out need prepend functions vdsp_. see have on function call "vdsp_create_fftsetup" not same problem. want point out other people similar problems.

Is there an upper limit on model size in Mysql workbench? -

i following error when trying open mwb model file error unserializing grt data string long my file 217 kb , using version 6.3.4.0 build 828 64 bit windows community edition last thing did before saving adding tables. did not add long names, comments or that the model file has 100++ tables , 10+ diagrams showing these. is bug, corrupt model file or there upper limit on size of models ? i faced same problem, close , open it, solved, bug in several versions

php - Upload png image black background -

when upload png image php, background color of image setted black. tried set transparent background doesn't work. code : if( $image_type == imagetype_png ) { $dst_r = imagecreatetruecolor($targ_w, $targ_h); imagealphablending($dst_r, false); imagesavealpha($dst_r, true); imagefill($dst_r,0,0,imagecolorallocatealpha($dst_r, 0,0,0,127)); imagecopyresampled($dst_r, $this->image, 0, 0, $targ_x, $targ_y, $targ_w, $targ_h, $targ_w, $targ_h); imagepng($dst_r,$filename, 9); } edited: i tought i'v finished problem wrong: $targ_w_thumb = $targ_h_thumb = 220; if($image_type == imagetype_png) { $dst_r = imagecreatetruecolor($targ_w_thumb, $targ_h_thumb); imagealphablending($dst_r, false); imagesavealpha($dst_r, true); imagefill($dst_r,0,0,imagecolorallocatealpha($dst_r, 0,0,0,127)); imagecopyresampled($dst_r, $this->image, 0, 0, $targ_x, $targ_y, $targ_w_thumb, $targ_h_thumb, $targ_w, $targ_h); imagepng($dst_r,$filename, 9...

Bootstrap Succes Message disappears -

i have bootstrap form , there have ajax code give data .php script. the problem is, ajax code shows success message 1 second , disappear after that.. here code: $( '#frmcontact').submit( function() { var formcheck = true var name =$( '#name' ); if(name.val() == '') { $( '#name-group-name' ).addclass( 'has-error' ); $('#name-group-name').append('<div class="help-block">' + 'error' + '</div>'); // add actual error message under our input return false; } if(formcheck) { $.ajax({ type: "post", url: "process.php", // data: $('frmcontact').serialize(), success: function(msg){ $( '#message' ).addclass( 'alert' ); $( '#message' ).addclass( 'alert-success' ); ...

List all combinations of option strings while following order of supplied array and rules of specific options - php -

i working on project company sells multitude of valves vast array of variations , need build site map links every valve data current navigation not use conventional links codes built via user interacting many options on page. have been able generate until options begin tricky because of vast array of combinations of these options there , rules follow. i attempting build every option string combinations rules can find below. given array of option codes (at end of post) must generate list of possible combinations must follow order presented , follow rules given row_mod. example when option_code of o in combinations option_code of on , op not allowed in combination. the row_mod info needs followed when building these strings "nawithop##" refers option not allowed it. some of possible combinations need come out of script be: otkz otk ot otosz otos o ol olkz olk i know isn't close exhaustive list of how many possible can't figure out how generate...

node.js - How to get validation errors from specific model when working with transactions? -

right not i'm using code this: return sequelize .transaction((t) => { return usermodel .update(req.body.user, {where: {userid: usermodel.id}, transaction: t}) .then((u) => passport.upsert(_.extend(req.body.passport, {userid: u.id}), {transaction: t})) }) .then(() => res.flash('success', 'save!')) .catch(sequelize.validationerror, (err) => { res.flash('danger', 'error!'); console.log('errors:', err); }); when error @ 'catch', instance of validationerror don't have reference model. result don't know has errors passport or user.

ios - Pass data to two tab bar view controllers -

i trying pass data first view controller 2 other view controllers, in tab bar, have been struggling trying through prepareforsegue . code @ moment: override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) { if (segue.identifier == "showrides") { var tabcontroller = segue.destinationviewcontroller as! uitabbarcontroller var navcontroller = tabcontroller.viewcontrollers![0] as! uinavigationcontroller var destcontroller = navcontroller.viewcontrollers[0] as! initalviewcontroller destcontroller.parkpassed = parkselected var tabcontroller1 = segue.destinationviewcontroller as! uitabbarcontroller var navcontroller1 = tabcontroller.viewcontrollers![1] as! uinavigationcontroller var destcontroller1 = navcontroller.viewcontrollers[1] as! mapviewcontroller destcontroller1.parkpassed = parkselected } } i have tried pass data first view controller first tab, , second tab, didn't have...

java - Cannot parse value from xml to code libgdx -

i trying parse data xml file libgdx game. xml file looks this: <?xml version="1.0" encoding="utf-8"?> <levels currentlevel = "1"> <level1 speed="1" direction="1" lineangle="14" /> <level2 speed="1" direction="1" lineangle="14" /> <level3 speed="1" direction="1" lineangle="14" /> </levels> and code call in show method take values xml is: xmlreader xml = new xmlreader(); try { xmlreader.element element = xml.parse(gdx.files.internal("levels.xml")); xmlreader.element root = element.getchildbyname("levels"); currentlevel = root.getint("currentlevel"); xmlreader.element level = root.getchildbyname("level1"); lineangle = level.getint("lineangle"); speed = level.getfloat("speed"); direction = level.g...

javascript - Why doesn't this function run when the reactive variable changes value? -

i'm new meteor , i'm trying hang of whole reactivity thing. there isn't specifc reason why want function re-run, in fact, not re-running desired behavior use case. want know why happening can better understand concepts. if add function property on template instance, this: template.services.oncreated( function() { this.templates = [ "web_design", "painting", "gardening" ]; this.current_index = new reactivevar(0); this.determineslidedirection = function() { console.log(this.current_index.get()); }; }); and update reactive var in response event. template.services.events({ 'click .nav-slider .slider-item': function(event, template) { var new_selection = event.currenttarget; template.current_index.set($(new_selection).index()); } }); the function not re-run upon invocation of set() call. however, if have helper utilizes variable, re-run. templa...

python - Tkinter Label: How do I know that the text is too long for it? -

let me explain. have label. fixed size. , i'd know if there way let me know whether text want display in label long it. len() not since not characters of same width. why ? have label next showing << when happens, solved len() thats not good. you can use font_measure determine how many pixels required particular string in particular font on particular screen. ... text="hello, world" default_font = tkfont.nametofont("tkdefaultfont") width = default_font.measure(text) height = default_font.metrics("linespace") ...

python - Django: get and use multiple results, by using return HttpResponse( , , , ,) from a form -

i tried searching lot. couldn't find appropriate answer. asking here. please kindly me, tell me if wrong or using wrong approach. suggest me better approach , pls tell me mistake. can multiple values using........ return httpresponse(text1, text2, text3) result = text1+ text2+ ....... return httpresponse(result) #(without using concatination) here code def post_form(request): return render(request, 'post.html') def postresult(request): if 'fname' in request.post: message = 'welcome : %s' % request.post['fname'] message2 = 'book %s' % request.post['book'] message3 = 'description of book : %s' % request.post['desc'] message4 = 'book %s' % request.post['book'] # message5 = 'liked or unlikd article: %s ' % request.post['like'] # result = message + message2 + message3 + message4 + message5 return httpresponse(message...

Unable to install Ember.js -

i trying install ember cli getting error, not getting need do. i running below command install ember cli in c drive: npm install -g ember-cli i getting below error: npm err! windows_nt 6.1.7601 npm err! argv "c:\\program files\\nodejs\\\\node.exe" "c:\\program files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "ember-cli" npm err! node v0.12.5 npm err! npm v2.11.2 npm err! code etimedout npm err! errno etimedout npm err! syscall connect npm err! network connect etimedout npm err! network not problem npm npm err! network , related network connectivity. npm err! network in cases behind proxy or have bad network settings. npm err! network npm err! network if behind proxy, please make sure npm err! network 'proxy' config set properly. see: 'npm config' npm err! windows_nt 6.1.7601 npm err! argv "c:\\program files\\nodejs\\\\node.exe" "c:\\program files\\nodejs\\node_modules\\npm\\...

c++ - [SOLVED]capture working directory of external process[Qt/WinAPI] -

how wait-then-capture working directory of external process (which possibly not running yet) inside qt/windows code? i did similar times ago, , here relevant part. show how works. waitforprocess class search exe every refresh milliseconds, passes arguments start . if use snippet, , start notepad.exe , show path in console. can emit signal or whatever once have information. main.cpp #include <qapplication> #include "waitforprocess.h" int main(int argc, char *argv[]) { qapplication a(argc, argv); waitforprocess wfp; wfp.start("notepad.exe", 1000); return a.exec(); } waitforprocess.h #ifndef waitforprocess_h #define waitforprocess_h #include <qobject> #include <qstring> #include <qtimer> class waitforprocess : public qobject { q_object public: explicit waitforprocess(qobject *parent = 0); ~waitforprocess(); signals: public slots: void start(const qstring& processname, int r...

twitter - Spark Streaming - CheckPointing issue -

i've done twitter streaming using twitter's streaming user api , spark streaming. runs on local machine. when run program on cluster in local mode. run first time. later on gives following exception. "exception in thread "main" org.apache.spark.sparkexception: found both spark.executor.extraclasspath , spark_classpath. use former." and spark class path unset already!! have make new checkpoint directory each time make run successfully. otherwise shows above exception. can me resolve issue? :) had faced similar issue. setting spark_classpath causes problems depricated. don't use it. export lib_jars=dependency/jcodings-1.0.8.jar,dependency.....etc spark-submit --deploy-mode client --master local --class org.xyz.spark.driver.someclass --num-executors 10 --jars ${lib_jars}

java - ContextRefreshedEvent is not triggring on AnnotationConfigApplicationContext loading -

i created spring application , i'm loading application context in standalone java application. code following public class application { public static void main(string[] args) { applicationcontext applicationcontext = new annotationconfigapplicationcontext(config.class); } } i want copy data in in-memory database before application start. if put code after applicationcontext applicationcontext = new annotationconfigapplicationcontext(config.class); starts copying data after context initialize. application start processing orders before copy data in in-memory database. want copy data before application start , after beans initialize(context load). i tried following public class apppostloader implements applicationlistener<contextrefreshedevent> { public void onapplicationevent(contextrefreshedevent event) { redistemplate<string, string> redistemplate = (redistemplate) event.getapplicationcontext().getbean("redistemplate...

excel - Python: How to open a multisheet .xslx file (with formatting) and edit a few cells and save it as another .xlsx file -

i have tried using openpyxl seems fail when saving file ( http://pastebin.com/vu5ltajh ) , cannot find info problem. any other modules let read edit , save .xlsx file while retaining style , formatting of original file? you can use win32com library (i assume you're working on windows) , dispatch excel application via com. inside, can use every method available in vba (so that's work object model reference documentation). below simplified example how use it. import win32com.client excel = win32com.client.gencache.ensuredispatch ("excel.application") excel.visible = true workbook = excel.workbooks.open(filepath) if isinstance(worksheetname, str): worksheet = workbook.worksheets(worksheetname) else: #assume worksheetname number sheet = workbook.worksheets[worksheetname] def getrange(worksheet, address): return worksheet.range(address) def getvalue(range_): """returns values specified range, tuple of tuples (even if ran...

html - PHP call is not returning all of the values -

Image
i trying use php access database created , load text boxes. currently, code below loads list of text boxes , populates 'name' field, loads empty text boxes other sections. i have made sure $row['query'] parameters correct. here seeing: $sql = "select * salesmen"; $stmt = $conn->query($sql); echo '<table border="0">'; echo '<tr> <td align="center">name</td> <td align="center">user id</td> <td align="center">password</td> <td align="center">commission</td> <td align="center">address</td> </tr>'; while($row = $stmt->fetch(pdo::fetch_assoc)) { echo '<tr>'; echo '<td><input type="text" name="name" value="' .$row['name']. '"></td>...

c++ - when defining a private structure in a class how do i use it as a function parameter or return type? -

i have created graph.h, graph.cpp, , main.cpp in graphics.h i've created 2 private structures edge , node, , i've declared edge first above node edge has node member i've forward declared node struct i'm running issues saying "graph::node*" incompatible "node *" occurs in graph.cpp addedgebyname(string,string,double) function, why happen? on top of dont know why had declare in (graphics.cpp) function graph::node * graph::findbyname(string name) thought way tried declare node * graph::findbyname(string name) work gave me error. im trying make directed weighted graph way. #include <iostream> #include <string> #include <vector> using std::cout; using std::cin; using std::endl; using std::string; using std::vector; struct node; class graph{ private: typedef struct edge{ double edgeweight; node *pointsto; edge(){} edge(const edge & copyobject){ ...