Posts

Showing posts from March, 2015

javascript - Is it possible to set up a rolling average for only one series of the dygraph -

i have tried using rollperiod per-series property in order display 1 "raw" time series , rolling average separate series, no success. there way ? ! no, it's not. if want average 1 series not another, you'll need before send data dygraphs.

c# - DataSource (object) not bind to textbox -

Image
i new vb , visual studio. followed online tutorial binding. can not click text property of advanced binding page, following. not sure what information necessary debug . so, post creenshot here. questions. please let me know. code of class used datasource: public class miconfig public m_name string public m_primary integer public sub new(byval name string, byval primary integer) m_name = name m_primary = primary end sub end class 'textbox1 ' me.textbox1.location = new system.drawing.point(3, 193) me.textbox1.name = "textbox1" me.textbox1.size = new system.drawing.size(120, 26) me.textbox1.tabindex = 3 update why down-voted, please leave comment or solution or anything? otherwise, down-voting cannot improve society. mark class datasource advanced binding (window in screenshot) -> binding -> add project datasource -> object -> select class select property of class in binding want use data-bind

xamarin.android - Automatic Scroll when searching in mono for android or in c# -

i have list of name in listview, have search when search name display 1 search. want automatic scroll 1 search. how can in mono android or in c#. if have no idea of mono android click link : http://www.codeguru.com/csharp/sample_chapter/introduction-to-mono-for-android.htm if understood correctly can try with: listview.smoothscrolltoposition(position);

security - web site access control PHP -

i want protect large class.php files on site. site runs on iis (godaddy); use web.config files; question: if page users viewing require('class.php') , can class.php file restricted server scripting? or file need in folder accessible. same db.php file containing database password. edit if make page on desktop link index.php file , right click , save have php file. can open ans see requires clss.php. can repeat , class.php file. want prevent end of edit so php processor have access file not users try download them. if possible rule add in web.config file? thank you! a simple way define constant in first file, in class.php can exit if it's not defined. put first line, , ensure not called entry point. or, place class.php outside of web root.

Configuring spring controller properties partially with annotation in class and partially in config xml -

is possible define few properties of spring controller annotation in class , few other properties in spring-servlet.xml. can use both annotations , xml config file same controller or use either of two.i.e. example, @controller @command name annotation //some properties public class controller { } and in servlet.xml: <bean id="controller" class = "the classpath"> <property name="someotherproperty" value="somevalue1"></property> <property name="someotherproperty" value="somevalue2"></property> </bean> you don't want that, because mess up. code, have problem finding right configuration specific part of project.

java - TextIO.getln() does not get input? -

