Posts

javascript - Convert MongoDB query result into JSONArray -

i have mongodb query via mongoose , result is: [ { "tablename": "name1" }, { "tablename": "name2" } ] but need jsonarray : { "tablename": [ "name1", "name2" ] } is there easy way convert? the aggregation framework can create desired result you. consider $group , $push accumulator operators follows: db.collection.aggregate([ { "$group": { "_id": null, "tablename": { "$push": "$tablename" } } }, { "$project": { "_id": 0, "tablename": 1 } } ]) sample output: /* 0 */ { "result" : [ { "tablename" : [ "name1", "name2" ] } ], "ok...

I am trying to debug my PowerShell but I cannot get anything to output -

i have script here: write-host "checking files" #to make more dynamical can save on 1 file #all file names including extension in different lines. #for example on path c:\filestowatch\watcher.txt #$filestowatch=get-content c:\filestowatch\watcher.txt #$filestowatch="felicio.txt","marcos.txt" $userfiles=dir c:\g\user\less\ $adminfiles=dir c:\g\admin\less\ #optionally instead of use if approach can #$adminfiles=dir c:\gt\admin\src\admin\wwwroot\content\less|? {$filestowatch -contains $_.name} #$userfiles=dir c:\gt\user-staging\src\user-staging\wwwroot\content\less|? {$filestowatch -contains $_.name} #loading in above manner first if statement on code bellow can removed because #we make sure $userfiles , $adminfiles have correct file monitor foreach($userfile in $userfiles) { if($filestowatch -contains $userfile.name) { $exactadminfile= $adminfiles | ? {$_.name -eq $userfile.name} |select -first 1 #my suggestion validate if g...

java - Having main method in an abstract class -

i know it's legal have main method in abstract class, because eclipse allows me following , run class java application. make sense this? is there real world scenario 1 need have main method in abstract class? public abstract class automobile { public boolean poweron() { // generic implementation powering on automobile return true; } public void move() { // generic implementation move } public void changedirection(string newdir) { // generic implementation changing direction } public abstract void accelerate(integer changeinspeed); public abstract integer refuel(integer inputfuel); public static void main(string[] args) { system.out.println("i main method inside abstract automobile class"); } } no, not really. trying create class hierarchy different classes share same main method doesn't seem useful. see example: public abstract class { public s...

CSS - Best practice for larger margin between all elements but smaller between same elements -

let's want have 2em vertical distance between elements (p, blockquote, dl, form, ol, ul, pre, table, etc) on page. so throw margin-bottom:2em; on necessary elements. great. then see several p tags, come right after each other, far apart, , i'd them have 1.5em, while keeping 2em between other elements. what's elegant way it, while sticking we're-going-to-govern-margins-by-only-using-the-bottom-margin concept? the selector p+p apply bottom margin in p "list" except first one. note put 1.5 margin on last p , should not have small margin, larger 2em bottom margin. i tried :last-child selector, putting small margin value on bottom of p tags first, using p:last-child set last paragraph larger 2em bottom margin. sounded great, didn't make change last p in grouping. note switch governing margin top margin, in case p+p elegant control spacing between p tags. however, have spacing @ top (of other elements h1, etc) , have over...

xslt - How to display appropriate language labels for items that have non-english version -

i have item uri http://hdl.handle.net/10862/717 in our local language has english version: http://hdl.handle.net/10862/152 . <dim:field element="relation" qualifier="hasversion" language="en" mdschema="dc">http://hdl.handle.net/10862/152</dim:field> my xsl template below: <xsl:template name="itemsummaryview-dim-hasversion"> <xsl:if test="dim:field[@element='relation' , @qualifier='hasversion' , descendant::text()]"> <div class="simple-item-view-uri item-page-field-wrapper table"> <h5><i18n:text>xmlui.dri2xhtml.mets-1.0.item-hasversion</i18n:text></h5> <span> <xsl:for-each select="dim:field[@element='relation' , @qualifier='hasversion']"> <a> <xsl:attribute name="href"> ...

jquery - Hide Asp:DropDownList based on select dropdownlist values? -

i'm trying hide 2 dropdownlists based on value "select" dropdownlist. ddlists want hide asp:dropdownlists. select class looks this: <select class="form-control" id="number_rooms"> <option>1</option> <option>2</option> </select> when value 1, dropdownlists should hidden. when value 2, users should see them. code: <asp:dropdownlist id="droplist1" cssclass="form-control" runat="server"> <asp:listitem>2</asp:listitem> <asp:listitem>1</asp:listitem> </asp:dropdownlist> <asp:dropdownlist id="droplist2" cssclass="form-control" runat="server"> <asp:listitem>2</asp:listitem> <asp:listitem>1</asp:listitem> </asp:dropdownlist> have tried jquery former posts, none seem work.. jquery code: ...

c# - Click a listbox item open WebBrowser -

in webbrowser control have listbox. data on html page has loaded listbox, how can click on each item in listbox , open html page corresponds? (html pages have been put in debug folder of project). can use selectedindexchanged event or not? thank you! in selectedindexchanged event, newly selected value of listbox , open url... system.diagnostic.process.start(urlfromlistbox);