Posts

Showing posts from August, 2012

emulation - 6502 cycle timing per instruction -

i writing first nes emulator in c. goal make understandable , cycle accurate (does not have code-efficient though), in order play games @ normal 'hardware' speed. when digging technical references of 6502, seems instructions consume more 1 cpu cycle - , has different cycles depending on given conditions (such branching). plan create read , write functions, , group opcodes addressing modes using switch . the question is: when have multiple-cycle instruction, such brk , need emulate happening in each cycle: #method 1 cycle - action 1 - read brk opcode 2 - read padding byte (ignored) 3 - store high byte of pc 4 - store low byte of pc 5 - store status flags b flag set 6 - low byte of target address 7 - high byte of target address ...or can execute required operations in 1 'cycle' (one switch case ) , nothing in remaining cycles? #method 2 1 - read brk opcode, read padding byte (ignored), store high byte of pc, store low byte of pc, store status flags b flag ...

ios - Cocoapods is installing old Pod version -

i'm using rxswift , other rx-pods in app, according podfile.lock use rxswift (3.2.0) , want update pods latest versions. so remove 4 rx..-pods use podfile , , run pod install , removed pods project , podfile.lock . re-add 4 rx..-pods , run pod instal again. installs rxswift 2.6.1 ... why? - i'm expecting install newest stable version of rxswift , 3.6.1.. i tried removing listed by: gem list --local | grep cocoapods , reinstalling cocoapods running: gem install cocoapods i tried running pod repo update without success. i tried running pod update , without uninstalling pods first, same outcome. i suspect issue cocoapods -gem, not rx-pods.. edit added podfile : source 'https://github.com/cocoapods/specs.git' # uncomment line define global platform project platform :ios, '9.0' # uncomment line if you're using swift use_frameworks! target 'myapp' pod 'brightfutures' pod 'alamofire' pod 'mbprogresshu...

html - Anchors with fixed navigation and sticky header -

as can see in this jsfiddle , have navbar , sticky header per div. if click on anchors scrolled down right position, header overlaps text of div. i want header positioned above div when scrolling down, can accomplished setting .header { margin-bottom: 40px; } if offset, don't want @ all, can see here: margin bottom is there way accomplish avoiding overlapping , having no margin? thank in advance! i tried offsetting adding padding-top anchor, suggested in answers of question , did not work either (still overlapping) check snippet: .navbar { position: fixed; height: 40px; background: green; top: 0; width: 100%; z-index: 5; } .nav_holder{ position:absolute; top:40px; } .content { margin-top: 60px; } .one, .two, .three { height: 1000px; padding-top:40px; } .header { position: sticky; top: 40px; background: white; } <div class="navbar"> navbar </div> <div class="co...

c# 7.0 - C# Interactive not recognizing ValueTuple reference -

i cannot use tuples in c# interactive window; following error: (1,15): error cs8137: cannot define class or member utilizes tuples because compiler required type 'system.runtime.compilerservices.tupleelementnamesattribute' cannot found. missing reference? (1,15): error cs8179: predefined type 'system.valuetuple`2' not defined or imported (2,9): error cs0103: name 'isliteraltypename' not exist in current context (2,47): error cs8179: predefined type 'system.valuetuple`2' not defined or imported (5,12): error cs8179: predefined type 'system.valuetuple`2' not defined or imported this after i've added reference valuetype assembly: #r "d:\myproject\packages\system.valuetuple.4.3.1\lib\netstandard1.0\system.valuetuple.dll" how can make use of value tuples c# interactive window? remove /r:system.valuetuple.dll from c:\program files (x86)\microsoft visual studio\2017\<edition>\common7\ide\commonextensions\micro...

javascript - Using Google analytics, Is it possible to create Custom dimension using API (programatically) -

i working on saas application, let user(s) use own google analytics account tracking site. while tracking, wants take benefit of custom dimensions. not possible telling/educating each client( most of them non-technical ) " how create custom dimension/metric using google analytic interface ". is there way, can create custom dimension using code. ga('<command>','<dimension name>', '<index>', '<scope>') you can create custom dimensions in google analytics management api, see: https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtreference/management/customdimensions/insert there example code working api here: https://github.com/google/google-api-java-client-samples/tree/master/analytics-cmdline-sample good luck :)