Image
i'm newbie in java. i'm reading book introduction programming using java v7 , found problem code this: public class createprofile { public static void main(string[] args) { // todo auto-generated method stub string name; string email; double salary; string favcolor; textio.putln("good afternoon! program create"); textio.putln("your profile file, if answer"); textio.putln("a few simple questions."); textio.putln(); /* gather responses users. */ textio.put("what name? "); name = textio.getln(); textio.put("what email address? "); email = textio.getln(); textio.put("what salary income? "); salary = textio.getdouble(); textio.putln(); textio.put("what favorite color? "); favcolor = textio.getln(); /* write user's informatio

java - How to store a space in a char array? -

i'm writing caesar cypher program can't figure out how store space in char array. here encrypt method public static string encrypt(string msg, int shift) { char[] list = msg.tochararray(); (int = 0; < list.length; i++) { // shift letter char letter = list[i]; letter = (char) (letter + shift); if (letter > 'z') { letter = (char) (letter - 26); } else if (letter < 'a') { letter = (char) (letter + 26); } else if (letter == ' ') { letter = '\0'; } list[i] = letter; } // return final string. return new string(list); } literally, answer question is: list[i] = ' '; however, code written looks rather broken. hint: think about: what happens characters aren't letters in range a z (lower case!), and what happens letter before test - if (letter == ' ') { ... .

How to autoscale y axis in matplotlib? -

Image
this question has answer here: add margin when plots run against edge of graph 1 answer i'm creating many plots , great while other need adjustment. below how can make hard see plot line easier see without having manually plot them? plot 50-100 of these @ time add them pdf report. i'd add space under line, example have ylim min limit set -0.1, automatically. this 1 hard see plot line: this 1 easy see plot line: here code plotting: def plot(chan_data): '''uses matplotlib plot channel ''' f, ax = plt.subplots(1, figsize=(8, 2.5)) x = dffinal['time'].keys() ax.plot(x, dffinal[chan_data].values, linewidth=0.4, color='blue') ax.xaxis.set_major_formatter(mdates.dateformatter('%m/%d/%y - %h:%m')) ax.xaxis.set_major_locator(mdates.autodatelocator(interval_multiples=true)) lgd1 = ax.legend(loc='center

Delphi - how read filestream byte by byte? -

i'm working stream files, "out of memory" error occurred. think must read stream, byte byte. load file method: fs := tfilestream.create("c:\a\a.avi", fmopenread or fmsharedenywrite) ; next reset stream position: fs.positon:=0; then i'm trying read first byte of stream: var onebyte:byte; begin fs.read(onebyte,2); but doesn't work properly. mistake? byte size 1 not 2 fs.read(onebyte, 1); such errors can prevented using sizeof() function fs.read(onebyte, sizeof(onebyte)); on note, read returns number of bytes read indicate whether or not entire read succeeded. expected check return value deal errors. the preferred idiom use readbuffer instead. call read , in case of error raise exception. as @david heffernan pointed out reading file stream byte byte not efficient way. take @ buffered files (for faster disk access)

c# - 2 threads increasing a static integer -

if increasing static 2 different tasks or threads need lock it? i have class used multiple threads @ same time, returns proxy used inside thread dont want use same proxy @ same time each thread, thought incrementing static integer best way, suggestions? class proxymanager { //static variabl gets increased every time getproxy() gets called private static int selectionindex; //list of proxies public static readonly string[] proxies = {}; //returns web proxy public static webproxy getproxy() { selectionindex = selectionindex < proxies.count()?selectionindex++:0; return new webproxy(proxies[selectionindex]) { credentials = new networkcredential("xxx", "xxx") }; } } based on selected answer if(interlocked.read(ref selectionindex) < proxies.count()) { interlocked.increment(ref selectionindex); } else { interlocked.exchange(ref selectionindex, 0); } selectionindex = interlocked.read(ref selectionindex);

debugging - Yii and bootstrap: How debug jQuery when I get a strange behavior? -

Image
i have problems developing yii application jquery. using firebug, when click in tab, can see navigator makes lot of calls: twice home page, 4 original destination, etc; can't see how happens. calls occurs , don't know where. however, if debug , see calls made, i'm pretty sure resolve it. my question: how debug jquery in case? edit: thank help. explain more problem. design of webpage. when click in "zones" tab, load webpage in contentarea_zone. have tabs (the tabs courtesy bootstrap extension yii, use jquery too) when click on tab "description", see calls in firebug console. but can't see come from. , if read right of firebug console, see "jquery.js" , line numbers, jquery library have 9405 lines. don't know why firebug reports calls in line 10079, 10692, etc. i'm lost. if problem remains unclear, me lot if recommend me suitable tool or method debugging case... edit 2: recommendations, started using firebug opti

ember.js - Socket.IO with Ember and Ember-Data -

i've been poking around , can't find date examples of ember (1.0.0-rc.1) , ember-data(revision 11) use socket.io. i've tried this. app.applicationroute = ember.route.extend({ setupcontroller: function(controller, data) { var socket = io.connect(), self = this; socket.on('apartment/new', function(apartment) { var apt = app.apartment.createrecord(apartment); self.controllerfor('apartments').pushobject(apt); }); } }); this create new model class, pushes object controller, , creates new li values not render. <ul class="list-view"> {{#each apartment in controller}} <li> {{#linkto 'apartment' apartment }} <span class="date">{{date apartment.date}}</span> {{apartment.title}} {{/linkto}} </li> {{/each}} </ul> does have run loop? how force values render? or there better approach this? there's simple solutio

mysql - I am having trouble with the logic in my code in android studio -

this code supposed serve on purpose, verify email address has been added database of "profiles" has not been entered before. after user enters relevant data, , attempts verify data legitimate entry, email address checked against other entries in database (because emails unique part of set of entries other nickname)and if email unique database, entry accepted , new column should created in database(which is). problem email accepted unique. this code shows how entries weeded out make sure fit convention of sign sheets public void registeraccount(view view) { loginentries entries = new loginentries( newemailaddressinput.gettext().tostring(), newpasswordinput.gettext().tostring(), newfirstnameinput.gettext().tostring(), newlastnameinput.gettext().tostring(), newnickname.gettext().tostring(),fullphonenumber); string istempemail = newemailaddressinput.gettext().tostring(); string istemppass = newpasswo

c# - Drag and Drop Row in a DataGridView -

i have windows form datagridview , need enable drag , drop rows in datagridview. it filled database. code not work because after first drag , drop cant drop row right position. this load forms datagridview filled database datatable bspeople; rectangle dragboxfrommousedown; int rowindexfrommousedown; int rowindexofitemundermousetodrop; private void form1_load(object sender, eventargs e) { datagridview1.allowdrop = true; bspeople= objpeople.returnpeople(); // fill data sql server datagridview1.datasource = bspeople; } this drag , drop events private void datagridview1_mousemove(object sender, mouseeventargs e) { if (((e.button ==mousebuttons.left))) { if (((dragboxfrommousedown != rectangle.empty) && !dragboxfrommousedown.contains(e.x, e.y))) { dragdropeffects dropeffect = datagridview1.dodragdrop(datagridview1.rows[rowindexfrommousedo

swift - Status bar not showing up on iOS app -

Image
i having problem getting status bar show in view on ios. have tried changing plist file of "status bar hidden" no still doesn't show up.this black bar , unsure why. edit: unsure why got down voted, did research , i've tried has not worked, maybe should more specific. ive tried both answers below, resulting in error. there missing delegation or similar. new swift , have issues delegations. one other thing can try click on name of project. click on name of project under targets . under says deployment info take @ says status bar style , change light . shift+cmd+k clean , run.

python 2.7 - Tight layout for matplotlib 3d surface plot -

Image
i trying create 3d surface plot in matplotlib. plot surface works fine using ax.plot_surface api. couldn't find way remove padding surrounding subplot. in fact, don't need outer axes go 0.0 1.0 @ all. how can remove padding? tried many suggestions stackoverflow "ax.autoscale_view('tight')" , "fig.tight_layout()". autoscale_view don't change , fig.tight_layout() not available in matplotlib version using. strict compatibility requirements have use old (version 0.99) version of matplotlib. ideas ? for completeness have added sample source code using: from mpl_toolkits.mplot3d import axes3d matplotlib import cm import matplotlib.pyplot plt import numpy np fig = plt.figure(figsize = (18,12)) rect = fig.add_subplot(2, 3, 2).get_position() ax = axes3d(fig, rect) x = np.arange(-5, 5, 0.025) y = np.arange(-5, 5, 0.025) x, y = np.meshgrid(x, y) r = np.sqrt(x**2 + y**2) z = np.sin(r) surf = ax.plot_surface(x, y, z, rstride=1, cstride=1, cmap=cm.jet

maven - mvn is not recognized as internal or external command -

i trying launch maven project command line when try using mvn --version or other maven command comes below error message mvn not recognized internal or external command maven not installed in os. please follow instructions following link http://maven.apache.org/download.cgi#installation

azure - Start service worker role using management rest api -

i trying stop / start azure worker role using windows scheduler. action url used follows: https://management.core.windows.net/<subscription-id>/services/hostedservices/<cloudservice-name>/deploymentslots/<deployment-slot>/ . secured using certificate. response following error. http action - response host 'management.core.windows.net': 'notfound' response headers: x-ms-servedbyregion: ussouth3 strict-transport-security: max-age=31536000; includesubdomains x-ms-request-id: e1f235c155cf6a00a904a527bc22c77f cache-control: no-cache date: fri, 15 jan 2016 19:55:02 gmt server: 1.0.6198.304 (rd_rdfe_stable.160106-1801) microsoft-httpapi/2.0 body: resourcenotfound the resource service name hostedservices not supported. i followed instructions here: https://msdn.microsoft.com/en-us/library/azure/ee460808.aspx raw post looks this: post https://management.core.windows.net/9974e512-xxxx-xxxx-xxxx-xxxxxxxxb846a/services/hostedservices/sblq

c++ - operator== container iterator const and non-const -

i'm trying have eventmanager impossibly fast c++ delegate discussed in article http://blog.coldflake.com/posts/c++-delegates-on-steroids/ ; template <typename t, typename r, typename... params> class delegate<r (t::*)(params...) const> { public: typedef r (t::*func_type)(params...) const; delegate(func_type func, const t& callee) : callee_(callee) , func_(func) {} r operator()(params... args) const { return (callee_.*func_)(args...); } bool operator==(const delegate& other) const { return (&callee_ == &other.callee_) && (func_ == other.func_); } bool operator!= (const delegate& other) const { return !(*this == other); } private: const t& callee_; func_type func_; }; and 1 of methods used; using eventlistenerdelegate = delegate<ieventdataptr>; using eventlistenerlist = std::list<eventlistenerdelegate>; bool eventmanager::addlistener(const eventlistenerdelegate&

.net - How to customize the controlbox of a winform in c# -

i want customize controlbox of winform different background , different button images. how can so? there way make custom controlbox usercontrol or , add winform? you can create own custom controls inheriting usercontrol so class mycontrol : system.windows.forms.button //this have been system.windows.forms.usercontrol or other existing control type template { protected override void onpaint(system.windows.forms.painteventargs e) { //paint whatever wish on buttons graphics using e.graphics } } there lot programming custom controls. answer here. reference is: http://msdn.microsoft.com/en-us/library/6hws6h2t.aspx you create own sort of forms control , hide parents controlbox. or maybe can inherit system.windows.form , createa custom form. have never tried myself. and using onpaint have keep rules in mind if care performance and/or flickering , such: what right way use onpaint in .net applications?

php - XAMPP: Phpmyadmin doesn't work with FastCGI -

i have local installation of xampp. reasons (java-php-bridge) have use fastcgi. set using guide: http://www3.umoncton.ca/dashboard/docs/use-php-fcgi.html this worked fine cannot access http://localhost/phpmyadmin/ error is: access forbidden! new xampp security concept: access requested directory available local network. this setting can configured in file "httpd-xampp.conf". here "httpd-xampp.conf" file: # # xampp settings # <ifmodule env_module> setenv mibdirs "c:/xampp/php/extras/mibs" setenv mysql_home "\\xampp\\mysql\\bin" setenv openssl_conf "c:/xampp/apache/bin/openssl.cnf" setenv php_pear_sysconf_dir "\\xampp\\php" setenv phprc "\\xampp\\php" setenv tmp "\\xampp\\tmp" </ifmodule> # # php-module setup # loadfile "c:/xampp/php/php5ts.dll" loadfile "c:/xampp/php/libpq.dll" #loadmodule php5_module "c:/x

android - arraylist is empty after adding values -

when execute program, shows blank screen , in logcat shows no adapter attached; skipping layout. when debug code arraylist not getting value (returning 0). public class mainactivity extends appcompatactivity implements constants, networkoperation, url { linearlayoutmanager manager; arraylist<offermodal> bestoffers; recyclerviewadapter adapter; recyclerview rv; fetchdata fetchdata; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); rv = (recyclerview) findviewbyid(r.id.recyclerview1); fetchdata = new fetchdata(this, this, cloud_section); fetchdata.fromserver(); manager = new linearlayoutmanager(getapplicationcontext(), linearlayoutmanager.vertical, false); rv.setlayoutmanager(new linearlayoutmanager(this)); } @override public void started() { } @override public void doingba

lotus notes - View Attachments in XPage -

i need view file attachments (doc scans jpg, tiff, pdf, etc.) in notes. there article here describes through standard notes ui. not know how call correctly, sorry. need view file attachments xpage. is there way use notes attachment -> view functionality within xpage ? xpages first , foremost server technology based on jsf. access xpages application through browser (in case of xpinc: browser embedded notes client). so want 'view' bound/limited browser's capabilities. the notes client has oem library called outsidein (afaik owned oracle) render many file formats without original application. library client library, not server code. domino treats attachments binary blob delivered when requested , viewers task make sense of them (the browser or whatever application reacts url). in case wondering attachment urls are, check out article: http://notessensei.com/blog/2010/06/attachment-urls-in-xpages.html

using batch files to create text files with text in each file -

i know title sounds crazy. anyway, here scenario: i need create 500 text files 500 different files. each text file contain information seen in example below. there easy way put single batch file without copy , pasting 500+ times? example of trying do.... echo ^<filename 1^> >> filename1.txt echo. >> filename1.txt echo. >> filename1.txt echo no ocr found >> filename1.txt using random numbers files... @echo off set loop=0 :loop set num=%random% if exist filename%num%.txt ( echo ^<filename %num%^> echo. echo. echo no ocr found ) > filename%num%.txt else ( goto loop ) set /a num+=1 if %loop%==500 goto end goto loop :end note: maximum amount of files 32767. to change amount of files made, change number in last if statement (e.g: make create 80 files change if %loop%==500 goto end if %loop%==80 goto end ).

Fast import data to mysql in Java -

how long take insert 500.000 records csv file mysql database java code? database hosted on localhost. table structure: ai id, | varchar(8) | datetime | int | varchar(2) . code need insert 70.000 records on 40 minutes. there way faster? here main part of code: csvreader pro ducts = new csvreader(path); products.readheaders(); stmt = con.createstatement(); string updatestring = "insert table (t_v1, date, t_v2, t_v3) values (?,?,?,?)"; preparedstatement preparedstatement = con.preparestatement(updatestring); while (products.readrecord()) { v1= products.get("v1"); date = format.parse(products.get("date") + " " + products.get("hour")); java.sql.date datedb = new java.sql.date(data.gettime()); v2 = products.get("v2"); v3 = products.get("v3"); preparedstatement.setstring(1, v1); preparedst

javascript - Html menu jumping to div on click -

i'm working on menu containing links targets iframe . @ same time web address revealed in separate div . the code below works pretty well, discovered page jumps top of web address text. i've tried few strategies to fix (including placing fixed position on wrapper), can't seem able stop page jumping address text. here snippet. <script> var lst; function changecolor(obj) { if (lst) lst.style.color = "#663399"; obj.style.color = "red"; lst = obj; } $("a").click(function() { $("iframe").attr("src", $($(this).attr("href")).find("a").attr("href")); }); </script> } a:active { text-decoration: underline; } .menu { font-size: 13px; top: 100px; width: 260px; height: 100px; left: 8px; } .header { font-size: 13px; height: 50px; width: 260px; } .hyperlinks { top: 50px; width: 260px; height: 50px; } #tabs p {

groovy - Why those two task definition syntaxes equivalent? -

can explain why 2 task definitions in gradle equivalent? task(type: copy, 'mytask') and task mytask(type: copy) is groovy magic syntax thingy i'm not familiar with, or gradle preprocessing? gradle seems use build script transformers, executed during buildscript compilation phase. here's transformer you're looking for. here list of transformations.

arrays - PHP: "Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset" -

i running php script, , keep getting errors like: notice: undefined variable: my_variable_name in c:\wamp\www\mypath\index.php on line 10 notice: undefined index: my_index c:\wamp\www\mypath\index.php on line 11 line 10 , 11 looks this: echo "my variable value is: " . $my_variable_name; echo "my index value is: " . $my_array["my_index"]; what these errors mean? why appear of sudden? used use script years , i've never had problem. what need fix them? this general reference question people link duplicate, instead of having explain issue on , on again. feel necessary because real-world answers on issue specific. related meta discussion: what can done repetitive questions? do “reference questions” make sense? notice: undefined variable from vast wisdom of php manual : relying on default value of uninitialized variable problematic in case of including 1 file uses same variable name. majo

python - Document classification in spark mllib -

i want classify documents if belong sports, entertainment, politics. have created bag of words output somthing : (1, 'saurashtra') (1, 'saumyajit') (1, 'satyendra') i want implement naive bayes algorithm classification using spark mllib. question how convert output can naive bayes use input classifcation rdd or if there trick can convert directly html files can used mllib naive bayes. for text classification, need: a word dictionary convert document vector using dictionary label document vectors: doc_vec1 -> label1 doc_vec2 -> label2 ... this sample pretty straghtforward.

html - How to make div's percentage width relative to parent div and not viewport -

here html working with . <div id="outer" style="min-width: 2000px; min-height: 1000px; background: #3e3e3e;"> <div id="inner" style="left: 1%; top: 45px; width: 50%; height: auto; position: absolute; z-index: 1;"> <div style="background: #efffef; position: absolute; height: 400px; right: 0px; left: 0px;"></div> </div> </div> what happen inner div occupy 50% of space given parent div(outer). instead, is getting 50% of space available viewport, means browser/viewport shrinks in size, it. given outer div has min-width of 2000px , expect inner div @ least 1000px wide. specifying non-static position, e.g., position: absolute/relative on node means used reference absolutely positioned elements within http://jsfiddle.net/e5eek/1/ #outer { min-width: 2000px; min-height: 1000px; background: #3e3e3e; position:relative } #inner { left: 1%;

C - Read bytes from the UDP socket buffer (Linux) -

i wrote code in order handle receiving udp packets. packets same length(120 bytes), , 1,000 packets coming in every second. simply, code this. int sock = -1; int flag = 0; int nread = 0; #define local_buff_size (8192) char buff[local_buff_size]; struct sockaddr_in sockaddr; memset((void *)&sockaddr, 0x00, sizeof(struct sockaddr_in)); if((sock = socket(pf_inet, sock_dgram, 0)) < 0) { /* print error , terminate */ } /* make non-blocking */ flag = fcntl( sock, f_getfl, 0 ); fcntl( sock, f_setfl, flag | o_nonblock ); sockaddr.sin_family = af_inet; sockaddr.sin_port = htons(portnum); sockaddr.sin_addr.s_addr = inaddr_any; if(bind(sock, (struct sockaddr *)&sockaddr, sizeof (sockaddr)) < 0) { /* print error , terminate */ } while(...) { nread = recv(sock, buff, local_buff_size, 0); if(nbytes > 0) { /* process data */ } else { /* if it's error, handle error */ } } when wrote code, expect recv() function

php - Reset the numeric keys of an array -

i have array this $array = array( 1 => 'one', 2 => 'two', 3 => 'three', 'row' => 'four', 'newrow' => 'five', ); i need re-index numeric keys - 1, 2, 3. expected output: $array = array( 0 => 'one', 1 => 'two', 2 => 'three', 'row' => 'four', 'newrow' => 'five', ); i've tried array_values , string keys gets indexed. what best way this? thanks. use array_merge reindex array. the code: <?php $array = array( 1 => 'one', 2 => 'two', 3 => 'three', 'row' => 'four', 'newrow' => 'five', ); $reindexed_array = array_merge($array); var_dump($reindexed_array); the result: array(5) { [0]=> string(3) "one" [1]=> string(3) "two" [2]=> string(5) "three&quo

python - Fastest way to replace space for underscore for a list of words in text -

given 10,000,000,000 lines of around 20-50 words each line, e.g.: anarchism defined political philosophy holds state undesirable , unnecessary , or harmful . , others argue while anti-statism central , inadequate define anarchism . therefore , argue instead anarchism entails opposing authority or hierarchical organization in conduct of human relations , including , not limited , state system . proponents of anarchism , known " anarchists " , advocate stateless societies based on non - hierarchical free association s. subtle , anti-dogmatic philosophy , anarchism draws on many currents of thought , strategy . anarchism not offer fixed body of doctrine single particular world view , instead fluxing , flowing philosophy . there many types , traditions of anarchism , not of mutually exclusive . anarchist schools of thought can differ fundamentally , supporting extreme individualism complete collectivism . strains of anarchism have been divided categories of social , indiv

Accessing attributes added via $meta in a MongoDB query -

i'm having difficulty accessing attributes added when performing weighted search: post.collection .find( { $text: { $search: 'whatever }}, { score: { $meta: 'textscore' } } ) .sort( { score: { $meta: 'textscore' } } ) .exec(function(error, results) { console.log(results[0].score) // returns undefined }) if console.log individual result, can see score attribute: { title: 'test post 6', content: 'keyword keyword keyword keyword keyword keyword', score: 3.9375, __v: 0, slug: 'test-post-6', _id: 569a4f33fad6dfc724e02508 } but accessing value via .score or key ['score'] returns undefined . how can access score meta attribute? i using underscore in code, leveraged _.getkeys() view of keys on result. there's 2 keys, get() , getvalue() available can used return score : post.collection .find( { $text: { $search:

java - Compression of zip archive -

this question has answer here: how create uncompressed zip archive in java 3 answers i'm trying compress directory content zip archive using java. fine, want clarify facts. here code use compress files: public void pack(@nonnull string archivename, @nonnull file outputdir, @nonnull file targetdir) { file zipfile = new file(outputdir, "out.zip"); zipoutputstream zipoutputstream = null; outputstream outputstream; try { // create stream writing zip archive outputstream = new fileoutputstream(zipfile); zipoutputstream = new zipoutputstream(outputstream); // write files recursively writefiles(zipoutputstream, targetdir.listfiles(), ""); } catch (ioexception e) { logger.error("io exception while packing files archive", e); } { // close output streams if (zipoutputstream != null) { try {

webdeploy - publish website from vso using web deploy -

this question has answer here: missing tasks in vsts 2 answers in last couple of days, spent time trying find out-of-box function in visual studio online (vso) publish asp.net website using web deploy, haven't found it. does exist? the iis web application deployment task still in preview . meaning deployed tenant not enabled. therefore won't able upload using tfx-cli. the way have access them seems if tenant in preview mode can request address mentioned under contact on this site . see this question .

php - How to fix "password fields present on an insecure (http //) page" without SSL? -

i read articles here , on google, have buy "ssl certificate", unfortunately not low priced. my question is: why "warning message" not on cms wordpress in backend (user password field)? doing differently? because page not on https. can explain me difference? how can fix without ssl?

oop - Can a Java constructor return already existing object of same type? -

whenever call constructor in java, creates new object , returns reference in end (of newly created object). is there possibility java constructor not create new object return reference created object? // possible myobject not new object, existing object myclass myobject = new myclass(); i have list of objects of class, , based on few parameters in constructor more efficient don't create new object, instead pick existing object. there other way? no. constructors definition run when new object created initialize it. if constructor run, new object has come existence, , there's nothing can it. what make static method either creates new object, or returns existing one. standard approach in such cases. say, boolean.valueof(boolean value) in standard library exists purpose of avoiding creation of objects. can create them using new boolean(value) , better call method because return same object same values.

android - Google Maps do not work on emulator -

Image
this question has answer here: how download google play services in android emulator? 12 answers sorry bad english. i have problem google maps. i did create program android studio selecting "google maps activity" in process of creating new project, program connecting real phone computer works, using emulator me appears written: "my application 90 not run without google play services, missing phone." with under button read: "get google play services" if click on button "get google play services" program collapses. how operate program even emulator? tell me if explained well. you should use emulator google api support. in sdk manager install system image google apis support (for example, selected 1 @ screenshot below). then when create android virtual device select system image:

selenium - Running automated tests in client machine -

basically requirement : i have developed framework using selenium webdriver,maven , testng application under test. now have pass on client without sharing source code ..so if wants can run test in machine without having else installed ..except java. , output should stored in 1 of specific folders of client machine. can use plugin in maven store result or copy result file folder of client machine.? please guide me how achieve this.. how pass on above client test run smoothly in machine . is there need take care while using maven in project? using chrome browser run tests.. application under test available accessed type of browser. kindly suggest.

How to make text appear in an android notification? -

i trying create notification on android in order notify user if happening. here example code (called mainactivity ) notificationcompat.builder mbuilder = new notificationcompat.builder(this) .setsmallicon(r.drawable.stoxx_icon) .setcontenttitle("my notification") .setcontenttext("hello world!"); intent resultintent = new intent(this, mainactivity.class); taskstackbuilder stackbuilder = taskstackbuilder.create(this); stackbuilder.addparentstack(mainactivity.class); stackbuilder.addnextintent(resultintent); pendingintent resultpendingintent = stackbuilder.getpendingintent( 0, pendingintent.flag_update_current ); mbuilder.setcontentintent(resultpendingintent); notificationmanager mnotificationmanager = (notificationmanager) getsystemservice(context.notification_service); int mid = 1001; mnotificationmanager.notify(mid, mbuilder.build()); the notifica

javascript - Request entity too large error for PNG Image on S3 -

i had entity large error when trying upload image amazon s3. strange thing has error png file merely have 85kb size. i tried other png has more hundred kb didn't error. var data = { key: file_name, body: buffer, contentencoding: 'base64', contenttype: 'image/jpeg' }; s3bucket.putobject(data, function(err, data){ if (err) { console.log(err); res.send({result:0}); } else { res.send({result:1,file_name:file_name}); } });

java - Anagrams lintcode -

given array of strings, return groups of strings anagrams. given ["lint", "intl", "inlt", "code"], return ["lint", "inlt", "intl"]. given ["ab", "ba", "cd", "dc", "e"], return ["ab", "ba", "cd", "dc"]. my code gave error msg @ "stringb.add(astring));" ; couldn4t figure out why. { /** * @param strs: list of strings * @return: list of strings */ private int hash(int[] count){ int hash = 0; int primea = 378551; int primeb = 378559; //int result = 0; for(int anumber: count){ hash = hash*primea + anumber; primea = primea*primeb; } } public list<string> anagrams(string[] strs) { // write code here int = 0; int l = 0; arraylist<string> result = new arrayli

ruby on rails - writing model method tests using minitest -

i use mini-test testing framework. try write model tests. class person include mongoid::document field :provider, type:string field :user_id, type:string field :name, type:string def self.create_with_omniauth(auth) create! |person| person.provider = auth["provider"] person.user_id = auth["uid"] #user.name = auth["info"]["name"] end end def self.find_by_provider_and_uid(provider, uid) where(provider: provider, user_id: uid).first end end above person model. want write test controls if person has "create_with_omniauth method" or not. how can write test. wait ideas? in advance. to accomplish can use assert_respond_to . a complete example: class persontest < minitest::unit::testcase def test_responds_to_create_with_omniauth assert_respond_to(person, :create_with_omniauth) end end my personal opinion test behaviour of method instead of asserting whether ex