Posts

Showing posts from March, 2014

jquery - Show or Hide Table rows based on drop down selection -

i have table has got sector column under . on changing sector column , using drop down need show / hide rows corresponding sector this code html code <table class="table table-striped marg_none tablesorter tablesorter-blackice" id="mytable" role="grid"> <tbody id="positivebody" aria-live="polite" aria-relevant="all"> <tr class="greencolor" role="row"> <td class="text-center"> <label for="ibrealest" class="marg_none"> <div></div> </label> </td> <td class="greencolor">jublfood</td> <td>99.15</td> <td>108.25</td> <td>cnx fmcg</td> </tr> <tr class="greencolor" role="row"> <td class="text-center&quo

symfony - Injecting webpack chunks to twig files -

i creating traditional website (not single page application) using php/twig/webpack tools. every site has own entry scripts. there vendor , common js files. how can inject entry chunks with hash (to handle browser cache) in twig files? stored in templates folder , should stay there (not go public folder since used php). how can inject script tags twig files? this twig general layout file: {% block html %} <!doctype html> <html lang="pl"> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <base href="/"> <title> {% block title %}{% endblock %} </title> <link href="css/style.css" rel="stylesheet"> <script src="js/vendor.js"></s

mysql - SQL cross table based on two columns -

Image
i want make cross table in mysql based on 2 columns in table. 1 evidence number of bus: called "boczny" (without repetitions in column) , number of lane: "linia". try convert "linia" column row, , count how evidence bus seen on given lane. acutualy have this, still mising pivot table (cross table). please help. select boczny, min(linia) vehicles group boczny a typical way uses conditional aggregation: select v.boczny, sum(v.linia = 1) linia_1, sum(v.linia = 2) linia_2 vehicles v group v.boczny; alternatively, put each linia on separate row: select v.boczny, v.linia, count(*) vehicles v group v.boczny, v.linia;

android - API 25 causing Rendering problems -

i have installed api 25 sdk manager , set build.gradle (module app) showing rendering problem enter image description here .. have set android version 25 in xml file . . still not working in advance

aws lambda - DynamoDb : Scan query does not return all the data -

i have dynamodb table thousands of data. scanning table using scan function , have applied "between" filterexpression. , query response gives 3 records whereas should return 100 records. i have created lambda function using node js. the other common issue whether scan executed until lastevaluatedkey empty. if doing , still not getting items, please show code @ in detail. if total number of scanned items exceeds maximum data set size limit of 1 mb, scan stops , results returned user lastevaluatedkey value continue scan in subsequent operation. results include number of items exceeding limit. scan can result in no table data meeting filter criteria. if lastevaluatedkey empty, "last page" of results has been processed , there no more data retrieved. if lastevaluatedkey not empty, not mean there more data in result set. way know when have reached end of result set when lastevaluatedkey empty.

python - Issue with the one line output when executing psexec command from subprocess.Popen -

i'm trying run , output of following command using psexec. 'psexec.exe -accepteula \\172.16.196.162 -u administrator -p builder!12 cmd.exe /c dir /b /s c:\\dir1' this command executed python using subprocess.popen(). please ignore rest of variables such psexecmdpath _childprocess = subprocess.popen(psexecmdpath + "\\" + 'psexec.exe -accepteula \\\\172.16.196.162 -u administrator -p builder!12 cmd.exe /c dir /b /s c:\\dir1', 0, none, none, subprocess.pipe, subprocess.pipe, none, false, false) the problem i'm facing when output stored in _output . given below snippet of code this. _childprocess = subprocess.popen(_cmd, 0, none, none, outfileobj, errorfileobj, none, false, true, psexecmdpath) retcode = _childprocess.wait() #after process has unblocked, it's safe assume no more writes being made. must return beginning in a+ mode. outfileobj.seek(0)

c# - Can't start a simple view with MVVMCross Xamarin IOS -

