Posts

Showing posts from May, 2010

Execute openssl using bash for loop -

i have list of ips need check if support tls1.2, , using openssl that. can't seem automate process within bash script. executes on first ip , waits input. read have either add < /dev/null or echo "x" not help. tried: for in `cat scope`; openssl s_client -tls1_2 -connect $i:443 < /dev/null; done or: for in `cat scope`; echo "x" | openssl s_client -tls1_2 -connect $i:443 < /dev/null; done edit: solved, port 443 not open on 2nd ip, that's why waiting. i advise use nmap instead of s_client check tls handshake (and catch case when port not open). for in `cat scope`; if nmap --script ssl-enum-ciphers -p 443 "$i" | grep "tlsv1.2" >/dev/null; echo "$i supports tlsv1.2" else echo "$i doesn't support tlsv1.2" fi done

php - Laravel 5.1 create 5 minute cookie then return view -

i want set 5 minutes cookie return view, but if use view in response, cookie loses. , when index page, can't see cookie. because lost. but if return response without view, works perfectly. $response = new illuminate\http\response(); return $response->withcookie(cookie('yes', 'value', 5)); this works perfectly. but not: $response = new illuminate\http\response(view('somepage')); return $response->withcookie(cookie('yes', 'value', 5)); how can create view after set cookie? here go: use illuminate\http\request; use illuminate\cookie\cookiejar; class newclass { public function handle(request $requestval, cookiejar $cookieval) { $cookieval->queue(cookie('yourcookie', $requestval->value, 5000)); return redirect('somepage'); } }

How to increase max line length when printing Clojure data -

i writing content edn file , maximum width of lines greater current default value: (use 'clojure.pprint) nil user=> *print-right-margin* 72 this seems accord output getting. how increase default value? this function i'm using write out edn file: (defn pp-str [x] (-> x clojure.pprint/pprint with-out-str)) example use: (spit "foo.edn" (u/pp-str foo)) where foo might hiccup, or other clojure data. try rebinding *print-right-margin* either outside pp-str function: (binding [*print-right-margin* 1000] (spit "foo.edn" (u/pp-str foo))) or inside: (defn pp-str [x] (binding [*print-right-margin* 1000] (-> x clojure.pprint/pprint with-out-str)))) this temporarily redefine value scope of enclosed block. should help

javascript - Creating rows in Angular when using ng-repeat -

