Posts

mysql - Some sort of join statement? -

how put these 2 queries single query? select count(id) cnt {$site_id}.proofingv2_packages active='1' select count(id) cnt {$site_id}.proofingv2_package_options active='1' , parent={$row["id"]} order sort $row['id'] id field first query. trying determine if there valid packages. valid package must active , have @ least 1 active option. running 2 queries doesn't seem right. can help? select count(id) cnt {$site_id}.proofingv2_packages pp inner join {$site_id}.proofingv2_package_options pt on pp.active = pt.active , pp.active = 1 if id pk or fk on same on both tables use query select count(id) cnt {$site_id}.proofingv2_packages pp inner join {$site_id}.proofingv2_package_options pt on pp.id= pt.id , pp.active = 1

razor - ASP.NET MVC 3: Using Enumerable extension methods in the view -

given following razor partial view , understanding product nhibernate mapped object calls ienumerable here fire database queries (when not cached). is bad practice? should providing flatter view of data view can make these calls in controller/business logic? @model ienumerable<myproject.data.models.product> <table> <tr> <th></th> <th>total orders</th> <th>fulfilled</th> <th>returned</th> <th>in stock</th> </tr> @foreach (var product in model) { <tr> <td> @html.actionlink(product .name, "detail", "product", new { id = product.id }, null) </td> <td> @product.orders.count </td> <td> @product.orders.where(x=>x.fulfilled).count() </td> <td> ...

java - tomcat with jsp -

how can compile , run jsp pages using tomcat. should place jsp page. in folder have placed it. a simple example of jsp can <html> <head> <title>hello world jsp</title> </head> <body> <% out.println("hello world"); %> </body> </html> to run jsp page save file in c:\program files\tomcat\tomcat-5.5.9\jsp-examples\ helloworld.jsp start tomcat server. type following url in address bar of web browser. http://localhost:8080/jsp-examples/helloworld.jsp jsp page displayed in web browser. a jsp page converted servlet internally jsp engine.and source file servlet can found @ \work directory in tomcat. for more information on how jsp works , how different servlet take @ what difference between jsf, servlet , jsp? also take at hidden features of jsp/servlet

python - plotting with matplotlib from a module -

it's first time i'm using python plot , guess don't quite understand interactions between objects in matplotlib. i'm having following module: import numpy np import matplotlib.pyplot plt def plotsomething(x,y): fig = plt.figure() ax = fig.add_subplot(111) ax.set_xscale("log", nonposx='clip') ax.set_yscale("log", nonposy='clip') ax.scatter(x,y) #(1) plt.scatter(x,y) #(2) and plots fine when function called (given x , y). a) if comment out (1) or (2) axis' plotted not scatter itself. b) however, if both (1) , (2) uncommented , add vars s=5, marker='+' either (1) xor (2) the figure show both markers (one on top of other) - default 'o' , '+', meaning plot scatter twice. but - if having both (1) , (2) uncommented i'm plotting twice, why need have both (1) , (2) in order see scatter? why in case (a) no scat...

design patterns - Singleton class -

we have application, access the config file, have singleton class , object of used. i understand singleton class , provide 1 instance of object. question why can't have opening , closing of config file whenever required. ofcourse, method may expensive since windows need allot handle , dispose off when not in use. are there specific reason using singleton class. thank you, harsha singleton class can pure evil. is. you'll see if ever decide apply loose-coupling code. my advice reconsider design. think of reading config file @ application start , persisting object configuration parameters in memory. can pass object classes/interfaces require config parameters. you may redesign application in way doesn't require numerous writes config file without using singleton (anti)pattern.

java - How to avoid stacktrace HTTP Status 500 page with MaxUploadSizeExceededException -

i have code (like in spring's reference): <bean id="multipartresolver" class="org.springframework.web.multipart.commons.commonsmultipartresolver"> <!-- 1 of properties available; maximum file size in bytes --> <property name="maxuploadsize" value="100000"/> </bean> when user tries upload file on 100 kb server error page http status 500 , stacktrace displayed. how avoid in simplest way? redirect form page , show own error message. assuming it's org.springframework.web.multipart.maxuploadsizeexceededexception , define error-page in web.xml follows: <error-page> <exception-type>org.springframework.web.multipart.maxuploadsizeexceededexception</exception-type> <location>/upload-error.jsp</location> </error-page> note works when don't have <error-page> covers servletexception or 1 of superclasses. otherwise you've brin...

javascript assign() -

as far i've tested, 2 methods works, don't know wich 1 best, neither differences between them, , that's i'd know. here's 2 methods : window.location = 'http://www.google.com'; window.location.assign = 'http://www.google.com'; thougths? these 2 methods equivalent. first 1 clearer me. syntax assign be: window.location.assign('http://www.google.com');