Posts

Showing posts from April, 2010

Retrieving an object just from a specific and unique instance variable - Java -

i have class (cars) has int id instance variable. the id not have unique - more of category id. if id exists add object array list within category if id not exist create new category id before create instance of class want check there isn't instance variable id. the way can think of doing right having static arraylist of cars within class cars. search through array list through each car , compare ids see if there id matches. if not - create the new car instance new id. surely there better way of doing this? using map, suggested lutz horn, better way of holding ids, , hashmap in runtime complexity of o(1), rather searching elements of container such list. if cars might concurrently created using several threads, should, of course, make sure not enter race condition.

javascript - Textarea: Allow to begin with linebreak -

i'm developing ionic/cordova app. there textarea visible user can input data, transferred server. here, user should able input line breaks. problem i'm facing right it's possible after input first character; , it's not possible begin line break. ng-model cuts off beginning line breaks. how can achieve goal? the textarea looks this: <textarea ng-model="card.text" id="text-message" rows="20"></textarea> thank you. according https://github.com/angular/angular.js/issues/2010 can apply ng-trim="false" element stop behaviour so: <textarea ng-model="card.text" ng-trim="false" id="text-message" rows="20"></textarea>

node.js - New Node V8 Inspector not logging to console on Windows PC -

on windows pc have latest version of node 6.9.1 has v8 inspector built in. when use --inspect flag run app.js file , go "chrome-devtools" url attach debugger, works fine (i can set breakpoints , step through code) console.log code doesn't print chrome console. checked console filter, set all. prints console window ran app, not chrome. i have windows server 2008 r2. dont have issue on macbook, logs chrome console fine. hoping check if have working on windows computer or if else has run issue. maybe server 2008 r2 issue? it easy test. create app.js file 1 line "console.log('test')", open command prompt or git bash or whatever in folder , type: node --inspect --debug-brk app.js it give chrome-devtools url. go url in chrome , see app. script execution stopped (due -brk flag) have resume it. if have same issue me, notice when resume it, nothing logged console.

php - How to create permalink with monthname instead of using monthnum? -

i want redirect blog articles this, http://www.example.com/blog/2014/september/03/post-name but in wordpress allows me use month number, http://www.example.com/blog/2014/09/03/post-name . i'm searching not found useful. unanswered posts , not saying, whether possible or not. in wordpress documents there no reference this. found following code changes url not linking post page. <?php /** * plugin name: month name * description: enables <code>%monthcode%</code> , <code>%monthname%</code> tag permalinks. * author: roger chen * license: gplv2 */ /** * enables use of monthname (january, june) , monthcode (jan, jun). * supports permalinks in form of /2016-nov/61742/..slug.. or /2016-november/61742/..slug.. */ class monthname { /** * month names */ public static $monthnames = array( 'january', 'february', 'march', 'april', 'may', 'june', 'july', 'august...

rest - Accessing Box Api using Refresh token -

how can access box api using refresh token generated? have followed steps generate access token , refresh token cannot find anywhere how can access api using refresh token. this have right now: curl -x -h "authorization: bearer <access-token>" "https://api.box.com/2.0/folders/0" i not able : curl -x -h "authorization: <refresh-token>" "https://api.box.com/2.0/folders/0" or curl -x -h "authorization: bearer <refresh-token>" "https://api.box.com/2.0/folders/0" any idea how can use refresh token in api call? the access_token used make box content api calls. the refresh_token used obtain new access_token & refresh_token pair since access_tokens expire in around 60 minutes. curl https://api.box.com/oauth2/token -d 'grant_type=refresh_token' \ -d 'refresh_token=<my_refresh_token>' \ -d 'client_id=<my_client_id>' \ -d 'client_secret=<my_c...

Sparql: Get individuals with given data property -

