Posts

Showing posts from August, 2014

swift - Build WatchOS Apps: Develop and Design -

i trying run sample code book build watchos: develop , design. following segment of code returns 2 errors: @ibaction func buttontapped(){ if animating { spinnerimage.stopanimating() animating = false animatewithduration(0.2, animations: updatebuttontostopped()) } else { spinnerimage.startanimating() animating = true animatewithduration(0.2, animations: updatebuttontogoing()) } } both errors occur in calls animatewithduration() , indicate there type conflict. ideas of how can fix this? in hurry? instead of calling animatewithduration so: animatewithduration(0.2, animations: updatebuttontostopped()) you'd give updatebuttontostopped function parameter so: animatewithduration(0.2, animations: updatebuttontostopped) notice () after updatebuttontostopped gone. and same goes updatebuttontogoing of course :) why? if @ documentation animatewithduration

Ansible: repeated lines exists but update only specific occurrence -

i have change `<!--<parameter name=\"hostnameverifier\">defaultandlocalhost</parameter>-->` to <!--<parameter name=\"hostnameverifier\">allowall</parameter>--> in apim_home/repository/conf/axis2/axis2.xml. i using - name: "modify hostnameverifier" lineinfile: dest: "/home/ec2-user/ansible-test/wso2am-2.0.0/repository/conf/axis2/axis2.xml" state: "present" line: "\t\t<parameter name=\"hostnameverifier\">allowall</parameter>" regexp: "<!--<parameter name=\"hostnameverifier\">defaultandlocalhost</parameter>-->" this replacing 3rd occurrence of regexp. want replace 2nd occurrence. how do that? you can't lineinfile . docs : ...only last line found replaced... and lineinfile iterates line-by-line – can't add more context it. you shoul

c++ - Linux - How to pass interprocess messages while preserving datatype -

i'm working on inherited codebase uses posix message queues pass data between processes. because of nature of mq , messages have passed in form of bytes , numbytes passed along when messages reconstructed, there's lot of ugly static_cast<pvoid> -ing. question is there interprocess message passing interface in linux maintains datatype of content? or there better way of doing this?

ansible - Get service tool error when trying to install vmware tools -

i trying install vmware tools on exsi host. code have it. --- - hosts: my-host tasks: - name: install vmware tools yum: pkg="open-vm-tools" state=present when: ansible_os_family == "redhat" - name: enabling , starting -> vmtoolsd service: name=vmtoolsd enabled=yes state=started this error after run code. play [my-host] task [setup] ******************************************************************* ok: [myhost.com] task [install vmware tools] **************************************************** skipping: [myhost.com] task [enabling , starting -> vmtoolsd] *************************************** fatal: [myhost.com]: failed! => {"changed": false, "failed": true, "msg": "get_service_tools not implemented on target platform"} no more hosts left ************************************************************* [warning]: not cre

android layout allignment issue -

i want put "type 1" , "type 2" in same line , make on center. means everything. working on api level 23. trued android:layout_centerhorizontal="true" in inner linearlayout doesn't work <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context="com.example.sid.roommanager.btrancol"> <linearlayout android:id="@+id/linearlayout02" android:layout_height="wrap_content" android:layout_width=

ruby on rails - Conditional links with active_model_serializers -

i'm trying create hypermedia api in rails. i'd serialize payloads active_model_serializers using json_api adapter. doesn't seem trivial serialize links conditionaly. it's kind of blog application users can follow other users. when serialize user resource, usera, want have link rel :follow if current_user not following usera , link rel :unfollow if current_user following usera. seems extremely trivial use case when creating hypermedia api. know if there's way of doing active_model_serializers? i wrote (and include in serializers): def self.link(rel, &block) serializer = self super user = scope next unless serializer.can?(user, rel, @object) instance_eval(&block) end end # , in serializer (just usual): link :self api_user_path(object.id) end it work. don't feel right. , wouldn't surprised if future changes active_model_serializers screw things me. if else looking solution here did.

