Posts

Showing posts from March, 2015

java - How to write the data to CSV with dynamic headers and Dynamic Values -

i have requirement export data ui table: i want add data csv file, column headers , data should e dynamic, based on column coming dynamically need add data csv file: my columns in map every time retrieving columns based on boolean value below: list<string> header1 = new arraylist<string>(); (entry<object, boolean> entry : layout.getlayout().entryset()) { if (entry.getvalue() == true) { header1.add(entry.getkey().name() + ","); } } i have object values respective columns , need write data csv file: i have option below write csv for (object object: result.getresults()) { (entry<object, boolean> entry : layout.getlayout().entryset()) { if (entry.getvalue() == true) { if(entry.getkey().name().equalsignorecase("xxxx")) { object.getxxx(); }

Using XPath Contains -

i trying scrape price data off various websites. working fine except 1 site xpath price unique each product page e.g. page - //*[@id="price-including-tax-2940"] page b - //*[@id="price-including-tax-1456"] i.e. have unique number part of query string. this example of 1 of pages in question http://thepowersite.co.uk/honda-gx200-powered-gear-driven-pump-pressure-washer-b2565hag to save me finding unique xpath price on each page, trying modify xpath query remove unique number. i've tried various things along these lines, //*[id=[contains(.,'price-including')]] lack of understanding of xpath letting me down. to me seems want //*[contains(@id,'price-including')]

regex - Escape special character ^ in a regular expression in Java -

this question has answer here: what special characters must escaped in regular expressions? 8 answers i want split string in java following format: "value^1" initial part, "value" in string. i wanted use split instead of substring, tried this: string.split("^")[0] but unfortunately ^ special character , guess has escaped. tried split("\^") no luck. anybody knows how achieve using split? thanks! escape escape: split("\\^") . or split(pattern.quote("^")) . but since want first part of it, there's no need use split : int pos = string.indexof('^'); string firstpart = (pos != -1) ? string.substring(0, pos) : string;

Asana Boards task api integration -

asana have released new boards feature. is there way column task belongs through api? i don't see documentation field. when call task rest resource there no data it: https://app.asana.com/api/1.0/projects/0000000000/tasks?&opt_expand=(this%7csubtasks%2b) { "data": [ { "id": 214497961570704, "created_at": "2016-11-17t07:30:18.834z", "modified_at": "2016-11-17t07:39:13.350z", "name": "title", "notes": "", "assignee": null, "completed": false, "assignee_status": "upcoming", "completed_at": null, "due_on": null, "due_at": null, "projects": [ { "id": 11111111111, "name": "name" } ], "tags": [], "workspace": { "id": 111111111, "name"

VHDL coding style and best practises reference guide -

do of know vhdl coding style guide , practises guide? sw there lot of material, vhdl don't see reference example. supposed because each maker has own synthesis tool, , code interpretation changes. i'm looking short guide instead of large book. thanks! in general, quick reference guide use is http://allaboutfpga.com/category/vhdl/ examples there have syntax , comments, it's optimized vhdl , more geared towards learning it, may or may not helpful. if using xilinx tools, have templates included every kind of operation or situation find in. suggest familiarizing if want avoid books reuse methodology ( https://www.amazon.com/reuse-methodology-manual-system-designs/dp/1402071418/ref=dp_ob_title_bk ) or designers guide vhdl. other rules of thumb understood things using std_logic's on ports, tabulating readability, registering outputs, , modularizing as possible.

Submitting C++ callback to .NET C++/CLI Wrapper -

i've been searching web solution following problem cannot head around it. we have big monolithic application med in c++. "upgrade" new world embed wpf views in generated in c++/cli managed wrapper. initial call made c++ via smartpointer. if (succeeded(ptr.createinstance(__uuidof(cloudservices)))) { crect rect; pwndcontainer->getwindowrect(rect); ptr->initializecontrol((long)pwndcontainer->getsafehwnd(), id_ais_balancematrix, bstr.m_str, rect.width(), rect.height()); } and in wrapper class interface declared like interface icloudservices : idispatch{ [id(1)] hresult initializecontrol([in] long hwndparent, [in] long controltypeid, [in] bstr parameters, [in] long width, [in] long height); and implemented in wrapper stdmethodimp ccloudservices::initializecontrol(long hwndparent, long controltypeid, bstr parameters, long width, long height) { ... } problem: works fine , wpf view rendered within c++ app. need

c++ - cast operator function compiles fine in g++ but not in other compilers. Why? -

this question has answer here: operator cast, gcc , clang: compiler right? 1 answer consider following program: struct s { using t = float; operator t() { return 9.9f; } }; int main() { s m; s::t t = m; t = m.operator t(); // correct ? } the program compiles fine in g++ ( see live demo here ) but fails in compilation in clang++, msvc++ & intel c++ compiler clang++ gives following errors ( see live demo here ) main.cpp:8:20: error: unknown type name 't'; did mean 's::t'? t = m.operator t(); // correct ? ^ s::t main.cpp:2:11: note: 's::t' declared here using t = float; msvc++ gives following errors ( see live demo here ) source_file.cpp(8): error c2833: 'operator t' not recognized operator or type source_file.cpp(8): error c2059: syntax error: 'new

twitter - How to write multiple txt files in Python? -

i doing preprocessing tweet in python. unpreprocess tweets in folder. each file containing unpreprocess tweet named 1.txt, 2.txt,...10000.txt. want preprocess them , write them new files named 1.txt , 2.txt,...10000.txt. code follows : for filename in glob.glob(os.path.join(path, '*.txt')): open(filename) file: tweet=file.read() def processtweet(tweet): tweet = tweet.lower() tweet = re.sub('((www\.[^\s]+)|(https?://[^\s]+))','url',tweet) tweet = re.sub('@[^\s]+','user',tweet) tweet = re.sub('[\s]+', ' ', tweet) tweet = re.sub(r'#([^\s]+)', r'\1', tweet) tweet = tweet.translate(none, string.punctuation) tweet = tweet.strip('\'"') return tweet fp = open(filename) line = fp.readline() count = 0 processedtweet = processtweet(line) line = fp.readline() count += 1 name = str(count) + &

c++ - Are static variables inlined by default inside templates in C++17? -

are static variables inlined default inside templates in c++17? here's example: template<typename t> struct someclass { static t test; }; struct someclass2 { static constexpr int test = 9; }; are variables inlined or still need out of line definition odr used? a static constexpr implicitly inline , otherwise need mark inline template<typename t> struct someclass { inline static t test; // inline }; struct someclass2 { static constexpr int test = 9; // inline }; cfr. n4606 [depr.static_constexpr] for compatibility prior c++ international standards, constexpr static data member may redundantly redeclared outside class no initializer. usage deprecated. example: struct { static constexpr int n = 5; // definition (declaration in c++ 2014) }; const int a::n; // redundant declaration (definition in c++ 2014) and [dcl.constexpr] (barry beat me it) a function or static data member declared constexpr specifier implic

How to put in Yandex translation API in an android application? -

how make android application translate english hindi using yandex translator? java api , json file. have got api key , i've no idea codes written include api , make work. helpful if post entire code :d thanks. you can start checking out how make api call translate function. documentation in part show syntax http request allow translate specific piece of text , specify languages want translate , from. in order implement android application, need able send http requests. there many great libraries this. loopj should able job. website tell how add library project/android app.

ubuntu - How to connect to git on a VPS server? -

this real beginner's question, drowning bit in huge sea of tutorials seem missing 1 or 2 vital steps... i have ubuntu vps server ssh access. got ssh access working key pair don't have type password every time connect. i have installed git on vps, , have created empty git repository in empty 'test1' folder using git init --bare my-project.git i have created second folder named 'test2' repository using git init now set 1 of these folders remote local project, can use git push place files on server (instead of using ftp put files on server). i can't seem find proper procedure push new repo. have added remote local project using: git remote add origin ssh://myname@100.00.000.000/test1/my-project.git git remote add origin ssh://myname@100.00.000.000:/test2/ i have tried cloning remote git clone ssh://myname@100.00.000.000/test1/ when pushing or cloning error: 'not valid git repository - make sure valid repository , have access pe

python - Pyspark converting RowMatrix to DataFrame or RDD -

i have square pyspark rowmatrix looks this: >>> row_mat.numrows() 100 >>> row_mat.numcols() 100 >>> row_mat.rows.first() sparsevector(100, {0: 0.0, 1: 0.0018, 2: 0.1562, 3: 0.0342...}) i run pyspark.ml.feature.pca , fit() method takes in dataframe . there way convert rowmatrix dataframe ? or there better way it? use: row_mat.rows.map(lambda x: (x, )).todf()

hibernate - Exception when updating Oracle DB row / entity with a Blob column / attribute -

the exception raises when try update entity bean contains blob column through hibernate merge, , state managed. message text is: ... caused by: java.sql.sqlexception: lob read/write functions called while read/write in progress: getbytes() @ oracle.jdbc.driver.t4cconnection.getbytes(t4cconnection.java:2963) @ oracle.sql.blob.getbytes(blob.java:392) @ oracle.jdbc.driver.oracleblobinputstream.needbytes(oracleblobinputstream.java:166) ... 120 common frames omitted any idea why i'm obtaining error? in advance.

Http, how do you deal with non text response in angular 2? -

i'm trying array buffer http request explicitely said array buffer. didn't manage , doc on subject rather scarce. let headers = new headers({'content-type': "audio/mpeg"}); let options = new requestoptions({responsetype: responsecontenttype.arraybuffer, headers: headers }); this.http.get("http://localhost:4200/piano/a4.mp3") .subscribe((response)=> this.play(response)); but can't manage array buffer out of response. response body in console inintelligible assume must correct format. content type of response indeed "audio/mpeg". edit : here working code future readers play(arrbf) { this.audiocontext.decodeaudiodata(arrbf, (buffer) => { let source = this.audiocontext.createbuffersource(); source.buffer = buffer; source.connect(this.audiocontext.destination); source.start(0); }); } loadsounds(){ let options = new requ

github - Using gitattributes for linguist examples -

are there concrete examples, in order detect wrong languages in github via linguist attributes? source: https://github.com/github/linguist linguist-documentation linguist-language linguist-vendored examples can found in linguist's readme file . want can achieved linguist-language attributes. linguist-language with following attribute, linguist detects .rb files being java files. *.rb linguist-language=java linguist-vendored with following attribute, linguist detects files in special-vendored-path directory (notice trailing mandatory * ) vendored , excludes them statistics. special-vendored-path/* linguist-vendored linguist-documentation without following attribute, linguist detect file docs/formatter.rb documentation , exclude statistics. docs/formatter.rb linguist-documentation=false

What does Spring Data Couchbase use the _class field for? -

i'm guessing type used crud operations. used else besides that? i'm wondering impact there configuring how gets populated. the _class field written allow polymorphic properties in domain model. see sample: class wrapper { object inner; } wrapper wrapper = new wrapper(); wrapper.inner = new foo(); couchbaseoperations.save(wrapper); you see how field inner foo serialized , persisted. on reading side of things have find out type create object of , type information in wrapper not enough states object . that's why spring data object mapping persists additional field (name customizable defaulting _class ) store information able inspect source document, derive type value written field , map document particular type. the spring data couchbase reference documentation doesn't document it, can find information way works in docs mongodb module . i've created a ticket spring data couchbase improve on docs that.

python - Using a dictionary as an answer key for user input -

this meant break out of loop when user enters file extension in dictionary: def ext_input(): ext_dict = {'doc', 'docx', 'pdf', 'rtf', 'txt', 'wps', 'csv'} while true: print('enter file extension (.pdf, .txt, etc..) type "help" list of extensions') fileext = input() if fileext == "help": print(ext_dict) return elif fileext != ext_dict: print('please enter correct file extension (.pdf, .txt, etc..) type "help" list of extensions') else: print("\"%s\" has been selected" % fileext) break still relatively new python, pointers in right direction great first, help_dict not dict , it's set . second: you're comparing string set - of course won't never ever compare equal. testing if set contains element done in operator: if in myset: -

sqlite - django and bank transfer system javascript injection using chrome extension -

for academic course of cryptography , security, have create basic system bank transfers. i decided use django, gives me authentication , database without effort. the task create chrome extension change receiver bank account number send server, user see 1 provided in transfers history. both, server , user, should think correct when have different numbers. my concern how approach this. when database (default sqlite3) created , edited using django (hence python) how fiddle using javascript in chrome extension. my database model: class transfer(models.model): user = models.foreignkey(settings.auth_user_model, editable=false) acc_num_from = models.charfield('from account number', max_length=28) amount = moneyfield('transfer amount', max_digits=12, decimal_places=2, default_currency='pln') acc_num_to = models.charfield('to account number', max_length=28) rec_name = models.charfield('receiver name', max_length=120)

javascript - Rendering SVG into HTML element -

i have svg in var below:- var chatinprogresstext = "<svg id='layer_4' data-name='layer 4' xmlns='http://www.w3.org/2000/svg' viewbox='0 0 30 30'>\n <defs><style>.cls-1{fill:#474747;}.cls-2{fill:#fff;}</style></defs>\n <title>chat-live-icon</title>\n <path class='cls-1' d='m15.08,0c6.76,0,0,5.17,0,11.51,0,17.14,5.42,22,12.65,22.88l11.77,27a1.16,1.16,0,0,0,.43,1,1.14,1.14,0,0,0,.71.24,1.3,1.3,0,0,0,.35,0l.1,0c1.86-.76,4.91-4.15,6.2-5.65,6.35-1.5,10.6-5.91,10.6-11c30.15,5.17,23.39,0,15.08,0z'/><path class='cls-2' d='m19.08,20.85a1.44,1.44,0,0,0-.78.47,37.25,37.25,0,0,1-4.53,4.56l14.4,23a1.48,1.48,0,0,0-.24-1.18,1.5,1.5,0,0,0-1.05-.61c-6.48-.71-11.37-4.87-11.37-9.68,0-5.4,6-9.79,13.35-9.79s13.35,4.39,13.35,9.79c28.43,15.81,24.67,19.56,19.08,20.85z'/><circle class='cls-1' cx='8.14' cy='11.79' r='2'/><circle class=&

spring - 404 on setting an association resource -

my first experiment spring data rest fails. i've taken "getting started" , modified bit create 2 entities have many-to-one relationships. entities book , shelve , many books can share shelve. the shelve entity looks this: package hello; import javax.persistence.entity; import javax.persistence.generatedvalue; import javax.persistence.generationtype; import javax.persistence.id; @entity public class shelve { @id @generatedvalue(strategy = generationtype.auto) private long id; private int length; public int getlength() { return length; } public void setlength(int length) { this.length = length; } } the book refers it: package hello; import javax.persistence.entity; import javax.persistence.generatedvalue; import javax.persistence.generationtype; import javax.persistence.id; import javax.persistence.manytoone; @entity public class book { @id @generatedvalue(strategy = generationtype.auto) priv

laravel - have same base code for multiple TLDs -

for example: abc.com there's registration/login authentication build in codeigniter using rest api somename.bm again there's registration/login authentication build in laravel using same ^ rest api both these domains uses same concept of authentication of user , after login, of pages same (expect data choose display , css). now simple question is , there way can have common code both these websites access same controller , somehow differentiate call , call rest api access data , display accordingly. again, if miss or need further elaboration, feel free contact me here.

java - rs is always true even when table employee is not present in servlet Database -

rs true when table employee not present in servlet database, want create table when table not present in database , select count(*)from information_schema.tables where(table_schema = 'servlet') , (table_name = 'employee')" return when executed preparedstement , result stored in resultset when table not there , when table there both cases public class table { public static void main(string[] args) { connection con=null; preparedstatement pstmt=null; preparedstatement pstmt1=null; preparedstatement pstmt2=null; resultset rs=null; string qry="select count(*)from information_schema.tables where(table_schema = 'servlet') , (table_name = 'employee')"; string qry1="create table servlet.employee (" + " id int(6) not null auto_increment, " + " name varchar(50) not null, " + " department varchar(20) not null, " + " salary decimal(8,2) not null, &qu

jquery - Turbolinks duplicating rich text editor -

Image
i'm using rails 5 turbolinks , summernote simple wysiwyg editor. i'm loading plugin on turbolinks:load, this: $(document).on('turbolinks:load', function() { $('[data-provider="summernote"]').each(function(){ $(this).summernote({ }); }) } but if navigate somewhere else , press button on browser editor gets duplicated i tried jquery document ready, plugin doesn't loaded unless page load first 1 editor. please help. i know there changes turbolinks between rails 4.2 , 5, here take on this. in many cases, can adjust code listen turbolinks:load event, fires once on initial page load , again after every turbolinks visit. https://github.com/turbolinks/turbolinks#running-javascript-when-a-page-loads if above quote right, each time visit page (whether on ready or page:load ) turbolink trigger fire. now 1 misconception turbolinks visiting page destroys javascript elements within page. this false, in fact big issue t

logging - Exception while attempting to add an entry to the access log -

tomcat 7 can't write access log , throws following exception. nov 17, 2016 5:10:37 pm org.apache.catalina.connector.coyoteadapter log warning: exception while attempting add entry access log java.lang.nullpointerexception @ org.apache.catalina.connector.coyoteadapter.log(coyoteadapter.java:555) @ org.apache.coyote.ajp.ajpprocessor.process(ajpprocessor.java:182) @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:611) @ org.apache.tomcat.util.net.jioendpoint$socketprocessor.run(jioendpoint.java:314) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1145) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615) @ org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run(taskthread.java:61) @ java.lang.thread.run(thread.java:745) how fix this? this known issue in tomcat fixed in tomcat 8.0.29. upgrading tomcat

c# - How to return correct error message to User when log in is restricted -

i new asp.net web development , stuck in handling exceptions when log in restricted. question: have owner log in , tenant log in. owner can restrict log in tenant. when log in restricted want show tenant credential correct log in restricted. below have tried till now. controller [httppost] [validateantiforgerytoken] public actionresult loginsubmit(loginmv userdata) { if (userdata != null) { usermv authenticateduser = authenticatetenant(userdata.username, userdata.password); if (authenticateduser == null) { modelstate.addmodelerror("invalid credentials"); } else { //do login } } return view("login", userdata); } user data api private static usermv authenticatetenant(string username, string password) { res response = mdlapi.authenticatetenant(username, password); try{ response.validate(username); }

js beautify - How to determine version numbers of modules of atom plugins -

i'm using atom-beautify plugin atom editor. started ignoring /* beautify preserve:start */ in javascript files. plugin (not atom) should using js beautify default, suspect bug introduced there. i'm not sure. i'd track down, realized don't know how determine module plugin using. there development feature of atom allow me enumerate plugins , dependency versions? apm list -g display atom packages , versions. npm list -g display of node packages along versions , dependencies. as far root of question, have looked relevant setting in atom-beautify package settings? (settings > atom-beautify > settings > javascript)

reactjs - How to use the "__webpack_public_path__" variable in my WebPack configuration? -

i working on web application using react, typescript , webpack. want webpack generate images urls according subdomain know on runtime , not during compile time. i've read on webpacks's documentation: http://webpack.github.io/docs/configuration.html#output-publicpath note: in cases when eventual publicpath of of output files isn’t known @ compile time, can left blank , set dynamically @ runtime in entry point file. if don’t know publicpath while compiling can omit , set webpack_public_path on entry point. webpack_public_path = myruntimepublicpath // rest of application entry but can't working. i've set "webpack_public_path" variable in app entry point. how can use value in webpack config. need use here: "module": { "rules": [ { "test": /.(png|jpg|gif)(\?[\s\s]+)?$/, "loaders": [ url?limit=8192&nam

node.js - Cant update Dynamo Db table , getting ValidationException -

i need update dynamo db table using partition key. got validation exeption. have created table 3 fields. id (partition key) name (sort key) age then have triyed update age field using id.(tryied modify age 30 40) code var aws = require("aws-sdk"); aws.config.update({ region: "us-east-1", }); var params = { tablename: 'test', key: { id: '100' }, updateexpression: 'set #age = :age ', conditionexpression: '#age = :testage', expressionattributenames: { '#age': 'age' }, expressionattributevalues: { ':age': '40', ':testage': '30' } }; var docclient = new aws.dynamodb.documentclient(); docclient.update(params, function (err, data) { if (err) { console.log(err); } else { console.log(data); } }); but got error this. { [validationexception: provided key element not match schema] message: 'the provided key elem

swift3 - if statement to load marker image swift 3 mapbox ios sdk -

i using swift 3. when hit specific string while going through loop of iterated geojson data (jsonobj[i]) need call right image file. able return right pass type , load markers in map correctly. can't seem figure out how app load right color per marker type. i have tried switch statement no luck. have looked @ if statement documentation among many other stack overflow posts , tutorials. var pass : string? var brown = uiimage(named: "brown.png") var purple = uiimage(named: "purple.png") var green = uiimage(named: "green.png") var image : uiimage? the block of code below in loop. each record iterated through loads marker title , subtitle. code reads first marker color "purple" , loads points purple marker instead of selecting based on pass1, pass2 returned. var pass = jsonobj[i]["properties"]["pass"] print("propertiespassstring: ", pass) if pass ==

Gremlin: Unable to add edges to graph using console -

i have created graph using following command , not able find way in add edges it. g = tinkergraph.open().traversal() g.addv('a1').addv('a2').addv('a3').addv('b3'). i have tried few variants of following command add edge. g.v('a2').addedge('pre',v('a1')) no signature of method: org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.defaultgraphtraversal.addedge() applicable argument types: (java.lang.string, org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.defaultgraphtraversal) values: [pre, [graphstep(vertex,[a1])]] you didn't mention version you're using, i'll referring apache tinkerpop 3.2.3. here link documentation add edge step adde() . when created vertices, add vertex step addv() takes vertex label parameter, not id. vertex labels aren't unique, you're better off using id. gremlin> gremlin.version() ==>3.2.3 gremlin> g = tinkergraph.open().traversal() ==>gr

mysql - SQL - Select All rows with Value X when a Row has Value Y -

i trying data row, rows data row. my table this: invoice desc item_code units price amount 1000 phase 45 10 20 200 1000 bolts 16 45 1 45 1000 jerry 10 1 100 100 1001 phase b 19 10 5 50 i want return rows whatever in invoice when desc phase a. i know enough write: select invoice, desc, item_code, units, price, amount tbl desc '%phase a%' this return row containing phase - want every row of phase below: 1000 phase 45 10 20 200 1000 bolts 16 45 1 45 1000 jerry 10 1 100 100 i feel should in in statement, or need append in statement, don't know should go. i feel should in in statement, or need append in statement, don't know should go. here selec

c++ - QT Creator - LNK2019 and LNK1120 errors -

Image
this question has answer here: what undefined reference/unresolved external symbol error , how fix it? 27 answers hello i've downloaded , installed qt creator. had made project , tried compile it. compiling had ended , recieved 2 errors , 1 warning: i've read on forum found should do: build/clean , after build/run qmake helpful of people not me. should solve problem. learn qt :| ps. didn't change in generated code in new project. , compiler 64-bit. installing qt creator not allow compile project. qt creator ide only. have have kit (compiler + qt libraries) installed on computer. if new qt , if trying compile code on pc (windows), should try install qt using online installer available on https://www.qt.io/download-open-source/ .

c# - GIF as icon for my Windows Forms Application -

i'm using visual studio 2015, , i'm trying create simple media player application. wondering, however, if possible use animated gif file icon displays in top left corner of application itself, pointed out in this picture . language using c#. can tell me if possible, and, if so, how go achieving this? edit: okay, there seems confusion i'm asking, perhaps should provide further details...the application designing simple media player designed play .wav files assigned specific buttons. application isn't browser, or that. picture provided cropped down picture [here]. apologize, new programming, , have learned point, learned through great , powerful youtube. ^.^ if guys need further information, let me know, , i'll provide can! again!!! edit 2: oops, did wrong image! i'm sorry! this correct image. apologies! edit 3: wow, that's got confusing...the site changed title of post automatically , didn't catch it. sorry, all... simple answer, n

c - gcc (6.1.0) using 'wrong' instructions in SSE intrinsics -

background : develop computationally intensive tool, written in c/c++, has able run on variety of different x86_64 processors. speed calculations both float , integer, code contains rather lot of sse* intrinsics different paths tailored different cpu sse capabilities. (as cpu flags detected @ start of program , used set booleans, i've assumed branch prediction tailored blocks of code work effectively). for simplicity i've assumed sse2 through sse4.2 need considered. in order access sse4.2 intrinsics fpr 4.2 paths, need use gcc's -msse4.2 option. the problem issue i'm having that, @ least 6.1.0, gcc goes , implements sse2 intrinsic, mm_cvtsi32_si128, sse4.2 instruction, pinsrd. if limit compilation using -msse2, use sse2 instruction, movd, ie. 1 intel "intrinsics guide" says it's supposed use. this annoying on 2 counts. 1) critical problem program crashes illegal instruction when gets run on pre4.2 cpu. don't have control on hw used

vba - My excel macro generates errors inconsistently -

i working on macro automate web browser stuff , there intermittent runtime error 91 "object variable or block variable not set". have been playing around how declare , create browser object nothing working. sub morning_script() dim webbrowser object set webbrowser = new internetexplorermedium webbrowser.visible = true webbrowser.navigate "www.google.com" while webbrowser.busy = true doevents wend webbrowser.document.getelementbyid("lst-ib").value = "test" 'webbrowser.document.getelementbyid("verify").value = worksheets("sheet1").range("b2") 'webbrowser.document.getelementbyid("institution").value = "xxx" 'worksheets("sheet1").range("b1").clear 'worksheets("sheet1").range("b2").clear end sub the url has been changed public website , form entry has been commented out now. if prefer avoid fixed timers, try one: dim objel

How would I get all errors from a form group in angular 2? -

if build form group this: this.passwordform = this._formbuilder.group({ "previous_password": [this.changepassword.previous_password, validators.compose([validators.required])], "new_password": [this.changepassword.new_password, validators.compose([validators.required,passwordvalidator.validate])], }); how errors form group? i've been doing this: <form role="form" [formgroup]="passwordform" novalidate (ngsubmit)="submitchangepassword()"> <input [(ngmodel)]="changepassword.previous_password" formcontrolname="previous_password" name="previous_password" type="password" placeholder="previous password" class="form-control" required> <input formcontrolname="new_password" [(ngmodel)]="changepassword.new_password" name="new_password" type="password" placeholder="new password" class=&qu

python - ISSUES Defining Cron jobs in Procfile (Heroku) using apscheduler for Django project -

hi stackoverflow community, having problem scheduling cron job requires scraping website , storing part of model (movie) in database. problem model seems loaded before procfile executed. how should create cron job runs internally in background , storing scraped information database? here codes: procfile: web: python manage.py runserver 0.0.0.0:$port scheduler: python cinemas/scheduler.py scheduler.py: # more code above cinemas.models import movie apscheduler.schedulers.blocking import blockingscheduler sched = blockingscheduler() @sched.scheduled_job('cron', day_of_week='mon-fri', hour=0, minutes=26) def get_movies_playing_now(): global url_movies_playing_now movie.objects.all().delete() while(url_movies_playing_now): title = [] description = [] #create beatifulsoup object url link s = requests.get(url_movies_playing_now, headers=headers) soup = bs4.beautifulsoup(s.text, "html.parser") movies = soup.find_a

java - app crashes when it starts after defining onClick method of an Actionbar Icon -

i started programming android apps few days ago , have problem when want build app multiple activities: basically want settings activity clicking on icon implemented in actionbar. i set onclick attribute of icon startsettings public void startsettings(view view) { intent intent = new intent(this, settingsactivity.class); startactivity(intent); } in (menu) main.xml file ... but when this, app crashes when want start it. weird thing is, when start method normal button in activity_main.xml file, works fine ... think problem in main.xml file. says in file method startsettings in 'mainactivity' has incorrect signature. , "checks if method specified in onclick xml attribute declared in related activity" don't know means ...:/ here error in console e/androidruntime: fatal exception: main process: com.example.kevs272.testing, pid: 31225 theme: themes:{default=overlay:com.ashok.nougatcm, fontpkg:com.ashok.nougatcm, com

python - DataFrame's elements as numpy arrays -

i'm trying change dataframe's values this: df['tokens'] = tokens tokens 2-d np.array . expected have column, each element 1-d np.array , found out, each element took first element of correspoding 1-d array . there way store arrays in dataframe's elements? is want? in [26]: df = pd.dataframe(np.random.rand(5,2), columns=list('ab')) in [27]: df out[27]: b 0 0.513723 0.886019 1 0.197956 0.172094 2 0.131495 0.476552 3 0.678821 0.106523 4 0.440118 0.802589 in [28]: arr = df.values in [29]: arr out[29]: array([[ 0.51372311, 0.88601887], [ 0.19795635, 0.17209383], [ 0.13149478, 0.47655197], [ 0.67882124, 0.10652332], [ 0.44011802, 0.80258924]]) in [30]: df['c'] = arr.tolist() in [31]: df out[31]: b c 0 0.513723 0.886019 [0.5137231110962795, 0.8860188692834928] 1 0.197956 0.172094 [0.19795634688449892, 0.17209

php - Adding ul class to function output -

i have function. shows that. <div id="sidebar-category"><h2 class="sidebar-title black">konular</h2> <ul> <li class="cat-item cat-item-2"><a href="http://www.domain.com/cats/girisimler/" >girişimler</a> </li> <li class="cat-item cat-item-3"><a href="http://www.domain.com/cats/isletme-yonetimi/" >İşletme yönetimi</a> </li> <li class="cat-item cat-item-4"><a href="http://www.domain.com/cats/proje-yonetimi/" >proje yönetimi</a> </li> <li class="cat-item cat-item-6"><a href="http://www.domain.com/cats/web-dunyasi/" >web dünyası</a> </li> </ul> </div> how can add class in <ul> ? this function : function arphabet_widgets_init() { register_sidebar( array( 'name' => 'home right s

wifi - Service discovery using dns-sd -

i have device configured in station mode. device connected smart phone on hotspot provided smartphone. device needs search service published application on smartphone _abc._tcp. i using command dns-sd -b _abc._tcp no output. please guide me may missing. the application publishes service. verified using bonjour application on android. also please clarify is possible discover services while in station mode. while searching services necessary provide complete service name. if not how can discover services published on smart phone can firewall settings on device affect service discovery? how can achieve same in c++. libraries can in discovering. thanks advance. is possible discover services while in station mode. see station mode while searching services necessary provide complete service name. yes if not how can discover services published on smart phone service discovery meant used discover severice you're looking printer or web

c# - Split a string so that it loses http:// and anything after the '.' -

i need parse url server shows "na30" when i'm doing split cant seem na30. have tried trimming '.' , '/' , think i'm getting array parts wrong. guidance? link https://na30.salesforce.com what i'm working on string thisurl; if (helper.instanceurl.contains(@"://")) { thisurl = helper.instanceurl.split(new[] { "://" }, 2, stringsplitoptions.none)[1]; return thisurl.split('/')[0].split('.')[0]; } return ""; you can find string uri class uri u = new uri("https://na30.salesforce.com"); console.writeline(u.host.split('.')[0]); a worth question read what's difference between uri.host , uri.authority

python - Tilde (~) isn't working in subprocess.Popen() -

when run in ubuntu terminal: sudo dd if=/dev/sda of=~/file bs=8k count=200k; rm -f ~/file it works fine. if run through pythons subprocess.popen() : output, err = subprocess.popen(['sudo', 'dd', 'if=/dev/' + disk, 'of=~/disk_benchmark_file', 'bs=8k', 'count=200k'], stderr=subprocess.pipe).communicate() print err it doesn't work. error is: dd: failed open '~/disk_benchmark_file': no such file or directory if change in popen() call tilde ~ /home/user , works! why that? and more important me: how can make work? don't know user name in production. you need wrap pathnames os.path.expanduser() : >>> import os >>> os.path.expanduser('~/disk_benchmark_file') '/home/dan/disk_benchmark_file' in code occurrence of: ['sudo', 'dd', 'if=/dev/' + disk, 'of=~/disk_benchmark_file', 'bs=8k', 'count=200k'] should rep

unable to understand function's signature of scala APIs -

i struggle @ times understand how call function. please me. i studying lists , writing sample examples of methods. the andthen defined follows def andthen[c](k: (a) ⇒ c): partialfunction[int, c] i understand have pass function literal andthen . created following code works. scala> val l = list (1,2,3,4) l: list[int] = list(1, 2, 3, 4) //x:int works scala> val listandthenexample = l.andthen((x:int) => (x*2)) listandthenexample: partialfunction[int,int] = <function1> //underscore works scala> val listandthenexample = l.andthen(_*2) listandthenexample: partialfunction[int,int] = <function1> as list of integers, has int. c can depending on output of function literal. the above makes sense. later tried applyorelse . signature follows def applyorelse[a1 <: int, b1 >: a](x: a1, default: (a1) ⇒ b1): b1 from above, understand a1 can int or subclass (upperbound) , b1 return type (depending on in default function). if understanding of a1

c++ - Ruby Program : Trailing zeros in the nth Power of a numbers factorial -

i trying port c++ code ruby. running script gives me "execution timed out" error. this ruby code: t = gets.to_i t.times = gets.to_i b = gets.to_i c = 0 j = 5 until j <= j*5 c += a/j end puts c*b end this c++ code: #include<iostream> main() { long t, a, b, = 0, j, c; std::cin >> t; for( ; < t ; i++) { std::cin >> >> b; c = 0; for( j = 5 ; j <= ; j *= 5) c += a/j; std::cout << c * b << '\n'; } } my input is: 2 100 10 5 4 any output is: 240 4 there 2 test-cases: the number of zeroes trailing in (100!)^10 the number of zeroes trailing in (5!)^4 i write calculation in ruby this: a = 100 b = 10 ((1..a).inject(:*)**b).to_s[/0*$/].size #=> 240 where (1..a).inject(:*) calculates a! , **b exponential function, to_s translates number string, [/0*$/] extracts trailing zeros und size counts them...

r - Splitting a string few characters after the delimiter -

i have large data set of names , states need split. after splitting, want create new rows each name , state. data strings in multiple lines this "peter johnson, in chet charles, tx ed walsh, az" "ralph hogan, tx, michael johnson, fl" i need data this attr name state 1 peter johnson in 2 chet charles tx 3 ed walsh az 4 ralph hogan tx 5 michael johnson fl i can't figure out how this, perhaps split somehow few characters after comma? appreciated. if multiple line strings, can create delimiter gsub , split strings using strsplit , create data.frame components of split in output list , , rbind together. d1 <- do.call(rbind, lapply(strsplit(gsub("([a-z]{2})(\\s+|,)", "\\1;", lines), "[,;]"), function(x) { x1 <- trimws(x) data.frame(name = x1[c(true, false)],state = x1[c(false, true)]) }

ICEPDF not converting pdf to image properly -

i using icepdf 4.2.2_3. trying convert pdf image. image created has random formatting of characters. there random spacing between characters doesn't appear in original pdf. using below code convert pdf data in bytearray convert image. bufferedimage image = (bufferedimage) document.getpageimage(pageindex, graphicsrenderinghints.screen, page.boundary_cropbox, rotation, scale); i tried various parameters related scaling none of them worked. can me on this?

LInux 1ms timer priority -

i have built linux kernel preemptrt . need 1 ms timer without jitter. use timer_create(clock_realtime, ...) function. works except ethernet traffic can hold off timer. is there different timer use have higher priority ethernet isr? is there way change ethernet isr lower priority?

String array with repeating characters python -

i'm trying break sentence characters such as: "the boy good", , place in sentence of each letter, each time letter 'o', place stays same both of letters. how can separate 2 same letters? with open("d:\users\hazembazem\desktop\python random\crap\encrypt.txt", "rb") f: file= f.read() print file file= list(file) item in file: a=file.index(item) print (a) the file txt file containing: "the boy good". a meant place of character, it's instead shows me this: 0 1 2 3 4 5 6 3 8 9 10 3 12 5 5 15 string.index(s, sub[, start[, end]]) like find() raise valueerror when substring not found. string.find(s, sub[, start[, end]]) return lowest index in s substring sub found... so, yeah, isn't want. check out with open("filename") f: string = f.read() print range(len(string)) i,c in enumerate(string): print i,c [0, 1, 2, 3, 4, 5,

objective c - What is a strategy for saving completion handlers when using State Restoration on iOS? -

i'm implementing state restoration in app allow app return right after app has been purged os. encoding , decoding necessary variables (such text user has typed in text field) straightforward, however, how save completion handler blocks set on variable? for instance, take apple's uialertcontroller . create uialertaction s, when created have parameter handler fires when tapped. handler: ((uialertaction) -> void)? if apple, , wanted restore uialertcontroller presented, how restore handler? contains unpredictable slew of variables being used in scope, can't imaging can use nscoder 's encodeobject method. is there accepted strategy this? or way whatsoever? yes, know delegation option, blocks being used more , more lately, , above apple using them. ability capture surrounding variable context important , delegation doesn't provide.

c - Prevent call to v/ucomisd before sqrt -

i optimizing code, , coming this #include <math.h> typedef double vector __attribute__((vector_size(16))); double norm_vector(vector u) { vector w = u*u; return sqrt(w[0]+w[1]); } i discovered compiling with gcc -xc -std=gnu11 -o3 -wall -wextra -fno-verbose-asm -march=haswell prior call sqrt vucomisd instruction executed norm_vector: vmulpd xmm0, xmm0, xmm0 vhaddpd xmm1, xmm0, xmm0 vsqrtsd xmm0, xmm0, xmm1 vucomisd xmm0, xmm0 jp .l13 ret .l13: sub rsp, 8 vmovapd xmm0, xmm1 call sqrt add rsp, 8 ret is taking care argument of sqrt non-negative? in case want avoid call (since definition argument positive), how this?