being totally new sparql , rdf(s) i'm apologizing in advance if question seem little stupid, , should know better. anyways ontologi goes this. subclasses got instances of spesific wine, example "dupont pome". different wines may have several data properties "year", "volume", "grapetype" etc. how set query in can fetch out 1 or more individual spesific xsd:string in grape type property or volume property xsd:positiveinteger? owl:things ----------wine --------------redwhine --------------whitewine --------------foowine i'm not entirely sure i'm formulering question well, please correct if i'm messing terminologies , such. also have included query looked far if knew begin. statements in can results far in experience sparql, getting subclasses in relation superclass in table. select distinct ?s {?s <volume_property_uri> "volume_value"^^xsd:positiveinteger}

swift - How to set two scrollable view -

Image
i want work view, when push on button of first view go on second view hiding first view. the 2 views have different heights... heres hierarchy: -> main view -> -> scroll view -> -> -> ui view 1 -> -> -> ui view 2 how can set constraints in configuration using storyboard please ?

python - Program to run another through command prompt -

i not sure if question answerable. in game using colorama features make nice, colorama features work when access python in command prompt, question how can python program run via command prompt, doable or not? have tried installing win32 in python 2 format , using 3.4 getting syntax errors wasnt sure how fix. i not sure why happening, mean, colorama not working without starting prompt. perhaps environment variables path or something. this 1 suggestion, , not sure work not changing window program running in, invoking cmd.exe i.e. command prompt start within , start python , script again. but worth try: # start of program: import sys, os if "started_with_prompt" not in sys.argv: cmd = 'cmd /c "'+sys.executable+' '+" ".join(sys.argv)+' started_with_prompt"' os.system(cmd) sys.exit() print "the rest of program" if doesn't work, there tricks can used through subprocess module similar thin...

montecarlo - Cannot figure out Reduce and Monte Carlo Simulations in R, calculating VaR -