c# - If and Switch statements; Is there an easier way of producing this code? -

my code follows: namespace calculation { class program { static void main(string[] args) { console.writeline("this system calculate speed, distance or time."); console.writeline("1 = speed - 2 = distance - 3 = time"); console.writeline("please enter calculation perform. 1, 2 or 3"); string usercalculation = console.readline(); int calculation = int.parse(usercalculation); if(calculation < 1) { console.writeline("please enter number greater or equal 1 less 3."); } if (calculation > 3) { console.writeline("please enter number less 3 greater or equal 1."); } else { switch (calculation) { //this statement calculates speed. case 1: console.writeline("you have chose calculate speed. s = d/t");

php - GuzzleHttps - How to send async. data via POST (using Pool) -

i'm trying send post data via pool in guzzle library. but, @ address data sending post empty - don't it. $client = new client(); $requests = function () { foreach($this->urls $url) { yield new request('post', $url, [ 'body' => '...' ]); } }; i tried form_params , multiparts, not working again (post empty again $_request & $_get). and of course piece of code (for completeness): $pool = new pool($client, $requests(), [ 'concurrency' => count($this->urls), 'fulfilled' => function ($response) {}, 'rejected' => function ($reason) {}, }); $promise = $pool->promise(); $promise->wait(); guzzle sends request correctly (enter on second server), in not have data. what doing wrong? thanks! edit: i'm trying replace code guzzle (is repeated in cycle now): $ch = curl_init(); $url = 'https://example.cop'; curl_setopt($ch, curlo

angularjs - Very strange unknown provider error from ui-router -

Image
i have unknown provider issue , have tried placing breakpoints see being caused from. have checked work against other work have done see if there stupid mistakes can't see any. i'd appreciate help. here attempt @ debugging: has come across before? if need post code. thanks ///<reference path="../../../../typings/angular.d.ts" /> ///<reference path="loginservice.ts" /> module app { export function logindirective(): ng.idirective { return { restrict: 'e', templateurl: '/scripts/controllers/common/login.html', scope : {}, controller: 'logincontroller', controlleras: 'vm', bindtocontroller: true }; } export class logincontroller { static $inject = ['$scope', '$http', 'loginservice']; public constructor( private $scope: ng.iscope,

dockerhub - How can I find public images (like ubuntu) in Docker-Hub, using REST API? -

previously used https://registry.hub.docker.com/v1/search?q=ubuntu&n=1 , got {"num_pages": 13196, "num_results": 13196, "results": [{"is_automated": false, "name": "ubuntu", "is_trusted": false, "is_official": true, "star_count": 4681, "description": "ubuntu debian-based linux operating system based on free software."}], "page_size": 1, "query": "ubuntu", "page": 1} but got outdated images how can now? i didn't find information here: https://docs.docker.com/v1.7/reference/api/docker-io_api/ thanks in advance

c# - Multiple process commands fail to get back any response -

having challenge being able send commands cmd.exe via c# process class. basically want call r.exe , send several commands stage data before run r functions , pull out result. but can't result simple 'dir' statemenet :( process p = new process(); processstartinfo info = new processstartinfo(); info.filename = "cmd.exe"; info.redirectstandardinput = true; info.redirectstandardoutput = true; info.useshellexecute = false; string pathtor = @"c:\program files\r\r-3.3.1\bin"; p.startinfo = info; p.start(); list<string> output = new list<string>(); using (streamwriter sw = p.standardinput) { if (sw.basestream.canwrite) { sw.writeline("cd " + pathtor); sw.writeline("dir"); while (p.standardoutput.peek() > -1) { var peekval = p.standardoutput.peek(); output.add(p.standardoutput.readline()); } } } foreach (var line in output) { console.wr

ftp - How to switch sites in different servers -

i have following problem: if have 1 website , server drops, can configure backup website? example: www.exemplesite.com goes offline because of techinical issues, www.exemplesite2.com goes online, users don't have wait until first site goes online? i want if> site 1 goes down then> site 2 goes online until site 1 down when site 1 comes work, put site 2 down again if i'm not being clear, i'm sorry, english poor buy domain , put exact same code in ? , make private , if goes down can unprivate ?

android - How to dynamically load images in GridView or how to optimazi it's work? -

Image
my application has gridview control display photos directory. if directory consist of 1000 or 2000 photos, gridview slow, because of loading photos @ once. is possible implement gradual loading of photos, example, after view 100 photos, loaded 100? or there more ways optimize speed of gridview? grateful advice. my code activity_main.xml the piece of code demonstrate gridview <gridview android:id="@+id/gridview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:columnwidth="90dp" android:numcolumns="auto_fit" android:verticalspacing="10dp" android:horizontalspacing="10dp" android:stretchmode="columnwidth" android:gravity="center"/> mainactivity.java public class mainactivity extends activity { imageadapter myimageadapter; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedins

mastercard - International characters resulting in bad OAuth 1.0 body hash -

i'm getting body hash mismatch when post body of xml web service request contains international characters. from i've read, sounds international characters in post body have encoded before calculating oauth body hash. utf-8 cafÉ of "caf%c3%89" doesn't seem work mastercard match web service. i'm having trouble tool we're using (iway service manager) re-interpreting "caf&#201;" "cafÉ". before figure out how squeeze encoder in before oauth step, hoping confirm had dealt issue. proper encoding use on post body international characters (or problem else)? for calculating mastercard oauth body hash, recommended encoding utf-8 . core sdk made available mastercard uses utf-8 encoder encode oauth_body_hash.

Prevent Changes to a Spotfire DXP -

is there way prevent changes (i.e., lock or hide) calculated columns or scripts in spotfire file (.dxp). we trying deploy template / file built in spotfire , our team use , prevent accidental changes while continue work on updates etc... any appreciated! there couple of ways can go this. scripting can remove scripting licenses users of dxp. wouldn't prevent calculated column changes. best method, in opinion, duplication , versioning. deploy live template public folder , keep backup in folder have access. then, edit copy of template version control number template2_2.dxp. when ready deploy it, overwrite live version. have of live version, need backup newest one. it's basic easy method , ensures don't leave room mistakes or on limit users removing licenses.

Sending email using perl with sendmail -

i trying send email using sendmail in perl. email sent content send subject gets added 'to:' in email. example, if address from@gmail.com , address to@gmail.com , subject "test subject" . email reply-to: field from@gmail.com,"subject:test.email","to:to"@gmail.com,"content-type:text/plain" here code: open(sendmail, "|/usr/lib/sendmail -oi -t '$to_email' -f '$from_email'") || ($error_message .= "<p>unable open email process.</p>"); print sendmail $reply_to; print sendmail $subject; print sendmail $send_to; print sendmail "content-type: text/plain\n\n"; print sendmail $content; close(sendmail); and if remove $reply_to , $send_to lines, email comes from: field apache server. any appreciated. not want use other library email::mime since doesn't exist on system. i not sure wrong show, here working code my ($header, $from,

Search Polymorphic relation in Laravel -

i'm using polymorphic relation store follower/following information users. list of following users, use: $following = user::with('following')->findorfail($id); in user.php , public function following() { return $this->morphmany('app\like', 'user', 'likeable_type')->with('follower'); } now, want search particular user in following users. tried: $followings = $user->following->where('follower.first_name', 'like', "%$query%"); and it's returning nothing. how can search particular user in case?

Order of generators in Scala "for comprehension" affects answer -

i'm new scala, , i'm working through scala impatient cay horstmann. going until got comprehension, , came against cryptic passage (section 2.6, advanced loops , comprehensions): [start quote] the generated collection compatible first generator. for (c <- "hello"; <- 0 1) yield (c + i).tochar // yields "hieflmlmop" (i <- 0 1; c <- "hello") yield (c + i).tochar // yields vector('h', 'e', 'l', 'l', 'o', 'i', 'f', 'm', 'm', 'p') [end quote] indeed, running in repl, see result of first code snippet has type string, , second code snippet has type scala.collection.immutable.indexedseq[char]. why types differ? think understand second line of code, don't understand why first line doesn't have type scala.collection.immutable.indexedseq[char]. magic happening string rather vector? author mean "compatible first generator"?

Haskell: how to treat big combinatorial Lists? -

just tried write program simulates simple system online game. idea behind is, let program calculate efficient set of items possible stat efficiency set. clarify bit more: you've got 8 item slots , 74 different items, can't use item twice, , doesn't matter item in slot. i'am not yet trying calculate 1 set of stats, i'am stuck way earlier! so problem number of possibilities (74^8) before filtering , (74 choose 8) after filtering. program starts lagging when try head(permu' 2). since know haskell supposed work infinite lists, how work list of 899 trillion entries? know takes lot of capacity pc that's why here ask: how treat big list in haskell can work it? the function simplified looks this: quicksort :: (ord a) => [a] -> [a] quicksort [] = [] quicksort [a] = [a] quicksort (x:xs) = (quicksort [y | y <- xs, y <= x]) ++ [x] ++ (quicksort [z | z <- xs , z > x]) eliminatedouble [] = [] eliminatedouble (x:xs) = if x `elem` xs eliminate

Cannot execute Javascript from Chrome console -

Image
in past has been possible write js in chrome console (and still possible on firefox). last month or hasn't worked, type in there silently accepted no obvious impact, functions call not run, etc. see screenshot direct console.log() fails produce output: i can't find documentation indicating feature removed nor can find obvious causes why isn't working anymore. happening in chrome 52. step 1: the little icon next no smoking looking sign looks half of hour glass (see image), click on it. filter settings. step 2: it give option: click on logs or all tab show console logs.

java - Extraneous postfixed data in JSON for POST method -

i wondering if can tell me if problem worth consider or how can fix if needed. we have web service written in java built using spring boot , running on amazon aws. used our other products , services internally. though endpoint public, there authentication prevents public access. one of our api accepts json parameter post method. our qe pointed out our api not detect extraneous data following json data. example, assuming our api expects data like: { "name": "john doe", "email": "john.doe@example.com" } our api not complain if following data given: { "name": "john doe", "email": "john.doe@example.com" } hello, i’m ignored! our api ignores extraneous portion completely. use jackson deserialize json string. looked jackson , spring documentation not able find out how can detected. so, question is: security threat? if so, how can fixed? thanks, masa i digged jackson source c

xml - Simple way to get execute an Xpath against a String in Java? -

i know similar question has been asked (and answered) number of times, , i've tried many of suggestions, reason, cannot get working. i have xml document (in "compositebodyline") in string variable, , want perform xpath search on xml document , result(s) xpath search. how can that? here's 1 example of i've tried (or merging several different things i've found: // from: http://javarevisited.blogspot.com/2012/12/create-and-evaluate-xpath-java-example-tutorial-program.html //create documentbuilderfactory reading xml file documentbuilderfactory factory = documentbuilderfactory.newinstance(); documentbuilder builder = factory.newdocumentbuilder(); inputstream inputstream = new bytearrayinputstream(compositebodyline.getbytes()); org.w3c.dom.document doc = builder.parse(inputstream); system.out.println("doc.getparentnode()=[" + doc.getparentnode().tostring() + "]"); // create xpathfactory creating xpath object

php - What is the correct call method for "api.tumblr.com/v2/blog/{blog-identifier}/post/delete" -

i have done before, , life of me, cannot seem reproduce code i've written. i trying delete specific posts on blog outdated, can automatically re-published updates. i can post fine, no problems there. the code having trouble is: $client->post("http://api.tumblr.com/v2/blog/.".$blog_name.".tumblr.com/post/delete?id=".$post_id); if run above code, print out so: stdclass object ( [meta] => stdclass object ( [status] => 401 [msg] => unauthorized ) [response] => array ( ) ) i have tried modify little changing url, , have come with, still, not seem working me. query: $client->post("http://api.tumblr.com/v2/blog/.".$blog_name.".tumblr.com/post/delete/".$post_id); response: stdclass object ( [meta] => stdclass object ( [status] => 404 [msg] => not found ) [response] => array ( ) ) one of errors saying not found, , error saying not authorised, when am, being able make posts, , follow, unfollow u

Cannot install .NET 3.5 on Windows Server 2012 R2 with Chef Test Kitchen -

i not find way install .net 3.5 chef test kitchen on windows server 2012 r2. i can install framework command line with c:\windows\system32\dism.exe /online /enable-feature /featurename:netfx3 /norestart /all /source:"c:\users\admin\appdata\local\temp\dotnetfx35.exe" or powershell prompt with install-windowsfeature –name net-framework-core –source "c:\users\admin\appdata\local\temp\dotnetfx35.exe" but if execute of following in chef same error: deployment image servicing , management tool version: 6.3.9600.17031 image version: 6.3.9600.17031 enabling feature(s) error: 0x800f0906 the source files not downloaded. use "source" option specify location of files required restore feature. more information on specifying source location, see http://go.microsoft.com/fwlink .... i have copied dotnetfx35.exe user's temp directory @ c:\users\admin\appdata\local\temp\dotnetfx35.exe chef --version ch

geolocation - What's the difference between "area" and "BoundingBox" from Redis's source code -

http://download.redis.io/redis-stable/deps/geohash-int/geohash_helper.c url above, know there 2 conceptions , 1 geohashboundingbox ,and area,my questions what's difference between them , why need them both? why sentence "geohashgetcoordrange(&long_range, &lat_range);" called 2 times? geohashradius geohashgetareasbyradius(double longitude, double latitude, double radius_meters) { geohashrange long_range, lat_range; geohashradius radius = { { 0 } }; geohashbits hash = { 0 }; geohashneighbors neighbors = { { 0 } }; geohasharea area = { { 0 } }; double min_lon, max_lon, min_lat, max_lat; double bounds[4]; int steps; geohashboundingbox(longitude, latitude, radius_meters, bounds); min_lon = bounds[0]; min_lat = bounds[1]; max_lon = bounds[2]; max_lat = bounds[3]; steps = geohashestimatestepsbyradius(radius_meters,latitude); geohashgetcoordrange(&long_range, &lat_range); geohashencode(&long_range, &lat_range, longitude, latitude, steps, &am

SQL Server procedure function value to used in select statement -

i created stored procedure p_calc_member_fee @id member_fee person , stored in temp table. and need extract value in select statement because need pass in member id member fee, created function named fn_get_member_fee call procedure return member_fee . seems cannot call function using select fn_get_member_fee (@member.id) member i got below error, please kindly help, thank you msg 557, level 16, state 2, line 39 functions , extended stored procedures can executed within function. you cannot execute sp function. there 1 exception insecure , highly not recommended (because of it's not provided here can found if required). you can rewrite sp accept table input parameter or rewrite output multiple rows, can insert values temp table , use within query.

c# - Dependency Graph using Dictionaries and Lists -

i'm in middle of working on dependency graph, , i'm having trouble adding dependents , dependees. i have set like: private list<tuple<string, string>> dg; private dictionary<string, list<string>> dependants; private dictionary<string, list<string>> dependees; and i'm trying add dictionaries like: for (int = 0; < dg.count; i++) { dependants.add(dg[i].item1, new list<string>().add(dg[i].item2); } it gives me error "argument2: cannot convert void system.collections.generic.list" try add new list in second parameter. think know why i'm getting errors, having trouble thinking of alternative way correctly add dictionaries. my goal this: //dg = {("a", "b"), ("a", "c"), ("b", "d"), ("d", "d")} // dependents("a") = {"b", "c"} // dependents("b") = {"d"} // depende

javascript - Using multiple methods on one controller in AngularJS -

please need , advice. want use 2 methods on 1 controller. first method display selected rooms , second display selected pax. however, first method works, second md-select don't display array in second method. here js , html code snippet: var app = angular.module('corewebapp', ['ngmaterial', 'ngmessages', 'nganimate']); app.controller('selectedtextcontroller', function($scope) { $scope.rooms = [1, 2, 3, 4, 5, 6, 7]; $scope.selectedroom; $scope.getselectedtext = function() { if ($scope.selectedroom !== undefined) { return $scope.selectedroom + " room(s)"; } else { return "rooms"; } }; $scope.paxes = [1, 2, 3, 4, 5]; $scope.selectedpax; $scope.getselectedpersons = function() { if ($scope.selectedpax !== undefined) { return $scope.selectedpax; } else { return "pax"; } }; }); <div> <label>rooms</label&

MySQL (now() - Interval 1 Month) for this year only -

i need this. i have following sql statement select * table month(orderdate) = month(now() - interval 1 month) the problem is returning data last month years... doing wrong or normal issue people face function? the problem facing if use year(now()) report writing not show data 2016 when hit 2017. i'm trying write 6 month sales history report. any guidance appreciated. added information select * data_wh.salesord_hdr month(orderdate) = month(now() - interval 1 month) returns.... '2015-08-14 00:00:00' try using date_sub between : select * data_wh.salesord_hdr orderdate between date_sub(now(), interval 1 month) , date_sub(now(), interval 2 month) this avoids problem of having deal boundary conditions when using month , year . edit: the above query return records order date between 1 , 2 months old . if want identify orders previous calendar month , have bit more work. try query: select * data_wh.salesord_hd

android - Intents in Kotlin -

so, know in java use launch new activity intent intent = new intent(this, someactivity.class); startactiviry(intent); but i'm writting project using kotlin, in kotlin it's val intent = intent(this,someactivity::class.java) startactivity(intent) but crashes problem fatal exception: main process: com.pashabred.passlin, pid: 15243 java.lang.runtimeexception: unable start activity componentinfo{com.pashabred.passlin/com.pashabred.passlin.enterring}: kotlin.kotlinnullpointerexception @ android.app.activitythread.performlaunchactivity(activitythread.java:2325) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2387) @ android.app.activitythread.access$800(activitythread.java:151) @ android.app.activitythread$h.handlemessage(activitythread.java:1303) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:135) @

asp.net mvc - Concatenate string in javascript -

i want dynamically append java script file name based on application culture name in mvc while giving reference of java script file. for e.g. <script src="~/clients/@tenant.clientname/backend/js/datetimepickerlocalizetion/fr.js"></script> suppose culture fr , want append dynamically in src tag, file name fr.js . i have culture name in tenant class, dependency injected. but not able append file name .js string. so, how can achieve ? you have couple of choices here. construct script link in code block , use in src this: @{ var scriptlink = $"~/clients/{tenant.clientname}/backend/js/datetimepickerlocalizetion/{tenant.culture}.js" } <script src="@scriptlink "></script> if want keep 1 liner, have use braces mark code blocks in markup. this: <script src="~/clients/@(tenant.clientname)/backend/js/datetimepickerlocalizetion/@(tenant.culture).js"></script>

dataframe - Groupwise computation in R -

this question has answer here: grouping functions (tapply, by, aggregate) , *apply family 9 answers i have grouped , summarized data frame in r have table like: group | value | count ========================== | 1 | 4 | 2 | 2 | 10 | 4 b | 3 | 2 b | 4 | 4 b | 2 | 3 c | 5 | 3 c | 2 | 6 i interested in finding out relative frequency of value 2 within each group: group | relative freq of 2 ========================== | 2/(4+2+4) = 0.2 b | 3/(2+4+3) = 0.33 c | 6/(3+6) = 0.67 is there simple, elegant way of calculating in r, other writing bunch of code loops , conditionals? possibly using dplyr. using dplyr , after grouping 'group', subset 'count' 'value' 2 (assuming there single 'value' of 2 per each 'group') , divide sum o

algorithm - Time Complexity of javascript indexOf method -

i studying big o notation technical interview , realized javascript's indexof method may have time complexity of o(n) traverses through each element of array , returns index found. we know time complexity of o(n^2) (n square) not performance measure larger data. so bad idea use indexof inside loops? in javascript, common see code indexof method being used inside loops, may measure equality or prepare object. rather arrays, should prefer objects wherever necessary provide lookup constant time performance o(1). any suggestions appreciated. to honest, tl;dr. but, did speed tests of various ways of checking occurrences in string (if goal using indexof. if trying position of match, don't know how there). ways tested were: .includes() .match() .indexof() (there variants such .search() , .lastindexof() , etc. have not tested). here test: var test = 'test string'; console.time('match'); console.log(test.match(/string/)); cons

JavaScript in Java code throwing exception -

i'm trying call javascript function java code. code follows: scriptenginemanager manager = new scriptenginemanager(); scriptengine engine = manager.getenginebyname("javascript"); string script = baseurl + "uiconfigurator/includes/js/datacaptureframework.js"; try { logger.info("evaluating engine"); logger.info(script); url url1 = new url(script); logger.info("url1 "+url1.getpath()+url1); bufferedreader in = new bufferedreader( new inputstreamreader(url1.openstream())); string inputline = null; stringbuffer buffer = new stringbuffer(); while ((inputline = in.readline()) != null) buffer.append(inputline); logger.info(buffer.tostring

base64 - php base64_encode image displayed on the site from external website -

i getting content first website , displaying on other website using file_get_contents() , using preg_replace() , preg_match() modify output way want it. now, there images base64_encode() stuck on figuring out how that? if use line of code: preg_match_all("/<img .*?(?=src)src=\"([^\"]+)\"/si", $fourth_content, $out) i can print out images src cannot encode them , send them src. does know how can achieve this? i'd advise think in steps. have do? fetch html remote url complete grab every image complete display every image todo you have image urls, what? want iterate on every image. sidenote: every image want grab means new http request (download). builds loading time. think: want? if so, let's break down: step 1 get html url. <?php // url $url = 'https://twitter.com/dogethedog'; // html url $data = file_get_contents($url); step 2 grab every image. // grab every image sou

java - Spring boot load image after upload -

i able upload image server , can locate image in path /static/images/gallery . when try load uploaded images application not displaying theme. after application restart. the static directory loaded @ startup. when upload images or make changes files or folder under static folder not reflect applicationcontext initialized. to upload dynamic image can follow these steps: step 1: create directory outside static folder media created on server /var/www/html/myapp/media step 2: upload files in media directory. step 3: implement webmvcconfigurer. @configuration public class additionalresourcewebconfiguration implements webmvcconfigurer { @override public void addresourcehandlers(final resourcehandlerregistry registry) { registry.addresourcehandler("/media/**").addresourcelocations("file:media/"); } } once uploaded can access file http://localhost:8080/media/filename.jpg dynamically.

javascript - "Uncaught [object Object] thrown - zone.js" error thrown when mocking response (Angular2) -

a strange error happening, apparently when try mock particular http response using angular2 / jasmine. i've narrowed down when have call httpmock.mockresponse happens, , if comment out, not. the error just: zone.js:260 uncaught [object object] thrown zone.runtask @ zone.js:260 zonetask.invoke @ zone.js:423 there no further information given though. ideas how start debug such error? i using chome devtools test.

javascript - meteorjs - admin users like django -

someone know 1 package or 1 tutorial make admin users django? i'd create superuser terminal , on admin pages create users i'd create personalization users schema of collection2. 'd remove create user of acconts-password , superuser can create users. what houston:admin ? houston zero-config meteor admin, modeled after django admin https://github.com/gterrono/houston i have not tried it, sounds it's looking for

javascript - How can I load all my site menu and other textual content first and then load images in wordpress? -

i using wordpress create website. when load page , check network tab, images taking long load, decreases website speed. so possible load other content, menu,page headings etc. , load images ? basically want improve website performance. what want called "lazy loading" of images. lazy loading means images loaded "on-demand" rather load initial load of page, make initial page load speed faster if have many images, or few big images. you write stand-alone javascript implementation. but since using wordpress, recommend wordpress plug-in , compatible wordpress right out-of-the-box. here 1 option i've found using quick google search: https://wordpress.org/plugins/lazy-load you need download plug-in, install on wordpress , activate (and might need follow instructions). plugin installation instruction: https://wordpress.org/plugins/lazy-load/installation/ plugin faq(with code): https://wordpress.org/plugins/lazy-load/faq/ regarding laz

JavaScript parse function JSON.parse does not work as expected -

the case: var s = '{"a": 2}'; var d = json.parse(s); // d = object {a: 2} it ok. the similar case not parse string, however. why? var s = "{'a': 2}"; var d= json.parse(s) // uncaught syntaxerror: unexpected token ' in json @ position 1 expected result - parsed object in first case. should have worked because ' , " interchangeable in javascript. according standard , need double quotes denotes string, key is.

c++ - Function template modifies parameter declared with top-level const: clang bug? -

the code below compiles correctly on clang 3.8.1-1 on archlinux. is clang bug? gcc issue correct warning/error on this. template <class t> struct bugreproducer{ using size_type = typename t::size_type; int bug1(size_type count); int bug2(size_type count) const; static int bug3(size_type count); }; template <class t> int bugreproducer<t>::bug1(size_type const count){ // bug. must not allowed count = 5; // return use result... return count; } template <class t> int bugreproducer<t>::bug2(size_type const count) const{ // same const method count = 5; return count; } template <class t> int bugreproducer<t>::bug3(size_type const count){ // same static method count = 5; return count; } struct dummyvector{ using size_type = int; }; int main(){ using bugrepr = bugreproducer<dummyvector>; bugrepr reproducer; auto = reproducer.bug1(1); auto b = repr

python - How to debug external .py functions run from Jupyter/IPython notebook -

Image
my jupyter/ipython notebook executes functions in external .py. i need set breakpoints within these functions, inspect variables, single step, etc. it isn't practical use combination of print statements , throwing exceptions early-exit cell. i need kind of workflow. is possible hook third-party editor/ide view .py , somehow connect python runtime jupyter/ipython using? so if set breakpoint in external .py using ide , execute cell in notebook encounters said breakpoint, can continue navigate manually within ide. edit: i've found https://pypi.python.org/pypi/ipdb https://www.quora.com/what-are-your-favorite-tricks-for-ipython-notebook edit https://www.youtube.com/watch?v=jb2hhoahvce <-- video getting close i'm after, can't quite see how put together. video demonstrates spyder ide ipython prompt... wonder if maybe can run notebook through prompt , debug it. edit: looks though pycharm i'm after: https://www.jetbrains.com/help/pycharm/2016.1/tut

ios - UITableViewCell with multline input field ? -

i want create uitableview cell , multiline input field (textview). height of textview or cell should increase automatically user enter text. hi there: has been bugging me day i've put think has cracked it. i'm assuming know how put basic tableview together. you need add uitextview each row, and, crucially, make tableviewcontroller delegate each uitextview. alongside array of string values each of rows, need have array of heights (cgfloats) each row. crucial aspect assign each textview numerical tag equal indexpath.row cell allows keep track of textview dealing with. start out array of identical values, idea update array needed when text gets big existing frame, demonstrate below. i implemented following 2 delegate functions bespoke function update layout required: func updatelayout(fortextview: uitextview) -> void { guard fortextview.tag < self.data.count else { return } // make sure we're not going try , access value not exist self.data[fo