my code repeats posts api , shows 9 posts in row. goal create grid - 3 rows 3 posts in each one. solution tried doesn't work. tried 'clearfix', no success. know how make work? here's code: var myapp = angular.module('myapp', ['ngroute', 'ui.bootstrap']); myapp.config(function ($routeprovider) { $routeprovider.when('/', { templateurl: 'allposts.htm', controller: 'postscontroller' }).when('/post', { templateurl: 'post.htm', controller: 'postcontroller' }).when('/addpost', { templateurl: 'addpost.htm', controller: 'addcontroller' }).otherwise({ redirectto: '/' }); }); myapp.controller('postscontroller', function ($scope) { }); myapp.controller('postcontroller&

ocaml - Cannot install utop on RHEL 5.0 -

having installed opam , having switched 4.01.0 version of compiler struggling install utop. installation failing @ 'conf-ncurses.1' step. running 'opam depext' not reveal much, saying 'no dependencies' need installed. switching latest stable compiler, , installing utop fails same problem. *.err , *.out files empty, hence not revealing problem. on box have ncurses-devl , pkgconfig installed (see rpm output below) below screenshot of can see (hopefully give enough information). ideas @ ?: screehshot first of all, not issue tracker , better report issue package maintainers. following command reveal urls issue trackers: opam show conf-ncurses | grep bug-reports opam show utop | grep bug-reports second, output not @ sync i'm seeing in opam-repository . @ current head there no check pkg-config ncurses @ all, removed 3 days ago. so, if indeed have ncurses-devel package installed, need update opam, with opam update

Beginner in Python, can't get this for loop to stop -

bit_128 = 0 bit_64 = 0 bit_32 = 0 bit_64 = 0 bit_32 = 0 bit_16 = 0 bit_8 = 0 bit_4 = 0 bit_2 = 0 bit_1 = 0 number = int(input("enter number converted: ")) power in range(7,0,-1): if (2**power) <= number: place_value = 2**power if place_value == 128: bit_128 = 1 elif place_value == 64: bit_64 = 1 elif place_value == 32: bit_32 = 1 elif place_value == 16: bit_16 = 1 elif place_value == 8: bit_8 = 1 elif place_value == 4: bit_4 = 1 elif place_value == 2: bit_2 = 1 elif place_value ==1: bit_1 = 1 number = number - (place_value) if number == 0: print ("binary form of"),number,("is"),bit_128,bit_64,bit_32,bit_16,bit_8,bit_4,bit_2,bit_1 i want loop move next 'power' value when fails first if condition, when run in interpreter, program keeps on running despite first condition not being true. want move on next conditions if first condition turns out true. how can this? first "big" program in p

c# - .NET Help using TCP classes -

Image
i'm trying learn network programming , i'm trying create tcp server , tcp client. the server start , listen connections. client connect , send string server. server reply string containing received string. the issue i'm facing first try works after client receive empty reply. below code server: public void handlerthread() { tcpclient tcpclient = clients[clients.count - 1]; networkstream networkstream = tcpclient.getstream(); int = -1; while (tcpclient.connected ) { byte[] data = new byte[1024]; if ((i=networkstream.read(data, 0, data.length)) != 0) { string incomingmessage = encoding.ascii.getstring(data); debug.writeline("ddb server incomingmessage: " + incomingmessage); this.invoke((methodinvoker)(() => lbmessage.items.add("message received is: " + incomingmessage))); // send response. data = new byte[1024]; string outmessage = string.empty; outmessage = "recieved msg: " + incomingmessage; da

Java loop inside Unmarshal object -

at link: jaxb unmarshalling xml string - looping through tags proposed solution. i'm trying benefit not able have working in case. consider xml this: <campaign value="field1"> <name value="firstname"/> <type value="type"/> <record> <firsttime value="13"/> <secondtime value="14"/> </record> </campaign> and consider classes unmarshalling, created , working. campaign class, containing name, value, record[] etc. jaxbcontext c = jaxbcontext.newinstance(campaign.class); unmarshaller u = c.createunmarshaller(); campaign campaign = (campaign) u.unmarshal(file); i can extract value of "name" , "type" but, because of list<>, not able go beyond this. private string name = null; [...] name = campaign.getname().getvalue(); system.out.println(name); how loop <record> , , values firsttime , secondtime, knowing there more <record>

Failed To Perform Action On Blocked Control Exception? Using Coded UI? -

Image
i automating wpf application, when record "wpfcombobox" control , performed select index on control throwing error "failed perform action on blocked control exception". please me on come problem. wpfcontrol customcontr = new wpfcontrol(subdvnmap.subdvsnitemcustom.subdvsnitemtablist.subdvsnpiprismprismextensiotabpage); customcontr.searchproperties.add(wpfcontrol.propertynames.automationid, "legalformatscontrol"); wpfcombobox comblegal = new wpfcombobox(customcontr); comblegal.searchproperties.add(wpfcombobox.propertynames.automationid, "legalformats"); comblegal.find(); comblegal.selectedindex = 2; the above code, throwing error @ comblegal.selectedindex =2 the reason issue: control placed inside invisible control placed inside parent control. in code, comblegal combobox inside customcontr wpfcontrol. there control blocks accessing combobox. designers must have used other purposes while debugging, , forgotten remove

html - Initial letter and word in jekyll posts and pages -

Image
i style initial letter , initial word of posts , pages in jekyll blog. this: i can achieve result following style , span tags: :not(.post-excerpt) > .initial-word { color: #166079; font-variant: small-caps; font-weight: bold; } :not(.post-excerpt) > .initial-word .initial-letter { float: left; font-size: 3.15em; line-height: 0.5; margin: 0.225em 0.159em 0 0; color: #166079; font-weight: normal; text-transform: uppercase; } <p> <span class="initial-word"><span class="initial-letter">l</span>orem</span> ipsum dolor sit amet </p> given jekyll post starting introduction text: lorem ipsum dolor sit amet # main title of post lorem ipsum dolor sit amet the content of post, accessible in layout via liquid code {{ content }} like: <p>lorem ipsum dolor sit amet</p> <h1>main title of post</h1> <p>lorem ipsum dolor sit amet</p>

authentication - Unable to Login to Hybris Mobile iOS B2B Application -

Image
i unable login hybris mobile app sdk ios. using default b2b sample application provided hybris in ios sdk. i have setup hybris platform on machine , have set ip address, port , username environments.plist file. default username b2b mark.rivers@pronto-hw.com , password: 12341234 below error: 2016-09-07 18:19:45:445 yb2bapp[20152:70b] login button pressed ... 2016-09-07 18:19:47.197 yb2bapp[20152:291779] retrieving first time token user mark.rivers@pronto-hw.com 2016-09-07 18:19:47:198 yb2bapp[20152:70b] injectauthorizationheader basic bwfyay5yaxzlcnnachjvbnrvlwh3lmnvbtoxmjm0mtizna== 2016-09-07 18:19:47:198 yb2bapp[20152:70b] url https://:9002/authorizationserver/oauth/token 2016-09-07 18:19:47:198 yb2bapp[20152:70b] params { "client_id" = "mobile_android"; "client_secret" = secret; "grant_type" = password; password = 12341234; username = "mark.rivers@pronto-hw.com"; } 2016-09-07 18:19:47:317 yb2bapp[20152:70b] error d

ios - Xcode: Universal framework: Conditionally link other .framework dependency for specific platform only -

Image
while working universal framework targets apple platforms wish conditionally link .framework dependency osx only. i can add dependency linked framework , libraries , mark optional. don't know custom field should add or modify in build settings link .framework specific platform only. (without since dependency optional - build fail ld: framework not found ) any suggestion guys? as workaround can split on 2 targets: 1 osx , 1 else, derail concept of universal framework. this can achieved without resorting linked framework , libraries. while have universal target full range of supported platforms: macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator , consider case want link framework osx only. for linking our framework need 2 things: add path desired .framework framework search path add -framework yourframeworkname other linker flags and build settings allows specify fields conditional specific platform. when expanding in

java - Namespace not declared at XML Node Transformation -

i trying process bpmn file own flow model. actually, problem not relate @ bpmn standard consider context issue. want xml node , transform string in order save later database. trying in following code bpmndiagram node, using xpath, , export string but, when try export expception not declaring nsi namespace. have declared namespaces @ xpath previous "query" once node , try transform it, error described below. xpath part working since getting right node. problem appears @ transformation phase. xml file (partial) <?xml version="1.0" encoding="utf-8"?> <bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/bpmn/20100524/model"xmlns:bpmndi="http://www.omg.org/spec/bpmn/20100524/di" xmlns:di="http://www.omg.org/spec/dd/20100524/di" xmlns:dc="http://www.omg.org/spec/dd/20100524/dc" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn"

ios - Using MMDrawer within existing navigation controller -

i trying implement mmdrawer implement left drawer in 1 view controller , not root controller. on click of login button should able redirect view controller having left drawer , centre view almost similar question using mmdrawer in sub navigation view -(void) signinbuttonlistener:(uibutton *)button{ uiviewcontroller * leftdrawer = [[leftdrawerviewcontroller alloc] init]; uiviewcontroller * center = [[centreviewcontroller alloc] init]; mmdrawercontroller * drawercontroller = [[mmdrawercontroller alloc] initwithcenterviewcontroller:center leftdrawerviewcontroller:leftdrawer rightdrawerviewcontroller:nil]; [drawercontroller setshowsshadow:no]; [drawercontroller setrestorationidentifier:@"mmdrawer"]; [drawercontroller setmaximumrightdrawerwidth:200.0]; [drawercontroller setopendrawergesturemodemask:mmopendrawergesturemodeall]; [drawercontroller setclosedrawergesturemodemask:mmclosedra

ios - Completion block for GPS coordinates -

as apps enables user location every , then, use ability location in completion block. @ moment i've set notification using nsnotificationcenter.defaultcenter().postnotificationname("functiontorun", object: nil) when user request location, run function func getlocation() -> cllocation { locationmanager.requestlocation() return location } however updating location can take while, , returning latest location, can implement in completion block, can actual location? cllocationmanager doesn't work way use cllocationmanager-blocks cocoa pod functionality. read through documentation make sure behaves way expect to.

Position tablix elements at the same position on different pages in SSRS -

i have multiple tablixes rendered individually on each excel worksheet when exported. however, need position of tablixes remain same throughout different sheets, because currently, second sheet onwards, tablix not in same position first one. please help! what have done in past: you should create tablix objects fixed height , width better use of assignment. you should altering more on 'properties' pane trying use mouse fixed positions more precise. set 'tablix' object of first 1 , select 'size' 3in, 0.75in 3 inch width , 0.75 in height. i set 'location' first 0in,0in. using similar method 2 setting fixed size, start next 1 @ 0in,(height of first)in. in case 0in,0.75in next one. set 'pagebreak' > 'breaklocation' 'end' first 1 , every other object need break onto new page. should not last object generate blank final page potentially. optional: you can name pages appear under 'pagename' names

css - First use BEM. What I doing wrong? -

i try use bem in first time , think don't quite understand it. is assign classes elements, include li , a ? grateful receive advice on peace of code: <header> <div class="container container-1170"> <div class="row"> <div class="col-md-12"> <nav class="navbar navbar-default header-menu"> <div class="navbar-header header-menu__toggle"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> <span class="sr-only">toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <img s

c# - Is DbContext thread safe? -

i wondering if dbcontext class thread safe, assuming it's not, executing paralell threads access dbcontext in application , getting host of locking exceptions , other things may thread related. until wasn't getting errors...but until wasn't accessing dbcontext in threads. if right, people suggest solution? it's not thread safe. create new instance of dbcontext in thread.

c++ - Read/Write bytes within two processes (apps) using virtual serial communication on Android -

i have written c/c++ application (ndk) android can open virtual port serial communication. writes , reads bytes port within same process. far working , didn´t have root device in order this. simple programm following: int fd = open("/dev/ptmx", o_rdwr | o_noctty); if (fd == -1) { logw("error opening file"); return 1; } grantpt(fd); unlockpt(fd); char* pts_name = ptsname(fd); logi("ptsname: %s\n", pts_name); char* inputbyte = "this test\n"; char byte; int numofbyteswritten = write(fd, inputbyte, strlen(inputbyte)); logi("number of bytes written: %d\n", numofbyteswritten); while (read(fd, &byte, 1) == 1) { logi("byte: %c\n", byte); } close(fd); now problem if want same thing within 2 processes (two apps) doesn´t work. 1 process opens /dev/ptmx, , other process should open /dev/pts directory. everytime slave tries open /dev/pts directory error "error opening file" (-1). have rooted device , s

javascript - Opencart 1.5; How to add 15% to dollar amount passed to Authorize.net gateway -

i using opencart version 1.5 , authorize.net gateway. shipping , tax needs calculated after purchase need sure , authorize amount above purchase price. know how add percentage amount 'authorize' amount sent gateway? simpler past experience, guessing need intercept amount variable directly after customer clicks purchase @ checkout prior posting gateway. to achieve need go below file: catalog\controller\payment\authorizenet_* search below code $data['x_amount'] and add below line after above line: $data['x_amount'] = $data['x_amount'] + ((15* $data['x_amount'])/100);

Timeit timing a python function -

i trying time below function, shows me error, can't import name val_in_range, what's error, there other method better? import timeit x = 10000000 def val_in_range(x, val): return val in range(x) print (val_in_range(x,x/2)) timeit.timeit( 'val_in_range(x,x/2)', 'from __main__ import val_in_range, x', number=10) output: true traceback (most recent call last): file "python", line 11, in <module> file "<timeit-src>", line 3, in inner importerror: cannot import name 'val_in_range' replace timeit.timeit( 'val_in_range(x,x/2)', 'from __main__ import val_in_range, x', number=10) with timeit.timeit(lambda:val_in_range(x,x/2), number=10) you can print value directly using print statement.

sql - Improving update performance in ACCESS -

i have 2 tables in access: tbl_rm: (+ primary key) + customername (short text) + countrycode (short text) + rmdate (date/time - format mmm-yy) + serialnumber (short text) blackclicks (double) colorclicks (double) accentclicks (double) professionalcolorclicks (double) the second table tbl_invoices: (+ primary key) + customername (short text) + countrycode (short text) + invoicedate (date/time) + serialnumber (short text) blackclicks (double) colorclicks (double) tbl_rm contains 98 496 records (out of 9113 match query below) tbl_invoices contains 9 618 records (all matching below request). i want update tbl_invoices data tbl_rm. here update query: update tbl_invoices inner join tbl_rm on tbl_invoices.customername = tbl_rm.customername , tbl_invoices.countrycode = tbl_rm.countrycode , tbl_invoices.serialnumber = tbl_rm.serialnumber , month(tbl_rm.rmdate) = month(tbl_invoices.invoicedate)

Python: lxml xpath to extract content -

below code able extract pe reuters link below. however, method not robust webpage stock has 2 lines lesser , result shift of data. how can encounter problem. point straight part of pe extract data not know how it. link 1: http://www.reuters.com/finance/stocks/financialhighlights?symbol=myeg.kl link 2: http://www.reuters.com/finance/stocks/financialhighlights?symbol=annj.kl from lxml import html import lxml page2 = requests.get('http://www.reuters.com/finance/stocks/financialhighlights?symbol=myeg.kl') treea = html.fromstring(page2.content) tree4 = treea.xpath('//td[@class]/text()') pe= tree4[37] this part wish code can extract part changes of webpage not affected. <tr class="stripe"> <td>p/e ratio (ttm)</td> <td class="data">36.79</td> <td class="data">25.99</td> <td class="data">21.70</td>

xslt - Java can't run cmd-command's properly -

i attempting generate list of installed programs on windows machine. this command using: wmic /output:d:\miep product name && type d:\miep > d:\miep_ you might have realized i'm trying make type-command need output in utf-8. i made whitelist simple loop later in file names appear , keep them while remove else. the command works in command prompt, when try same inside java program keeps telling me i've got invalid get-expression ... here function: void createlists() throws ioexception { //string cmd = "wmic /output:d:\\miep.csv product name /format:\"%windir%\\system32\\wbem\\de-de\\csv.xsl\""; string cmd = "wmic /output:d:\\miep product name && type d:\\miep > d:\\miep_"; system.out.println(cmd); process p; p = runtime.getruntime().exec(cmd); p.getoutputstream().close(); string line; bufferedreader stdout = new bufferedreader(new inputstreamreader(p.getinputstream())); w

matplotlib - Python - Removing vertical bar lines from histogram -

Image
i'm wanting remove vertical bar outlines histogram plot, preserving "etching" of histogram, if makes since. import matplotlib.pyplot plt import numpy np bins = 35 fig = plt.figure(figsize=(7,6)) ax = fig.add_subplot(111) ax.hist(subvel_hydro1, bins=bins, facecolor='none', edgecolor='black', label = 'pecuiliar vel') ax.set_xlabel('$v_{_{b|a}} $ [$km\ s^{-1}$]', fontsize = 16) ax.set_ylabel(r'$p\ (r_{_{b|a}} )$', fontsize = 16) ax.legend(frameon=false) giving is doable in matplotlibs histogram functionality? hope provided enough clarity. in pyplot.hist() set value of histtype = 'step' . example code: import matplotlib mpl import matplotlib.pyplot plt import numpy np x = np.random.normal(0,1,size=1000) fig = plt.figure() ax = fig.add_subplot(111) ax.hist(x, bins=50, histtype = 'step', fill = none) plt.show() sample output:

Swift 3 - Reading array and dictionary from JSON -

Image
i don't know how access nested array/dictionary values in result. tried many variations, possibly part wrong didn't values. here result , want values of subarticles array. in advance!

Iterate over Array and add element to empty dictionary in Swift 2.2 -

i have array of colors number of elements in array can change. example may have 1 color 1 day 3 colors next day. how can iterate on array , add elements empty dictionary? var colors = [string]() var colordict = [string: anyobject]() //day1 array has 2 colors self.colors = ["red", "blue"] //day2 array has 3 colors self.colors = ["red", "blue", "orange"] //day3 array has 1 color self.colors = ["blue"] //regardless of day need iterate on array , add whatever inside dictionary color in self.colors{ //how add elements self.colordict? } for solving of issue try use approach: for color in colors{ colordict["somekey"] = color } as can see should firstly assign key , value key. in case key "somekey" , value color array. if not have clear amount of keys. enumerate index of array item. for (index, element) in colors.enumerate() { colordict[string(index)] = element }

jquery - jsPDF css style does not working -

i'm trying convert div pdf using jspdf , div : <div id="pdffile" style="display:none" class="containerpdf"> <headerp><h1 id="pdftitle" style="text-align: center; color:red;"></h1></headerp> <navp> <div id="pdfimage"></div> </navp> <articlep> <h1>description</h1><p id="pdfdescription"></p> </articlep> <footerp style="text-align: center;">copyright © emoovio</footerp> </div> <div id="editor"></div> and jquery code : $('#cmd').click(function () { var x = $(".entry-title").text(); doc.fromhtml($('#pdffile').html(), 15, 15, { 'width': 170, 'elementhandlers': specialelementhandlers }); //doc.autoprint(); doc.save('emoovio-'+x+

c# - Regex Beginning to End of a text file -

hi read text including <?xml version="1.0" encoding="iso-8859-1"?> </document> large text files. can need text start with <?xml version="1.0" encoding="iso-8859-1"?> , end </document> . mean separate xml part document. please me provide regex in c# currently using following code : if (text.contains("<?xml")) { foreach (match match in regex.matches(text, @"(?s)<?xml(.*?)</document>")) console.writeline(match.groups[1].value); console.readkey(); } however not including .?xml... , ./document. please advice some of characters in regex not escaped , can use match group 0 include entire matched string. i've updated example below: foreach (match match in regex.matches(text, @"(?s)\<\?xml(.*)</document>")) { console.writeline(match.groups[0].value); }

android - Keyboard closing the edit text -

i have dialog fragment edit text in it. set height,width of dialog fragment using - @override public void onresume(){ super.onresume(); displaymetrics displaymetrics = new displaymetrics(); getactivity().getwindowmanager().getdefaultdisplay().getmetrics(displaymetrics); int height = displaymetrics.heightpixels; int width = displaymetrics.widthpixels; getdialog().getwindow().setlayout((int)(width * 0.8),(int)(height * 0.8)); } the problem when click on edittext of dialog fragment, key board appears , closes edittext , cannot see typing. see have typed, have close keyboard. how make dialog fragment adjust when keyboard opens up. have tried this: android:imeoptions="flagnoextractui" . can add edittext. hope solves problem.

pyspark - Spark Dataframe Maximum Column Count -

what maximum column count of spark dataframe? tried getting data frame documentation unable find it. from architectural perspective, scalable, there should not limit on column count, can give rise uneven load on nodes & may affect overall performance of transformations.

json - How to change the folder where the Enviroment.CurrentDirectory is positioned. C# -

i want change positioning folder in order create file can consume, of on runtime. is there form target release folder dinamicaly create file there , consume it? or, if that's not possible, is possible give instructions move folder found in enviroment.currentdirectory, can place myself in space have permits create file without problem? like "c:/" if works of course, need place somewhere can modify later. i'm looking create json file consumption here base code: public partial class webform1 : system.web.ui.page { list<logindata> lstlogindata = new list<logindata>(); //with 1 check if login successfull public bool loginvalidated = false; string namefile = "somefile.json"; string whereisthefile = environment.currentdirectory + "\\"; datatable dt = new datatable(); protected void page_load(object sender, eventargs e) { whereisthefile += namefi

tsql - T-SQL - how can I use group by on xml objects -

i've wrote following query expect return data-set outlined under query query select relatedrecordid [organisationid], data.value('(//opportunityviewevent/title)[1]','nvarchar(255)') opportunitytitle, data.value('(//opportunityviewevent/id)[1]','int') opportunityid, count(data.value('(//opportunityviewevent/id)[1]','int')) visits [audit].[eventdata] left outer join employed.organisation org on [eventdata].relatedrecordid = org.id eventtypeid = 4 group relatedrecordid order visits desc expected result +-----------------+-----------------+---------------+--------+ | organisationid | opportunitytitle | opportunityid | visits | +-----------------+------------------+---------------+--------+ | 23 | plumber | 122 | 567 | | 65 | accountant | 34 | 288 | | 12 | developer | 81 | 100 | | 45 | driver |

how to replace elements in xml using python -

sorry poor english. need ;( i have 2 xml files. one is: <root> <data name="aaaa"> <value>"old value1"</value> <comment>"this old value1 of aaaa"</comment> </data> <data name="bbbb"> <value>"old value2"</value> <comment>"this old value2 of bbbb"</comment> </data> </root> two is: <root> <data name="aaaa"> <value>"value1"</value> <comment>"this value 1 of aaaa"</comment> </data> <data name="bbbb"> <value>"value2"</value> <comment>"this value2 of bbbb"</comment> </data> <data name="cccc"> <value>"value3"</value> <comment>"this value3 of cccc"</comment> </data> </root> one.xml updated two.xml. so, one.xml should this. o

python - Django Rest framework - change the URL hostname in hyperlinkedmodel serializer -

i have webservice built drf 1.8.x model driven. intent provide absolute urls in response foreign key fields , includes right hostname(gateway hostname). however, since api sits behind nginx gateway, hostname field modified , sending context['request'] serializer instance doesn't seem help. as of i'm using decorators modifying hostname , handling version based behaviour self url field forieign key fields still showing api hostname. here code below: serializers.py class nodeserializer(serializers.hyperlinkedmodelserializer): url = serializers.serializermethodfield() class meta: model = node fields = ('url', 'name', 'description', 'owner', 'address', 'created', 'updated', 'endpoint') extra_kwargs= { 'endpoint': {'view_name': 'loadbalancerendpoint-detail'}, 'owner': {'view_name': 'artifactow

object - How to Insert an Excel workbook into another Excel workbook range -

i need insert 1 excel workbook excel workbook, @ same range address of 2nd workbook. have seen "selection.insertfile" method,but how can make specific range selection? i tried: jdt.sheets("document template").range("e44").select selection.insertfile filename:=path & fname but got:"object doesn't support property or method" i realized inserting object, had use ole, unfamiliar. found , adapted answer macro yesterday, forgot come , post it, "reminder" post benefit of others: 'inserts backup template file jdt file each cell in jdt.sheets("document template").range("e44") if isempty(cell) dim ol oleobject set ol = activesheet.oleobjects.add(filename:=path & fname, link:=false, displayasicon:=true, height:=2) ol .top = cell.offset(0, 1).top .left = cell.offset(0, 1).left end end if next i realize for-next loop target 1 cell inefficient, gave me c

string matching - excel partial match in reverse -

Image
i have 2 columns. 1 has values like: 0008347_abcd 2008756_abgr 0008746_gss1 ....... and second column 4 digit numbers of above column entries partially match i.e. 8347 8746 ... i want find of first column entries have partially matching entry in second column. can return (true false, 0 1), want find them. in above example flag first , third values. there might multiple entries in column 1 match 1 entry in column 2 , flag them all. the first column has 3346 entries , second 334. can me in excel? this give 1s , 0s: =sumproduct(1*(isnumber(search($c$1:$c$2,a1)))) for true/false: =sumproduct(1*(isnumber(search($c$1:$c$2,a1))))>0

javascript - Content Tools add br instead of p when pressing the Enter -

content tools i need when pressing "enter" instead tag p add tag br, how can implemented? thank in advance. contentedit (which part of contenttools) provides setting allow configure behaviour of return key in text elements - prefer_line_breaks (see settings documentation here: http://getcontenttools.com/api/content-edit#settings ). so configure application insert line breaks ( br tags) when enter key pressed need set prefer_line_breaks true so: contentedit.prefer_line_breaks = true;

if statement - Powershell CSV import and update IF function -

Image
i have .csv file wish work in powershell. .csv has 3 columns accountnumber1, accountnumber2, order the data can in number of variables now data non consistent, there accountnumber2. if accountnumber1 exists account number needs used. other import-csv options have no ideas on how progress this, wondered if length = 0 or around unsure. easy in excel prefer not write excel function in feel layer of complexity shouldn't need. import-csv -literalpath 'l:\slist.txt' -headers accountnumber1,accountnumber2,correctac,order excel be; =if(a2="",b2,a2) how completed in ps? use calculated properties replace empty accountnumber1 fields: $headers = 'accountnumber1','accountnumber2','correctac','order' import-csv -literalpath 'l:\slist.txt' -headers $headers | select-object -property *,@{n='accountnumber1';e={ if (! $_.accountnumber1) {$_.accountnumber2} }} -exclude accountnumber1

scala - Nested describe blocks with nested beforeAll/afterAll methods in ScalaTest? -

we trying translate our old rspecs scalatest funspec . have run problem nesting describe blocks. in rspec, each nested describe block can have own before/after(:all/:each) blocks added outer scope. useful thing able do, , have made use of it. unfortunately, scalatest can have before/afterall/each() methods @ root level of test class, not being nestable. is there workaround this? rspec: describe 'a person 2 email addresses' before(:all) # create data end after(:all) # delete data end 'should have 2 phone numbers' # ... end describe 'and 1 email address retired' before(:all) # change settings end 'should able delete retired email address' # ... end 'should not able retire other email address' # ... end end end

android - How to get Firebase Exception into a switch statement -

i have code: if (!task.issuccessful() && task.getexception() != null) { firebasecrash.report(task.getexception()); log.w(tag, "signinwithcredential", task.getexception()); toast.maketext(signup.this, "authentication failed: " + task.getexception().getmessage(),toast.length_long).show(); } sometimes user gets firebaseauthusercollisionexception , , want detect in switch statement so: switch(task.getexception()){ case /*i don't know goes here*/: //whatever } but read, don't know put in case statement. put in there? in other words, firebaseauthusercollisionexception located can access it? firebaseauthusercollisionexception class can't it. firebase authentication exceptions derive firebaseauthexception , has geterrorcode() method. so: if(task.getexception() instanceof firebaseauthexception){ firebaseauthexception e = (firebaseauthexception)task.getexception(); switch (e.geterrorcode()) {