Posts

Showing posts from July, 2014

jsf - h:inputText value is null in action method -

container glassfish. the jsf page setting message #{senderbean.messagetext} , <h:messages/> output null messagetext property. <?xml version='1.0' encoding='utf-8' ?> <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://xmlns.jcp.org/jsf/html"> <h:head> <title>message sender</title> </h:head> <h:body> <h:form> <h2>type message in message text field</h2> <h:outputlabel for="messagetext" value="message text:"/> <h:inputtext id="messagetext" title="message text" value="#{senderbean.messagetext}" required="true" requiredmessage="error: message text id required" maxlength="128" ...

php - Symfony config.yml can't load Twig extension -

my config.yml follows: imports: - { resource: parameters.yml } - { resource: security.yml } framework: #translator: { fallback: %locale% } secret: %secret% router: resource: "%kernel.root_dir%/config/routing.yml" strict_requirements: ~ form: ~ csrf_protection: ~ validation: { enable_annotations: true } templating: engines: ['twig'] #assets_version: someversionscheme default_locale: "%locale%" trusted_proxies: ~ session: ~ fragments: ~ http_method_override: true i error: 'the service definition "templating.engine.twig" not exist.' but twig extension in /vendor/twig folder. more have change make work? you have register twigbundle , configure it. example can seen in symfony standard edition: app/config/config.yml : # twig configuration twig: debug: "%kernel.debug%...

php password hash - Call to undefined function password_hash() in PHP 5.4 -

i trying use password_hash() function in website, , getting error call undefined function password_hash(). checked server details in godaddy, , current version of php 5.4. how can fix this? password_hash() not available in php 5.4. new feature in php 5.5. in meantime can use this compatibility pack replacement . compatibility pack sidenote: this library requires php >= 5.3.7 or version has $2y fix backported (such redhat provides). note debian's 5.3.3 version not supported. for versions not covered these versions, consult: http://php.net/crypt - (php 4, php 5)

java - Lucene vs Solr, indexning speed for sampe data -

