Posts

Showing posts from March, 2014

java - Which code performs better in terms of Time-complexity? -

below 2 java codes find number of 1 bits in integer n. code 1: int count = 0; while (n != 0) { n = n & (n - 1); count++; } return count; code 2: int = n; = - ((i >>> 1) & 0x55555555); = (i & 0x33333333) + ((i >>> 2) & 0x33333333); = (i + (i >>> 4)) & 0x0f0f0f0f; = + (i >>> 8); = + (i >>> 16); return & 0x3f; as far understand, first approach has complexity of o(n), while second 1 o(1). second 1 supposed better. however not sure it. you have take care when talking time complexity. big-o provides measure of asymptotic runtimes, means need measure runtimes arbitrarily large n. programming languages not provide (by default) int types arbitrarily large fudge issue bit , pretend do. the first code snippet works if pretend int can large possible. runs 1 loop per 1 in binary representation of n , in worst case takes log_2(n) iterations. it's o(log n). the second code snippet doesn&

laravel 5 - CLI stopped working error -

i "cli stopped working" error when press upload button.i used sample code 1 of website upload file database column. use laravel 5.2.39. command used: php artisan serve code:(only test version) form.blade.php <form method="post" enctype="multipart/form-data" action="/upload_file"> {{ csrf_field() }} <input type="file" name="file" /> <input type="submit" name="submit" value="upload" /> </form> routes.php (not ideal place code file upload test purpose) route::get('/upload_form', function() { $data['files'] = attachment::get(); return view::make('form', $data); }); route::post('/upload_file', function() { $rules = array( 'file' => 'required|mimes:doc,docx,pdf', ); $validator = validator::make(request::all(), $rules); if(request::hasfile('file

computation theory - A language that is RE complete with respect to polynomial-time reductions? -

is there language in re complete regard polynomial-time reductions? i think a_tm example,but i'm not sure... yes, a tm re -complete respect polynomial-time reductions. given re language l, let m recognizer it. function f(w) = can computed in polynomial time (for reasonable representation of tuples) because m fixed machine , length of w in encoded version should @ polynomially larger original input w. have w &in; l if , if m accepts w if , if &in; a tm , f polynomial-time reduction arbitrary re language l a tm , making a tm re -complete respect polynomial-time reductions. i'm not sure why you'd interested in particular notion of re -completeness, since re useful notions of computability (can solve problem @ all?) while polynomial-time reductions complexity (can solve problem efficiently?) if have interesting use case them, though, i'd love hear it!

python - How to pick key words from a list, after appending a .csv file to that list? -

i need able pick keywords excel csv file, i've appended file list. program phone troubleshoot, , need input ("the screen won't turn on") have same output if inputted ("the display blank"). "troubleshooting program give user solution trouble they've encountered based on inputted key words." phoneprob=input("what problem having phone? ") prob=open("phone.csv","r") phone=prob.read() prob.close() eachprob=phone.split("\n") print(eachprob) problist=[eachprob] print (problist) are trying build keyword dictionary or retriving sentence problem ? in both case, need associate problem keywords. a basic approch keywords split sentence in words (using s.split()) , update keyword list used of them... difflib can here. since don't know given file schema, assume it's list of sentence , provided keyword/problems elsewhere (situation dict). for example: csv_ret = ["i can't tu

java - How to manage Repository and UnitOfWork on top of JDBC -

i'm wondering best way of implementing unitofwork pattern on top of jdbc when using repository pattern. i want use uow commit or rollback commands potentially multiple different repositories. came repositories connection going execute commands on uow object , let manage committing or rolling back. now question how shall uow manage connections? shall 1 connection on start of cycle , share repositories when call connection , @ end either commit or roll back. or shall let datasource manage connections, , keep reference connections obtained in 1 session in order able commit or rollback of them? which way use best out of connection pooling , have less trouble in managing connections? maybe worth noting use single threaded approach, meaning whole cycle (single uow) run on single thread , there no fancy multithreading management required neither in uow nor in repositories. multiple cycles may run in parallel each on own thread.

java - Random User Id in MobileFirst 7.1 Test Token Endpoint -

i trying implement integration tests mobile first adapters. adapters use user identity custom realm. when writing tests adapters, need know user id, can prepare data in database , prepare mocked services. the problem test token endpoint generates random user id. , seems there no way configure provide same user id each request. there solution ? given there no way change in mobilefirst platform foundation 7.1, ore mentioned in comments, perhaps should return same mock data irregardless of user identity.

vb.net - Troubles to connect to Siemens S7 probably cause of bad protocol used -

i encounter many troubles connect plc, that, use libnodave library. here last informlations got : cpu 412-2 communication : cp 443-1 so far, manage connect automaton, but, if use - usertransport protocol, programs crashes when try read datum - isotpc or mpi protocols, can't connect plc ... so far, code isn't different 1 : http://www.automation-sense.com/medias/images/source-code-and-example-visual-basic-libnodave.jpg in case, port number 25, rack value 0 , slot value 3. what may suggest me do? thanks

jquery - How to execute specific JavaScript to enable specific panel after postback -

i find out there way execute specific javascript trigger visibility of specific block after post back? this link button suppose job <asp:linkbutton id="lbtview" runat="server" cssclass="btn btn-xs btn-default" commandargument='<%# eval("orderid.orderid") %>' commandname='<%# "details" %>'><i class="fa fa-eye"></i></asp:linkbutton> <%--order datails--%> this script want execute after postback, toggle visibility of specific block response.write("$('').hide(); $('#orderdetails').show()"); section of current code <asp:listview id="listview1" runat="server" onitemcommand="listview1_itemcommand"> <itemtemplate> <tr> <td><asp:label id="lblorderno" runat="

javascript - Can I use a script alias existing in another node module's package.json? -

i've created node module produces json file data multiple apis. it's designed able save json file whatever directory you're within in cmd/terminal . i'm able run project, i've developed independently main project it's used within. has been installed in main project can run it's package.json exists because that's script alias resides. there other node modules need use json file, once navigate other modules' root directories in cmd/terminal node wants use module's package.json , can't find script alias since doesn't exist there. adding script alias every module isn't viable solution since project prototype , being added upon. is there way relevant package.json referenced , used script alias regardless of i'm running within main project? am going solving problem wrong? appreciated. first question if i've done wrong asking this, please let me know can improve. in advance. a little bit late answer none

javascript - Multiple views, multiple resolve but for one controller in AngularJS -

i have 2 views share same controller. in each 1 of view used resolve retrieve date before displaying it. inject in controller (so inject 2 dependancy each view). but problem when go view another, console display error because doesn't see dependancy other view. route configuration .state('ambassade', { url: '/mot_ambassadeur', views: { "@": { templateurl: "pages/gestionambassade/mot_ambassadeur.html", controller: "gestionambassadecontroller", resolve: { informationsambassade: function(gestionambassadeservice) { return gestionambassadeservice.getmotambassadeurservice(); } } } } }) .state('personnel', {

operating system - What does BIOS do after loading Global/Interrupt Descriptor Table Register in JOS? -

i have analyzed first codes when bios starts executing until loading global/interrupt descriptor table register. bios i'm talking 1 mits course "operating systems engineering". have difficulities understanding how bios after that. [f000:fff0] 0xffff0: ljmp $0xf000,$0xe05b #when bios starts executing, jump address fe05bh continue execute [f000:e05b] 0xfe05b: cmpl $0x0,%cs:0x6574 [f000:e062] 0xfe062: jne 0xfd2b6 [f000:e066] 0xfe066: xor %ax,%ax [f000:e068] 0xfe068: mov %ax,%ss #set %ss 0 [f000:e06a] 0xfe06a: mov $0x7000,%esp [f000:e070] 0xfe070: mov $0xf3c24,%edx [f000:e076] 0xfe076: jmp 0xfd124 [f000:d124] 0xfd124: mov %eax,%ecx [f000:d127] 0xfd127: cli #turn off interrupt [f000:d128] 0xfd128: cld # set df flag 0, when df=0, si = si + 1 , di = di + 1 [f000:d129] 0xfd129: mov $0x8f,%eax [f000:d12f] 0xfd12f: out %al,$0x70 [f000:d131] 0xfd131: in $0x71,%al #close nmi through 70h i/o port, sel

Powershell script to fetch task name from notepad and find the status of it in windows task scheduler -

i need powershell script tasks listed out in text file needs read , status of tasks needs fetched windows task scheduler , output in csv file. i able read contents using get-content cmdlet.but get-scheduledtask throwing error not recognized valid cmdlet. kindly me new powershell. get-scheduledtask tasks | get-scheduledtaskinfo | select-object taskname, lasttaskresult | export-csv -notypeinformation -path d:\first\one.csv i have txt file named tasks contain list of tasks iterated , listed out csv file this 1 works me: $tasks = get-content -path "c:\users\administrator\desktop\tasks.txt" get-scheduledtask -taskname $tasks | get-scheduledtaskinfo | select-object taskname, lasttaskresult | export-csv c:\users\administrator\desktop\tasks.csv -notypeinformation txt file in following format: task 1 task 2 task 3 i've tried in ps 4 on windows 8.1, don't have cmdlet in previous versions of windows (like windows 7 / windows server 2008 r2). for

foreign keys - Mysql several columns for polymorphic relationship - feasible? -

i have several 'modules'(at moment , 4) , each of has own table. i want implement tag system these modules. tags have many many relationship between each module respectively. to implement polymorphic relationship, thought of creating pivot table this: tag_name|module_1_id | module_2_id| module_3_id |module_4_id... on. any row of tag_module pivot table have valid fk 1 module_id , rest set null. my question is, extremely hazardous way go implementation ? there ways far better want ? how can ensure uniqueness of tag_name module_n_id , meaning particular item particular module should have specific tag assigned once ? also, on time, number of modules increase , in future , possible number of columns 10,20 50. kind of implementation prevent kind of growth? just create table module id , tag name fields , create multi-column unique index on these 2 columns (you can add other field table). multi column unique index allow associate same tag name multiple module

File not working in Lua -

i doing small program school in lua, need help. open file, when write, nothing appears in .txt file. can help? snippet of code trying fix: file=io.open('var.txt',"w+") io.output(file) io.write('hi!') edit: tried file:close() , io.flush() , haven't managed make work. try following: io.output('var.txt') io.write('hi!') io.close() the function io.output allows specify current file output filename . in example, passing file handler created io.open instead of filename . implicitly creates bad file handler io.write cannot use. for more info, check out chapter on "the simple i/o model" "programming in lua" .

spring - Storing base java project inside child project jar (maven, docker) -

thanks having @ this! max in future i'm going building lots of microservices based upon same parent java project. these microservices going using spring cloud , docker. have base java project , child project. main each microservices should inherited parent project. till i've been using mvn clean package assembly:single for building jar microservice parent store inside jar. run java -cp microservice.jar path.to.parent.main which working fine. i'm sure it's not best way go , i'd love advice improvements. my problem want use docker:build mvn clean package docker:build after packaging microservice using docker:build, how specify path parent project's main since parent project no longer being stored in jar made docker:build . microservice (child) <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.

git - Eclipse not able to pull or fetch a replaced tag from remote -

another developer forced replace existing tag on remote master branch. in eclipse (luna in case), not updated tag, no matter team | pull or team | fetch upstream. the solution found in eclipse (luna in case) is: right click project in project explorer go team | remote | configure fetch upstream... in configure fetch window, click button advanced... in annotated tags fetching strategy, change option "automatically follow tags if fetch thing point at" option "always fetch tags, if not have thing points at" click button finish. that's it. can fetch new updated tag.

sql - Query returns no records -

Image
hello making schema purchasing orders these orders can ordered user , received user. so created below schema. schema the issue when userid column in purchaseorders , deliveries tables has different values query returns no records. query select dbo.users.firstname, dbo.users.lastname, dbo.purchaseorders.purchaseorderdate, dbo.deliveries.expecteddeliverydate, dbo.deliveries.actualdeliverydate dbo.purchaseorders inner join dbo.users on dbo.purchaseorders.userid = dbo.users.userid inner join dbo.deliveries on dbo.purchaseorders.purchaseorderid = dbo.deliveries.purchaseorderid , dbo.users.userid = dbo.purchaseorders.userid , dbo.users.userid = dbo.deliveries.userid you need 2 different joins users . need learn use table aliases: select pu.firstname purchase_firstname, pu.lastname purchase_lastname, du.firstname delivery_firstname, du.lastname delivery_lastname, po.purchaseorderdate, d.expecteddeliverydate, d.actualdeliver

test for internet connection in android login -

i want check internet connection. tried using code doesn't work. didn't got message (aucune connexion internet) private boolean isconnectingtointernet(context applicationcontext){ connectivitymanager cm = (connectivitymanager) getsystemservice(context.connectivity_service); networkinfo ni = cm.getactivenetworkinfo(); if (ni == null) { // there no active networks. toast.maketext(getapplicationcontext(), "no internet", toast.length_long).show(); return false; } else return true; } and protected void onpostexecute(string s) { super.onpostexecute(s); loading.dismiss(); if(isconnectingtointernet(getapplicationcontext())) { showemployee(s); }else{ // show alert toast.maketext(mainactivity.this, "aucune connexion internet", toast.length_short).show();

r - Looping arithmetic calculation between tables -

i have table this: table1 not visible visible <na> 0.29 0.50 0.20 bowtie 0.24 0.17 0.59 cola 0.15 0.83 0.02 squig 0.49 0.51 0.49 i have 9 other similar tables. below example: table2 not visible visible <na> 0.28 0.50 0.23 bowtie 0.11 0.30 0.59 cola 0.30 0.67 0.03 squig 0.42 0.51 0.06 i want result of table1 - table2 below want table 1 each of other 9 tables. not visible visible <na> 0.01 0.00 -0.03 bowtie 0.13 -0.13 0.00 cola -0.15 0.16 -0.01 squig 0.07 0.00 0.43 how do without writing table 1 - table 2; table 1 - table 3; table 1 - table 4 etc? if try looping code below (as example), non-numeric argument binary error: tables <- c("table1", "table2") ## example (r in tables) { yy <- paste(r,"res", sep = "-

sql - MySQL 5.6: Complex Query with Grouped Parameters -

i'm far mysql expert, , i'm struggling relatively complicated query. i have 2 tables: a data table columns follows: `location` bigint(20) unsigned not null, `source` bigint(20) unsigned not null, `param` bigint(20) unsigned not null, `type` bigint(20) unsigned not null, `inittime` datetime not null default '0000-00-00 00:00:00', `validtime` datetime not null default '0000-00-00 00:00:00', `value` double default null a location group table columns follows: `group` bigint(20) unsigned not null, `location` bigint(20) unsigned not null, the data table stores data of interest, each 'value' valid particular 'validtime'. however, data in table comes calculation run periodically. initialisation time @ calculation run stored in 'inittime' field. given calculation particular inittime may result in, 10 values being output valid times (a - j). more recent calculation, more recent inittime, may result in 10 values being output valid ti

Customize spring boot validation message from database -

i using spring validation validate rest controller input, appreciate if 1 can tell me there possibility of throwing custom message in case of exception , custom message should come database rather properties file. you can achieve setting custom validation message source on spring's localvalidatorfactorybean . your message source needs implement messagesource interface , read messages database. reference: http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/validation/beanvalidation/localvalidatorfactorybean.html#setvalidationmessagesource-org.springframework.context.messagesource- http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/context/messagesource.html

javascript - Why blurry the SVG elements in Chrome using Panzoom? -

i using timmywil's panzoom ( https://github.com/timmywil/jquery.panzoom ) on svg elements, google geochart , month ago have noticed when zoom in; svg blurry. example, see demos: https://timmywil.github.io/jquery.panzoom/demo/ in firefox, ie, maxthon works well. using newest version of browsers. anybody knows what's wrong or how solve this? solved!: put "-webkit-backface-visibility: initial !important;" on svg elements style. it looks chrome automatically rasterizng svg. chrome have lots of 'hidden' features speed rendering time etc of many can tweak example below. type chrome://flags in address bar , press enter. enable gpu rasterization gpu rasterization msaa sample count number of raster threads lcd text antialiasing - enabled you can check varous flags here i've found this page particular useful:

java - NoSuchMethodError: javax.persistence.JoinColumn.ForeignKey -

this question has answer here: nosuchmethoderror: javax.persistence.joincolumn.foreignkey() 2 answers how fix nosuchmethoderror? 18 answers when i'm trying run test (in fact it's empty , i'm using control building of test :)) i'm getting error: caused by: java.lang.nosuchmethoderror: javax.persistence.joincolumn.foreignkey()ljavax/persistence/foreignkey; @ org.hibernate.cfg.annotationbinder.bindmanytoone(annotationbinder.java:2898) @ org.hibernate.cfg.annotationbinder.processelementannotations(annotationbinder.java:1742) @ org.hibernate.cfg.annotationbinder.processidpropertiesifnotalready(annotationbinder.java:906) @ org.hibernate.cfg.annotationbinder.bindclass(annotationbinder.java:733) @ org.hibernate.boot.model.source.internal.annotations.annotationmetadata

javascript - Unable to change more than one phong material for an object on key press -

thanks stack overflow community helping ammature coders me, here i'm trying switch phong materials .obj loaded model on keypress, reason taking first element in material array on key press. have made sure looping proper. here demo , please let me know if there anyway resolve code <html> <head> <style> body { background-color: #fff; margin: 0px; overflow: hidden; } </style> </head> <body> <script src="three.js"></script> <script src="ddsloader.js"></script> <script src="mtlloader.js"></script> <script src="objloader.js"></script> <script src="ddsloader.js"></script> <script type="text/javascript" src="orbitcontrols.js"></script> <script> // three.js info box follows shape var renderer, s

ios - Animate segue and display keyboard together smoothly -

i have view controller accepts text input using uitextview called "mytextview". when segue mytextview, use following: self.performseguewithidentifier("mytextview", sender: self) mytextview presented. next keyboard displayed after viewdidappear : override func viewdidappear(animated: bool) { self.mytyping.becomefirstresponder() } everything animates smoothly. want keyboard display @ same time segue animating , being displayed , not 1 after other. i can call keyboard segue call. however, animation jittery , choppy, , not smooth. how can both segue mytextview view controller , display keyboard @ same time without animation jitters?

excel vba - find function with two criteria in vba -

i want search data 2 conditions. eg: column "a" should match str (string) , column "j" should contain "completed" below coding, able put 1 condition. please advise me changes required add second condition. set rng = .find(what:=str,after:=.cells(.cells.count),lookin:=xlvalues, _ lookat:=xlwhole, searchorder:=xlbyrows, _ searchdirection:=xlprevious, _ matchcase:=false)

javascript - Prevent a user from exiting from firefox using js -

how can prevent user exit firefox? want user woldn`t leave page before required fields filled. happy see full example... thanks you can't stop closing browser, or navigating away page, if that's want do. it's their browser - can't force them anything. that said, can pop message hooking onbeforeunload event , returning string if there still actions want them perform. browsers display string in dialog asking whether want navigate away (or close browser etc), the firefox devs have taken stance that security risk , present generic message instead. in place, user can still choose close browser or navigate away.

polymer retrieving data from sub elements -

i have following dom repeat, takes array of survey question , displays them. <template is="dom-repeat" items="{{survey.questions}}"> <template is="dom-if" restamp if="{{isformat(item.type, 'single-select')}}"> <question-singleselect question="{{item}}" auth-data="{{authdata}}"></question-singleselect> </template> <template is="dom-if" restamp if="{{isformat(item.type,'open-ended')}}"> <question-openended question="{{item}}" auth-data="{{authdata}}"></question-openended> </template> and in code further down, want take answers, , create header record, , detail/answer records... header, can save no problem, detail records, trying following. for(question in survey.questions) { ... } getting error message, 'survey cannot found'. how can gain access array of questions displaying on pag

jquery - Static S3 site using AngularJS and database (simple online store) -

this more question of possibility, more nitty-gritty of how. i'd build pseudo dynamic website can host entirely on static server (assume aws s3), possible achieve below on static machine? cost associated full nginx/apache server these small apps, hence looking option. simple database of items, cost (can updatable json/third-party db) list above items on simgle page add items cart push items payment system (paypal/stripe work) callback payment system mark item sold basically singe-layer online store, no storage of user details. simply, see something, buy it, mark sold. you could think biggest problem without having secure executable server code you'd unable secure database passwords or auth tokens paypal/stripe. so, able have direct unequivocal access database. make app extremely liable attack. example, go site, @ javascript code credentials database, , log in , drop tables. suddenly, gone. additionally, access paypal/stripe refund or transfer dollars o

java - How to represent a 5 letter string as digit? -

i want create numerical representation of 5 letter codes. codes may have 1-5 letters or digits. the number must of course unique . not absolutely necessairy numbers can converted ascii. thus need digits 0 zzzzz the resulting number size should small possible. i started following, it's not quite want: string a="zzzzzz"; (int = 0; < a.length(); ++i) { system.out.print(a.charat(i)-'a'+1); } zzzzzz=262626262626 000000=-16-16-16-16-16-16 start enumerating possible "digits" of number: ten decimal digits 0 through 9 twenty 6 letters a through z you have 36 possible "digits" 5 positions, max number 36 5 =60,466,176. number fits in int . you can make number calling integer.parseint , , passing radix of 36: system.out.println(integer.parseint("abzxy", 36)); // 17355958 demo.

Zoom into Clusters (with Bing Maps) does not refresh clusters -

i followed bing maps docs zoom clusters . since microsoft embeds screenshot, here's working example . when click on cluster, notice cluster not updated. pan map little bit, , map clusters refreshed. so either bing maps documentation broken or bing maps bug. any idea workaround, e.g. how force map refresh after map has zoomed in? the relevant code (which not update map/clusters) this, last line: function clusterclicked(e) { if (e.target.containedpushpins) { var locs = []; (var = 0, len = e.target.containedpushpins.length; < len; i++) { //get location of each pushpin. locs.push(e.target.containedpushpins[i].getlocation()); } //create bounding box pushpins. var bounds = microsoft.maps.locationrect.fromlocations(locs); //zoom bounding box of cluster. //add padding compensate pixel area of pushpins. map.setview({ bounds: bounds, padding: 100 }); } this known issue h

sql - Oracle - How to bulk insert values in one query with an array of values to insert -

i have these tables: a { id, name } b { id, name, aid } aid foreign key table a so have list of strings need inserted table b. list: names['name1', 'name2'] also have select statement fetches me list of a.id's. list: id's[1, 2] the problem table b needs have rows inserted every a.id queried , @ same time string list should taken consideration. end result id's (1, 2) instance, 4 rows created (2 each id because every id needs insert string in list): insert b (id, name, aid) values (b_id_seq.nextval, name1, 1) insert b (id, name, aid) values (b_id_seq.nextval, name2, 1) insert b (id, name, aid) values (b_id_seq.nextval, name1, 2) insert b (id, name, aid) values (b_id_seq.nextval, name2, 2) what have gotten work write select statement returns array of id's. tried implement select these 2 lists without luck. first attempt use in clause inside of specific column value part , second attempt use insert all. not figure out how genera

mysql - Symfony2 not reading form parameter.yml file on production -

good monday! have working symfony2 proyect, developed in computer (macos) , formerly deployed in heroku, when deployed in centos apache vhost. website works database connection not working. parameters.yml file: # file auto-generated during composer install parameters: database_host: 127.0.0.1 database_port: null database_name: dbname database_user: dbuser database_password: 8xffdsafdsck my config.yml file: # doctrine configuration doctrine: dbal: driver: pdo_mysql host: "%database_host%" port: "%database_port%" dbname: "%database_name%" user: "%database_user%" password: "%database_password%" charset: utf8 server_version: 5.6 # if using pdo_sqlite database driver: # 1. add path in parameters.yml # e.g. database_path: "%kernel.root_dir%/data/data.db3" # 2. uncomment database_p

reactjs - redux-form-material-ui using getRenderedComponent() throws always an error -

i'm basing on official example redux-form-material-ui repo. code looks that: import react 'react'; import { field } 'redux-form'; import { textfield } 'redux-form-material-ui'; export default class formtextfield extends react.component { constructor(props) { super(props); } componentwillupdate(nextprops) { const { name, withref, focus } = nextprops; if (withref && focus) { this.refs[name] .getrenderedcomponent() .getrenderedcomponent() .focus(); } } render() { const { name, label, errortext, withref } = this.props; return ( <field name={name} component={textfield} hinttext={label} floatinglabeltext={label} errortext={errortext} ref={name} withref={withref} /> ); } } i'm passing focus , withref properties first field error. on field error: uncaught (in promise) error: if want access getren

python - parsing CSV to pandas dataframes (one-to-many unmunge) -

i have csv file imported pandas dataframe. came database export combined one-to-many parent , detail table. format of csv file follows: header1, header2, header3, header4, header5, header6 sample1, property1,,,average1,average2 ,,detail1,detail2,, ,,detail1,detail2,, ,,detail1,detail2,, sample2, ... ,,detail1,detail2,, ,,detail1,detail2,, ... (i.e. line 0 header , line 1 record 1 , lines 2 through n details, line n+1 record 2 , on...) what best way extricate (renormalize?) details separate dataframes can referenced using values in sample# records? number of each subset of details different each sample. i can use: samplelist = df.header2[pd.notnull(df.header2)] to starting index of each sample can grab samplelist.index[0] samplelist.index[1] , put in smaller dataframe. detail records have no reference sample came from, has inferred order of csv file (notice there no intersection of filled/empty fields in example). should make list of dataframes, dict of datafra

Cartopy-Python syntax - multiple objects/countries in one line -

i'm following example, python mapping in matplotlib cartopy color 1 country . it's working several countries, e.g. usa, france, uk, japan. for country in countries: if country.attributes['adm0_a3'] == 'usa': ax.add_geometries(country.geometry, ccrs.platecarree(), facecolor='#008744', alpha = 0.5, label=country.attributes['adm0_a3']), if country.attributes['adm0_a3'] == 'fra': ax.add_geometries(country.geometry, ccrs.platecarree(), facecolor='#008744', alpha = 0.5, label=country.attributes['adm0_a3']), + 'gbr' + 'jpn' else: ax.add_geometries(country.geometry, ccrs.platecarree(), facecolor=('#c4e6ff'), label=country.attributes['adm0_a3']) i'd put list of countries in 1 line rather repeating statemen

linux - install mysql 5.7 purely from bash script on Ubuntu -

Image
i want bash script installs mysql 5.7 instance without needing manual input. i following tutorial on digital ocean , says 5.7 have run following commands , put commands prompt (screenshot below). wget http://dev.mysql.com/get/mysql-apt-config_0.6.0-1_all.deb sudo dpkg -i mysql-apt-config_0.6.0-1_all.deb how can automate installation if requires me use prompt? should try simulate keystrokes? or going wrong way? this answer combination , alteration of bimmy's , khrm's answers. step 1: you have set debconf values automatically fill in values prompted installation. export debian_frontend="noninteractive" sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password rootpw" sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password rootpw" to values need, run installation normally, tutorial of here step 2: update information needed apt adding 5.7 repos