Posts

Showing posts from September, 2012

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

regex - R regular expression replace :75% -> 0.75 -

surely naive question i'm in r , have expression v <- "gastrula:75%" that want replace "gastrula0.75" i tried things : v <- sub("\\.(\\d+)%","0.\\1",v) v <- sub("[:punct:](\\d)\\1+[:punct:]","0.\\1",v) but didn't find worked. here's possibility: v <- "gastrula:75%" str <- unlist(strsplit(v,":")) paste0(str[1], as.numeric(gsub("%","",str[2]))/100)

php - Amazon s3 - Call file after upload -

i'm using php script upload file amazon s3 $s3->putobjectfile($url,$bucket,$filename, s3::acl_private,array(),array("content-type" => "application/json")); immediately after upload, need information file , call through cloudfront see file available after minutes. do know why , if there way sort out? there way have file available? thank you it available me test... $ date;aws s3 cp foo s3://bucket/foo;date;curl -i http://dxxx.cloudfront.net/foo;date thu aug 6 04:30:01 utc 2015 upload: ./foo s3://bucket/foo thu aug 6 04:30:02 utc 2015 http/1.1 200 ok content-type: text/html content-length: 24 connection: keep-alive date: thu, 06 aug 2015 04:30:03 gmt x-amz-version-id: null last-modified: thu, 06 aug 2015 04:30:03 gmt etag: "5089fc210a3df99a6a04fe64c929d8e7" accept-ranges: bytes server: amazons3 x-cache: miss cloudfront via: 1.1 fed2ed9d8e7c2b37559eac3b2a2386fc.cloudfront.net (cloudfront) x-amz-cf-id: geaaklcqstyadakxkbvmmsj

java - Sorting ArrayList according to 2 attributes -