javascript - React contentEditable and cursor position -

i have simple component class contenteditable extends react.component{ constructor(props){ super(props); this.handleinput = this.handleinput.bind(this); } handleinput(event) { let html = event.target.innerhtml; if(this.props.onchange && html !== this.lasthtml){ this.props.onchange({target:{value: html,name: this.props.name}}); this.lasthtml = html; } } render(){ return (<span contenteditable="true" oninput={ this.handleinput } classname={ 'auto '+this.props.classname } dangerouslysetinnerhtml={ {__html: this.props.value} }> </span>); } } export default contenteditable; <contenteditable value={this.state.name} onchange={(e)=>{this.setstate({name:e.target.value});}} /> component works cursor time on first position instead after rendered text. i tested examples form forum doesn't work me. i use react 15....

Excel - Search from range, not specific cell? -

Image
i have range of cells in column i2:i8: wiley elsevier springer taylor sage oxford cambridge i want use search function on column g, it'll search 1 of values in range, , return true/false column h if finds anything. problem is, values in column g longer, , string in column substring of column g text. column g contains (for example): blackwell publ ltd israel medical assoc journal pergamon-elsevier science ltd pergamon-elsevier science ltd mosby, inc oxford univ press cell press amer coll physicians nature publishing group cold spring harbor lab press, publications dept amer coll physicians massachusetts medical soc wiley-blackwell blackwell publishing inc amer assoc advancement science oxford univ press massachusetts medical soc oxford univ press academic press inc elsevier science academic press ltd- elsevier science ltd so examples, each time word wiley, oxford, elsevier etc appear in column g (such in oxford univ press or wiley-blackwell or academic press inc elsevier...

r - Unable to install 'rstats-db/bigrquery' from ipython notebook -

i'm trying query google big query r ipython notebook. i'm following post here: https://cloud.google.com/blog/big-data/2017/04/google-cloud-platform-for-data-scientists-using-r-with-google-bigquery it breaks when run line: devtools::install_github("rstats-db/bigrquery", force = true) the full error message isn't clear me, i'll paste below. when run interactive r environment this: sh: /usr/bin/gnutar: no such file or directory sh: /usr/bin/gnutar: no such file or directory installation failed: error in running command trying url 'https://cran.rstudio.com/src/contrib/readr_1.1.1.tar.gz' content type 'application/x-gzip' length 233793 bytes (228 kb) ================================================== downloaded 228 kb it seems unable unpack files. i've tried installing gnutar brew, error still occurs. how can passed error? full error message: installing package ‘/users/user/library/r/3.3/library’ (as ‘lib’ unspecified) do...

Concatenate Worksheets in Google Spreadsheet to new worksheet -

i have google spreadsheet contains multiple worksheets. worksheets have same columns have additional columns. concatenate worksheets single, newly created worksheet in same workbook. differences in columns should contain blank values. bonus points if adapted use on multiple workbooks. preferable if select sheets concatenate. i have tried write script struggling. the mother of sheets you of spreadsheets in drive , of them well. i'm not doing it. allows include sheets want concatenated adding them array includedsheet. function concatallsheets() { var includedsheet=['sheet1','sheet2','sheet3']; var ss=spreadsheetapp.getactive(); var allsheets=ss.getsheets(); var sheetname='motherofallsheets-' + utilities.formatdate(new date(), session.getscripttimezone(), "yyyymmddhhmm") var mother=ss.insertsheet(sheetname); for(var i=0;i<allsheets.length;i++) { var sht=allsheets[i]; if(includedsheet.indexof(sht....

Install Java EE Developer Tool on Eclipse Luna in a virtual machine -