please help! just spend more 8 hours trying 1 simple view presented in ios, not working. no idea whats going on. this code. setup.cs public class setup : mvxiossetup { public setup(mvxapplicationdelegate applicationdelegate, uiwindow window) : base(applicationdelegate, window) { } public setup(mvxapplicationdelegate applicationdelegate, imvxiosviewpresenter presenter) : base(applicationdelegate, presenter) { } protected override void initializeioc() { base.initializeioc(); mvx.registersingleton<ilanguageservice>(() => new languageservice()); mvx.registersingleton<isoundplayerservice>(() => new soundplayerservice()); mvx.registersingleton<ialertservice>(() => new alertservice()); mvx.registersingleton<itagmanagerservice>(() => new tagmanagerservice()); mvx.registersingleton<ibackcompatservice>(() => new backcompatservice()); mvx.

php - Laravel webwizo shortcodes package Shortcodes class not found -

i started using laravel i'm beginner, , right i'm working on small project requires me use shortcodes(like ones in wordpress). searched little bit , found package: https://packagist.org/packages/webwizo/laravel-shortcodes i ran installation , usage way it's written error : class 'app\providers\shortcode' not found in provider have make using laravel make:provider command specified in package instructions, below exact usage , install code. added providers array : /* * shortcodes providers */ webwizo\shortcodes\shortcodesserviceprovider::class, app\providers\shortcodesserviceprovider::class, added aliases: 'shortcode' => webwizo\shortcodes\facades\shortcode::class, this content of shortcodesserviceprovider in app/providers: namespace app\providers; use illuminate\support\serviceprovider; use app\shortcodes\jobsform; class shortcodesserviceprovider extends serviceprovider { /** bootstrap application services. * @return void */ p

javascript - Mongoose Express.js delete object with relationships -

so have schema town , want delete 1 town ads in , relashionships ads.here schemas: let adschema = mongoose.schema ( { author: {type: objectid, ref: 'user'}, category: {type: objectid, ref: 'category', required: true}, town: {type: objectid, ref: 'town', required: true}, } ); let categoryschema = mongoose.schema ( { name: {type: string, required:true, unique: true}, ads: [{type: objectid, ref: 'ad'}] } ); let townschema = mongoose.schema ( { name: {type: string, required:true, unique:true}, ads: [{type: objectid, ref: 'ad'}] } ); let userschema = mongoose.schema( { email: {type: string, required: true, unique: true}, ads: [{type: objectid, ref: 'ad'}], } ); i using code this: let id = req.params.id; town.findbyidandremove(id).populate('ads').then(town => { let ads = town.ads; if (ads.length !== 0) { ads.foreach(ad => {

server - PHP IMAP module - does not work -

i install script (temporary email) on dedicated root server. this script requires php imap module. problem not module installed , / or activated. i have tried enable , / or install php imap module using different methods: apt-get install libc-client-dev cd /root wget files.directadmin.com/services/all/imap_php.sh chmod 755 imap_php.sh ./imap_php.sh or sh imap.sh cd /usr/local/directadmin/custombuild mkdir -p custom/ap2 cp -p configure/ap2/configure.php5 custom/ap2 ./build php n or apt-get install php5-imap php5enmod imap systemctl restart httpd.service or aptitude install php5-imap apache2ctl graceful or //in php.ini file// ; configuration php imap module extension=imap.so //in extensions section of php.ini// but not work. i have rebooted server , services countless times. still not work! information server: server software debian , web control panel directadmin. i have no experience when comes something. not know do! i hope can me.

javascript - How to find when an object value changes in IE -

i'm working on big application has no documentation or comments. there difference in behavior between ie , firefox , chrome. in order debug have find place property being changed (tinymce.editors.length , need find out tinymce editor being created, because created in ie not in firefox or chrome). of option seems to blindly put breakpoints around scripts, there tens of thousands of lines, other ideas appreciated. when load script tinymce create global object in browser named tinymce . sheer act of loading script creates object. within tinymce object array named editors . tinymce editor uses array keep track of editor instances on web page. each time initialize instance of tinymce added array , each time remove instance of tinymce removed array. should never need manipulate tinymce.editors array yourself. the common way initialize instance of tinymce via init() function. simple example of can found here: https://www.tinymce.com/docs/get-started/first-steps/#

php - Doctrine fails to persist on record delete -

when user want's delete record (language in case) want prevent deletion of record (language) if it's referenced in other table in system. problem language (record) in case gets deleted if it's referenced in other table. checked relationships in mysql workbench , says on delete , on update restrict action reason doctrine/symfony allows delete of same field. does knows problem? here entity setup: /** * many drivers have many langauges (owning side) * * @orm\manytomany(targetentity="language", inversedby="language", cascade={"persist"}) * @orm\jointable(name="bus_drivers_languages", * joincolumns={@orm\joincolumn(name="bus_driver_id", referencedcolumnname="id")}, * inversejoincolumns={@orm\joincolumn(name="languages_id", referencedcolumnname="id")} * ) **/ private $languages; /** * @var arraycollection * * @orm\many

java.security.AccessControlException: Multithreading in App engine with Basic Scaling -

i using gae backend(module created through android studio). added library helps in sending fcm messages fcm cloud connection server library spawns threads handle things getting exception trying spawn threads. now, know taskqueue api provided purpose library not under control. how can around problems using 3rd party libs use concurrency? the answer is, you can't , , not in google app engine standard. i had complement standard gae app flexible microservice sending messages. for searching, here ref: gae flexible

Custom view with scroll in Xamarin.Android -

i have display large diagram in xamarin.android application , user must able scroll horizontally and/or vertically. a. first thought create custom view (inheriting view) handles drawing in ondraw , place custom view in scrollview. in situation not know: how tell scrollview how content has scroll; how know inside custom view scroll can draw corresponding part of diagram (i want draw visible). just testing tried layout below cannot scroll: <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" > <button android:id="@+id/btnloaddiagram" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="load diagram" /> <scrollview android:layout_width="fill_parent" android:layout_height=

c - Clarification on the use of fgetc -

this question has answer here: difference between int , char in getchar/fgetc , putchar/fputc? 2 answers there following code part of function have been given: char ch; ch = fgetc(fp); if (ch == eof) return -1; where fp pointer-to-file/stream passed parameter function. however, having checked usage of fgetc() , getc() , getchar() , seems return type int rather type char because eof not fit in values 0-255 used in char, , < 0 (e.g. -1). however, leads me ask 3 questions: if getchar() returns int, why char c; c = getchar(); valid usage of function? c automatically type cast char in case, , in case getchar() replaced getc(fp) or fgetc(fp) ? what happen in program when fgetc() or other 2 functions return eof? again try , cast char before fail? gets stored in ch , if anything? if eof not character, how ch == eof valid comparison, since eof cannot

c++ - Arrays enums and input -

i have enumerated data type for/in class. want set/assign values inside main. code looks like class pet { public: enum species { bird,cat,dog,rat,horse }; enum demands { food,water,companionship }; demands demand; species petspecies; float waterlevel = 100; float foodlevel = 100; float happiness = 100; //species not initialized in class , have initialized separately in main string name; //and bunch of functions here , there }; inside main function using vector create set of pets each own name , species. setting species pets proving difficult. how do it? vector_pets[i].petspecies = pet::horse; should want.

how can i remove null section and combine into one in mysql? -

Image
select a_name, round(case when m_type_code = 001 avg(a_price) end) a, round(case when m_type_code = 002 avg(a_price) end) b price group a_name, m_type_code; when use result is a_name ã…£ ã…£ b ã…£ apple ã…£(null) ã…£ 3313 ã…£ apple ã…£ 3000 ã…£ (null) ã…£ grape ã…£(null) ã…£ 5020 ã…£ grape ã…£ 3140 ã…£ (null) ã…£ ... so thought group a_name one, instead ii came out 2 different row null how can remove null , combine one? not sure if avg , coalese give desired results though. select a_name , round(avg(case when m_type_code = '001' coalesce(a_price,0) end)) , round(avg(case when m_type_code = '002' coalesce(a_price,0) end)) b price group a_name; or maybe depending on you're trying accomplish avg. select a_name , round(avg(case when m_type_code = '001' a_price end)) , round(avg(case when m_type_code = '002' a_price end)) b price group a_name;

html - iframe in bigcommerce is flushed to the right by some unseen border or panel -

i'm trying place iframe bigcommerce site site created in adobe muse. here page link: http://bmulzac2.mybigcommerce.com/archive/ the iframe showing properly, being flushed right reason, , need centered on page. help! here html: i tried various align tags - middle, bottom, left - of them still show flushed right!

continuous integration - Automatically build .apk from someone else's github repository -

i looking tool/service allows following done: given public repository of open source android app (say signal), want automatic tool build .apk me, , send phone. useful don't have waste time building myself, plus don't have on computer build. also, if tool builds every new commit, date. is there such tool? or there way of using combination of services in order achieve that? like, if fork repository, , set keeps up-to-date every 30minutes, make easier me find service automatically generates , sends .apks phone? you talking continuous integration. there several tools out can job. pretty famous , open source solution jenkins. https://jenkins.io jenkins need own server. beside can find several online tools that. example buildkite. https://buildkite.com these tools can not send apk directly, if combine them services hockeyapp ( https://hockeyapp.net/ ) or fabric ( https://get.fabric.io/ ) can add functionality in build process. possible send apk dropbox or google dri

ios - UICollectionView: animating an in-cell animation -

i working on card-style ui. within uicollectionview single cell takes of collectionview frame. collectionview has 1 item in it. when user wants go next card (on-screen button) use collectionview.insertitems add next 'card' , collectionview.deleteitems remove previous one. override layout attributes create effect old card scaling , new card animating in, on top of it: override open func finallayoutattributesfordisappearingitem(at itemindexpath: indexpath) -> uicollectionviewlayoutattributes? { let layoutattibutes = layoutattributesforitem(at: itemindexpath)?.copy() as! uicollectionviewlayoutattributes layoutattibutes.center = cgpoint(x: (layoutattibutes.center.x), y: (layoutattibutes.center.y) ) layoutattibutes.transform = cgaffinetransform(scalex: 0.95, y: 0.95) layoutattibutes.zindex = 0 return layoutattibutes } override open func initiallayoutattributesforappearingitem(at itemindexpath: indexpath) -> uicollectionviewlayoutattributes? {

ios - What is the right way (Best practice) for dequeue a reusable cell in swift 3? -

i'm want dequeue cell use in table view i'm afraid i'm doing in wrong way. currently i'm doing way: func tableview(_ tableview: uitableview, cellforrowat indexpath: indexpath) -> uitableviewcell { guard let cell = tableview.dequeuereusablecell(withidentifier: "cellid", for: indexpath) as? customcell else { return uitableviewcell() } //configure atributes here. return cell } what i'm want know if right or have check if cell nil? var cell = tableview.dequeuereusablecell(withidentifier: "cellid", for: indexpath) customcell if cell == nil { cell = customcell() } what code correct? if none of them right witch way right way? just forced unwrap cell: let cell = tableview.dequeuereusablecell(withidentifier: "cellid", for: indexpath) as! customcell ... return cell since you have designed cell in interface builder crash reveal design error.

Mule batch processing vs foreach vs splitter-aggregator -

in mule, have quite many records process, processing includes calculations, going , forth database etc.. can process collections of records these options batch processing foreach splitter-aggregator so main differences between them? when should prefer 1 others? mule batch processing option not seem have batch job scope variable definition, example. or, if want benefit multithreading fasten overall task? or, better if want modify payload during processing? when write "quite many" assume it's main memory, rules out spliter/aggregator because has collect records return them list. i assume have records in stream or iterator, otherwise have memory problem... so when use for-each , when use batch? for each the simple solution, has drawbacks: it single threaded (so may slow use case) it "fire , forget": can't collect within loop, e.g. record count there not support handling "broken" records within loop, can have seve

Date formatting parse error Java -

i want format date sun apr 10 07:05:45 mdt 2017 2017-04-10t07:05:45.24z . i using following: datetimeformatter formatter = datetimeformatter.ofpattern("eee-lll-dd h:mm:sszuuuu"); formatter.parse(date); date in format given above. getting parse error @ index 3 there multiple issues. correct pattern "eee mmm dd hh:mm:ss z uuuu" need use m instead of l - i'm investigating why @ moment. see datetimeformatter month pattern letter "l" fails . if .format("lll") returns 4, in 4th month. need use spaces instead of - need spaces between s, z , uuuu need use hh not h april 10th monday, not sunday see example code run live @ ideone.com . string input = "mon apr 10 07:05:45 mdt 2017" ; datetimeformatter f = datetimeformatter.ofpattern( "eee mmm dd hh:mm:ss z uuuu" , locale.us ); zoneddatetime zdt = zoneddatetime.parse( input , f ); zdt.tostring(): 2017-04-10t07:05:45-06:00[america/denver]

java - Cucumber and Spring boot integration -

i have rest/spring application using cucumber integration test. start spring boot maven following config during integration test phase. <plugin> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-maven-plugin</artifactid> <executions> <execution> <id>pre-integration-test</id> <goals> <goal>start</goal> </goals> <configuration> <arguments>--server.port=${server.port}</arguments> </configuration> </execution> <execution> <id>post-integration-test</id> <goals> <goal>stop</go

SpriteKit enemy sprites skip after contact with player -

i have made game basic idea player sprite has either collide or avoid falling enemy sprites depending on letter assigned enemy. problem when player makes contact sprite, surrounding enemies skip forward significantly. makes game hard play because there isn't enough time player move out of way of oncoming enemy sprites. happens on device , simulator. to see mean, @ brief video. can see lag @ 00:06 , 00:013: https://www.dropbox.com/s/8pp66baxc9uhy26/simulatorscreensnapz002.mov?dl=0 here code player , enemy contact: class gameplaysceneclass: skscene, skphysicscontactdelegate { private var player:player? private var center = cgfloat() private var canmove = false, moveleft = false private var itemcontroller = itemcontroller() private var scorelabel: sklabelnode? private var wordlabel: sklabelnode? private var score = 0 private var theword = "" private var vowelpressed = false let correct = soundsfx("correct.wav") let wrong = soundsfx("no

c# - How to use RDLC Report in WPF Spark? -

i using wpf spark making window application looks better. working till unless tried use rdlc api. rdlc working normal window when use sparkwindow rdlc doesn't seem have support in window because report there in invisible form because when right click on form gives me options print out report not visible on form. <windowsformshost height="500" width="500"> <rv:reportviewer x:name="reportletter" processingmode="local"/> </windowsformshost>

javascript - AngularJS instead of using two ng-show and two dropdowns Can I use one dropdown -

i want use 1 dropdown need satisfy both conditions. <div ng-show="user == 'admin'"> <div class="col-md-8 col-sm-12 col-xs-12"> <select ng-model="li" > <option ng-repeat="li in list">{{li.name}}</option> </select> </div> </div> <div ng-show="user != 'admin'"> <div class="col-md-8 col-sm-12 col-xs-12"> <select ng-model="li" > <option ng-repeat="li in list|limitto:1">{{li.name}}</option> </select> </div> </div> code in plunker you can try this: <div ng-if="user == 'admin'"> <div class="col-md-8 col-sm-12 col-xs-12"> <select ng-model="li"> <option ng-repeat="li in list">{{li.name}}&

java - Android APP failed to redirect button after FB login -

i'm working on building app 0 knowledge... checking on tutorials old ones, 2014~ code has changed bit or lot. here problems: added login facebook button problem don't know how redirect after login process confirmed... here's code package com.pagina.httpwww.pagina; import android.app.activity; import android.content.intent; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.view.view; import android.widget.button; import android.widget.textview; import com.facebook.callbackmanager; import com.facebook.facebookcallback; import com.facebook.facebookexception; import com.facebook.facebooksdk; import com.facebook.login.loginresult; import com.facebook.login.widget.loginbutton; public class mainactivity extends appcompatactivity implements view.onclicklistener{ loginbutton loginbutton; textview textview; callbackmanager callbackmanager; button redirect; @override protected void oncreate(bundle savedinstanc

database - How can I extract a last name from full name in mysql? -

i have table fullname column. want make query finding person via last name last name in full name column. would matter if accidentally returned first name matched query? a simple query be: select * table fullname '%insertlastname%' if want define last name name after last space: select substring_index(fullname, ' ', -1) lastname table lastname='insertlastname' two suboptimal answers, answers @ least.

Javascript array to multi level Object -

i have array in javascript , need convert multi-level object. example: input : var myarray = ["abc", "def", "ghi"] ; output want : var myobj = {abc:{ def: { ghi: {} } }}; what efficient way achieve javascript ? you can use reduce() , pass empty object accumulator. var myarray = ["abc", "def", "ghi"] ; var obj = {} myarray.reduce((r, e) => r[e] = {}, obj); console.log(obj)

xslt - SharePoint 2013 web part errors after running patch -

this isn't question, possible solution people tearing hair out on notorious , mysterious dataview web part error "web part cannot displayed... correlation id blah blah blah...". in our case, fought hard use xslt-customized data view web parts display list data on our sp publishing web. working great (and consistently) after fixing many "list not found" errors , like. ran microsoft patch on server, find of our data view web parts broke in process. side note: site load balanced, infrastructure team ran patch on 1 of servers. bad! after getting microsoft on phone, following solution fixed problem: we instructed following parameters in our dataview web part , delete them: <asp:parameter name="startrowindex" defaultvalue="0"/> <asp:parameter name="nextpagedata" defaultvalue="0"/> <asp:parameter name="maximumrows" defaultvalue="1000"/> the ms rep told patch added parameters our w

jquery - Javascript inline function call -

i have question inline function call in javascript. this example works: <button onclick="{alert($(this).text());}">testing</button> while not working: <button onclick="function(){alert($(this).text());}">testing</button> my question - why second case not working , first 1 does? i've come accross issue, using jquery-ui droppable: $( ".selector" ).droppable({ drop: function( event, ui ) {} }); droppable using syntax (without function() ). why that? lets break down sample sample <button onclick="{alert($(this).text());}">testing</button> this same doing following in pure javascript. document.queryselector('button').addeventlistener('click', function() { { alert($(this).text()); } }); it's bit weird add braces allowed , code within executed. second sample gets weird though. <button onclick="function(){alert($(this).text());}">t

mysql - Is necessary to create an explicit relation in the data base after defining it in the Sails js' model? -

i created model respective relation using following approach http://sailsjs.com/documentation/concepts/models-and-orm/associations and seems ok. but, when open model's tables sailsjs created, in mysql workbench. there isn't relation between tables. so; need specify relations or leave tables , continue working relations exists on sailsjs ? join table required n-n relationships, not 1-n ones. also, in config/models.js , if migrate set 'drop' sails drops , creates tables. when using 'alter' tries create added tables, using 'safe' doesn't create added tables. there isn't relation between tables what type of relation expecting?

Install WebExtensions on Firefox from the command line -

i found question how install firefox addon command line in scripts? seems work firefox extensions (i.e. ones install.rdf file) webextensions (extension manifest.json file instead)? please see: installing extensions customizing firefox: including extensions distribution of firefox the question link on askubuntu: how install firefox addon command line in scripts? several years out of date, have information. at point, mozilla add-ons, including firefox webextension add-ons, installed manually placing add-on's .xpi file in appropriate directory correct name extension without unpacking (unzipping) contents. [you can install them downloading them in firefox, drag-and-drop .xpi onto firefox/thunderbird, etc.] you can determine add-ons must unpacked unpacking add-on's .xpi file , looking @ install.rdf file see if has <em:unpack>true</em:unpack> . webextensions don't have file, , installed without unpacking. the .xpi file must called [e

c# - How to reference/link to a listbox that is dynamically created using a button and tabControl? -

i working on making music player in c#. making music playlists right , stuck. of right using tabcontrol , button adds tab empty listbox in it. here code button: private void button10_click(object sender, eventargs e) { tabpage tp = new tabpage("playlist"); tabcontrol1.tabpages.add(tp); listbox lb = new listbox(); lb.dock = dockstyle.fill; tp.controls.add(lb); } the problem running not know how allow user add music these dynamically created listboxes within tabs. main list of music located in listbox in first tab , want user able select music , put in new listboxes or "playlists" need reference them somehow. i'll assume have button ( addtoplaylistbutton ), textbox ( playlistname ) add selected song entered playlist (tab-) name , songs listbox called songlist . i'll furthermore assume every new playlist has new tab. in case you'll have identify them i'd change name of tabs: tabpage tp = new tabpage($"play

CommandLineRunner and Beans (Spring) -

code question about: @springbootapplication public class application { private static final logger log = loggerfactory.getlogger(application.class); public static void main(string args[]) { springapplication.run(application.class); } @bean public object test(resttemplate resttemplate) { quote quote = resttemplate.getforobject( "http://gturnquist-quoters.cfapps.io/api/random", quote.class); log.info(quote.tostring()); return new random(); } @bean public resttemplate resttemplate(resttemplatebuilder builder) { return builder.build(); } @bean public commandlinerunner run(resttemplate resttemplate) throws exception { return args -> { quote quote = resttemplate.getforobject( "http://gturnquist-quoters.cfapps.io/api/random", quote.class); log.info(quote.tostring()); }; } } i'm new spring.

scala - value saveAsTextFile is not a member of org.apache.spark.streaming.dstream.DStream[(String, Long)] -

i try save wordcount result in file. val wordcounts = words.map(x => (x, 1l)).reducebykey(_ + _) wordcounts.saveastextfile("/home/hadoop/datafile1") but showing value saveastextfile not member of org.apache.spark.streaming.dstream.dstream[(string, long)] [error] wordcounts.saveastextfile("/home/hadoop/datafile1") i using spark 2.1. show 1 answer suggesting old spark version.but want in spark 2.1. thanks. you using method defined rdd on dstream . this method on rdd : def saveastextfile(path: string): unit ...with description " save rdd text file, using string representations of elements ." this method on dstream : saveastextfiles(prefix: string, suffix: string = ""): unit ...with description " save each rdd in dstream @ text file, using string representation of elements. file name @ each batch interval generated based on prefix , suffix: "prefix-time_in_ms.suffix. " so method

performance - does RewriteRule (htaccess) increase call time? -

for example, htaccess rewrite rules, each call to: /myfolder/file.jpg should show files from: /another/file.jpg so, had question, increase call (file load) time? there new call made after browser goes first link?

Do I need clock synchronisation for cassandra if only one client writes to cluster? -

from cassandra's documentation got know cassandra uses timestamps of query resolve conflicts between 2 writes , hence clocks on nodes of cluster needs synchronised. in use-case have 1 client writing cluster , multiple clients reading cluster. so, if use client-side timestamp generator (which believe default version>3) still need have cluster node clocks synchronised each other? in context of write timestamps associated data being stored, clock synchronization not needed if using client timestamps , single client. however, still discourage not @ least trying keep clocks in sync in cassandra cluster. there have been cases clock skew affects other parts of cassandra. example, cassandra-11991 shows case clock skew effected node clocks used light weight transactions. while particular issue has been addressed, still seems idea make effort synchronize.

javascript - How to convert JSX to String? -

here jsx scode sample: export default class element extends react.component { render() { return ( <div> <div classname="alert alert-success"> {this.props.langs.map((lang, i) => <span key={i} classname="label label-default">{lang}</span>)} </div> </div> ) } } how string this? <div><div classname="alert alert-success">{this.props.langs.map((lang, i) => <span key={i} classname="label label-default">{lang}</span>)}</div></div> upd: got react components render on server. want them strings transform them templating library on client side. just call rendertostaticmarkup() , should static html markup language generated react. somewhat this: import reactdomserver 'react-dom/server'; import element './path/to/element/class'; const element = <element />; reactdomserver.rendertostat

JavaScript closure inside loops – simple practical example -

var funcs = []; (var = 0; < 3; i++) { // let's create 3 functions funcs[i] = function() { // , store them in funcs console.log("my value: " + i); // each should log value. }; } (var j = 0; j < 3; j++) { funcs[j](); // , let's run each 1 see } it outputs this: my value: 3 value: 3 value: 3 whereas i'd output: my value: 0 value: 1 value: 2 what's solution basic problem? well, problem variable i , within each of anonymous functions, bound same variable outside of function. what want bind variable within each function separate, unchanging value outside of function: var funcs = []; function createfunc(i) { return function() { console.log("my value: " + i); }; } (var = 0; < 3; i++) { funcs[i] = createfunc(i); } (var j = 0; j < 3; j++) { funcs[j](); // , let's run each 1 see }

javascript - Can a regular expression be crafted which determines the return type of a function? -

given text of following function: function f3() { return math.random() > 0.5 ? promise.resolve(true): 'naaah' } can regular expression compiled determines return type of f3() call, without calling function? given code, cannot determine return type of via regular expressions. proof contradiction: assume can find return type using regular expression. the return type decided in final line, via non-deterministic call random (it isn't known ahead of time). regular expressions deterministic- have same output when run on same input. thus, function's return type must static, since can run regular expression , find return type (and regular expression return same thing). contradiction: function's return type must static, function's return type variable due random note: above assumes type must single one, , not account union types on own. additionally, proof on why can't always. assume somehow can figure out every type used in fu

php - Page reloads even after return false in ajax $.post request -

i trying upload image after form submit using ajax call, having issue annoying me, new formdata($(this)[0]) gives me actual values, whenever try send through ajax malfunctioning , reloads page, cant see console well, please correct me wrong. my javascript code $("#editimage").submit(function(){ var data = new formdata($(this)[0]); console.log(data); return false; $.post("../galimages", data).done(function(response){ console.log(response); }); return false;}); my html code <form name="edit-image" id="editimage" action="" method="post" enctype="multipart/form-data"><input type="file" name="change-image" accept="image/*" class="form-control mb-20" value="upload image"> <input type="hidden" name="edit-img-id" id="editimageid"><input type="submit" class="btn btn-primary&q

javascript - jQuery doesn't recognize identical textnodes (sometimes) -

i wanted use jquery tweak copy-mechanism. noticed when anchor , focus nodes of selection same, corresponding jquery objects (compared using .is method) not. in chrome , firefox (windows) comparison fails in example: <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> <script> $(function () { $("#testdiv").on("copy", function(event) { var sel = window.getselection(); var $anchornode = $(sel.anchornode); var $focusnode = $(sel.focusnode); $("#logdiv").append("<p>the dom nodes are" + (sel.anchornode == sel.focusnode ? "" : "<b> not</b>") + " same.</p>"); $("#logdiv").append("<p>the jquery objects are" + ($anchornode.is($focusno

matlab - Showing density of something in 2d spacematlab -

i have 3 1 n vectors: x, y , phi. x , y determine position in 2d space , phi(i) amount of particles exist in position(x(i),y(i)). want plot 2d region shows amount of particles in space colors. example, positions in particles concentrated different positions smaller amount of particles. me how can that? answers highly appreciated %assuming x,y locations positive (otherwise shift) s = max( max(x), max(y) ); map = zeros(s,s); particle = 1:n map( x(particle ), y(particle ) ) = map( x(particle ), y(particle ) ) + 1; end %then can surf map plot map using surf or imshow. surf looking for!

python - Using pyHook to detect key up and down -

i found script using pyhook print mouse clicking , down: class record(object): def onmouseevent(self, event): print 'messagename:',event.messagename print 'message:',event.message print 'time:',event.time print 'window:',event.window print 'windowname:',event.windowname print 'position:',event.position print 'wheel:',event.wheel print 'injected:',event.injected print '---' #time.sleep(1) #if uncomment this, running program freeze stuff, mentioned earlier. return true record = record() hm = pyhook.hookmanager() hm.mouseall = record.onmouseevent hm.hookmouse() pythoncom.pumpmessages() when used pyhook same way detect keys , down on keyboard showed me key down def onkeyboardevent(event): print ('messagename:',event.messagename ) print ('message:',event.message) print ('time:',even