i have worked upon lucene before , moving towards solr. problem not able indexing on solr fast lucene can do. my lucene code: public class luceneindexer { public static void main(string[] args) { string indexdir = "/home/demo/indexes/index1/"; indexwriterconfig indexwriterconfig = null; long starttime = system.currenttimemillis(); try (directory dir = fsdirectory.open(paths.get(indexdir)); analyzer analyzer = new standardanalyzer(); indexwriter indexwriter = new indexwriter(dir, (indexwriterconfig = new indexwriterconfig(analyzer)));) { indexwriterconfig.setopenmode(openmode.create); stringfield bat = new stringfield("bat", "", store.yes); //$non-nls-1$ //$non-nls-2$ stringfield id = new stringfield("id", "", store.yes); //$non-nls-1$ //$non-nls-2$ stringfield name = new stringfield("name", "", store....

swift - iOS segue freeze for many seconds before showing new view -

in main view of app have table view , 2 prototype cells. have configured segues each cell using storyboard. in view controller override prepareforsegue pass information on selected cell destination view. the destination view isn't particularly complex , doesn't require heavy processing load. the problem when tap on cell in main controller first time, destination view appears after long delay, 5 40 seconds. edit #2 : subsequent taps faster note that: if tap on same cell again before destination view has appeared, triggers destination view appear immediately. as above, tapping on different cell results in view appearing data first cell. as above, tapping on different control (with no associated segues) triggers destination view appear immediately. subsequent "taps" manifest less delay. the time profiler - can see - shows absolutely nothing happening during many seconds of delay. i have tried different type of segues, made no difference a few prin...

java - Retrieving SQL query execution results asynchronously. -

after quite bit of research decided go ahead , write question may seem redundant here on stack-overflow, i'm asking because i've failed find answer. i've been having fun java nio2 framework has increased scalability of applications tremendously. (we using old-school i/o tpc server/client setup mildly populated emulation servers), , let me tell you. concurrency queen b if know mean. we're moving using threads answer (in attempt better practices , become more familiar advancing technology). using flat-file storage (text/binary format storage) user-data , have migrated on sql database. while doing i've noticed there's not problem, waiting on database never fun, , in emulated game-environment waiting database call never fun, when entire game-server waiting. substitute threading. why not execute sql call on thread using thread pool or similar. the java nio2 completablefuture<k,v> has been huge type of asynchronous event, i've been trying find wa...

Apache CXF + JavaFX No conduit initiator was found for the namespace -

i'm triying run javafx rest client using cxf. simple test. when try url org.apache.cxf.busexception: no conduit initiator found namespace http://cxf.apache.org/transports/http . took @ related questions here, no luck. appreciated. maven dependency added cxf-rt-rs-client 3.1.0 code is: webclient client = webclient.create("http://www.stackoverflow.com"); client.type("text/html").accept("text/html"); system.out.println(client.get()); stacktrace: caused by: org.apache.cxf.busexception: no conduit initiator found namespace http://cxf.apache.org/transports/http. @ org.apache.cxf.bus.managers.conduitinitiatormanagerimpl.getconduitinitiator(conduitinitiatormanagerimpl.java:110) @ org.apache.cxf.endpoint.abstractconduitselector.getselectedconduit(abstractconduitselector.java:104) @ org.apache.cxf.endpoint.upfrontconduitselector.selectconduit(upfrontconduitselector.java:77) @ org.apache.cxf.message.exchangeimpl.getconduit(exchangeimpl...

Understanding a PHP Generated JSON Array -

i'm trying make sense of json output , hoping here might kind enough walk me through it's been while since used json. i have following php $query01 = "select `department`,`departmentheadid` `department`"; $result01 = mysql_query($query01) or die("error 01: " . mysql_error()); while($r = mysql_fetch_array($result01)) { // create json data: $rows[] = $r; } // echo json_encode($rows); $data = json_encode($rows); echo '<pre>'; print_r(json_decode($data)); echo '</pre>'; which generates following: array ( [0] => stdclass object ( [0] => despatch [department] => despatch [1] => 1 [departmentheadid] => 1 ) [1] => stdclass object ( [0] => factory [department] => factory [1] => 2 [departmentheadid] => 2 ) [2] => stdclass object ( [0] => finishing [department] => finishing [1] ...

Javascript evaluating undefined expressions in OR statement -

so have statement looks this subsetsumarray[i][j]=(subsetsumarray[i-1][j] || subsetsumarray[i-1][j-arr[i]]); the problem when variable j less arr[i], subsetsumarray[i-1][j-arr[i]] return undefined. if subsetsumarray undefined treated false. whats shortest way this. i'd want work ( some undefined variable || true) ===> return true thanks in advance help! the shortest way double negative ( !! ) trick: subsetsumarray[i][j]=!!(subsetsumarray[i-1][j] || subsetsumarray[i-1][j-arr[i]]); see below code , run it: // empty array var = []; // var[1] undefined alert( a[1] ); // undefined alert(!! a[1] ); // false alert(a[1] || true); // true alert( a[1] || a[2] ); // undefined alert( !! (a[1] || a[2]) ); // false

python - SqlAlchemy get all strings (don't cast to boolean or datetime) -

how can change way sqlalchemy cast return values of select, returns strings, instead of booleans or datetime objects? i'm reading postgresql db. for example i'm getting this: >>>result = connection.execute("select * some_table").first() >>>result (123, 'some string field', true, datetime.datetime(2015, 06, ....)) when this: >>>result ('123', 'some string field', 'true', '2015-06-13....') how about: result = tuple([str(col_value) col_value in result]) if conversion happen on db side, have perform cast(...) function on each column separately.

android - Listview is not visible with other elements on top of it -

Image
i'm trying create ui attached image. xmal code below. there 1 main issue i"m running into. understand can't embed listview within scrollview . problem is, because of stuff on top of listview, small portion of listview shown no matter kind of height give parent linearlayout. how can layout ui listview visible , can scrolled other ui elements on top of it? suggestion apperciated. in advance <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:minwidth="25px" android:minheight="25px" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/bkicon" android:id="@+id/linearlayout1"> <linearlayout android:orientation="horizontal" android:minwidth="25dp" android:minheight="...

javascript - I can not hold a session variable passing by get -

good afternoon, hope can me code, , have 4 hours searching , can not find error, i'm doing exchange, variables stored in session, problem $discount being cleared every time added, delete, delete or update product, put off variable remains active others. this code: <!doctype html> <html> <head> <meta charset="utf-8"> <title>vender</title> <style> body { width: 80%; margin: 0 auto; padding: 20px; } table { width:100%; margin: 0 auto; border: 1px solid black; border-collapse: collapse; padding: 3px; } td { border: 1px solid black; border-collapse: collapse; } form { display: inline-block; margin-right: 10px; margin-bottom: 10px; } table { margin-bottom: 10px; } </style> </head> <body> <?php //iniciamos sesion session_start(); //conectamos la...

c# - Cannot add image asp.net mvc 5 -

i have model of client property — public string photopath {get; set;}. i'm trying add image in create httppost method: public actionresult fileupload(httppostedfilebase file, guid id) { if (file != null) { string pic = system.io.path.getfilename(file.filename); string path = system.io.path.combine( server.mappath("~/images/profile"), pic); file.saveas(path); client client = db.clients.find(id); if (client == null) return httpnotfound(); client.photopath = path; viewbag.imagepath = path; } return redirecttoaction("create"); } there view (with buttons adding): @using (html.beginform("fileupload", "clientscontroller", formmethod.post, new { enctype = "multipart/form-data", id = model.Сlientidentificator })) { <label for="fil...

powershell - Retrieve a random number of items from a randomized array -

in powershell v4, need read in contents of file contains skus , associated product names (likely comma-delimited), randomize entries, display random number of resulting skus , names. instance, there may file 12 product names , associated skus in it. on first run, might result in this: sku: 123456, productname: apples sku: 789012, productname: oranges ...and next time it's run, might result in this: sku: 524367, productname: bananas sku: 235023, productname: avocados sku: 123456, productname: apples sku: 543782, productname: peaches ...and on. number of entries in list of skus , products large twenty thousand, i'd need display between 1 , fifty skus , products @ time. there way accomplish within powershell? i'm new powershell, have basics down; far, have done lot of get-wmiobject commands or interacting processes , services. forgive wordiness remarks below; i'm trying make goal , process plain possible. # create arrays of skus , product names (i have...

How to remove/delete a row in javascript array by having value of first item of array row? -

i create array this: var myarray = new array(); myarray.push({ url: urlvalue, filename: filenamevalue }); urlvalue , filenamevalue javascript variables. after while array lots of items , if want delete row having urlvalue how can delete row?(by row mean delete urlvalue , filenamevalue).for example want delete row has urlvalue= http://www.somsite.com/pics/picture12.jpg , filenamevalue=picseasonnewname.jpg you can remove entire object array using function removerow(value){ for(var i=0; i<myarray.length; i++){ if(myarray[i].urlvalue == value) myarray.splice(i,1); } }

ios - Am I Querying and Subclassing Correctly? -

below code using query object parse: func findemployeeforloggedinuser(completion: (array: [anyobject], error: string?) -> void) { var query = pfquery(classname: "employee") query.wherekey("employerid", equalto: pfuser.currentuser()!.objectid!) query.findobjectsinbackgroundwithblock { (results, error) -> void in println(results) var employeearray = results if let error = error { let errorstring = error.userinfo?["error"] as? string if let objects = employeearray { completion(array: objects, error: errorstring) } else { completion(array: [], error: errorstring) } } else { completion(array: employeearray!, error: nil) } } } below code subclass of pfobject declared: class pfemployee: pfobject, pfsubclassing { override class func initialize() { self.registersubclass() } class func parseclass...

r - Using dplyr to transform two columns to 625 columns -

i have function my_function takes 2 arbitrary-length numeric vectors , transforms single numeric vector has 625 dimensions. i have dataframe data includes 3 columns: factor group, numeric variable x, , numeric variable y. i want operation along these lines: library(dplyr) data %>% group_by(group) %>% summarize(my_625_new_columns=my_function(x, y)) the result should 626 column dataframe: 1 column group , 625 columns corresponding each element in output of my_function. there should 1 row per group. is possible within dplyr's framework? you use ddply plyr this. do works dplyr . ## data set.seed(0) dat <- data.frame(group=factor(rep(1:2, 100)), x=rnorm(100), y=rnorm(100)) ## random function apply groups ## returns data.frame same number of columns length of x , y func <- function(x, y) as.data.frame(t( (x+y)/2 )) library(plyr) res <- ddply(dat, .(group), function(x) { func(x$x, x$y) }) res # group v1 v2 v3...

node.js - Push new items into JSON array -

let's table inside collection: { "_id" : objectid("557cf6bbd8efe38c627bffdf"), "name" : "john doe", "rating" : 9, "newf" : [ "milk", "eggs", "beans", "cream" ] } once user types in input, sent node server, , node server adds item list "newf" , sent mongodb , saved. i'm trying use update, can change values inside of table, i'm not sure how add new items onto list. did $push inside mongodb shell , not sure how on node. here's snippet of code: db.collection('connlist').update({ _id: new objectid("e57cf6bb28efe38c6a7bf6df")}, { name: "johndoe", rating: 9, newf: ["milk, eggs", "beans"] }, function(err,doc){ console.log(doc); }); well syntax adding new items same in shell: // make sure imported "objectid" var objectid = req...

ios - Why is my tableview blank after using UISearchResultsUpdating cancel button? -

i have tableview loads function , displays data in viewdidappear. same tableview (i assume) used when user taps on searchbar in navigation title, , searches query. the problem after user taps cancel button: function calling original data performs , prints correct data, doesn't appear on screen after tableview.reloaddata. i've tried placing function in various places (didcancel, didendediting), , function called/correctly returns data, doesn't appear on table. any suggestions or workarounds? class locationviewcontroller: uiviewcontroller, uitableviewdelegate, uitableviewdatasource, uisearchresultsupdating, uisearchbardelegate, uisearchcontrollerdelegate { override func viewdidload() { super.viewdidload() tableview.delegate = self tableview.datasource = self } override func viewwillappear(animated: bool) { self.load0() tableview.reloaddata() self.locationsearchcontroller = ({ let controller = uisearchcontroller(searchresu...

excel vba - Show or hide a worksheet using a single button -

i have user form single button. question: possible show or hide worksheet using single button? if code like? i tried 1 far: private sub data_button_click() if data_button.caption = "hidden" worksheets("u").visible = true data_button.caption = "visible" end if if data_button.caption = "visible" worksheets("u").visible = false data_button.caption = "hidden" end if end sub merge 2 if statements 1 this: private sub data_button_click() if data_button.caption = "hidden" worksheets("u").visible = true data_button.caption = "visible" elseif data_button.caption = "visible" worksheets("u").visible = false data_button.caption = "hidden" end if end sub

javac - java file compilation with file extension -

when compile java program use javac file.java command while running use java file . so why necessary explicitly specify file extension while compiling , not needed when run java program? because when "run" java .class compiled file telling java application launcher class contains main method. launcher starts java runtime environment , loads specified class. if write java myclass , class main method myclass . note erroneous write java myclass.class , since myclass.class not name of class. when compile javac myclass.java need tell java compiler extension, because file , need find it.

if statement - How to break if-else-if using C# -

how break if-else-if.....why not working? checking conditions instead of performing tasks. following code. have checked through breakpoints moving conditions why doesn't stop after meeting correct condition. not going if activity read conditions , nothing @ end. private void showhash() { inpic = pb_selected.image; bitmap image = new bitmap(inpic); byte[] imgbytes = new byte[0]; imgbytes = (byte[])converter.convertto(image, imgbytes.gettype()); string hash = computehashcode(imgbytes); txt_selectedtext.text = hash; gethash(); } private void gethash() { if (txt_sel1.text == null && (txt_sel2.text == null || txt_sel3.text == null || txt_sel4.text == null || txt_sel5.text == null )) { txt_sel1.text = txt_selectedtext.text; return; } else if (txt_sel1.text != null && (txt_sel2.text == null || txt_sel3.text == null || txt_sel4.text == null || ...

opengl es - Android OpenGLES Brown square -

so i'm trying learn opengles 2.0 , create textured rectangle. apparently didn't follow instructions , i've ended odd color square. heres shaders. final string vertexshader = "uniform mat4 u_mvpmatrix; \n" // constant representing combined model/view/projection matrix. + "attribute vec2 a_texcoordinate;\n" // per-vertex texture coordinate information pass in. + "attribute vec4 a_position; \n" // per-vertex position information pass in. // + "attribute vec4 a_color; \n" // per-vertex color information pass in. // + "varying vec4 v_color; \n" // passed fragment shader. + "varying vec2 v_texcoordinate; \n" // passed fragment shader. + "void main() \n" // entry point our vertex shader. + "{ \n" + " ...

javascript - jQuery detect scroll reach bottom not working on mobile browsers -

i' trying detect when user scroll down bottom of web page load show contents when user scroll near bottom, i use below function works on desktop web browsers, not worked on mobile browsers. jquery(function(){ jquery(document).scroll(function () { if (jquery(window).scrolltop() + jquery(window).height() > jquery(document).height() -100) { //show contents alert('near bottom') } }); }); this working website applied above http://discount.today/ when scroll down shows products, working on normal browsers not on mobile browsers, can me fix issue please. tried lots of solution on internet no luck, thank you mobile webs different desktop webs. reason simple, margins , padding different. your website doesn't know how detect change has occurred when running on mobile far web's concern, didn't reach bottom. you need use css 3 maybe or jquery, signal web change in platform made, site smaller , bottom of page....

jasper reports - Jspersoft, How to change the null label in input controls from "---" to "ALL"? -

how change null label in input controls "---" "all"? the input control combobox, single value select query. you can create variable , put parameter in. use replace on input parameter change value of input parameter "---" "all". after use variable instead of input parameter. hope :)

powershell - Match the User Name against the Security EventLog -

i want take domain user , want check security event logs logon , print events match returns me null value: get-eventlog -log security -computer pc1 -instanceid 4624 -after(get-date).adddays(-2) | ? { $_.message -match "account name:\s+qasimali\s" -and $_.message -match 'logon type:\s+(2|10)\s" } but generates no data output read-host : name cannot null or empty. whereas command runs , gives no error. want check whether command running fine or not. the way have done in past follows ( thoroughly commented clarity) : ## set username input $userinput = "domainuser" ## set date in past retrieve events $starttime = ((get-date).addminutes(-2)) ##set domain controller search on $computername = "dc1" ## retrieve event 4624 dc eveng logs $logons = get-winevent -computername $computername -filterhashtable @{logname="security"; id="4624"; starttime=$starttime;endtime=(get-date)} ## initialize variable st...

php - Display multiple rows in html -

i having issue pulling info database , displaying on page. in table have multiple entries in each column. need pull info , display in descending order column id. displays rows on page: ### ### ### #1# #1# #1# ### ### ### ### ### ### #2# #2# #2# ### ### ### ### ### ### #3# #3# #3# ### ### ### i can't figure out doing wrong here. it's been little bit since did php , mysql may writing incorrectly don't know. <? require 'dbinfo.php'; $link = mysqli_connect($servername, $username, $password); if (!$link) { die('could not connect: ' . mysqli_error($link)); } mysqli_select_db($link, $database) or die(mysqli_error($link)); $query = "select `id`, `build`, `buildby`, `description`, `download` `buildlist` order id desc"; $result = mysqli_query($link,$query) or die(mysqli_error($link)); $row = mysqli_fetch_row($result); $num = mysqli_num_rows($result); ?> <? $num = mysqli_num_rows($result); ...

parse.com - How should I handle secret tokens for open source android projects? -

i learning build android app parse. instructed, need initialize parse sdk following method in application.java : parse.initialize(context context, string applicationid, string clientkey) and question how should handle applicationid , clientkey in android project not expose them on github? for web projects, there app.conf.example copy app.conf , listed in .gitignore . when setting local or production environments, need put correct secret tokens in app.conf manually. i wanna know there android app development? thank much! short solution : i think can put that, e.g : parse.initialize(context context, string applicationid, string clientkey) on application.java. commit as-is, , use correct applicationid , clientkey locally. this because there no notable changes application.java class, in case need change something, remove correct code, edit class, push github, , put correct code locally.

c# Animation, using TranslateTransform and DoubleAnimation -

Image
i have simple map , square move point d, through b , c. i've declared method animate: public void animate(double[] firstpoint, double[] secondpoint, image img) { double x1 = firstpoint[0]; double x2 = secondpoint[0]; double y1 = firstpoint[1]; double y2 = secondpoint[1]; translatetransform trans = new translatetransform(); img.rendertransform = trans; doubleanimation anim1 = new doubleanimation(y1, y2, timespan.fromseconds(1)); doubleanimation anim2 = new doubleanimation(x1, x2, timespan.fromseconds(1)); trans.beginanimation(translatetransform.yproperty, anim1); trans.beginanimation(translatetransform.xproperty, anim2); } the main problem when use method this: obj.animate(obj.a, obj.b, car); obj.animate(obj.b, obj.c, car); obj.animate(obj.c, obj.d, car); ...there's animation shown point c d. when added messagebox.show animate method, displayed animation properly. i feel...

ios - Get Unresolved Identifier for MMWormhole in Watch InterfaceController.swift -

my apple watch project in swift. have used cocoapods install mmwormhole, , created bridging header described in these links: http://bencoding.com/2015/04/15/adding-a-swift-bridge-header-manually/ how call objective-c code swift when created bridging header, target iphone app, , watch extension. the bridging header.h, have this: #import "mmwormhole.h" in iphone app view controller, have this: import uikit import foundation let wormhole = mmwormhole(applicationgroupidentifier: "group.cocosharedata", optionaldirectory: "wormhole") and there no complain. however, in watch interface controller, have this: import watchkit import foundation ... override func willactivate() { // method called when watch view controller visible user super.willactivate() let wormhole = mmwormhole(applicationgroupidentifier: "group.cocosharedata", optionaldirectory: "wormhole") } and complains "use of un...

servlets - Download a file from the server in gwt -

i've made application using gwt , works far. creates file on server. try download file. tried with window.open(gwt.gethostpagebaseurl() + "file.xml", "file.xml", ""); but that, browser opens file, cause xml, instead of download it. after tried with <iframe src="javascript:''" id="__gwt_downloadframe" tabindex='-1' style="position: absolute; width: 0; height: 0; border: 0; display: none;"></iframe> in web.xml , public static void triggerdownload(final string url) { if (url == null) { throw new illegalargumentexception("url must not null"); } // if if (downloadframe == null) { downloadframe = frame.wrap(document.get().getelementbyid("__gwt_downloadframe")); } // if downloadframe.seturl(url); } // triggerdownload() in client side, url=gwt.gethostpagebaseurl() + "epk.epml" this...

javascript - Having trouble stepping through function that reduces an array of functions -

when using reduce method on array of functions having difficulty tracing through how reduce works on array exactly. combofunc(num, functionsarr) { return functionsarr.reduce(function (last, current) { return current(last); }, input); } so functionsarr = [add, multi] , functions add , multi being function add(num) { return num + 1; } and function multi(num) { return num * 30; } the function combofunc would: combofunc(2, functionsarr); //returns 90; i understand how reduce method works on array of numbers folding array 1 value were, applying function each element of array. example combofunc taking array of functions parameter uses simple enough math can understand how reduce produces value of 90 mathematically don't understand happening line line , on each iteration functional level. i'm unable articulate in mind happening when---how input of 2 getting passed function function vis-a-vis closure , sequential firing off of each function, etc. i...