Image
i trying install java ee developer tool(for dynamic web project) in eclipse luna onto virtual machine unable see selection options. here image showing struggling with: if want solve problem in easy way should download eclipse ide java ee developer. can links below. http://www.eclipse.org/downloads/eclipse-packages/ if want eclipse marketplace have search webtools platform. refer link below more information. https://eclipse.org/webtools/ http://download.eclipse.org/webtools/updates/ to install it, add following url http://download.eclipse.org/webtools/repository/luna/ if want eclipse oxygen repository, add same above url replace version name like. http://download.eclipse.org/webtools/repository/oxygen/

c# - Query and map complex objects -

my goal query , map complex objects little overhead possible. working large database lots of related tables. trying use linq select , projection select necessary information need make object. this original query had fast , worked great. list<clientdto> clientlist = dbclients.select(client => new clientdto { id = client.clientid, firstname = client.firstname, lastname = client.lastname, //etc.... products = client.products .select(prod => new productdto { id = prod.id, dateoftransaction = prod.date, //etc... }).tolist(), items = client.items .select(item => new itemdto { id = item.id, date = item.date, //etc... } }); keep in mind client table has on 50 related tables, query worked great in selected fields needed make object. now needed make mappers these objects , try build same query statement using mappers time. here...

objective c - BAD_ACCESS error -

in h file have @property __strong ghost* **gameboard; and initialized in m file this sharedengine.gameboard = (ghost* __strong** )malloc(sizeof(ghost**) * [levelmanager sharedmanager].selectedlevel.fieldrowsnumber); for(int = 0; < [levelmanager sharedmanager].selectedlevel.fieldrowsnumber; i++ ) { sharedengine.gameboard[i] = (ghost* __strong*)malloc(sizeof(ghost*) * [levelmanager sharedmanager].selectedlevel.fieldcolumnsnumber); } have done wrong because having bad_access crashes.

vba - Enum condition behavior : enum_Var = str1 Or str2 -

(i use simple example , not original code, not relevant) i wanted make if statement on enum, or . excel vba editor suggested use kind of syntax : if current = apple or peach then (dropdown choice, see below) screenshot well, curious why not. figured out while testing behavior wasn't 1 expect : public enum fruit apple peach banana end enum public sub pick() dim current fruit current = banana if current = apple or peach '//the condition true msgbox "toc" end if end sub indeed, in code, if true. not don't know why : think peach evaluated integer or so, beeing different 0, it's true . proof, if in enum fruit declaration, peach forced 0, it's false . public enum fruit apple peach = 0 banana end enum public sub pick() dim current fruit current = banana if current = apple or peach '//the condition false time msgbox "toc" end if end su...

javascript - fetch data to display in ng-options but set dynamic default value -

a user object available view populates form. 1 of elements display information drop-down. 2 requests made. 1 user information , , other list of timezones . both resolved through ui-router state so: .state('app.userprofile', { url: '/userprofile', component: 'user', resolve: { user: ['userservice', function(userservice) { return userservice.fetchuser(); }], timezones: ['timezoneservice', function(timezoneservice){ return timezoneservice.fetchusatimezones(); }] } }) }]); i have given read of article found online after select element failed populate users timezone, select element still fails display information. question how populate default select option data user object populate options second response. <label for="timezones">time zone</label> <div> <select name="timez...

How to trigger signature-pad's onEnd event using Protractor/Javascript -

i'm trying write automation test protractor signs signature pad, trigger onend event fire. currently, automated signing looks this: var canvas = document.getelementsbytagname('canvas')[0]; var ctx = canvas.getcontext("2d"); ctx.moveto(0,0); ctx.lineto(200,100); ctx.stroke(); if use mouse or finger on signature-pad, fires onend event. however, not. there way can manually event fire?

linear algebra - Multiply elements of a matrix with a scalar - Spark MLlib -

i working rowmatrix , matrices classes spark mllib library implement linear regression. want multiply or divide elements of rowmatrix scalar, can't find function or operator this. what's way execute linear algebra operations on spark? the reason use rowmatrix because earlier in code compute matrix multiplication between rowmatrix , local matrix. thank in advance, nadia

graylog2 - Sending an entire log file to graylog using fluentd -

