Posts

java - Read/write XML file preserving original attribute order -

i using javax.xml.parsers.documentbuilder parse existing xml file , instance of org.w3c.dom.document . after manipulations on instance, need write file. therefore how can write org.w3c.dom.document object xml file using xmlstreamwriter ? ps: asking this, because think need use xmlstreamwriter in order write xml file without losing attribute orders. attribute orders important because in version tree, because of attribute order changes, don't want see xml file changed. attribute order insignificant per xml recommendation : note order of attribute specifications in start-tag or empty-element tag not significant. therefore, xmlstreamwriter provides no way constrain attribute ordering. in general, xml recommendations consider attribute ordering insignificant, see section on attribute processing in xml normalization recommendation or canonical xml recommendation if application has need attribute ordering.

How can I capture context information when publishing with rebus -

i capture information current user when publishing messages rebus handlers , sagas have transparent , correct access application user information. i'm getting little lost in source code i'm trying set several things: a hook runs when message published , puts current user information header a hook runs in worker when message received , rewrites claimsprincipal.current. a hook runs in worker when processing done , resets claimsprincipal.current. any suggestions appreciated. you can use rebus' events configurer hook messagesent event fired whenever outgoing message sent (i.e. send publish , reply) this: configure.with(...) .(...) .events(e => e.messagesent += automaticallysetusernameifpossible) .(...) and automaticallysetusernameifpossible might this: void automaticallysetusernameifpossible(ibus bus, string destination, object message) { var principal = thread.currentprincipal; if (principal == null) return; var ide...

php - Sort database records by cost but as if the cost was incremented by 1p per day? -

i'm wondering if it's possible add little maths sorting database mysql , php. in short, friend wanting website people pay want service, attention go higher payments, , work down lower ones when has time. the easy way order records amount paid, mean payment of 5p priority on that's been sitting there 20 days, had idea of incrementing amount paid 1p per day. is there way sql statement doesn't involve writing table, or should php array , calculations there? alternatively worth having 2 tables in database, 1 incremented cost, , other keep track of when last updated, avoid having recalculate more once day? i'd try have efficient solution, , while php calculation route seems easiest, i'd have process records @ once , sort them, might quite heavy on server. you can using datediff() : order payment + datediff(curdate(), submitdate) desc

python - How to GroupBy a Dataframe in Pandas and keep Columns -

given dataframe logs uses of books this: name type id book1 ebook 1 book2 paper 2 book3 paper 3 book1 ebook 1 book2 paper 2 i need count of books, keeping other columns , this: name type id count book1 ebook 1 2 book2 paper 2 2 book3 paper 3 1 how can done? thanks! you want following: in [20]: df.groupby(['name','type','id']).count().reset_index() out[20]: name type id count 0 book1 ebook 1 2 1 book2 paper 2 2 2 book3 paper 3 1 in case 'name', 'type' , 'id' cols match in values can groupby on these, call count , reset_index . an alternative approach add 'count' column using transform , call drop_duplicates : in [25]: df['count'] = df.groupby(['name'])['id'].transform('count') df.drop_duplicates() out[25]: name type id count 0 book1 ebook 1 2 1 book2 paper 2 2 2 boo...

android - Volley postparams array -

i've got 1 object containing 2 arrays of integer , want past object in params of post request. { "arrayofinteger1": [ 1, 2 ], "arrayofinteger2": [ 1, 2 ] } i'm struggling method "getparams" hours now, me please? getparams wont work in case because expects map<string,string> output can create json representation of above object , pass jsonobjectrequest(request.method.post, string url, jsonobject yourrequestobject,listener<jsonobject> listener, errorlistener errorlistener) or jsonarrayrequest similar parameters depending upon response expect

java - Song Class, Using abstract class and interface -

what i'am trying program output information of song using tostring on song class. when output it, fine except songtype/genre. still outputting undetermined. abstract class song implements isong //song class { private string name; private string rating; private int id; private songtype genre; public song() { name = " "; rating = " "; id = 0; genre = songtype.undetermined; } public song(string name, string rating, int id) { this.name = name; this.rating = rating; this.id = id; this.genre =song.undetermined; } public void setname(string name) { this.name = name; } public void setrating(string rating) { this.rating = rating; } public void setid(int id) { this.id = id; } public string getname() { return(this.name); } public string getrating() { return(this.rating); } public int getid() { return(this.id); } @override public string tostring() { return("song: " + this.name + ...

wpf - EntityWrapper Confusion -

wpf entity framework 6.0 database first, entities generated tt file. i'm having problems entitywrapper , , can't find useful information it. i have entities, when generated looks this: //generated code public partial class scm_supplierdepot : ipartsentity, inotifypropertychanged { [...] public virtual dms_address dms_address { get; set; } } public partial class dms_address : ipartsentity, inotifypropertychanged { //shortened brevity public system.guid addressid { get; set; } public string streetnumber { get; set; } public string streetname { get; set; } public string apartmentnumber { get; set; } public string city { get; set; } public string stateprovince { get; set; } public string postalcode { get; set; } public string housename { get; set; } public string country { get; set; } public string address2 { get; set; } public string county { get; set; } //inotifypropertychanged [..] } i...