apologies title. not think of how title this... (also, know shite question, hoping out there can help.) i have following mean vector , covariance matrix: > mu0 msft aapl 0.001250251 0.001060690 > sig0 msft aapl msft 1.275625e-04 3.334225e-05 aapl 3.334225e-05 1.484212e-04 i have following chunk of code (i know 500 simulations. brevity's sake. ramp when figure out code.): wta = 0.562546911; wtm = 0.437453089; ct = -1000000*c(wtm,wta); lambda = .97; k = 20; m = 500; l1 = 0.0; l1 = rep(0,m); mu1 = mu0; sig1 = sig0; l1=0.0; rando = rmvnorm(m, mu1, sig1) for(i in 1:m){ xtd = t(rando[i,]) mu1 = lambda*mu1+(1-lambda)*xtd sig1 = lambda*sig0+(1-lambda)*t(xtd)%*%xtd; l1 = l1+t(ct)%*%t(xtd) l1=l1+t(ct)%*%t(xtd) for(j in 2:k){ xtd=rmvnorm(1,mu1, sig1) mu1=lambda*mu1+(1-lambda)*xtd sig1=lambda*sig0+(1-lambda)*t(xtd)%*%xtd l1=l1+t(ct)%*%t(xtd) } l1[i]=l1 } i hate code. slow, , perhaps more importantly,...

file - Reading specific lines only (Python) -

i'm using loop read file, want read specific lines, line #26 , #30. there built-in feature achieve this? thanks if file read big, , don't want read whole file in memory @ once: fp = open("file") i, line in enumerate(fp): if == 25: # 26th line elif == 29: # 30th line elif > 29: break fp.close() note i == n-1 n th line. in python 2.6 or later: with open("file") fp: i, line in enumerate(fp): if == 25: # 26th line elif == 29: # 30th line elif > 29: break

c# - Multiple requests with Include and Where condtition throws exception -

Image
i using asp.net core ef core. if multiple requests same controller method of thoes requests throws: object reference not set instance of object , without detailed explanation. if 1 request controller- no exception occur. here reconstructed example of existing system public class player { public int id { get; set; } public string name { get; set; } public team team { get; set; } } public class team { public int id { get; set; } public string name { get; set; } public list<player> players { get; set; } } this code throws exception public async task<list<player>> test() { using (repository.dataprovider.repodbcontext db = new repository.dataprovider.repodbcontext()) { return await db.players.include(x => x.team).where(x => x.team.id == 1).tolistasync(); } } i did little research , realize exceptions occurs if there combination include , where statement using same property...

java - Spring JPA how to delete entry from ModelAndView and from view but leave it in db? -

i trying write web application can send messages between users. want add option allows remove message view, not db. how this? controller: @controller public class messagescontroller { @autowired private messageservice messageservice; @requestmapping(value = "/messages", method = requestmethod.get) modelandview messages(modelandview modelandview, @requestparam(value = "p", defaultvalue = "1") int p) { message message = new message(); authentication auth = securitycontextholder.getcontext().getauthentication(); list<message> inbox = messageservice.getinbox(auth.getname()); list<message> outbox = messageservice.getoutbox(auth.getname()); modelandview.setviewname("app.messages"); modelandview.getmodel().put("message", message); modelandview.getmodel().put("inbox", inbox); modelandview.getmodel().put("outbox", outbox); return modelandview; } @requestmap...

r - Creating Groups with Dplyr's "group_by" then Using Stringr or Set Operations to Find Differences Between Groups -

i use dplyr , stringr if possible, or @ least stay within tidyverse achieve following: i need group data caseworker , client , compare "task" , "task2" find categories in "task2" not in "task", along associated total time "task2" category. "task" can have categories not in "task2", i'm interested in finding categories in "task2" not in "task". great able create new columns show specific entries in "task2" , not in "task", along associated "time" value. the end result should show 4 new columns client chris, 1 "iron shirt" , 1 column associated "time" of 45, , column "do homework" , column "time" of 21. there 2 new columns client eric, 1 "iron shirt" , 1 associated time of 12. caseworker<-c("john","john","john","john","john","john","joh...

apache - Redirect a specific folder to a virtual folder using .Htaccess (make it look like a subdomain) -

so here's directory structure: |--public_html dir |--index.php file |--search.php file |----assets/ dir |----acp/ dir |------assets/ dir what need .htaccess way of doing following: redirect http://example.com/ --> http://club.example.com/ (where club not sub directory, doesn't exist on server) redirect pages same way: e.g. http://club.example.com/search.php redirect /acp/ directory , it's files this: http://club.example.com/acp/post.php redirect /public_html/assets/ directory javascript files, css files , images there. should able access them this: http://club.example.com/assets/theme/reset.css , etc. the same goes /acp/assets/ directory. contains styling , scripting admin page need access files inside this: http://club.example.com/acp/assets/scripts/menu.js

How to change the local SFTP location of MIVA export -

in miva, trying write export fetch catalog. i using miva code of standard export (export products flat file) mails catalog user. in situation email-id not mentioned saves catalog in following path: /mivadata/merchant5/s01/export/products.csv also, when taking export miva catalog it's being saved in own sftp location. what wanted know that, possible change default sftp location?

andThen in List scala -

has got example of how use andthen lists? notice andthen defined list documentations hasn't got example show how use it. my understanding f andthen g means execute function f , execute function g. input of function g output of function f. correct? question 1 - have written following code not see why should use andthen because can achieve same result map. scala> val l = list(1,2,3,4,5) l: list[int] = list(1, 2, 3, 4, 5) //simple function increments value of element of list scala> def f(l:list[int]):list[int] = {l.map(x=>x-1)} f: (l: list[int])list[int] //function decrements value of elements of list scala> def g(l:list[int]):list[int] = {l.map(x=>x+1)} g: (l: list[int])list[int] scala> val p = f _ andthen g _ p: list[int] => list[int] = <function1> //printing original list scala> l res75: list[int] = list(1, 2, 3, 4, 5) //p works expected. scala> p(l) res74: list[int] = list(1, 2, 3, 4, 5) //but can achieve same 2 maps. point of andth...

Add recurring index to pandas multi indexed dataframe while keeping the order -

i add new column dataframe belwow name new_col contain number of entry in last index (while keeping order or ordering them ordered update time each sub group). result should below show in new_col. update_time new_col book_name business_date measure_def_id 144 02-nov-16 12:00:00 pnl 02-nov-16 05:30:24 1 03-nov-16 05:30:29 2 04-nov-16 04:38:46 3 risk 02-nov-16 09:32:26 1 03-nov-16 09:31:49 2 03-nov-16 11:08:17 3 i think need set_index : print (df.set_index('new_col', append=true)) update_time book_name business_date measure_def_id new_col ...

exim - EXIM4 configuration directives: .ifdef, ifndef -

all! i'm configuring exim mail-server , i'm newbie it. not first mail server configuration, first of exim. so far, have read different config docs (e.g. this one ) in internet , exim's configuration manual, well. , more clear me. 1 issue not clear yet - concerned .ifdef, .ifndef directives. example, .ifdef check_mail_helo_issued deny message = no helo given before mail command condition = ${if def:sender_helo_name {no}{yes}} .endif far saw manual , clause means if macros check_mail_helo_issued declared, followed actions applied. if not present anywhere, actions not applied. , if want apply acl (it part of acl), better use without .ifdef directive. so, please, correct me if i'm wrong, you either delete .ifdef , .endif directives or define check_mail_helo_issued = yes somwhere logically 'before' deny statement.

node.js - socket.io, webrtc, nodejs video chat app getting errors over https: ERR_SSL_PROTOCOL_ERROR, 404 (Not Found), and ERR_CONNECTION_TIMED_OUT -

i have put video chat app using socket.io, webrtc, nodejs online tutorial github getting errors when converting used on https: request url:https://telemed.caduceususa.com/socket.io/?eio=3&transport=polling&t=1479396416422-0 request method:get status code:404 not found remote address:10.9.2.169:443 other errors have gotten in process follows: when try declare different port - err_ssl_protocol_error, when try declare port 80 or 8080 get: err_connection_timed_out something going wrong on line inside socket.io.js: xhr.send(this.data); i running node.js server on windows server 2012 , have set iis serve server on port 80. have created subdomain https://telemed.caduceususa.com in dns , have purchased trusted ssl cert run site on https. here excerpt of code dev tools contains above line causing error other code: /** * creates xhr object , sends request. * * @api private */ request.prototype.create = function(){ var opts = { agent: this.agent, xdomain: th...

ios - Swift 3 Get Notification Data -

Image
i'm trying data out of notification in swift 3, using tutorial: developing push notifications ios 10 unfortunately following error: private func getalert(notification: [nsobject:anyobject]) -> (string, string) { let aps = notification["aps"] as? [string:anyobject] let alert = aps["alert"] as? [string:anyobject] let title = alert?["title"] as? string let body = alert?["body"] as? string return (title ?? "-", body ?? "-") } the issue notification declared dictionary keys of type nsobject . attempt access dictionary key of type string . string not nsobject . 1 solution cast string nsstring . fixing presents error fixed on next line. code ends this: private func getalert(notification: [nsobject:anyobject]) -> (string, string) { let aps = notification["aps" nsstring] as? [string:anyobject] let alert = aps?["alert"] as? [string:anyobject] let titl...

java - How to execute code during a drag and drop operation? -

i have node want implement drag , drop (this object source not target). want object move along mouse cursor. managed both of these not @ same time. it appears setondragdetected , setonmousedragged don't work together. consider node following handlers: import javafx.application.application; import javafx.scene.group; import javafx.scene.scene; import javafx.scene.input.clipboardcontent; import javafx.scene.input.dragboard; import javafx.scene.input.transfermode; import javafx.scene.shape.rectangle; import javafx.stage.stage; public class example extends application { @override public void start(stage primarystage) throws exception { rectangle rect = new rectangle(20, 20); rect.setonmousepressed(e -> system.out.println("pressed")); rect.setonmousedragged(e -> system.out.println("dragged")); rect.setondragdetected(e -> { system.out.println("detected"); clipboardcontent c...

html - Keep radio button and label on the same line -

i'm having css issue radio button , label appearing on different lines if label spans multiple lines. here example: () option () option b () option c long span 2 lines () option d see how long lines breaking after radio option? long label-body should span 2 lines, should inline radio option such as: () option c long span 2 lines here's css input[type="radio"] { display: inline; margin-bottom: 0px; } label > .label-body { display: inline-block; margin-left: .5rem; font-weight: normal; } and html <label> <input type="radio"> <span class="label-body">option a</span> </label> i can't seem figure out why happening. if helps, i'm using skeleton framework ( http://getskeleton.com/ ). try removing inline-block on span.label-body , if possible. sets span in same line radio button, because default inline. div { width: 200px; } input[type="radio"] {...

android - How to delete object from onclick in recyclerview? -

i trying create first android application , im having trouble recognising easiest way delete objects shown in list. more specifically: i have recyclerview of objects , wants able delete objects through onclicklistener in list. thinking easiest way make onclicklistener recognize index on recyclerview clicked , objectlist.remove(index), not quite sure if possible? another way onclicklistener recognize name of object represents @ textview , iterate through objectlist, doesn't seem quite efficient first. how can make onclicklistener recognise lis titem belongs to? or there way haven't been able see? thanks in advance! you need implement onclicklistener inside oncreateview() method of recycler view adapter. view v = layoutinflater.from(parent.getcontext()) .inflate(r.layout.holder_layout, parent, false); final customviewholder holder = new customviewholder(v); holder.itemview.setonclicklistener(new view.onclicklistener() ...

Mirth Connect SQL Server Error : Conversion failed when converting date and/or time from character string -

i trying insert sql server datetime field. trying simple scenario of 1 table having datetime column named start_date only. query trying insert test (start_date) values (${start_date}) start_date channelmap variable of type java.util.date , created using : var start_date = dateutil.getdate('yyyymmddhhmmss', msg['date'].tostring()); here start_date of java.util.date, why mirth treats string when tries insert database ?? you can handle conversion in sql. hope helps var start_date = msg['pid']['pid.7']['pid.7.1'].tostring(); // 19831123 - yyyymmdd format try { sql="insert test (start_date) values (convert(datetime,'" + start_date + "',5))"; logger.info(sql); rst = dbconn.executeupdate(sql); } catch(err) { logger.info('err: ' + err); } out in db below. select * test start_date | ---------- 1983-11-23 00:00:00.000 2nd approach if still want use util try below var start_d...

java - Maven profiles equivalent of Gradle -

i'm trying achieve simple scenario in spring boot project build: including / excluding dependencies , packaging war or jar depending on environment. so example, environment dev include devtools , package jar, prod package war etc. i know not xml based configuration anymore , can write if statements in build.gradle there recommended way of achieving this? can declare common dependencies , refer them in single file instead of creating multiple build files? is there best practice changing build configuration based on build target environment? ext { devdependencies = ['org.foo:dep1:1.0', 'org.foo:dep2:1.0'] proddependencies = ['org.foo:dep3:1.0', 'org.foo:dep4:1.0'] isprod = system.properties['env'] == 'prod' isdev = system.properties['env'] == 'dev' } apply plugin: 'java' dependencies { compile 'org.foo:common:1.0' if (isprod) { compile proddependenci...

c# - Reading any string coming from Arduino -

i developing application read data through serial port. trying read string empty or in it. my first attempt creating array inside of able insert come serial port. string[] pass = new string[4]; pass[0] = ""; pass[1] = "something"; pass[2] = "to"; pass[3] = "read"; (int = 0; < pass.length; i++) { string element = pass[i]; } but isn't work me because wanna read thing serial port. in next option, in data.tostring() == "any string want" . string data = serport.readexisting(); if (data.tostring() == "any string want") { environment.exit(0); } basically, instead of "any string want" every time send through arduino recognized application. do guys have suggestions this? in other words, if incoming data equal string written arduino something. you need decide on termination char , add arduino code sending serial string , char in incoming data. i'm using carriage return line feed....

android - cannot resolve symbol "LoadPreferences" , "nSharedPreferenceListener" -

this main activity,actually trying display settings option pressing icon on action bar , settings option invokes preference options(the default values) . getting errors . there red marks on "loadpreferences" , "nsharedpreferencelistener" import android.content.intent; import android.content.sharedpreferences; import android.content.pm.packagemanager; import android.os.asynctask; import android.os.bundle; import android.os.powermanager; import android.preference.preferencemanager; import android.support.v7.app.appcompatactivity; import android.view.menu; import android.view.menuinflater; import android.view.menuitem; import android.view.surfaceholder; import android.view.surfaceview; import android.widget.textview; import org.apache.http.conn.util.inetaddressutils; import java.net.inetaddress; import java.net.networkinterface; import java.util.enumeration; public class launcheractivity_streamcameraactivity extends appcompatactivity implements surfac...

javascript - How do I concatenate several different variables to create a URL -

i'm trying use loop generate bunch of different urls use in table via javascript. the final url want is: http://www.enviroptics.com/ecommerce/environmentally-sealed-thermocouple-nb4-caxl-14u-12-aag.html the url broken down 4 sections: prefix: ' http://www.enviroptics.com/ecommerce/ ' product name: 'environmentally-sealed-thermocouple-' product number: 'nb4-caxl-14u-12-aag' suffix: '.html' the prefix , suffix wont changing. product name stay same within javascript want separate variable because plan on making bunch of javascripts, 1 each different product name. product number change each different row , link in table. this have far: var eo_url_1 = 'http://www.enviroptics.com/ecommerce/'; var eo_url_ext = "environmentally-sealed-thermocouple-" var eo_url_2 = '.html'; i have loop generating part number , when use console log this: console.log(eopartnum[i]); //yields following part number results //nb4-c...

vim - yank into register also yank to the default one after upgrading to MacOS Sierra -

if remember correctly, before updating, "+y yank system clipboard, not affect register p using. after updating does. this controlled clipboard option. see it's set to, run: :set clipboard? this can have number of values, including combinations. if it's unnamed , p , y , etc. use * register. if it's unnamedplus , they'll use + register. there other values , combinations (see :help 'clipboard' (include quotes)). it's yours set unnamedplus , or possibly combination ( unnamed,unnamedplus , put in both * , + ). if don't want "+y affecting default p register, put in ~/.vimrc : set clipboard=unnamed

Multiple Solr environments with one Zookeeper ensemble -

we have 2 solr environments in production. 1 solr environment has latest 2 years data. other has last 10 years of archived data. @ moment, these 2 solr environments connect separate zookeeper ensembles. the collections have same name & configuration in both solr environments. want reduce number of servers zookeeper. is feasible have both solr environments in production connect 1 zookeeper ensemble without overwriting configs each other? or mandatory have separate zookeeper ensemble each solr environment? you can use same zookeeper ensemble handle more 1 solr or solrcloud instance. however, data must kept separate. (probably) best done using "chroot" functionality in zookeeper. essentially, when create "space" in zookeeper solr instance, append /some_thing_unique , keep in appropriate config files in solr - should have no trouble. i haven't experienced moving existing solr instance 1 zookeeper - i'd guess have take solr down, ch...

vb.net - ".accdb" has become corrupted -

my program works fine inserting stuff in .accdb file, updating etc. working until add field in .accdb type "calculated field" whenever program can no longer open .accdb. it's throwing error database has become corrupted. happens adding field in database, without changing coding in program. has come around issue? there way fix it? i'm inserting "column1","column2","column3","column4","column5" , sixth column has calculated field column1 + column2 etc.

jobs - How to fetch supervisor id and supervisor name for all employees in ps_job -

i new peoplesoft system, there 1 query retrieve supervisor name , supervisor i'd ps_names table employees of ps_job table. can please tell me how this? , can please tell me result variation using different join condition. in ps query create query records job , names. ps query suggest join on common emplid fields, since want name of supervisor, refuse suggestion. add join manually adding criterium states supervisor id of job should equal emplid field of names. you have 2 join options: standard: rows have match returned, job rows empty supervisor id, or rows supervisor id has no corresponding entry in names table excluded left outer join: rows of job shown including no corresponding match in names, selected fields of names table empty. (making abstraction of effdt)

java - Blur TextView on click, Android -

i trying blur out textview , when button clicked. far code looks likes this: @override public void onclick(view v) { float radius = pdf.gettextsize() / 3; blurmaskfilter filter = new blurmaskfilter(radius, blurmaskfilter.blur.normal); if (v==pause){ if (paused){ paused=false; pdf.getpaint().setmaskfilter(null); } else{ paused=true; pdf.getpaint().setmaskfilter(filter); } } } what doing wrong? just set pdf.setlayertype(view.layer_type_software, null); befor line: pdf.getpaint().setmaskfilter(filter);

javascript - tesseract.js sample code not working -

i'm trying make tesseract.js working. i have taken simple code web, apprarently declared working, doesn't. <html> <head> <script src='https://cdn.rawgit.com/naptha/tesseract.js/1.0.10/dist/tesseract.js'></script> <title>tesseract test</title> </head> <body> <label for="fileinput">choose file ocr:</label> <input type="file" id="fileinput" name="fileinput"/> <br /> <br /> <div id="document-content"> </div> </body> <script> document.addeventlistener('domcontentloaded', function(){ var fileinput = document.getelementbyid('fileinput'); fileinput.addeventlistener('change', handleinputchange); }); function handleinputchange(event){ var input = event.targ...

deviantart login through python -

i'm trying make tiny bot (without api's or anything), filter out evil comments(just gonna use notepad list of swearwords) on profile page, , automatically hide them, can't log in deviantart no matter do, current script: import urllib, urllib2, cookielib username = 'usr' password = 'psw' cj = cookielib.cookiejar() opener = urllib2.build_opener(urllib2.httpcookieprocessor(cj)) login_data = urllib.urlencode({'username' : username, 'password' : password}) opener.open('https://www.deviantart.com/users/login', login_data) resp = opener.open('https://www.deviantart.com/settings/identity') print resp.read() i'm opening identity page because it's page works when you're logged in, @ moment logged in user "null"

Batch: Checking for null value and writing a string in its place -

i have group of text files contain either 1 line of data or blank. need of files dumped single file. part's easy enough, need blank file return "nodata" or similar string in new file. setlocal enabledelayedexpansion type nul >c:\somedirectory\dataall.txt rem find files in direcotry; files %%g in (c:\somedirectory\txt??.txt) ( rem find of text within found files /f "tokens=*" %%t in ('type "c:\somedirectory\%%~ng.txt"') ( set datain=%%t rem check see if file empty , write nodata final variable if if "c:\somedirectory\%%~ng.txt" lss 1('set "/a datain=nodata"') rem check see if file not empty , write data final variable if "c:\somedirectory\%%~ng.txt" neq 0 ('set /a "datain=%%t"') rem write datain final text file >> "c:\somedirectory\dataall.txt" echo !datain! ) ) endlocal this duplicates previous text file's data blank one. exampl...

Setting client version for Java irc bot -

i'm trying build irc bot java. problem cannot connect quakenet. i'm getting "your client may not compatible server." might because haven't set client version bot. how can that? i'm aware there libraries building irc bot java create 1 scratch more knowledge it. what means server sending client message querying version, , client, if it's responding @ all, isn't responding string server likes. has nothing software library (or version thereof) you're using. i'd recommend reading rfc1459 (irc protocol) , watching raw traffic getting sent client see going on. yogi berra once said, "you observe lot watching."

ios - How do I keep the constraints of my UILabels and put them in StackViews? -

Image
notice in image below, 3 rows of 8's. all 3 rows have been set width: 45px height 45px , following lines of code applied make them round: self.wonlabel.layer.maskstobounds = true self.wonlabel.layer.cornerradius = self.wonlabel.frame.width/2 however, want arrange these uilabels within stackviews (along appropriate label) keep neat , tidy in grid format. when try place row of 8's in stackview, stackview automatically squashes width of each uilabel - notice 1st row of 8's. how keep constraints of uilabels , put them in stackviews?

make: g++ command not found error with makefile -

i'm writing makefile so: lib_dir = $(shell pwd)/.linuxbrew/cellar/boost/1.62.0/ flags = -std=c++14 inc= -i$(lib_dir)include lib_path = -l$(lib_dir)lib lib = $(lib_dir)lib libnames := filesystem-mt filesystem system-mt system libs := $(foreach n,$(libnames),$(lib)libboost_$n.a $(lib)libboost_$n.dylib) path = /some/path/ default: g++ main.cpp $(flags) $(inc) $(lib_path) $(libs) -o assemble ./assemble $(path) clean: rm assemble the problem is, once include variable 'lib_dir', complains g++ can't found. use help. it's not lib_dir , rather path that's killing you. try commenting out line. (i'm assuming g++ not in /some/path/)

How to verify presence of scrollbar in textarea using selenium. -

i have text area in web page has no scrollbar initially. when exceeds character 1000, scrollbar displayed in textarea. i have verify same whether scrollbar present or not in textarea when click or edit same textarea. the client width or height decrease if scrollbar added. 1 way check size before , after. here's example (java) : long height_before = long.parselong(element.getattribute("clientheight")); element.sendkeys("wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww") long height_after = long.parselong(element.getattribute("clientheight")); assert.true((height_before - height_after) > 10); or: long clientheight = long.parselong(element.getattribute("clientheight")); long offsetheight = long.parselong(element.getattribute("offsetheight")); assert.true((offsetheight - clientheight) > 10);

bash - Adding variable inside quotes in a python script -

i'm writing python script automate bash commands , having trouble passing variable inside curl command. have: subprocess.call('''curl -h 'content-type: application/json' -x put -d '{"name": "{}".format(somevariable), "hive_ql": "create view user_balance select name, lob,account,balance csvtable"}' localhost:someport/api''', shell=true) i'm trying pass variable in 'name' parameter, denoted 'somevariable' in example. error stating: "message": "failed decode json object: expecting ',' delimiter: line 1 column 14 (char 13): when replace format part actual string, script executes fine know i'm doing wrong passing variable between quotes, not sure correct syntax is. it clearer pass list subprocess.call : import json import subprocess somevariable = 'hello' hive_ql = 'create view user_balance select name, lob,account,balance csv...

ios - Customize every single UISearchBar From AppDelegate Not Working -

Image
i have code below in appdelegate.swift : func customizebars() { let bartintcolor = uicolor(colorliteralred: 20/255, green: 160/255, blue: 160/255, alpha: 1) uisearchbar.appearance().tintcolor = bartintcolor window!.tintcolor = uicolor(red: 10/255, green: 80/255, blue: 80/255, alpha: 1) } i call function ( customizebars() ) in didfinishlaunchingwithoptions method: func application(_ application: uiapplication, didfinishlaunchingwithoptions launchoptions: [uiapplicationlaunchoptionskey: any]?) -> bool { customizebars() return true } i have in uisearchbardelegate if makes difference: func position(for bar: uibarpositioning) -> uibarposition { return uibarposition.topattached } but reason when run app doesn't change tintcolor of of uisearchbars have in app or window tint color. there doing wrong? you can change search bar color using below line of code - uisearchbar.appearance().bartintcolor = uicolo...

struct - C# field must be fully assigned error -

i working on game , getting error. "fields must assigned before control returned caller". can't seem figure out, driving me crazy. here code using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; using opentk; using opentk.graphics.opengl; using system.drawing; using system.io; namespace box2 { struct level { private block[,] grid; public int height { { return grid.getlength(1); } } public int width { { return grid.getlength(0); } } public enum blocktype { solid, empty, platform, ladder, ladderplatform } struct block { private blocktype type; private int posx, posy; private bool solid, platform, ladder; public blocktype type { { return type; } } public int x { { retu...

PHP - Two directories up doesn't seem to work -

i have problem concerning direcotries. need include file in php script, , file in folder script. itself, isn't problem, go directory using ../ , work way file. problem occuring when script 2 folders deep , use ../../ , error. here relevant code: <?php $rootdir = "../../"; ?> which followed later by: <?php include($rootdir . "style/header.inc.php"); include($rootdir . "style/navigation.inc.php"); ?> and file located in root\projects\twpweb\ , file trying include located in root\style\ strange thing .css file located in exact same folder , gets accessed in exact same way , work, while include doesn't. <link rel="stylesheet" type="text/css" href="<?php echo $rootdir ?>style/style.css"> any appreciated.