i want sort arraylist on base of 2 attributes. first on base of id , on base of score. each entry has score. here code. public class outputsentence { int tokenid; double similarityscore; string title; string quantity; string unit; public outputsentence(int tokenid,double similarityscore,string title,string quantity,string unit) { this.tokenid = tokenid; this.similarityscore = similarityscore; this.title = title; this.quantity = quantity; this.unit = unit; } @override public string tostring() { // todo auto-generated method stub return ("token_id: "+this.tokenid + " score: "+this.similarityscore + " title: "+ this.title + " quantity: "+this.quantity+ " unit: "+this.unit); } public int gettokenid() { retur

xml rpc - posting to a wordpress blog using XML-RPC without credentials -

i able create post within iphone app/server code. i'm guessing there no problem doing xml-rpc. the thing app user needs give me admin user/password blog, avoid (as user have problem disclosing data myself) the question - can avoid somehow? having user install plugin wrote somehow me seems more reasonable me - question is: "will help? can done? creative solutions welcomed... security through obscurity never idea suggest making username , password same thing while setting user role author.this post little effort.

http - Connection to website cannot be established (randomly) -

we manage website: http://elearning.uem.mz it mozambique (hosted in portugal), , have lot of complaints users can't connect it. it seems problem connection user, can't pinpoint exact problem. what know is: it affects randomly (a computer works 1 day, next doesn't); it seems based on time (a user won't able connect 30 minutes 2 hours); sometimes gives privoxy 500 error; sometimes gives err_names_not_resolved; it affects browsers. we created small .bat script has run administrator: ipconfig /flushdns ipconfig /renew ipconfig /registerdns this seems solve times, each issue has handled individually. is there minimize issue? after lot of time , testing, found out problem happening every other site in respective country... it seems have been problems/upgrades whole infra-structure was, , still is, messing dns.

ios - dyld: Library not loaded: @rpath/SwiftyJSON.framework/SwiftyJSON -

i've been using simulator test app. today decided test using other devices in simulator , surprise crashes on startup on devices, on others works perfectly my app builds runs on : ipad air resizable ipad iphone 5s iphone 6 iphone 6plus resizable iphone my app crashes on: ipad 2 ipad retina iphone 4s iphone 5 the error i'm getting : dyld: library not loaded: @rpath/swiftyjson.framework/swiftyjson referenced from: /users/data/library/developer/coresimulator/devices/2accff1f-d35f-444a-b709-2a41ac9cc7d2/data/containers/bundle/application/da7480f6-4032-4eb5-a51f-5d028088ffe1/demo mobile.app/demo mobile reason: no suitable image found. (lldb) sometimes more information : referenced from: /users/data/library/developer/coresimulator/devices/2accff1f-d35f-444a-b709-2a41ac9cc7d2/data/containers/bundle/application/da7480f6-4032-4eb5-a51f-5d028088ffe1/demo mobile.app/demo mobile reason: no suitable image found. did find: /users/data/library/developer/co

Visual Sourcesafe in VS2013 -

i have visual studio 2013 , have number of projects in visual studio online, still have old projects in visual source safe. works fine on 2 pcs have third when try set source control visual source safe not show up. doe have ideas on how add visual source safe vs 2013 show choice in dropdown. according microsoft support: visual source safe no more active product , no surprise if plugin not available in visual studio 2013 microsoft stopped supporting long ago , replaced team foundation server. if still using visual source safe, recommended upgrade team foundation server. you can use team foundation server express (up 5 users) free , use visual sourcesafe upgrade tool import project directly tfs. or buy full server $400 , up. alternatively, can open visual studio online account (free 5 users) , migrate sources cloud. can add additional users monthly license fee. if msdn subscriber or microsoft partner, subscription might include fu

jquery - using spservices to search a list -

i trying search sharepoint list called mollylist. has column name food, calories, weight... ect. modified sample code below, keep getting error: post /_vti_bin/lists.asmx 500 (internal server error) and have no idea issue? can check out code? <!-- begin snippet: js hide: false --> <body> <table><tbody><tr><td align="right">calories</td> <td align="left"><input id="firstname" type="text"/></td></tr> <tr><td align="right">weight:</td> <td align="left"><input id="wt" type="text"/></td></tr> <tr><td align="right">weight:</td> <td align="left"><input id="wt2" type="text"/></td></tr></tbody></table> <p><input id="sb" type="button" value="search"/> <

ruby on rails - Modal updating data but throwing error -

i want able update data in modal, , have updated data displayed in table on close of modal. it updating db, after throws error: nomethoderror in products#update and highlights line of code: , says @products nil <% @products.each |product| %> this in index.html.erb <div class="container-fluid col-md-8"> <h1>products</h1> <table class="table table-striped table-hover table-bordered table-condensed sortable"> <thead> <tr> <th><a>title</a></th> <th><a>asin</a></th> <th><a>price</a></th> <th> </th> <th><a>toggle</a></th> </tr> </thead> <tbody> <% @products.each |product| %> <tr> <td><%= product.title %></td> <td><%= link_to product.asin, "" %></td> <td><%= number_to_currency(pr

c# - Edit and Save Pivot Table in Database in ASP.NET -

i want create asp.net web page have 1 dropdownlist control , upon changing selection of it. pivot table should created. column headers , row headers of table should come database. values shown in table retrieved database respect corresponding column header , row header. table values should editable , upon "save" button click data in values should saved in database corresponding column header , row header. example: | lot1 | lot2 | lot3 | ... --------------------------------------------- product1 | 100 | 2000 | 3000 | ... --------------------------------------------- product2 | 1000 | 3000 | 4000 | ... --------------------------------------------- product3 | 3500 | 6000 | 4500 | ... --------------------------------------------- . . these values should editable , upon save button click these should save in database respect lot number , product.

What is the best way to create this Layout in Android? -

Image
i have been struggling hours layout work. here code: <linearlayout 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:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:paddingbottom="@dimen/activity_vertical_margin" android:orientation="horizontal" tools:context=".mainpreviewactivity"> <fragment android:name="com.apps.foo.cleanpreviewfragment" android:id="@+id/clean_preview_fragment" android:layout_weight="0.5" android:layout_width="0dp" android:layout_height="match_parent"> </fragme

ruby on rails - Destroying some records takes a really, really long time -

i have product model has_many productattributes in rails 4.2.3 application. a product can have on 10,000 producattributes sometimes. i need delete of these products, when call destroy on product, takes really, long time. looks gets list of ids productattribute , called delete on each 1 individually. but when gets end, sort of hangs. have lot of data delete, , need this. but can't have thing hang forever. have ctrl-c , after time see rollback happening. my question is, in heck doing? why can't reliably delete lots of data application layer? i suspect use like has_many :product_attributes, dependent: :destroy you might want using dependent: :delete rails doesn't instantiate dependent records before destroying them individually. the documentation have more information consequences (e.g. if callbacks executed on dependent models etc.)

Python: can't create subdirectory -

i want apply test list of files. files past test should moved directory "pass"; others should moved directory "fail". thus output directory should contain subdirectories "pass" , "fail". here attempt: if(<scan==pass>) # working fine point dest_dir = outdir + '\\' + 'pass' # problem here print("pass", xmlfile) movefiletodirectory(indir, xmlfile, dest_dir) else: dest_dir = os.path.dirname(outdir + '\\' + 'fail') print("fail: ", xmlfile) movefiletodirectory(indir, xmlfile, dest_dir) however, code moving files output directory , not creating "pass" or "fail" subdirectories. ideas why? use os.path.join(). example: os.path.join(outdir, 'pass') see post also, don't know movefiletodirectory does. use standard os.rename : os.rename("path/to/c

jQuery-File-Upload send error -

i want upload file added input. use code this <form> <input id="myinput" type="file"> </form> <script> $('#myinput').fileupload({ url: '/upload', change: function() { $('#myinput').fileupload('send', {}) .success(function() { console.log('success') }) .error(function() { console.log('error') }); } }); </script> i see jquery-file-upload send request files queue , server returns 200 ok. promise rejects , have 'error' in console. i inside plugin code , see in case returns promise rejects. should pass fileinput or files 'send' parameter resolvable promise. files duplicated. how can resolved promise server response?

oracle sqldeveloper - SQL for joining 2 tables but a bit complicated for my understanding -

got situation thats bit beyond understanding. table has product, country , factory table b has product, factory , city. the scenario such sales forecast data flows country level via factory , city level. have factories in rotterdam , amsterdam. issue such factories in table need same factory in table b. i have clean data situations c&d factories in table wrong , need cleaning. therefore first need identify these wrong records: here got far joining table , b select a.prod,a.country,a.factory,b.prod,b.factory,b.city table1 a, table2 b , a.prod=b.prod , a.factory <>b.factory of course can find specific known wrong record using below sql, need find wrong records without specifying product or select a.prod,a.country,a.factory,b.prod,b.factory,b.city table1 a, table2 b a.prod=b.prod , a.factory <>b.factory , a.country ='norway' , a.factory ='rotterdam' , b.city ='oslo' situation 1 table a product country factory proda

JWT signature validation using certificate authority's public key -

i trying this: on client side: 1. generate json web token (jwt) using header, payload. 2. sign jwt using private key. have certificate signed root ca. 3. send jwt server. on server side: 1. verify received jwt. 2. have access public key/certificate of root ca has signed certificate. is possible verify signature of jwt using public key or certificate of root ca. please note not want verify jwt using public key there many clients have private-public ket pairs , not possible server obtain public keys clients. goal make server-side validation use public key/certificate of root ca validate jwt. is possible? no not possible in way describe: you'll need actual certificate to: verify signature on jwt public key in it verify certificate signed root ca but again because of 2. don't need exchange certificate out-of-band sender can send certificate along jwt. can satisfy goal anyway since don't have obtain public keys clients separately.

http - C# Logging in to a website with cookies -

i've been trying program log in website few days now, no avail. believe have bit of correct (particularly format of data needs posted). however, i'm having hard time figuring out problem i'm having. website requires cookies authenticate login , i'm not sure how handle cookies. i've tried following many google results it's silly, , yet none of them great job of explaining need know. to achieve log in, i'm using httpwebrequest , httpwebresponse. code i'm using put other stack overflow questions did not solve problem. means, essentially, not understand process required log website http. have fiddler installed, , have used chrome developers tools monitor network traffic , compare post of website. here code: using system; using system.net; using system.io; using system.text; using system.threading.tasks; using system.net.http; namespace formposting { class program { static void main(string[] args) { // url of l

node.js - express-session, read vars on socket.io interaction -

i making chat customers of web page, express.js, , socket.io, , i'm trying manage sessions express-session, problem is, how read session values on socket. here's part of code. thanks :) var express = require('express'); var app = express(); var http = require('http').server(app); var io = require('socket.io')(http); var bodyparser = require('body-parser'); var session = require('express-session'); var shortid = require('shortid'); app.use(express.static('public')); app.use( session({ secret: 'dont move', resave: true, saveuninitialized: true }) ); app.use( bodyparser.urlencoded({ extended: true }) ); app.post('/chat', function(req, res){ var sess = req.session; sess.ssid = shortid.generate(); res.render('chat', { name: "name" }); }); io.on('connection', func

r - Operator == inconsistent in logical columns in data.table -

please see following reproducible example: library(data.table) set.seed(123) dt <- data.table(a=rep(0.3,10000)) dt[, b := runif(.n) < a] dt[b == t, .n] # [1] 3005 dt[, summary(b)] # mode false true na's # logical 6995 3005 0 everything looks fine , count of "true" values same 2 methods. replace col b new one. dt[, b := runif(.n) < a] dt[b == t, .n] # [1] 3331 dt[, summary(b)] # mode false true na's # logical 6981 3019 0 the count of 't' in column b different!!! same column 1 method gives 3331 "true" values , other 3019. when == bypassed dt[b != f, .n] # [1] 3019 dt[, summary(b)] # mode false true na's # logical 6981 3019 0 which correct again i can reproduce data.table v1.94 , 1.9.5 on windows 8.1 x64. here's easier reproducible example without runif() . require(data.table) ## 1.9.4+ dt = data.table(x = 1:5) dt[, y := x <= 2l] # x

SagePay not receiving all responses from PayPal -

i have client using sage pay payment provider, gives option pay paypal when clicking through sagepay. appears transactions user has selected "paypal", sagepay not receiving confirmation payment successful. therefore website seeing transaction failed. isn't happening every paypal transaction enough starting cause issue. is else having problem how start think handling it?

python - Tornado - why does static files without StaticFileHandler donot work? -

i new tornado. trying link css file html template. using jinja2 tornado. due unknown reasons css file not loading up. edit : have created custom render_template function working fine. directory structure: app.py static css custom.css templates index.html here request handler's class: class index(requesthandler): def get(self): path = os.path.join('static/css/', 'custom.css') return self.write(render_template('index.html', path = path)) and here index.html template: <!doctype html> <html> <head> <link rel="stylesheet" type="text/css" href="{{path}}"/> </head> <body> <div> <div class="header"> asdasdasd </div> </div><!--wrapper--> </body> </html> but browser returning 404-notfound error css file correct url, http://localhost/static/css/custom.css h

angularjs - Non-assignable error in directive when using ternary operator -

i have directive has isolate scope action property. when using ternary operator in view, i'm getting expression 'ctrl.someboolean ? 'some text' : 'different text'' used directive 'mydirective' non-assignable! usages <my-directive name='my name' action="ctrl.someboolean ? 'some text' : 'different text'"> <my-directive name='my name 2' action="'some static text'"> directive angular.module('example') .directive('mydirective', [ function() { return { restrict: 'e', replace: true, transclude: true, templateurl: 'mydirective.html', scope: { name: '@', action: '=?' }, require: ['mydirective', 'form'], controller: 'mydirectivectrl', controlleras: 'ctrl', bindtocontroller: true

angularjs - Angular directive where one of two attributes are required -

how write directive requires either ng-model or k-ng-model ? documentation doesn't cover :( app.directive('mydir', function () { return { require: 'ngmodel || kngmodel', // omitted }; }); you need pass them in array of strings. you can't tell angular @ least 1 of these needs available, set them optional , check in link function if 1 of both available. update code to: app.directive('mydir', function () { return { require: ['?ngmodel', '?kngmodel'], link: function(scope, element, attrs, controllers){ if(!controllers[0] && !controllers[1]){ throw 'mydir expects either ng-model or k-ng-model defined'; } } }; });

python - Unable to access AJAX url with requests, BeautifulSoup -

i trying read data of table, onclick ajax event of following webpage the event initiates if click + sign right of tabelas tab, @ bootom of page. using firebug (for example) browser y can optain ajax url xhr tab of net section. the url valid , browser picks , shows it. my script: import requests urls="http://www.hidrografico.pt/components/com_products/scripts/server/data_getestactable.php" headers = { 'user-agent':'mozilla/5.0 (x11; ubuntu; linux x86_64; rv:39.0) gecko/20100101 firefox/39.0', 'accept': 'application/json, text/javascript, */*; q=0.01', 'content-type': 'application/x-www-form-urlencoded; charset=utf-8', 'x-requested-with': 'xmlhttprequest' } s = requests.session() s.post(urls) content = s.post(urls, headers=headers) print content.content the output gives: direct access file prohibited. so seems there no direct access url although if paste url in browser can see table

How to find configurations changes on a SQL server regarding principal and mirror settings? -

Image
is possible find time stamp , login used when changing principal or mirror settings specific database server? it's on sql server 2008 r2 if relevant might helpful if of above image didn't record please run below query follow above image instruction, works me exec sp_configure 'show advanced options', 1; go reconfigure override; go exec sp_configure 'default trace enabled', 0; go reconfigure override; go exec sp_configure 'default trace enabled', 1; go reconfigure override; and can of sys object, have give physical path of trace file can record of activity select * fn_trace_gettable ('c:\program files\microsoft sql server\mssql11.sqlexpress\mssql\log\log_34.trc', default)

linux - Internal compiler error: Segmentation fault while installing a python library -

i have ubuntu 14.04. trying install python library (deepdish) when execute command sudo python setup.py install following errors. x86_64-linux-gnu-gcc: internal compiler error: segmentation fault (program collect2) i facing similar type of 'internal compiler error' while trying install or make other things. think there problem has occurred in system. seems have gotten corrupted. cant figure out reason. has got gcc or build-essential. following detailed output : $ sudo python setup.py install running install running bdist_egg running egg_info writing requirements deepdish.egg-info/requires.txt writing deepdish.egg-info/pkg-info writing top-level names deepdish.egg-info/top_level.txt writing dependency_links deepdish.egg-info/dependency_links.txt reading manifest file 'deepdish.egg-info/sources.txt' reading manifest template 'manifest.in' writing manifest file 'deepdish.egg-info/sources.txt' installing library code build/bdist.linux-x86_64/eg

Accessing attributes of a list of objects in python -

i have list of objects, known bricks , want check attributes of objects in list. tried: pos = [brick.start_pos brick in self.brick_list] to create list of required attribute i.e start_pos , populates list attribute of last brick in brick_list. using python 3.4. need lot of different attributes comprehension makes sense me. brick class holder data , defined: class brick: def __init__(self, start_pos=0, current_pos=0, variety=0, moveability=0, neighbours=0, max_range=0, sides=0, rotation=0, length=0, previous_pos =0): self.start_pos = start_pos self.current_pos = current_pos self.moveability = moveability self.variety = variety self.neighbours = neighbours self.max_range = max_range self.sides = sides self.rotation = rotation self.length = length self.previous_pos = previous_pos with couple simple functions. it appears list contains same brick inst

oauth - How to read users outlook email using Oauth2? -

i'm building service scans peoples email specific pdf attachments , indexes them. implemented oauth2 gmail using extensive gmail api works fine. i want implement same outlook/live/hotmail . searched around, , read you can "connect outlook.com imap using oauth 2.0 " ( tutorial here ). thing implements full imap connection. far know more meant aftermarket applications user can view , send email, not applications need download email in background (like mine). i haven't worked imap within code, main problems see that: if read emails set "read" in inbox of user, don't want (i don't want interfere normal email usage of user). i need either stay connected email inboxes, or loop through email inboxes new emails. my questions actually; is there no other way imap users outlook.com email? or problems not problems , should create imap "receiver" outlook email accounts? in answer point #1, according max , can us

ios - Infinite loop in connection:didReceiveData in AFURLConnectionOperation.m -

i using afnetworking2 ios project requires extensive image loading. after downloading number of images, outgoing requests queued in operation queue , never go out. i found out because in afurlconnectionoperation.m,(void)connection:didreceivedata there while(yes) loop , breaks when [self.outputstream hasspaceavailable] or when self.outputstream.streamerror occurs. but, in case, [self.outputstream hasspaceavailable] returns no, , operation remains stuck in while (yes) loop. has experienced issue, , solution? here code of afurlconnectionoperation.m,(void)connection:didreceivedata for context: - (void)connection:(nsurlconnection __unused *)connection didreceivedata:(nsdata *)data { nsuinteger length = [data length]; while (yes) { ... if ([self.outputstream hasspaceavailable]) { ... break; } if (self.outputstream.streamerror) { .... return; }

adding many polyLines in R leaflet -

is there way add poly lines @ once. doing way below slow... at moment, i'm doing through loop follows: leafletproxy("mainmap") %>% addpolylines(lng = currentgeodata[i,c("custlon","sercenterlon")], lat = currentgeodata[i,c("custlat","sercenterlat")], color = "red") so each time lng variable vector of length 2 , lat variable same. as long you're going through entire column, don't need index i : leafletproxy("mainmap") %>% addpolylines(lng = currentgeodata[c("custlon","sercenterlon")], lat = currentgeodata[c("custlat","sercenterlat")], color = "red")

Can I make at least one field a requirement on a Django Model? -

say have person model: class person(models.model): name = models.charfield(max_length=50) email = models.emailfield() telephone = models.charfield(max_length=50) for every person want ensure there contact information. don't need both email , telephone (though both okay) need ensure at least one provided. i know can check stuff in forms, there way can @ model/database level save repeating myself? write clean method model. from django.core.exceptions import validationerror class person(models.model): name = models.charfield(max_length=50) email = models.emailfield() telephone = models.charfield(max_length=50) def clean(self): if not (self.email or self.telephone): raise validationerror("you must specify either email or telephone") if use model form (e.g. in django admin), django call clean method you. alteratively, if using orm directly, can call full_clean() method on instance manually.

c# - Deserialize JSON object that has the same object as member in it -

Image
i having trouble de-serializing json has structure following. public class entity { public int id; public string entityname; private list<entity> _items; //sub entities public ireadonlylist<entity> items { get{ return _items; } } } while in debug mode, able see items > 0 via json visualizer(as in below image) when try de-serialize items count = 0 i tried using following statements, still no luck. var json = await response.getcontentasync<string>(); try 1 var deserializedlist = jsonconvert.deserializeobject<ienumerabld<entity>>json); try 2 var settings = new jsonserializersettings{maxdepth = 5}; var deserializedlist = jsonconvert.deserializeobject<ireadonlylist<entity>>(json, settings); any regarding appreciated. the first option make ilist<entity> if want keep ireadonlylist<entity> can supplying setter - public ireadonlylist&l

php - Stylesheets not loading after mod_rewrite -

i'm working on language function webpage using mod_rewrite. can enter url language option , extract information in php index file $_get. reason css files wont load more. here .htaccess code: rewriteengine on rewritebase /books/ rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewritecond %{request_filename} !-l rewriterule ^(se|en)/(.*)$ index.php?url=$2&language=$1 [qsa,l] rewriterule ^(.*)$ index.php?url=$1 [qsa,l] my stylesheets linked this: <link rel="stylesheet" type="text/css" href="localhost/books/css/style.css"> if try find css file in browser seems it's still rewriting though got rewritecond in place. any suggestions why causing problems? you can use: rewriteengine on rewritebase /books/ rewritecond %{request_filename} -d [or] rewritecond %{request_filename} -f [or] rewritecond %{request_filename} -l rewriterule ^ - [l] rewriterule ^(se|en)/(.*)$ index.php?url=$2&la

css - Top fix for bootstrap divs -

Image
.divcountertext{ text-align: center; } .resultscountertxt{ color: #fff; font-size: 12pt; padding:1%; text-align:center; } .resultsctrvalue { color: #fff; font-size: 28px; } .touchimagesearch { width: 83%; height: 70%; outline: none; cursor: hand; padding:1%; text-align:center; } .ordivtext{ padding:20%; color: #ffffff; font-size: 14pt; } #ortext{ height: 100%; } #searchmanual{ border-radius: 5pt; width: 100%; padding: 4%; text-align: center; } .paddingcol{ padding:1%; } i have following code , changes height 27px instead of default height of col-md-1 . should fix it? code: <div class="col-xs-1 col-sm-1 col-md-1 clearfix divcountertext"> <span class="ordivtext">or</span> </div> span or displayed on top space @ bottom on navbar / div. adding screenshot better understanding, different div. code:

android - Running AOSP on MAC: stdarg.h error -

i have source code android-5.0.0_r7.0.1. after doing: make -j4 i keep getting this: error: stdarg.h: no such file or directory in file included system/core/include/cutils/log.h:1, system/core/include/utils/keyedvector.h:24, frameworks/native/include/input/input.h:26, frameworks/native/include/input/inputdevice.h:20, frameworks/native/libs/input/inputdevice.cpp:23: system/core/include/log/log.h:35:20: error: stdarg.h: no such file or directory make: *** [out/host/darwin-x86/obj32/executables/validatekeymaps_intermediates/main.o] error 1 make: *** waiting unfinished jobs.... make: *** [out/host/darwin-x86/obj32/static_libraries/libinput_intermediates/keyboard.o] error 1 make: *** [out/host/darwin-x86/obj32/static_libraries/libinput_intermediates/inputdevice.o] error 1 make: *** [out/host/darwin-x86/obj32/static_libraries/libinput_intermediates/input.o] error 1 #### make failed build targets (01:32 (mm:ss)) #### i have look

c# - How to extend IdentityManager for IdentityServer3 -

i have identityserver 3 , running users, roles, claims, clients etc running database. administer have decided use identitymanager. have noticed though covers users , roles. there way extend cover clients well? you can use: identityserver3.admin or identityserver3.admin.entityframework i tried identityserver3.admin.entityframework works fine me.

api - Is it possible to retrieve a document stored in DocuWare via PHP? -

according website have docuware platform .net api cannot see tutorials connecting , retrieving document docuware. we have existing client portal written in php , have purchased , started use docuware document management. have added functionality our client portal connect docuware sql server database perform queries , show documents available in docuware our customer. the point stuck on how retrieve actual document , show within our client portal using php? i no php expert, need post , http requests docuware server , keep track of cookies. can view documentation if called platform api in browser: http://your.docuware.server/docuware/platform

c# - How do I create methods at run time in a pre-existing class? -

i'm using fluent pattern helping unit testing, , result object building. biggest pain point of fluent builder pattern having define these with____ methods each , every property might want set. when comes object maybe 30 fields might want set, don't want write out 30 methods pretty same thing. i'd rather write out dynamic can handle similar logic me. for example (psuedo code) for each property in this.properties define method( property.name return type: this.class, parameter types: [property.type]){ set property property.name, parameters[0] return } here have far in c# var properties = typeof(enginemodelbuilder).getproperties(); foreach (var property in properties){ // how create method here property? // property has .propertytype , .name // , return type going 'this' } for reference, here how normal fluent builder method looks: public enginemodelbuilder withdescription(string description) { _descr

c# - sending xml in Microsoft.Exchange.WebServices.Data.emailmessage.culture -

i trying send xml string through exchange service here code servicepointmanager.expect100continue = true; servicepointmanager.securityprotocol = securityprotocoltype.ssl3; servicepointmanager.servercertificatevalidationcallback = delegate(object s, x509certificate certificate, x509chain chain, sslpolicyerrors sslpolicyerrors) { return true; }; exservice.usedefaultcredentials = false; exservice.credentials = new networkcredential("set of credentials"); exservice.url = new uri("https://url"); public void sendmail(string subject, string body, string to) { lock (this) { emailmessage msg = new emailmessage(exservice); #if debug msg.torecipients.add("test@address.com"); #else msg.torecipients.add(to); #endif msg.body = body; msg.subject = subject; msg.send(); }} the subject , guess string

Cannot run a batch file from SQL Server Agent (Access denied) -

i trying execute batch file sql server agent (as needs done before ssis-packages run). when execute job fails in few seconds saying "access denied". the account under sql server agent runs has full control on folder contains batch file. result of batch deleting files in folder, calling webservice , same files webservice. can run batch file when start own (admin) account. i googled , found several other questions , answers none of covering problem. hope can point other options. thanks help. johan batch file contents: echo removing txt files of last run del employees.txt del hrdepfun.txt del hrempactual.txt echo files removed echo starting getconnectors {call webservice} -> cannot disclose on stackoverflow echo getconnectors done batch file execution statement sql server agent job (type operating system (cmdexec)): cmd.exe /c "c:\program files (x86)\afas\afasremote_call_getconnectors.bat" > connectorlog.txt 2> connectorerrorlog.txt

javascript - How to render Jade in Electron? -

in express possible set view engine jade following code: app.set('view engine', 'jade'); so, allows express read , return compiled html jade files directly. how can in electron ? i built small module intercept jade protocols , compile ending .jade , rest considered local files. use in main file following: 'use strict'; var app = require('app'); var locals = {/* ...*/}; var j = require('electron-jade')({pretty: true}, locals); var browserwindow = require('browser-window'); // standard stuff app.on('ready', function () { mainwindow = new browserwindow({ width: 800, height: 600 }); mainwindow.loadurl('jade://' + __dirname + '/index.jade'); // rest... }); note instead of file:// write jade:// . disclaimer : module in stages , logic still not mature enough. update : i published package on npm: https://www.npmjs.com/package/electron-jade