Posts

Showing posts from April, 2011

php - Call/embed wordpress post outside loop? -

permalink of post set to: <a href="/?link=<?php echo get_permalink( $postid ); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2> by example comes this: http://website.com/?link=http://website.com./post-example/ i want stay on home page, , need code embed content of http://website.com./post-example/ , nice thing have post tag post-example . by tag able call , embed post inside home page? $_get['link'] http://website.com./post-example/ now how call post? solutions? , should like: if ?link= exist in url, call function (embed post title , content), otherwise nothing. it seems have post's id. ( $postid ) if have post's id , want display specific post can this: <?php $my_special_post = get_post($postid, array_a); ?> after can display post's properties. example: <?php echo $my_special_post['post_title']; ?> <?php echo $my_special_pos

Separate git directories (master/dev) -

i work locally in 1 directory source code. i've got 2 branches : master , dev. want push on dedicated server each branch own directory, resulting 1 directory production , developpement. next, can configure nginx accessing each 1 on subdomains, etc. i tried use code, on post-receive file in (only) project.git/hooks/post-receive. #!/bin/bash while read oldrev newrev ref branch=`echo $ref | cut -d/ -f3` if [ "master" == "$branch" ]; git --work-tree=/home/myself/project/site --git-dir=/home/myself/myproject/myproject.git checkout -f echo 'changes pushed live.' fi if [ "dev" == "$branch" ]; git --work-tree=/home/myself/myproject/site-dev --git-dir=/home/myself/myproject/myproject.git checkout -f echo 'changes pushed dev.' fi done i try commit changes dev branch. push ("changes pushed dev"). dev directory has not been changed @ on remote server (same master branch). could me please

cloud - How to see command prompt progress bar reflecting parallel uploads in google bucket -

i trying upload big file (1 gb , 10 gb) through gsutil bucket on google cloud storage. i have updated .boto file @ 2 places. parallel_composite_upload_threshold = 150m parallel_composite_upload_component_size = 150m the threshold being maximum size of file can uploaded without using parallel upload , component size being size in big file divided while uploading. the big file created follows, mkfile -n 1g 1gb_file then use command, gsutil -m cp -r 1gb_file gs://temp-bucket the documentation @ https://cloud.google.com/storage/docs/gsutil/commands/cp says should see upload progress indicator continuously updates several different uploads @ once (corresponding each of sections of file being uploaded in parallel), until parallel upload completes. but can not see on cmd. progress indicator follows, copying file://1gb_file [content-type=application/octet-stream]... - [1/1 files][ 1.0 gib/ 1.0 gib] 100% done 302.8 kib/s eta 00:00:00 operation completed on 1 objects

scripting - Shell script runner and `--help` generator -

i've got tree full of shell scripts doing sorts of things relevant project. love if there tool foo such run foo --help , print documentation associated each of scripts (say, uniform system of annotation). bonus points if can run foo build , run scripts/build.sh . googling around has turned nothing, maybe haven't looked right places. there such program? no problem write, surprised if hasn't already.

javascript - Why my promise cant resolve? -