is there way send entire log file inconsistent format graylog's web interface message field using fluentd? regarding graylog , not require specific log format. pattern needed if want parse , separate fields easy querying , statistics. based on fluentd plugins page there plugin named fluentd gelf output able format , output fluentd logs graylog . i not fluentd therefore cannot give details configuration of such plugin. based on readme of project seems straight forward.

python - Pandas: substitute commas for points in a column -

i have column of values csv-file contain commas instead of points. code below want turn these points, not work. there no error message, code runs , if call column betrag() (german: absolute value) datafram umsatz , display no change. commas still in place. def removecom(value): value=value.replace(',','.') umsatz['betrag()']=umsatz['betrag()'].apply(lambda value: removecom(value)) umsatz['betrag()'] for instance turn 7,99 7.99 the reason see no change because removecom returns nothing. should return value function this: def removecom(value): return value.replace(',','.') however, better method recommend using df.str.replace : umsatz['betrag()'] = umsatz['betrag()'].str.replace(',', '.') demo: in [750]: df out[750]: col1 0 foo,bar 1 abc,def in [751]: df['col1'] = df.col1.str.replace(',', '.') in [752]: df out[752]: col1 0...

mysql - sql - Is it possible to set a column value as per the value in another column? -

let's i'm making 'students' database , there's table called 'exams' in it. have following 2 columns- 'marks' , 'grade' in , want 'grade' column automatically receive value based on value entered in 'marks'. 'a' 'marks'>=90, 'b' 'marks'>=80 , on. there way that? not easily. in mysql, can update: update students set grade = (case when marks >= 90 'a' when marks >= 80 'b' . . . end); but out-of-date next insert or update statement. in mysql 5.7.6, can have column generated automatically: alter table students add grade char(1) (case when marks >= 90 'a' when marks >= 80 'b' . . . end); this convenient, because column calculated @ query time automatically up-to-date. ...

qt - How to Use QML StackView? -

