Posts

Showing posts from 2015

java - Why is there a "deadbranch" in my code? -

below code working fine until last if-else. appears i've done wrong boolean variables cangraduate , onprobation. perhaps i'm reassigning them incorrectly in prior if-else statements. deadbranch occurs @ else half of last if-else. package lab5; import java.util.scanner; public class lab5 { public static void main(string[] args) { //creates scanner object scanner scanner = new scanner(system.in); //part ii //creating variables double gpa; int totalcreditstaken; int mathsciencecredits; int liberalartscredits; int electivecredits; boolean cangraduate = true; boolean onprobation = false; //prompts user imput system.out.println("what gpa?"); gpa = scanner.nextdouble(); system.out.println("what's total amount of credits you've taken?"); totalcreditstaken = scanner.nextint(); system.out.println("how many math , science credits have taken?"); mathsciencecre...

c - Calling close() on a valid file descriptor for a COM port blocks forever if the device has been powered off on Mac OS X -

i'm writing application in c on mac os x communicates bluetooth device using com ports. if bluetooth device powered off after connection has been made, subsequent calls close block indefinitely. note using aio_read , aio_write read , write device. if device left powered on, close succeeds expected. example: /* open com port */ int fd = open (g_comname, o_rdwr | o_noctty | o_async ); /* ensure fd valid, work, power off bluetooth device */ /* wait until aysnc io complete */ while (aio_cancel(fd, null) == aio_notcanceled) {} /* application hang here */ close(fd); what doing wrong? guess os waiting confirmation device, never gets anything. there anyway force close connection? edit: as suggested, setting o_nonblock did trick: fcntl(fd, f_setfl, o_async)

permissions - PhpStorm 9: Why doesn't the remote path's directories/files display when connected via FTP -

Image
i trying connect remote host in phpstorm 9 via ftp , connects host not display files/directories. i able ftp , see files/directories fine via filezilla same ftp profile/settings used in phpstorm 9. why not able see files/directories via ftp in phpstorm 9? try switching between active ans passive ftp modes (option located in advanced options dialog of deployment settings/preferences page.

php - Why is APCu segfaulting inside a Docker container? -

i'm trying run php 5.5 (with fpm) apcu inside docker container. i'm using boot2docker on osx. when try run php-fpm -i , segfaults. running in gdb , following backtrace: (gdb) run -i starting program: /usr/local/sbin/php-fpm -i [thread debugging using libthread_db enabled] using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". program received signal sigsegv, segmentation fault. 0x00007ffff542474c in __pthread_rwlock_init (rwlock=rwlock@entry=0xffffffffffffffff, attr=attr@entry=0x7ffff1bda988 <apc_lock_attr>) @ pthread_rwlock_init.c:40 40 pthread_rwlock_init.c: no such file or directory. (gdb) bt #0 0x00007ffff542474c in __pthread_rwlock_init (rwlock=rwlock@entry=0xffffffffffffffff, attr=attr@entry=0x7ffff1bda988 <apc_lock_attr>) @ pthread_rwlock_init.c:40 #1 0x00007ffff19ca9d0 in apc_lock_create (lock=lock@entry=0xffffffffffffffff) @ /tmp/pear/temp/apcu/apc_lock.c:180 #2 0x00007ffff19d0135 in apc_sma_api_init (sma=0x7fff...

java - Having trouble removing from a queue and adding to another -

i have input file containing many strings , ints. ex. blah 40 hello 10 asdf 20 etc... i have read them queue hold them. need take them out of queue , add priority queue whenever int equals ints in data file. this have far.. for(int = 0; i<=50; i++) { object x = normalqueue.dequeue(); //this makes x equal line of data file dequeued. if(i == x.secondint) //secondint objects method gets integer in data file { pqueue.insert(x); //inserts x pqueue if = second int in data file } else { normalqueue.enqueue(x); //adds x queue1 normalqueue.switchends(); //swaps 1st , last node } } the problem having is printing out 2 files of data file. i'm not quite sure intend happen when running code, happen this: given following input: blah 40 hello 10 asdf 20 (i'm assuming add elements of queue when reading file, ordering data-file retained) in first 40 iterations of loop taking "blah 40" out o...

unity3d - Why is my Object not filled -

i trying create select object script in unity. what should when hover on object colors red (and does) , when press "1" gameobject's targethighlighted filled object hovering on @ moment. in debug.log works fine, targethighlighted is filled. when press "1" targethighlighted object still left empty. doesn't matter if press while hovering on object or away it. my full code more extensive this. section of code contains problem, reduced this. can explain me how come when press "1" the debug.log doesn't show targethighlighted or targetselected ? basically why mouseenter , mouseexit log right object, settarget function doesn't? using unityengine; using system.collections; public class targetselectionscript: monobehaviour { // store current selected gameobject gameobject targethighlighted; renderer rend; color initialcolor = color.white; color selectedcolor = color.red; public gamecontrollerscript gam...

java - maven 3.3 support for Websphere 8.5.5 - pom.xml -

i not find way deploy war file in websphere 8.5.5 using maven's pom.xml. see there plugin called was6-maven-plugin-1.2.1. , can support 6+, 7+, 8+ seems. but not deploy war file using plugin. throws following error. [error] failed execute goal org.codehaus.mojo:was6-maven-plugin:1.2.1:installapp (default-cli) on project test: bad archive: c:\test.war -> [help 1] please comment on... my pom.xml configuration fyr: <plugin> <groupid>org.codehaus.mojo</groupid> <artifactid>was6-maven-plugin</artifactid> <version>1.2.1</version> <executions> <execution> <id>integration-test</id> <phase>integration-test</phase> <goals> <goal>installapp</goal> </goals> </execution> </executions> <configuratio...

javascript - Same Height DIV's using NG-Repeat -

i'm having issue trying 2 divs side side same height when content each of divs generated using ng-repeat. flex box stops site being responsive , can't work out when suitable time call jquery function views nested , page doesn't load when new html displayed. have tried ng-repeat-start , end no avail. ideally once content has loaded div on right same height div on left. appreciate problem. cheers edit - code included <div class="row"> <div class="nospacing col-xs-6"> <div class="col-xs-12 nospacing rottnestgreen"> <div ng-repeat="bh in bikehire" class="row"> <p class="col-xs-6">{{bh.type}}</p> <select class="inline col-xs-3 nospacing np" ng-model="bikehire[$index].quantity" ng-options="ddl ddl in ddlnumbers" ng-change="addops(bh.type, bikehire[$index].q...

javascript - When shall one make a function return a promise? -

i'm getting generators , promises , i've kind of gotten handle of how work. it's time make own functions utilize these. there guides out there explaining how make them , discuss appropriate times when 1 should used. i know has lie promises generators code writing synchronous (among other things). so question is: when should , when should not promisify function have? from understanding if cpu being utilized 100% function should not promisify there no point. if cpu being blocked , waiting external such waiting download guess should promisify function. promises should used when have asynchronous operations want execute in sequence. operations costly, writing file/db, making request service, forth, have asynchronous api, since doing synchronously block single-threaded javascript application. in cases, either use promises cleaner code, use named functions , explicitly call them 1 after other callbacks or don't use , have pyramid of doom full of callbac...

ios - No 750x1334 Launch Image option available in Xamarin for iPhone 6s? -

title pretty explains itself. under info.plist have options add 320x480, 640x960, , 640x1136 launch images, developing iphone 6s....is 640x1136 1 want or there kind of bug no 750x1334 option showing? you need set of launch images in info.plist, should use new storyboard or xib launch screen option: https://developer.xamarin.com/guides/ios/application_fundamentals/working_with_images/launch-screens/ to set images need use asset catalog: https://developer.xamarin.com/guides/ios/application_fundamentals/working_with_images/launch-screens/#managing_launch_screens_with_asset_catalogs or can specify in info.plist manually: http://conceptdev.blogspot.com/2014/09/iphone-6-and-6-plus-launch-images-for.html

html - How to create new top headers for weebly -

on weebly.com same 4 headers landing page, no header, small header, large header... how go summing of them 1 header of own similar website? https://www.revivalgame.com/ they have 1 overall header , navigated pages show beneath it. weebly capable of through it's html/css? a quick google search revealed weebly indeed have html/css editor. for example, header image css rule similar this: .wsite-header { background: transparent url(%%headerimg%%) no-repeat center top; width:750px; height:250px; } check out link: weebly custom editor

parsing - java.text.ParseException: Unparseable date "yyyy-MM-dd'T'HH:mm:ss.SSSZ" - SimpleDateFormat -

i appreciate finding bug exception: java.text.parseexception: unparseable date: "2007-09-25t15:40:51.0000000z" and following code: simpledateformat sdf = new simpledateformat("yyyy-mm-dd't'hh:mm:ss.sssz"); date date = sdf.parse(timevalue); long mills = date.gettime(); this.point.time = string.valueof(mills); it throws expcetion date date = sdf.parse(timevalue); . timevalue = "2007-09-25t15:40:51.0000000z"; , in exception. thanks. z represents timezone character. needs quoted: simpledateformat sdf = new simpledateformat("yyyy-mm-dd't'hh:mm:ss.sss'z'");

windows - How to fill the page and adjust text position according to resize -

i'm new xaml , windows 10 gui programming. want design page textblock, listbox , button, centered in page. want textblock , button reside @ top , bottom of page no matter how users resize window. listbox should stretch fill gap between textblock , listbox automatically. have tried set verticalalignment different value, doesn't seem anything. <page x:class="firstwin10.mainpage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:firstwin10" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:ignorable="d"> <stackpanel background="{themeresource applicationpagebackgroundthemebrush}" orientation="vertical"> <textblock x:name="textblock" horizontalalignment="center" margin="1...

multithreading - My message loop in thread is not getting any messages -

i have created thread, want listen mouse messages app receives. however peekmessage never returning true. tried min , max filter of 0. here message loop: peekmessage(lmessage, null, 0, 0, pm_noremove); while (true) { var rez = peekmessage(lmessage, null, 0, 0, pm_remove) if (rez) { // console.log('peekmessage true'); } sleep 1000; } // console.log('message loop eneded'); as hwnd null thought should receive messages window in app, im not getting though. know whats up? i tried getmessage approach: var rez = getmessage(lmessage, null, 0, 0); console.log('rez:', rez); however hangs , never gets console.log . thanks the documentation peekmessage says: if hwnd null, peekmessage retrieves messages window belongs current thread , , messages on current thread's message queue hwnd value null. [emphasis added] a similar note in getmessage documentation. the call getmessage stalls because the...

c# - How do you reference the executing assembly in DNX Core 5.0 (ASP.NET 5)? -

i porting code .net 3.5 - 4.5. inside of assembly, have code reads resource executing assembly. however, getexecutingassembly() isn't method on assembly type in dnx core 5.0. var xsdstream = assembly.getexecutingassembly().getmanifestresourcestream(xsdpath); what equivalent of assembly.getexecutingassembly() in dnx core 5.0? or if need namespace method (an extension method perhaps?), namespace? typeof(<a type in assembly>).gettypeinfo().assembly

android - Calling stopService in onActivityResult() is not effective -

in onactivityresult, wanted stop , restart service. i'm not able stop service code below. if (requestcode == device_selection) { if(resultcode == result_ok) { intent = new intent(this, myservice.class); stopservice(i); } } in debugging mode, able reach stopservice() line, app never calls ondestroy() of myservice class (which extends service class) , service not destroyed. does have idea why case? my service can started , able destroy service when stopservice() called in ondestroy() method of activity indicates me service class implemented correctly. you need cache intent have started service use same intent stop service, work for example lets intent = new intent(this, myservice.class); intent used start service startservice(i) , use same intent stop it. don't create new intent.

c++ - read string into array -

i want read string integers , whitespaces array. example have string looks 1 2 3 4 5, , want convert integer array arr[5]={1, 2, 3, 4, 5}. how should that? i tried delete whitespaces, assign whole 12345 every array element. if don't element assigned 1. for (int = 0; < str.length(); i++){ if (str[i] == ' ') str.erase(i, 1); } (int j = 0; j < size; j++){ // size given arr[j] = atoi(str.c_str()); } a couple of notes: use std::vector . never know size of input @ compile time. if do, use std::array . if have c++11 available you, maybe think stoi or stol , throw upon failed conversion you accomplish task std::stringstream allow treat std::string std::istream std::cin . recommend way alternatively, go hard route , attempt tokenize std::string based on ' ' delimiter, appears trying do. finally, why reinvent wheel if go tokenization route? use boost's split function. stri...

java - Android app won't build - Fails with an exception -

in android studio, when try build app nothing base activity in it, i'm presented error says: execution failed task ':app:packagedebug'. > implementing class someone told me give them stack trace, later didn't respond. when used --stacktrace when building, i'm presented this: * exception is: org.gradle.api.tasks.taskexecutionexception: execution failed task ':app:packagedebug'. @ org.gradle.api.internal.tasks.execution.executeactionstaskexecuter.executeactions(executeactionstaskexecuter.java:69) @ org.gradle.api.internal.tasks.execution.executeactionstaskexecuter.execute(executeactionstaskexecuter.java:46) @ org.gradle.api.internal.tasks.execution.postexecutionanalysistaskexecuter.execute(postexecutionanalysistaskexecuter.java:35) @ org.gradle.api.internal.tasks.execution.skipuptodatetaskexecuter.execute(skipuptodatetaskexecuter.java:64) @ org.gradle.api.internal.tasks.execution.validatingtaskexecuter.execute(validatingtaskexecuter.java:58) @ org...

java - Data does not appear in javafx Table View -

im trying make gui program using javafx. program supposed take data csv file, store in public list , display in javafx tableview in gui controller class. here controller code package controllers; import java.io.ioexception; import java.net.url; import java.util.resourcebundle; import javafx.collections.fxcollections; import javafx.collections.observablelist; import javafx.event.actionevent; import javafx.fxml.fxml; import javafx.fxml.fxmlloader; import javafx.fxml.initializable; import javafx.scene.parent; import javafx.scene.scene; import javafx.scene.control.button; import javafx.scene.control.tablecolumn; import javafx.scene.control.tableview; import javafx.scene.control.cell.propertyvaluefactory; import javafx.stage.stage; import application.main; import application.tablaest; public class controllerver1 implements initializable { public stage stage = new stage(); private observablelist<tablaest> data = fxcollections.observablearraylist(); @fxml ...

android - Converting Facebook ProfilePictureView to bitmap to use in ImageView -

i trying convert profile image returned facebook , change bitmap can use in method requires bitmap. i'm able profile picture using code below , put profilepictureview. created 2 other views testing...a circleimageview , imageview. far profilepictureview shows image. here example of code tried, although have tried several methods i've found on web create bitmap , none have worked. suggestions/solutions appreciated! profilepictureview profilepictureview; profilepictureview = (profilepictureview) findviewbyid(r.id.facebookpictureview); profilepictureview.setprofileid(userid); //this works , set profile pic standardimageview = (imageview) findviewbyid(r.id.imageview); circleimageview = (circleimageview) findviewbyid(r.id.profimage); asynctask<void, void, bitmap> t = new asynctask<void, void, bitmap>() { protected bitmap doinbackground(void... p) { bitmap bmp = null; try { url aurl = ne...

how to chop out an ipaddress from a packet using java -

"i have packet format(srcip,destip,protocol number,frame length)in files in file.i need scrip. 49.112.250.206,0.217.206.74,17,1458 25.82.23.122,211.231.164.237,6,46 218.55.186.252,211.231.171.101,6,46 36.63.70.74,73.151.138.2,6,1504 232.60.178.64,78.217.241.214,6,1504 181.175.235.118,58.57.101.205,6,1504 133.203.23.94,74.110.251.121,6,1504 ...... ......" for (list<string> read : readfiles.values()) { while(last>=0) { last=1; string element=read.get(first); stringtokenizer st=new stringtokenizer(element, ","); //int token=integer.parseint(st.nexttoken(",")); first++; } } string tmp[]=element.split(" "); //get 1 one for(string s:tmp) { system.out.println(s.split(",")[0]); //get srcip }

android - Suggestions needed: Remove a background of a photo programmatically and retain the human/object image of the photo -

i trying develop small android app, photo taken selfie cam/gallery. once photo chosen in app, app redirects next activity. there button in new activity. work of button remove background of photo , retain object/human image (which equivalent photo shop quick selection tool). i stuck implementation of cropping part. suggestions valuable development. 1) there libraries/ apis image processing? 2) there app has done part before? can use app communicate app , retrieve cropped image back? 3) if there no ready made api/app, how go forward development? 4) if 3 option, in how many days can achieve cropping part work?

java - no error then why ObservableList is not working in this project? -

Image
i saw project in previous answer , tried run didn't how pass data parsed text file , insert values observablelist in javafx? data inputted text file table view , piechart javafx, work except pie chart trying data table view pie chart, have done after few edits can't run anymore the problem in observablelist piechartdata = fxcollections .observablearraylist() this code package show; import java.io.bufferedreader; import java.io.ioexception; import java.nio.charset.standardcharsets; import java.nio.file.files; import java.nio.file.path; import java.nio.file.paths; import java.util.arraylist; import java.util.list; import javafx.application.application; import javafx.beans.property.simpledoubleproperty; import javafx.beans.property.simpleintegerproperty; import javafx.beans.property.simplestringproperty; import javafx.collections.fxcollections; import javafx.collections.observ...

oracle - Varchar2 datatype allows systimestamp -

i have 1 table varchar2 datatypes below create table t11 (aa varchar2(100),bb varchar2(100)); now, if trying insert systimestamp above, values getting inserted: insert t11 values (systimestamp,systimestamp); commit; question why conversion allowed in oracle. i using oracle 11g. your column type varchar2 , return type of systimestamp timestamp . timestamp can not stored directly varchar2 column, oracle implicitly convert timestamp value varchar2 rule specified in init parameter, nls_timestamp_format . you can read data conversion rules , nls_timestamp_format more detail.

Why does this statement work in Java? -

i accidentally wrote on netbeans: system.out.println(("apples") system.out.println("oranges")); it showed me no error, compiled , output was: apples oranges after running started showing me error still compiled , gave same output. also, system.out.println((grade/=3) + "%") valid statement? edit: people saying not compiling, here screenshot: http://s1.postimg.org/m1ezmm3vz/untitled.png compiling me :/ the second statement valid: system.out.println((grade/=3) + "%"); here (grade/=3) calculated first , % appended. but system.out.println(("apples") system.out.println("oranges")); is invalid statement. case compiler generates compilation errors : error: ')' expected error: illegal start of expression error: ';' expected

php - Codeigniter form validate for optional fileds -

i have form fields email , phone.out of these 1 need filled. $this->form_validation->set_rules('phone[]', 'phone', 'trim|required|xss_clean'); $this->form_validation->set_rules('email[]', 'email', 'trim|required|xss_clean'); how can this? you need call callbabk function $this->form_validation->set_rules('phone[]', 'phone', 'trim|xss_clean'); $this->form_validation->set_rules('email[]', 'email', 'trim|xss_clean|callback_check_validation');// call calback in callback have check empty fields email , phone. function check_validation() { $phone=$this->input->post('phone'); $email=$this->input->post('email'); if(empty($phone) && empty($email)){// check empty of both filed $this->form_validation->set_message("check_validation", 'atleast phone or email required'); ...

How to replace null value of a String in java? -

i know it's dumb question still. but want know possible replace string set null ? string str=null; string str2= str.replace('l','o'); system.out.println(str2); currently giving me nullpointerexception . i want know possible how replace value of string set null ? if yes, how ? help appreciated. thanks use string.valueof() : string str2 = string.valueof(str).replace('l','o'); from javadoc of string.valueof(object obj) : if argument null, string equal "null"; otherwise, value of obj.tostring() returned. which of course string itself.

java - Two ArrayList in one ListView in Android -

please me in putting 2 arraylist in 1 listview only. display 2 columns database using 2 listview. im not in programming need guys. in advance this main activity public class mainactivity extends activity { datadb data = new datadb(); listview list; listview list2; arrayadapter<string> listadapter; public mainactivity() { } protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); list = (listview) findviewbyid(r.id.listview); list2 = (listview) findviewbyid(r.id.listview2); // set data arraylist<string> firstname = new arraylist<string>(); try { firstname = data.getfnamedb(this); } catch (sqlexception e) { e.printstacktrace(); } listadapter = new arrayadapter<string>(this, r.layout.support_simple_spinner_dropdown_item, firstname); // set adapter list.setadapter(listadapter); arraylist<string> lastname = ...

Ajax - Upload multiple files in one request using multipart form-data -

what best plugin upload multiple files in 1 request using multi-part form-data in ajax? i trying upload multiple files in 1 server call using ajax. but not find plugin satisfy requirement. any suggestions or working examples?

http - C# Console Application:Execute Javascript from HttpWebResponse String -

i making program using console application,i response text html page string,now want inject javascript code httpwebresponse , execute it.thanks. [ execute string in c# console app ] real requirement click ok button redirect new url ,then 1 of param of full url.

hadoop - get MAX from SUM in PIG -

player = load 'ass2_player' using org.apache.hive.hcatalog.pig.hcatloader(); player = foreach player generate (chararray)$3 tmid, (int)$1 year, (int)$8 points; group_data = group player (year, tmid); sum_data = foreach group_data generate group, sum(player.points) tot_points; max_data = foreach sum_data generate flatten(group), max(sum_data.tot_points); dump max_data; i want select tmid of team has highest point each year. how whole row or partial fields or row max value. like, after group year, group contains "year" , tuple take "tmid, tot_points". how got like: (year, tmid, tot_points) each year. you there. here schema sum_data : ((year, tmid), tot_points) from here, need group on year , take max on tot_points . easier if flatten group in sum_data step only, such as: sum_data = foreach group_data generate flatten(group) (year, tmid), sum(player.points) tot_points; sum_data_grouped = group sum_data year; max_dat...

android - HTML parser to create GTFS formatted data -

there transit agency, doesn't provide gtfs formatted transit schedule data. make android application, can search in it, format useful. transit schedule data has website, seems hard separate useful things. <td class="b stoppoint p0" background="nline.gif"><a href="line.cgi?id=1&dir=back&zero=15901&city=so&term=20141214"><img src="coming.gif" class="stoppoint" alt="a megállóhoz tartozó indulási időpontok megjelenítéséhez kérem, kattintson ide!" /></a></td> <td class="b stoptime p0">2</td> <td class="b stoppeaktime p0">2</td> <td class="b stopname p0" colspan="1">frankenburg úti aluljáró</td> <td class="b stoptransfer p0"><img src="transfer.gif" class="icontransfer" alt="Átszállási lehetőség felsorolt autóbuszvonalakra" />&nbsp;&nbsp;<a h...

xslt - How to use a variable value -

the variable behaviour here not work expected. have variable named fonttag value html line both start , end tags , divider. <xsl:variable name="fonttag"> <font face="angsana new" size="12">|</font> </xsl:variable> when try use it, part of string back, empty string: <xsl:value-of select="substring-before($fonttag ,'|')"/> where expected substring : <font face="angsana new" size="12"> similarly <xsl:value-of select="$fonttag"/> returns nothing, although <xsl:copy-of select="$fonttag"/> return whole string. there way achieve expected result ? a derived-question : possible nest xsl select tags (cannot work either) <xsl:copy-of select="substring-before( <xsl:copy-of select="$fonttag"/>,'|')"/> ? thanks i afraid misunderstand how xslt works. variable not contain string ...

javascript - android native webrtc vs browser webrtc performance -

i have question related performance of 2 types of application - javascript browser application supports webrtc video/audio or native android webrtc app? have working webrtc application browser noticed after time using app becomes slow , not responsive ( during video call ). decided compare native , browser app. managed run apprtcdemo app here on octa core tablet: http://www.webrtc.org/native-code/android i spent 1 day testing native , javascript webrtc app , noticed there no difference of both apps. ran loopback test on same devices , turned on statistics (for browser app chrome://webrtc-internals , native app there option showing same statisics)the fps same, widht , height differs same , other statistics. thought native significant faster browser app. why webrtc behavior same on native , browser app?

php - Warning: Creating default object from empty value -

i'm checking whether or not username , email user has entered taken. works fine; if it's in use doesn't register account , informs user, if it's not taken account made, however, warning message regardless. this error coming from, based off tutorials have been using code should work fine: $sql = "select username, email users username = $username , email = $email"; $result = $conn->query($sql); if ($result->num_rows = 0) change : if ($result->num_rows = 0)//assignment to: if ($result->num_rows == 0)//condition checking.

php - How to Return a Text with an Image in Laravel 4 -

i'm working on laravel 4 application , wrote method called show() inside controller gets id route , makes array of elements database, these elements returned image. can return image without text using response::make() , header, if bind data can't read image. i tried : public function show($id){ $onlinead = onlineads::where('id', $id)->get(array('title', 'short_description', 'full_description')); $filename = onlineads::find($id)->image; $path = 'app/storage/uploads/mobile/' . $filename; return response::json([ "data" => $onlinead, "image"=> base64_encode(file::get($path)) ]); } this returns data perfectly, image returns unreadable text instead. suggestions? i assume don't in view, meant "code handles displaying of image" before inserting in src attribute, should format image payload properly. change bit of code so: return re...

How to compare random numbers in Swift -

Image
i’m beginner in programming , playing around arc4random_uniform() function in swift. program i’m making far generates random number 1-10 regenerated uibutton. however, want variable ’highest' gets initialised random number update if next generated number larger 1 held in it. example random number 6 stored in highest , if next number 8 highest becomes 8. don't know how go this. have connected uibutton ibaction function , have following code: var randomvalue = arc4random_uniform(11) + 1 highest = int(randomvalue) if (int(randomvalue) < highest) { // don’t know } initialise highest 0 every time generate new random number, replace value of highest higher of 2 numbers highest = max(highest, randomvalue) the max() function part of swift standard library , returns larger of 2 passed in vales. edited add here's playground showing bit more detail, including casting of types: var highest: int = 0 func random() -> int { ...

php - DateTime returns wrong year -

my code following: <?php $newdate = new datetime('2012'); echo $newdate->format('y'); why $newdate->format('y') returns 2015 (current year) , not 2012? because 2012 not valid date string. default date , time set object current, 2015. can hint format going use datetime::createfromformat $date = datetime::createfromformat('y', '2012'); echo $date->format('y');

python - OpenCV's waitKey() alternative in IPython Notebook -

i'm trying show images cv2 library in jupiter notebook cv2.imshow(img) , shows expected, can not use or don't know how use cv2.waitkey(0) , hence cell not stop executing. cv2.waitkey(0) works in script, not in notebook. here's snippet: cv2.imshow('image', img) cv2.waitkey(0) cv2.destroyallwindows() how stop executing cell without restarting whole kernel? so, @micka, here's solution: you must write cv2.startwindowthread() first, explained here .

testing - Test file upload in Flask -

i have flask's controller (post) upload file: f = request.files['external_data'] filename = secure_filename(f.filename) f.save(filename) i have tried test it: handle = open(filepath, 'rb') fs = filestorage(stream=handle, filename=filename, name='external_data') payload['files'] = fs url = '/my/upload/url' test_client.post(url, data=payload) but in controller request.files contains: immutablemultidict: immutablemultidict([('files', <filestorage: u'myfile.png' ('image/png')>)]) my tests pass in case replace 'external_data' 'files' how possible create flask test request contains request.files('external_data') ?

vbscript - VB Script Dynamic Userform -

is possible create dynamic user form using vb script? form needs pull in values tool , excel sheet , should contain checkboxes , textboxes , ok buttons. (this script written inside tool). if guide me appreciate it. i'm new vb script , know how create msg boxes , text boxes. please help! you can start nice example in hta : hta input examples

jquery - notifyjs disappears without hide effect -

i have notification notifyjs jquery plugin. var notifyprops = {}; notifyprops.showanimation = 'slidedown'; notifyprops.showduration = 2500; notifyprops.hideanimation = 'slideup'; notifyprops.hideduration = 2500; notifyprops.style = 'mystyle'; notifyprops.clicktohide = true; var insertid = ("myid"+ math.random()).replace('0\.',''); //just id $.notify({title: $('<div id="'+insertid+'"></div>').append(elem.element)},notifyprops); the notification appears correctly showanimation of slidedown, when clicked, disappears instead of sliding up, or fading out if fadeout set hideanimation . i'm using addstyle define mystyle so: $notify.addstyle("mystyle", { html: "<div>" + "<div class='clearfix'>" + "<div class='lb-close'></div>" + "<div class='notify-title' data-notify...

javascript - use variable in pattern -

i new jquery have simple html textarea , want count specific word in text area , show count , highlight text too. $(document).ready(function() { $(".text").on('input',function(){ var a= $(".text").val(); //var a="i m running"; /*if(a==="nokia"){ alert("nokia found"); } else{ alert("not found"); }*/ var pattern = /nokia/; var pattern1 = /samsung/; var pattern2 = /iphone/; var pattern3 = /qmobile/; //returns true or false... var exists = pattern.test(a); var exists1 = pattern1.test(a); var exists2 = pattern2.test(a); var exists3 = pattern3.test(a); if(exists){ //true statement, whatever //alert("nokia"); $(".nokia").css("background-color", "green"); } else{ //false statement..do whatever //alert("not nokia"); $(...

basic reading input from user in java -

i want read character , store char[] array , here method called getaline public static int getaline(char message[], int maxlength) { int index = 0; while (message[index] != '\n') { message[index] = fgetc(system.out); index++; } index++; } and fgetc method: public static int fgetc(inputstream stream) and method should returns character input stream. but keep getting error message when compile: error: possible loss of precision message[index] = fgetc(system.in); ^ required: char found: int what should put inside fgetc can collect input user?? your code expecting char , return int here: public static int fgetc(inputstream stream) // ↑ tells method return int you can change method signature return char . public static char fgetc(inputstream stream) // ↑ tells method return char cast returned value char casting conversion ( §5.5 ) converts ...

java - Horizontal Scrollbar is not working under composite inside a CTabItem -

i have ctabitem inside which, there composite widget. then, have added few components inside it. code goes - composite composite = new composite(tabfolder, swt.h_scroll); tabitem.setcontrol(composite); label lblname = new label(composite, swt.none); lblname.setbounds(10, 28, 55, 15); lblname.settext("name"); textname = new styledtext(composite, swt.border); string mytext = tree.getselection()[0].gettext(); textname.settext(mytext); point textnamesize = textname.computesize(swt.default, swt.default); textname.setbounds(76, 28, textnamesize.x, 21); label lblpath = new label(composite, swt.none); lblpath.setbounds(10, 83, 55, 15); lblpath.settext("path"); textpath = new styledtext(composite, swt.read_only); textpath.setbackground(new color(d, 240, 240, 240)); button savebutton = new button(composite, swt.none); savebutton.setbounds(456, 134, 75, 25); savebutton.settext("save"); ...