i have got 2 promises. 1 not being resolved , dont know why. processtradeoffer : chain of promises tries procced object called 'offer' . identifyoffer return var "valida" | "aceptable" | "denegable" . if 'valida' need identify items offer. need async function identifyitems(offer) return var 'offerstate' "denegable" | "aceptable" , can decline or accept offer. i know problem there not in statement (offerstate == 'valida'). code: const processtradeoffer = function(offer) { return new promise(function(resolve, reject) { identyoffer(offer) .then(function(offerstate) { return finishtradeoffer(offer, offerstate); }).then(function() { console.log('aqui'); return resolve(); }) }) } const finishtradeoffer = function(offer, offerstate) { return new promise(function(resolve, reject) {

ios simulator - iPhoneX can not show launch image well? -

Image
i add 1125x2436 launch image left iphonex. however, strange result in simulator right. have not idea causes that. update: i found "landscape" launch image read on iphonex simulator, , not "portrait". app set "portrait" device orientation only. if remove "landscape" launch image, , app seem use "portrait" image instead while can not found "landscape" image. still not idea how fix it.

playframework - Scala testing Web Service Client for POST request -

so play documentation can find here gives simple example call without auth header or parameters. could me figure out how use similar strategy more complex post request json data body , auth header required? can't work right now. i want know how test client using ws it's external http requests. thanks here snippet of code 1 of projects sends sms via twilio api: class smsserviceimpl @inject()(config: configuration, ws: wsclient) extends smsservice { val twilloaccountsid = config.getstring("twillo.accountsid").get val twilloauthtoken = config.getstring("twillo.authtoken").get val smsapiurl = config.getstring("twillo.apibaseurl").get + "/" +twilloaccountsid+"/messages.json" override def send(phone: string, message: string): future[unit] = { val data = map( "to" -> seq(phone), "from" -> seq(config.getstring("twillo.fromphone").get), "body&

docker - How to check if an externally linked container is connected -

using docker-compose, can add externally linked container so: foo/dockerfile services: has-external-link: networks: - default - other_default external_links: - other-service networks: other_default: external: true which should connect image service other-service defined in other/dockerfile . docker compose doesn't seem care if other-service or not when starting has-external-link . there way verify containers indeed linked expected?* *...that doesn't require executing in other-service , in modern age of docker not have curl or installed

sql server - How to find records exist with one date but not the other within the same table with sql -

i have table so: locationid | createddate | headcount -----------+-------------+----------- 1 | 2017-6-5 | 12 3 | 2017-6-5 | 458 5 | 2017-6-5 | 125 1 | 2017-8-5 | 12 5 | 2017-8-5 | 458 i need find locationids in table exist on particular date not exist in date. in table above i'd need return 3 | 2017-6-5 | 458 i'm trying below, think may need use temp tables accomplish task. select * headcounts full outer join headcounts b on a.locationid = b.locationid a.createddate = '2017-6-5' , b.createddate = '2017-6-5' , a.locationid null or b.locationid null any appreciated. you can where not exists : select * headcounts h1 not exists ( select * headcounts h2 h1.locationid = h2.locationid , h1.createddate <> h2.createddate )

Run Tensorflow object detecion with Nvidia GTX650 Ti (2GB)? -

is there way let run object detection 2gb graphic card? have 24gb dd3 ram on main board, can't use gpu? i did try add session_config.gpu_options.allow_growth=true in trainer.py don't help. seems graphic card doesn't have enough memory. cardinfos: 0, name: geforce gtx 650, pci bus id: 0000:01:00.0) [name: "/cpu:0" device_type: "cpu" memory_limit: 268435456 locality { } incarnation: 4876955943962853047 , name: "/gpu:0" device_type: "gpu" memory_limit: 1375862784 locality { bus_id: 1 } incarnation: 4236842880144430162 physical_device_desc: "device: 0, name: geforce gtx 650, pci bus id: 0000:01:00.0" ] train.py output: limit: 219414528 inuse: 192361216 maxinuse: 192483072 numallocs: 6030 maxallocsize: 6131712 2017-09-13 13:47:13.429510: w tensorflow/core/common_runtime/bfc_allocator.cc:277] ***********************************

javascript - How to get a tile representing a preview of a plan? -

question dronedeploy platform. by approach getting max difference in lat or lng, assign zoom according how big difference , tile: .. var maxlat, minlat, maxlng, minlng, zoom; plan.geometry.map(function(node){ maxlat==undefined ? maxlat=node.lat : (node.lat > maxlat ? maxlat = node.lat : false) minlat==undefined ? minlat=node.lat : (node.lat < minlat ? minlat = node.lat : false) maxlng==undefined ? maxlng=node.lng : (node.lng > maxlng ? maxlng = node.lng : false) minlng==undefined ? minlng=node.lng : (node.lng < minlng ? minlng = node.lng : false) }) if (maxlat-minlat > maxlng-minlng){ if ((maxlat-minlat)*1000>1 && (maxlat-minlat)*1000<2){ zoom = 17; } // other scopes zoom levels here else if ((maxlat-minlat)*100>1 && (maxlat-minlat)*100<9){ zoom = 8; } }else{ if ((maxlng-minlng)*1000>1 && (maxlng-minlng)*1000<2){ zoom = 17; } // other scopes zoom levels here else if ((maxlng-minlng)

How to join 2 views in mysql? -

this question has answer here: how full outer join in mysql? 12 answers i have 2 views columns, view1 = (id, number) view2 = (id, number, name) how create select display such that display = (id, number, name) and display full outer join view1 , view2. select view2.* view1 left join view 2 on view1.id = view2.id union select view2.* view1 right join view 2 on view1.id = view2.id

laravel - Connecting Google Compute Engine with Google App Engine -

i trying connect google compute engine instance mysql database google app engine using laravel. have connected google app engine cloud sql instance, don't have problem this, need additional database connection database located on google compute engine. google compute engine instance on different project. scheme: project -> compute engine -> instance -> mysql database project b -> app engine -> laravel project b -> cloud sql -> db-instance -> mysql database this app.yaml file: runtime: php env: flex runtime_config: document_root: public # ensure skip ".env", local development skip_files: - .env env_variables: # put production environment variables here. app_log: "errorlog" app_key: "[key]" storage_dir: "/tmp" cache_driver: "database" session_driver: "database" app_debug: "true" #cloud sql database connection db_connection: "[database_1_name]&qu

javascript - Invalid CSRF Token using Ajax -

i using purely javascript access web services built spring. when tried use ajax post call 1 of services encountered issue csrf. the ajax call lines of: var data = {'attribute1':'1','attribute2':'2'}; $.ajax({ type: "post", url: url, data: data, success: function(data) { if (typeof inputid !== 'undefined') { $("#"+inputid).val(json.stringify(data)); } console.log(json.stringify(data)); } }); i have been searching web, found update backend (jsp, php) populate attribute "${_csrf.parametername}" in form. however, not using backend, page html , javascript only. csrf_token cookie sent down , stored in browser web framework/server. typically when posting via ajax call you're doing... need send csrf_token value part of json data. that... need use javascript find cookie name , obtain value. need assign value right variable name

rworldmaps-R- Cant make it interactive -

Image
my code is: thecountry <- c("can", "deu", "ita","usa","gbr","fra","jpn") # these iso3 names of countries you'd plot in red maldf <- data.frame(country = c("can", "deu", "ita","usa","gbr","fra","jpn"), sixtyfiveplus = c("16.15%", "21.12%", "22.36%", "14.64%", "18.12%", "18.94%", "26.02%")) # maldf data.frame iso3 country names plus variable # merge map data malmap <- joincountrydata2map(maldf, joincode = "iso3", namejoincolumn = "country") # join maldf data.frame country map data mapcountrydata(malmap, namecolumntoplot="sixtyfiveplus", catmethod = "categorical", missingcountrycol = gray(.8), colourpalette = c("seagreen","seagreen1",&quo

cordova - Reliable Background Geolocation Service on Android in JavaScript -

the app should track user in background, calculations on locations received , notify user of events of interest. the logic has been written in javascript (for post-mortem analysis). so, not re-implement same in java/swift, i'm aiming cordova/reactnative/nativescript/titanium . android kill backgrounded app in tight memory conditions. make background operation more reliable, android service used. 1 make service "foreground" tell os user aware of service , service of importance user. os kill such app/service process. when ask re-start service asap. the problem looks javascript vm not started service , there no way run javascript logic. same problem frameworks mentioned. thus, service must all-native , re-implementation of logic. questions: are findings correct? i.e. in either mentioned framework there no easy way re-start javascript vm service? somewhere on saw trick service ran (invisible) activity instantiated vm again. possible? can give link/explanatio

r - Order of plots in ggplot2 facet -

Image
>panel_data concentration statistic name 1 100 39.100 cd4 subset_but 2 10 39.700 cd4 subset_but 3 1 0.012 cd4 subset_but 4 0 41.200 cd4 subset_but 5 100 3.970 cd4 subset/cd103 subset_but 6 10 2.940 cd4 subset/cd103 subset_but 7 1 100.000 cd4 subset/cd103 subset_but 8 0 2.620 cd4 subset/cd103 subset_but 9 100 57.900 cd4 subset/cd39 subset_but 10 10 31.200 cd4 subset/cd39 subset_but 11 1 0.000 cd4 subset/cd39 subset_but 12 0 30.600 cd4 subset/cd39 subset_but 13 100 8.090 cd4 subset/cd69 subset_but 14 10 6.530 cd4 subset/cd69 subset_but 15 1 100.000 cd4 subset/cd69 sub

Git clone through process builder in java -

i want run following command through process builder in java: git clone --depth 1 <url> the requirement interact command prompt fill username , password when asked. when hit command through cmd, asks username , password when same thing through process builder in java, instead of asking username , password gives following error: bash: dev/tty no such command or device error: couldn't username .. and code exits. note: providing username , password in url not desirable. using window credentials msnager popup not desirable , has been set false.

Reactjs, Redux - redux-persist -

i working on reactjs/redux application - , using java spring boot codebase acting api. i've got login system in place - notice when refresh page -- authentication state lost. i've added redux-persist, doesn't appear take affect in stashing logged in state , resuming experience? the bulk of redux-persist in place on router.js --- here store/provider gets set application. i unsure how , store state when user has logged in -- i've exposed form login , can see start check this.props.authdata states -- ideal call persistor.rehydrate() -- don't have access persistor or store on pages? //router.js import react, { component } 'react' import { browserrouter router, route, redirect, switch } 'react-router-dom' import createbrowserhistory 'history/createbrowserhistory' import { provider } 'react-redux' import { createstore, applymiddleware } 'redux' import thunk 'redux-thunk'; import {persiststore, autorehydrate}

reactjs - Redux-observable combineepics not mapping -

i new redux-observables , attempting combine epics, not working believe should. below code makes "menu_toggle" toggle correctly , delay prior console logging out button has been pressed, login_request won't mapto login_success. have following example: import { combineepics } 'redux-observable'; import 'rxjs'; const loginrequest = action$ => action$.oftype('login_request') .delay(1000) .mapto({ type: 'login_success' }); const menutoggle = action$ => action$.oftype('menu_toggle') .delay(1000) .subscribe(action => { console.log('button pressed!'); }); export const rootepic = combineepics( loginrequest, menutoggle ); the above example, have actual code in separate files, not seem work. if alter to: export const rootepic = combineepics(loginrequest); then fires correctly. add additional epic combineepics, won't fire epic longer. i cannot seem figure

List as an object field - how to handle it via Stream (Java 8)? -

there waybill object has set < packing > field, packing object has price field. list < waybill >. need calculate total cost of packing entire list < waybill >. how competently make through stream? thank you. class waybill { set<packing> setofpacking; } class packing { int price; } list<waybill> allwaybills = ... import java.util.stream.* list<waybill> allwaybills = ... int totalcost = allwaybills .stream() .maptoint(w -> w.setofpacking .stream() .maptoint(p -> p.price) .sum() ) .sum();

swift - How can I display an error and terminate the app when `NSURLSession` times out? -

so i'm trying run nsurlsession datatask on intranet-- if user isn't connected intranet, request time out. in case, want display error user, , terminate app i have this: let task = session.datatask(with: request, completionhandler: { (data, response, error) in if error != nil { let alert = nsalert() alert.messagetext = "network error" alert.informativetext = "make sure connected internal network. closing..." alert.alertstyle = nsalertstyle.warning alert.addbutton(withtitle: "ok") dispatchqueue.main.async { if alert.runmodal() == nsalertfirstbuttonreturn { nsapplication.shared().terminate(self) } } } let httpresponse = response as! httpurlresponse but code crashes @ alert.runmodal() current stack trace: 0 libswiftcore.dylib 0x0000000102b99130 swift_repor

regex - Writing a regexp that excludes a pattern while matching very generally -

i've been struggling bit now. trying write regexp catches places there's space before colon ( : )except cases. want not catch cases match ?.* : . in, question mark has space before it, sequence of characters, space , colon should considered okay. i've tried bunch of negative lookahead methods etc, problem i'm running main pattern more general exclusion pattern, it's not able exclude want. \s+: catches bad cases, catches 2 false positives. (\s+\?.*\s+:) catches false positives. how combine them don't false positives? bad cases (should caught): var type : cgfloat = 5.0 let dictionary = [ "string" : "key" ] let dictionary = [container<thing?>(value: value) : "woohoo"] good cases (shouldn't caught): var atest = true ? "true" : "false" let dict = [ "string": "key" ] class atest: supertype let multilineternary = true ? "a string" : "b s

angularjs directive - Angular 2 pass data between two components -

i want pass data between 2 components problem is: i have 2 components, lets suppose 1 'main' , 'modal-dialog'. in main want open modal-dialog , data modal-dialog without leaving main component i know how use @input can't see way use in app for example in main.html, if want pass data main modal use <modal-dialog [data]="data"> </modal-dialog> but want inverse something that <modal-dialog /*get data modal when event happens*/ > </modal-dialog> modal-dialog send message main, example, if close or click in button. look @output <modal-dialog [data]="data" (dialogevent)="processevent($event)"> </modal-dialog> in modaldialogcomponent @output() public dialogevent = new eventemitter(); public methodwhichtriggers(){ this.dialogevent.emit({id: 1, type: "anything need"}) } in maincomponent need have public processevent($event){ console.log($event); //will

performance - How can we optimize CPU/core/executor for different stages of a Spark job? -

Image
as below picture shows: my spark job has 3 stages: 0. groupby 1. repartition 2. collect stage 0 , 1 pretty lightweight, stage 2 quite cpu intensive. is possible have different configuration different stages of 1 spark job? i thought separate spark job 2 sub-ones, defeats purpose of using spark has intermediate result stored in memory. , extend our job time. any ideas please? no, it's not possible change spark configurations @ runtime. see documentation sparkconf : note once sparkconf object passed spark, cloned , can no longer modified user. spark not support modifying configuration @ runtime. however, guess not need repartition before collect , if there no other operations in-between. repartition move data around on nodes unnecessary if want collect them onto driver node.

mongodb - Count occurences and store IDs of not-empty multiple specific fields -

i have simple find query finds documents either first field not null, or second field not null looks this: db.registries.find({ "$or": [ { "field1": { "$ne": null } }, { "field2": { "$ne": null } } ] }, { "field1": 1, "field2": 1 }) then, on result, in javascript, i'm doing filter , map on array(result) i'm checking occurences of field1 , field2 , dividing them 3 arrays ids(objectids), 1 field1 not being null, 2nd field2 not being null , 3rd both fields not null i discovered using count instead of find lot faster, doesn't give me want, divide them 3 arrays, storing there ids is there way can speed find or use count instead, gives me output want?

javascript - CORS 405 Method Not Allowed even though I have the right headers (I think) -

i need more eyes on this. preflight request failing 405 method not allowed. as far can tell should working. here's request: options http://diffdomain/spf/v1/user/user@example.com/password/change http/1.1 host: diffdomain.com connection: keep-alive access-control-request-method: put origin: http://www.example.com user-agent: mozilla/5.0 (windows nt 10.0; win64; x64) applewebkit/537.36 (khtml, gecko) chrome/60.0.3112.113 safari/537.36 accept: */* referer: http://www.example.com/appname/index.html accept-encoding: gzip, deflate accept-language: en-us,es-us;q=0.8,es;q=0.6,en;q=0.4 response: http/1.1 405 method not allowed date: thu, 14 sep 2017 02:06:30 gmt server: apache/2.4.7 (ubuntu) access-control-allow-methods: post, get, put, options, delete x-powered-by: php/5.5.9-1ubuntu4.20 access-control-allow-origin: * access-control-allow-headers: content-type, api_key, authorization, accept content-length: 0 keep-alive: timeout=5, max=100 connection: keep-alive content-type

How to log contextual trace-id in an asynchronous scala application with slf4j + logback? -

i trying use mdc pass contextual information logging, asynchronous nature of scala means thread local model of mdc won't work application. although 1 possible solution problem offered here ( https://github.com/jroper/thread-local-context-propagation/ ), readme states author not recommend solution , instead recommends passing context explicitly. so given pass context explicitly, i'm wondering how using logback in way can programmatically parse out trace-id later on. help!

Cannot read file into array list java -

my program saves doubles in txt file read later arraylist. here code string missratiopathname = "/users/tomfinet/desktop/cache_experiment_miss_ratio_data.txt"; bufferedreader missratioinput = new bufferedreader(new filereader( new file(missratiopathname))); string missratioline; while ((missratioline = missratioinput.readline()) != null) { if (!(missratioline.trim().indexof("0") == 0) || (missratioline.trim().indexof(" ") == 0) || (missratioline.isempty())) { string rawdata = missratioline.split("\n")[0]; if (!rawdata.equals("")) missratiodata.add(double.parsedouble(rawdata)); } } here text file, every line in text file should added array double. 0.9932 0.98792 0.9806 0.97508 0.96796 0.9608 0.95704 0.95056 0.94284 0.93464 0.93028 0.92472 0.91952 when run program none of these lines added missratiodata arraylist because line of code never reached. ho

html - Images are displayed bigger than the actual size -

i have wordpress theme photographers notice images been displayed bigger actual size upload. stretching screen resolution guess, problem if users have such big resolution images seem poor quality, change show pictures @ original size, or stretch until max original size. can't quite find code responsible changes, this gallery link http://prophotosjapan.com/gallery/harbour-wedding/ but when open them individually http://prophotosjapan.com/wp-content/uploads/2017/09/engagement31-2-684x1024.jpg engagement31-2-684x1024.jpg (jpeg image, 684 × 1024 pixels) - scaled (78%) is code should change?

preg replace - preg_replace remove only the word after @ -

i'm trying remove username in string. tried code below removes after @ $string = 'he @username die'; $string = preg_replace('/@.*/','',$string); echo $string; // output: i want output be: die thanks use \s means not space character (the opposite of \s ) instead of . : $string = 'he @username die'; $string = preg_replace('/@\s+/','',$string); echo $string; // output: die you may want remove following space: $string = 'he @username die'; $string = preg_replace('/@\s+\s*/','',$string); echo $string; // output: die

uitableview - UITableViewRowAction is too wide in iOS 11 -

Image
i use following trick in order have images in table view row actions: how manage equal width uitableviewrowaction in ios8.0?(more,delete,etc actions) uitableviewrowaction *completeaction = [uitableviewrowaction rowactionwithstyle:uitableviewrowactionstylenormal title:@" " handler:^(uitableviewrowaction *action, nsindexpath *indexpath) { ... }]; completeaction.backgroundcolor = [uicolor colorwithpatternimage:[uiimage imagenamed:@"myimagehere"]]; but no longer works ios 11 - width of row action button big image it's repeated: is there fix this? i had same problem , able fix it. however, solution quite hacky , needs explanation: we'll have implement own uitableview , modifies layout of it's subviews , subsubviews in layoutsubviews

hyper v - How to set node priority in Windows server 2016 Failover cluster -

i have 4 nodes , each node have 10 - 15 resources. there way can set node priority whenever failover happens resource failed on priority 1 node. server: windows server 2016 failover cluster manager: 10.0 resource configuration version: 8.0 thanks in advance. change preferred owner setting in failover cluster. follow following steps. open failover cluster console in 1 of nodes right click on role want provide high availability (example vm - properties) select nodes want in failover cluster , make node 1 up.

MySQL match against 0 result in MyISAM but works on InnoDB -

i have table create table `tbl` ( `id` bigint(20) not null, `code` varchar(64) collate utf8mb4_unicode_ci default null ) engine=myisam default charset=utf8mb4 collate=utf8mb4_unicode_ci; alter table `tbl` add primary key (`id`); alter table `tbl` add fulltext key `code` (`code`); insert `tbl` (`id`, `code`) values (1, '110.103'); and query select code `tbl` (match (code) against (' 110.103 *' in boolean mode) ) but there no result. idea? first of all, fulltext indexes stores words. words seperated e.g. period - isn't letter, digit, underscore or single apostrophe. text consists of 2 words, "101" , "103". the mysql fulltext index store words a minimum word length . myisam uses 4 default value ft_min_word_len , 3-digit "words" not included, while innodb uses 3 innodb_ft_min_token_size , why included. change these settings (and rebuild index), , both engines find same rows. that being said: match (code) agai

asp.net mvc - C++ Unmanaged external dll load in IIS -

Image
i have external c++ unmanaged dll & want use in asp.net application following way : [dllimport("c:\\windows\\system32\\inetsrv\\project2.dll", callingconvention = callingconvention.cdecl)] when run program visual studio 13 work fine. when publish project on web server (iis 7) can't work display message.

ionic framework - cordova.getCurrentLocation() method not working properly -

i'm, building android ionic app using cordova.geolocation.getcurrentposition gps break every time, unable current location moves error function. it's working fine in lower version of android (5.0.0) breaks in higher version (6.0.1 , above). here code: var options = { timeout: 10000, maximumage: 100, enablehighaccuracy: false }; $cordovageolocation.getcurrentposition(options).then(function(position) { $scope.usercurrentlat = position.coords.latitude; $scope.usercurrentlng = position.coords.longitude; var source = new google.maps.latlng($scope.usercurrentlat, $scope.usercurrentlng); var destination = new google.maps.latlng(data.data.geolocation.coordinates[0], data.data.geolocation.coordinates[1]); var directionsservice = new google.maps.directionsservice(); $scope.userrestdistance = parsefloat((google.maps.geometry.spherical.computedistancebetween(source, destination)/1000).tofixed(1))+" km"; $ionicloading.hide(); }, f

regex - regular expression in Perl to excluded patterns but include pattern -

i want have regex pattern match line: 1.this line must contain word "s200" 2. end of string cannot "sping","js","json","css" here monster got,which doesn't work (?=^.*$(?<!sping)(?<!js)(?<!css)(?<!json))(?=s200) i new regex, aapreciated! you have tagged perl , here's perl solution: $_ = $stringtotest; if (/s200/) { # know string contains "s200" if (/sping|json|js|css$/) { # know end 1 of sping,json,js or css } }

javascript - Detect back button in browser when the user go back to original page -

Image
i have page hides query string parameter on load using pushstate method in javascript. example original url, www.iprocess.com?acsn=23423432423432434; what hides acsn parameter on load. looks www.iprocess.com problem when click link inside page , goes page read www.iprocess.com without query string parameter data not load. what want if user go page loads query string parameters @ same time hides it. this code: window.history.pushstate('currentpage', 'title', window.location.pathname); instead of using pushstate , use replacestate , way won't keep parameter state in history. note easy make live example, here plnkr . please open windowed mode ( in top right corner)

java - Can we use selenium webdriver for opera and safari browsers? -

mostly use selenium google chrome, firefox , ie. can use selenium opera , safari browsers? safari support windows has been withdrawn, can run safari tests on mac. we can execute tests on opera using following post - system.setproperty("webdriver.opera.driver", "path opera driver"); webdriver driver = new operadriver(); driver.get("https://google.com/");

javascript - How to logout user in specific time -

i have simple application login in webforms , need automatic logout user in specific time, due updates e.g in 13:30 need logout user website redirect login page. thank you. i suppose use iis webserver. easiest way take app offline put app_offline.htm in web root folder. iis redirects request file. https://blogs.msdn.microsoft.com/amb/2012/02/03/easiest-way-to-take-your-web-site-offline-iis-6-0-or-iis-7-5-with-net-4-0/

ruby on rails - Reduce multiple file upload time -

i uploading multiple images , videos input[type='file'], upload takes lot of time. there way can reduce upload time. here current code: paperclip settings has_attached_file :file, styles: lambda { |a| a.instance.check_file_type} validates_attachment_content_type :file, content_type: [/\aimage\/.*\z/,/\avideo\/.*\z/] def is_video? file.content_type =~ %r(video) end def is_image? file.content_type =~ %r(image) end def check_file_type if is_image? { :medium => { :geometry => "640x480" }, :thumb => { :geometry => "100x100#" } } elsif is_video? { :medium => { :geometry => "640x480", :format => 'mp4', :processors => [:transcoder] }, :thumb => { :geometry => "100x100#", :format => 'jpg', :time => 10 }} else {} end end _form.html.erb <%= simple_form_for(@room, remote: true, format: :js, authenticity_token:

vagrant - Request API on an other VM -

i have 2 vm ansible, 1 deploy our django project, , 1 deploy our wordpress websites. we made wordpress plugin wich request rest api of django project. problem : want dev in local on django project , must enter url of django project in wordpress plugin made. problem is, url accessible host machin not on other vm. vagrantfile port config of django vm : config.vm.network :forwarded_port, guest: 8443, host: 8443 vagrantfile port config of wordpress vm : config.vm.network :forwarded_port, guest: 5580, host: 5580 sorry bad english thanks in advance; add line in each vm's vagrantfile : config.vm.network "private_network", ip: "ipaddress" substitute ipaddress fitting ip , way can access whichever vm through set ip. need both vm's running @ same time in order communication successful though.

xml - Generate Equals und HashCode with jaxb2-maven-plugin Version 2.2 -

we use jaxb2-maven-plugin (version 2.2) , generate equal , hashcode method each jaxbobject. have alreade binding.xjb file configure anything. is there way generate methods? if try add arguments -xequals -xhashcode, following exception: unbekannter parameter -xequals -xhashcode configuration: <configuration> <arguments>-xequals -xhashcode</arguments> </configuration> thank you! you can generate hashcode , equals jaxb2 basics plugins: <project ...> ... <build> <plugins> ... <plugin> <groupid>org.jvnet.jaxb2.maven2</groupid> <artifactid>maven-jaxb2-plugin</artifactid> <executions> <execution> <goals> <goal>generate</goal> </goals> </execution>

mysql - I have joined 4 tables in sql , Is it correct or not ? please verify the code -

below query executed selecting price , size along brand , category, sub-category name db select c.cname ,sc.scname ,b.bname ,p.size ,p.price ( ( ( price p inner join category c on p.c_id = c.c_id ) inner join subcategory sc on p.sc_id = sc.sc_id ) inner join brand b on p.b_id = b.p_id )

AngularJS stream audio from PHP server -

due cors , authentication third-party server, cannot load audio file directly angularjs , has php backend. here php server code serve audio file downloaded third-party server: header('pragma: public'); // required header('content-type: audio/mpeg'); header('content-length: ' . filesize($file)); header("content-transfer-encoding: binary"); header('content-disposition: filename="' . basename($file)); header('x-pad: avoid browser bug'); header('cache-control: no-cache'); $len = readfile($file); exit(); here angularjs client code: var blob = new blob([response], { type: 'audio/mpeg' }); var url = window.url.createobjecturl(blob); var audio = new audio(url); audio.play(); however fails exception message: domexception: failed load because no supported source found. any advice , insight appreciated. since you're creating audio object response anyway, there's no reason have you're doin

android - How to use Content Resolver to query SQLite database? -

currently i'm using db.query() method access database directly,and code running perfectly. when try use content resolver access database using cursor cursor = getcontentresolver().query() method app isn't starts.i have created contract class store constant , customerprovider class use contantprovider. catalogactivity (mainactivity): public class catalogactivity extends appcompatactivity { private customerdbhelper mdbhelper; button addbutton; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_catalog); addbutton= (button) findviewbyid(r.id.addbutton); addbutton.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { intent intent = new intent(catalogactivity.this, addcustomeractivity.class); startactivity(intent); } }); mdbhelper=new customerdbhelper(this); displaydatabaseinfo();