i beginner in qml , have worked more on stackwidget in qt c++.in qml confused use stackview , have written following code: window { visible: true width: 640 height: 480 title: qstr("stack view") mainform { stackview { id: stackview x: 0 y: 0 width: 360 height: 360 initialitem: page1 rectangle { id: page1 //anchors.fill: parent color: "lightgreen" button { id: buttonpage1 text: "back 2" anchors.centerin: parent onclicked: { stackview.pop() //**is correct** stackview.push(page2) //**is correct** } } textedit { id: te1 width: 105 height:...

Modify / Update element in ArrayList in working memory in rule Drools -

we working on rule structured follows: we have list contains validated , non-validated elements. difference between validated , non-validated done giving different status elements. we obtain non-validated elements list. each non-validated element compared validated elements in same list. after comparison non-validated element become validated element needs considered when validating non-validated elements. the problem arises when want update original arraylist of elements. need able update non-validated element has become validated in original arraylist in working memory loop can take "refreshed" arraylist account. three questions: first of all, exact difference between using modify , update in drools. according drools documentation: "on right hand side of rule modifystatement recommended, makes changes , notifies engine in single statement." so difference between 1 , other simple semantics like: modify( $sprinkler ) { seton( true ) };...

c# - Cannot find security header in the message -

i did research related questions, not find answer in case. i have created service reference , when calling method, i'm getting following exception: security processor unable find security header in message. might because message unsecured fault or because there binding mismatch between communicating parties. can occur if service configured security , client not using security i have following setting in appconfig file: <system.servicemodel> <bindings> <basichttpsbinding> <binding name="myhttpbinding"> <security mode="transportwithmessagecredential"> <transport clientcredentialtype="none"></transport> <!--<message clientcredentialtype="username"/>--> </security> </binding> </basichttpsbinding> </bindings> <client> <endpoint address="https://webserviceurl/services/myobject...

sparql - Are typed literals "tricky" in RDF4J? -

in rdf, can have entity bound single property multiple literal values. values can typed add clarity. :dumptruck :weight "heavy"^^xsd:string . :dumptruck :weight "36000"^^xsd:integer . in sparql, can query type want select ?w { :dumptruck :weight ?w filter ( datatype(?w) = xsd:integer ) } is there getstatement in rdf4j can constrained datatype that? there's no priori constraint possible, can post-process result filter on datatype. example use along these lines (untested drift hopefully): queryresults.stream(conn.getstatements(dumptruck, weight, null)) .filter(s -> ((literal)s.getobject()).getdatatype().equals(xmlschema.integer)) .collect(collectors.tolist()); or alternatively, stick in model first , filter: model m = queryresults.asmodel(conn.getstatements(dumptruck, weight, null)); list intvalues = models.objectliterals(m).stream().filter(l -> l.getdatatype().equals(xmlschema.integer)).coll...

Relationship between java memory allocation needs and available memory/swap -

when starting new java process getting error sounds this: "could not reserve enough space 16775168kb object heap" looking @ log file produced jvm see following: # there insufficient memory java runtime environment continue. # native memory allocation (malloc) failed allocate 32744 bytes chunkpool::allocate # possible reasons: # system out of physical ram or swap space # in 32 bit mode, process size limit hit at same time @ bottom of log file there statement: memory: 4k page, physical 67098420k(52119824k free), swap 86034256k(8132400k free) vm_info: java hotspot(tm) 64-bit server vm (25.45-b02) windows-amd64 jre (1.8.0_45-b15), built on apr 30 2015 12:40:44 "java_re" ms vc++ 10.0 (vs2010) how can java process fail allocate 1gb of memory if @ same time there bigger amount of memory available both physical memory , swap space? thanks lot boris excerpt log file: # # there insufficient memory java runtime environment continue. # native memory...

In grpc, what is the generated_pool method doing? -

i'm bit confused of autogenerated code in grpc , can't find documentation it. here's proto file called route_guide.proto syntax = "proto3"; ... package routeguide; // interface exported server. service routeguide { // simple rpc. // // obtains feature @ given position. // // feature empty name returned if there's no feature @ given // position. rpc getfeature(point) returns (feature) {} ... // points represented latitude-longitude pairs in e7 representation // (degrees multiplied 10**7 , rounded nearest integer). // latitudes should in range +/- 90 degrees , longitude should in // range +/- 180 degrees (inclusive). message point { int32 latitude = 1; int32 longitude = 2; } // latitude-longitude rectangle, represented 2 diagonally opposite ... // feature names @ given point. // // if feature not named, name empty. message feature { // name of feature. string name = 1; // point feature detected. point location = 2; } if...

email - In PowerShell, is there a way to dispose of Send-MailMessage resources? -

i've written powershell script sends email message. used send-mailmessage commandlet. send-mailmessage -smtpserver $mailserver ` -to $mailto ` -from $mailfrom ` -subject $mailsubject ` -body $mailbody this concise. if execute script rapidly in succession on workstation, following error appears in powershell console. unable read data transport connection: established connection aborted software in host machine. what suspect resources aren't being released or thread getting blocked. below current workaround, has advantage of being disposable. , can run in rapid succession no transport connection errors. more verbose send-mailmessage. [object]$smtpclient = new-object system.net.mail.smtpclient [object]$mailmessage = new-object system.net.mail.mailmessage $smtpclient.host = $mailserver $mailmessage.to.add($mailto) $mailmessage.from = $mailfrom $mailmessage.subject = $mailsubject $mailmessage.body = $mailbody $smtpclient.send($mailmessage) $mailmessage.dispos...

java - Container exception using Hibernate from an external project (server.ContainerException: ... org.hibernate.internal.CoreMessageLogger -

Image
i'm deploying rest project on glassfish 4.1.1 bundle netbeans server. maven dependency, have included external netbeans project done , tested, uses hibernate provide functionallity. should use java library project in rest web services project. when debug rest project, once deployed , started glassfish in debug mode, rest services called , going nice until call method uses hibernate (from external lib project) needed. crashes shown below in attached image. at starting of glassfish sever, noticed these 2 warnigs: warning: web application [unknown] registered jdbc driver [com.mysql.jdbc.driver] failed unregister when web application stopped. prevent memory leak, jdbc driver has been forcibly unregistered. warning: web application [unknown] registered jdbc driver [com.mysql.fabric.jdbc.fabricmysqldriver] failed unregister when web application stopped. prevent memory leak, jdbc driver has been forcibly unregistered. information: hv000001: hibernate validator 5.1.2.final ...

jquery - How to use hexo to pop up a picture -

Image
i changed hexo (landscape theme) sharing button, following code. (hexo\themes\landscape\layout_partial\article.ejs) <article id="<%= post.layout %>-<%= post.slug %>" class="article article-type-<%= post.layout %>" itemscope itemprop="blogpost"> <div class="article-meta"> <%- partial('post/date', {class_name: 'article-date', date_format: null}) %> <%- partial('post/category') %> </div> <div class="article-inner"> <%- partial('post/gallery') %> <% if (post.link || post.title){ %> <header class="article-header"> <%- partial('post/title', {class_name: 'article-title'}) %> </header> <% } %> <div class="article-entry" itemprop="articlebody"> <% if (post.excerpt && index){ %> <%- post.ex...

nio - Azure notification hub java.net.ConnectException: Connection timed out: no further information -

am trying use azure notification hub, via java. when trying create registration, java.net.connectexception: connection timed out: no further information. can me understand why issue may come? pls let me know if need more information. thanks. am using code found https://github.com/azure/azure-notificationhubs-java-backend/blob/master/notificationhubs . jar file versions below: httpclient - 4.3.1 httpcore - 4.3.1 httpcore-nio - 4.3.1 error happens in synccallback class, method - "failed". exception trace below. java.lang.runtimeexception: java.net.connectexception: connection timed out: no further information @ com.org.utils.notifications.synccallback.failed(synccallback.java:41) @ org.apache.http.concurrent.basicfuture.failed(basicfuture.java:130) @ org.apache.http.impl.nio.client.defaultclientexchangehandlerimpl.connectionrequestfailed(defaultclientexchangehandlerimpl.java:318) @ org.apache.http.impl.nio.client.defaultclientexchangehandlerimpl.ac...

oop - Dynamically instantiating child classes with different constructor parameters in Python -

suppose have python 2.7 code maintains list of options. parsing options, code can determine child class of complicated inheritance tree instantiate next. however, different child classes have different constructors take different parameter numbers. find myself writing code this: childclassstr = get_child_class(currentoptiondict) childclass = getattr(importlib.import_module("meow"), childclassstr) # necessary parameters available @ point if childclass == class1: classinstance = childclass(param3, param4) elif childclass == class2: classinstance = childclass(param2, param3, param4) else: classinstance = childclass(param1, param2, param3, param4) i realize not way handle this. there accepted way of doing instantiation? should dynamically build parameter list avoid if else statements , write like: childclassstr = get_child_class(currentoptiondict) childclass = getattr(importlib.import_module("meow"), childclassstr) paramlist = assemble_class_param...

c# - Get the position of a gameobject in an array -

Image
i using script sort array alphanumeric: public class alphanumcomparatorfast : icomparer<string> { public int compare(string x, string y) { string s1 = x string; if (s1 == null) { return 0; } string s2 = y string; if (s2 == null) { return 0; } int len1 = s1.length; int len2 = s2.length; int marker1 = 0; int marker2 = 0; // walk through 2 strings 2 markers. while (marker1 < len1 && marker2 < len2) { char ch1 = s1[marker1]; char ch2 = s2[marker2]; // buffers can build characters in each chunk. char[] space1 = new char[len1]; int loc1 = 0; char[] space2 = new char[len2]; int loc2 = 0; // walk through following characters digits or // characters in both strings starting @ appropriate marker. //...

why is spring boot's DataJpaTest scanning @Component -

confident hasn't been asked reading through spring docs , testing utilities found annotation , thought i'd start using it. reading through fine print read: regular @component beans not loaded applicationcontext. sounded , liked idea of using h2 except found entity wanted use had catalog , schema modifiers , default h2 couldn't figure out how support that. made h2 datasource test branch , use , override replace. wound @runwith(springrunner.class) @contextconfiguration(classes=abch2congfiguration.class) @datajpatest @autoconfiguretestdatabase(replace= autoconfiguretestdatabase.replace.none) public class statusrepositorytest { } however tests fails fro caused by: org.springframework.beans.factory.nosuchbeandefinitionexception: no qualifying bean of type. leads to: error creating bean name 'customerserviceimpl': unsatisfied dependency. however customerserviceimpl bean: @component public class customerserviceimpl implements customerservice { } that ...

php - MySQL query for finding relation between three tables with constraints, even if the relation doesn't exist -

i working on online university has users, courses, , user course status. have list of users, , list of courses. want find course status of given users , courses, including null status course user hasn't yet started. so example: user ids: [1, 7, 14, 21] course ids: [5, 8, 36, 50] desired result: name course status john doe how tie shoes complete john doe how paint house in progress jane doe how tie shoes complete jane doe how paint house not started <-- these tricky ones ... it seems can perform left join on tables , null values, can coalesce 'not started' add constraints limit courses and/or users i'm looking for...it stops giving me null values values because null course id isn't in list of courses above. here's example query giving idea of i've been trying (among other things): select `users`.`name` `name`, `users`.`email` `email`, `courses`.`number` `course #...

indexing - Python index issue -

this question has answer here: accessing index in python 'for' loops 13 answers how find occurrences of element in list? 8 answers finding indices of matching elements in list in python 3 answers below code. why behaving so? alternative? line2 = ["a", "b","c","d","e","f","g","a","c", "d","e","g","h",] x in line2: print("x value is:", x, " , index is:", line2.index(x)) output is: x value is: , index is: 0 x value is: b , index is: 1 x value is: c , index is: 2 x value is: d , index is: 3 x value is: e , index is: 4 x v...

Input selection using powershell -

i relatively new powershell .how can provide user selection scenario in powershell ?. able write script getting parameters user having them type instead of letting them select given options . below scenario env: 1) staging 2) prod selection: select action perform: 1) foo 2) bar selection: schedule or leave blank schedule (yyyy-mm-dd hh:mm:ss): note (leave blank skip): plan of action: >> sending action to: >> scheduling action of: >> schedule date: >> notes: ok proceed? (y|n): any in pointing me in right direction appreciated. time this should started. function do-stuff { param($environment,$action,$schedule,$note) <# logic #> } $splat = @{ environment=''; action=''; schedule=''; note=''; } write-host "env:`r`n`t1) staging`r`n`t2) prod`r`nselection:" $splat.environment = read-host write-host "select action perform:`r`n`t1) foo`r`n`t2) bar`r`nse...

python - Losing images when running program -

i'm running os.rename program on thousands of images rename them , deletes hundreds of them. luckily made backups, there way stop this?? my code looks this: #!/usr/bin/python import os, shutil _src = ("/path/to/directory") i,filename in enumerate(os.listdir(_src)): newname = ('truck-' + str(i).zfill(3)) os.rename(os.path.join(_src, filename), os.path.join(_src,newname)) print('renaming "%s" "%s"...' % (filename, newname)) the thing can think of doing somehow keeping file loaded don't know start on that.

How can I use Jenkins git credentials in groovy script -

i using extensible choice parameter plugin with groovy script return ['git','ls-remote','-h', 'git@github.com:company/project.git' ] .execute().text.split("\\n?[a-f0-9\t]+refs/heads/") .tolist().tail().collect{ it-> it.trim()} this works on older version of jenkins trying migrate , works when using public git hub repo https i not sure need work. on jenkins 2.60.2 , plugins date

AngularJS constants vs global JavaScript variables -

in angularjs application benefit of using constants , vs creating window scoped variables in javascript? i can define global variables in js doing : <script type="text/javascript">const global_variable= "myvalue"</script> instead of angular way of declaring constant, injecting controller, , setting on scope