Posts

algorithm - Finding all the intervals that does not overlap with the point -

i have intervals of form (a1, b1), (a2, b2), ...., (an, bn) . support following operations adding new interval. deleting existing interval. given point, find intervals not overlap point. intervals tree straightforward solution if want find intervals overlap point. case when want find non intersecting intervals? have nodes in 2 trees simultaneously. tree holds them key ai , tree b holds them key bi . insertion , deletion o(log n) . requirement 3, print nodes in b smallest biggest , stop when bi still smaller point. same, backwards, in a. example: given (1,10), (5,18), (13,20) , , point 12 . interval(s) in ai bigger 12 (13,20) , , in b interval(s) smaller (1,10) .

javascript - How to stream Data in with java websockets -

i read tutorials or tried have js code connects java websocket , when click on button sends test string websocket , reciev other. now wanna have realtime stream in string js code recieves current time in milliseconds how can achiev don't know every second new time ? maybe better idea use normal time instead of milliseconds can change this. my codes far javascript var websocket; $(document).ready(function(){ websocket = new websocket("ws://localhost:8080/timestreamingtestartid-1.0-snapshot/websockets/simplestockmarket") websocket.onopen = function(){ alert("sucess: registered!!"); } $("#start").click(function(){ websocket.send("test") websocket.onmessage = function(erg){ console.log(erg); } }); }); my java websocket code @serverendpoint("/websockets/simplestockmarket") public class simplestockmarketwsserverendpoint { @onopen public void open(session session) { } @onmessage...

shell - How to recursively resolve symlinks without readlink or realpath? -

what's best portable (posix?) way script finding target link if readlink , realpath not available? would ls -l , , if starts l take text after -> sed , repeat until no longer starts l ? per bashfaq #29 (which endorses gnu find approach suggested @eugeniurosca ): one available (though not pure-posix) option use perl : target=/path/to/symlink-name perl -le 'print readlink $env{target}' if symlink's name guaranteed not contain -> , can parse output of ls . the below code combines both approaches: # define best readlink function available platform if command -v readlink >/dev/null 2>/dev/null; # first choice: use real readlink command readlink() { command readlink -- "$@" } elif find . -maxdepth 0 -printf '%l' >/dev/null 2>/dev/null; # second choice: use gnu find readlink() { local ll candidate >/dev/null 2>&1 ||: if candidate=$(find "$1" -maxdepth 0 -printf '...

excel - Worksheet_Change determine value not content -

i trying detect if there changes in cell value, not particularly cell contents. have found multiple solutions find out if cell contents has changed, not work when cell equal cell. for example, have cell a1 set equal b1 , b1 has formula calls in multiple other cells, not able go beginning , determine whether cell has changed that. needs come directly a1. this 1 of examples found on site, not determine if value of a1 has changed, whether contents has changed. private sub worksheet_change(byval target range) if target.column = 1 cells(target.row, 3).value = date end if end sub the function application.volatile true @ top of sub make sub calculate each time value in excel changes. need global variable stores last-known value of specified range, , time sub runs, start if new_cell_value <> stored_global_variable then... and close stored_global_variable = new_cell value' end if see here further info [h/t vzczc original answer , method]: refresh...

compare two values and generate a percentage (excel) -

i trying create spreadsheet keeps track of how many files have been quality checked against haven't , displays amount left checked percentage. currently on open spreadsheet pulls details checked folder , work checked folder follows:- private sub pdf_loading() range("m5").clear dim folderpath string, path string, count integer folderpath = "c:\path folder\" ' looks in spercific folder path = folderpath & "*.pdf" ' file type time pdf files, though if change word files, or psd's filename = dir(path) while filename <> "" ' checks filename <less or >greater "filename" "" empty not spercific file count = count + 1 ' counts amount of pdf files, add 1 last known number filename = dir() ' contiunes count until reaches end of directory loop range("m5").value = count ' puts final count value in cell each cell in [m:m] if cell.value = "0" cell.clearc...

php - Match exact word with any character regex -

how match exact word contains special character ? $string = 'fall in love #pepsimoji! celebrate #worldemojiday downloading our keyboard @ http://bit.ly/pepsikb & take text game notch. - teacher'; preg_match("/\b#worldemojiday\b/i",$string); //false i want match exact word containing character. if want match word 'download' in string, should return false preg_match("/\bdownload\b/i",$string); //false but when search downloading, should return true. thanks the problem \b word boundary before # non-word character. \b cannot match position between 2 non-word (or between 2 word) characters, thus, not match. a solution either remove first \b , or use \b (a non-word boundary matching between 2 word or 2 non-word characters) instead of it. \b#worldemojiday\b or #worldemojiday\b see demo (or this one ) note \b matches @ beginning of string. here a way build regex dynamically, adding word boundaries necessary: ...

javascript - Angular: How to access angular $scope.ng-model_name from outside $http.get method? -

Image
i using angularjs code $http.get method, when tried access $scope.metric.label. giving error "error: $scope.metric undefined not defined. want create dynamic url selection options. not able create dynamic url. demo http://plnkr.co/edit/urufgauqjt8golz7qvsl?p=preview in demo uncomment alert(url) see not working //fetching metrics , filling metric selection options $http.get("https:localhost:8080/metering/data/") .success(function(response) { $scope.metrics = response.nova_meters.concat(response.glance_meters).concat(response.cinder_meters).concat(response.ipmi_meters).concat(response.neutron_meters).concat(response.swift_meters).concat(response.kwapi_meters); $scope.metric = $scope.metrics[0]; }); // fetching list of instances , filling group selection options $http.get("https:localhost:8080/metering/project/") .success(function(response) { //alert(json.stringify(response[0].instances)); $scope.groups = res...