Posts

mysql - Django group by dates and SUM values -

this question has answer here: django: group date (day, month, year) 5 answers is possible reproduce following mysql query in django without using select method ? mariadb [db1]> select datetime, sum(datas) table , datetime between '2013-07-26 13:00:00' , '2013-07-26 23:00:00' group datetime; to kind of result : +---------------------+-----------+ | datetime | sum(data) | +---------------------+-----------+ | 2013-07-26 13:00:00 | 489 | | 2013-07-26 14:00:00 | 2923 | | 2013-07-26 15:00:00 | 984 | | 2013-07-26 16:00:00 | 2795 | | 2013-07-26 17:00:00 | 1308 | | 2013-07-26 18:00:00 | 1365 | | 2013-07-26 19:00:00 | 1331 | | 2013-07-26 20:00:00 | 914 | | 2013-07-26 21:00:00 | 919 | | 2013-07-26 22:00:00 | 722 | | 2013-07-26 23:00:00 | 731 | +---------------------+-----------+ 1...

javascript - Autocomplete - two fields -

i'm trying create page fields, use autocomplete function. first field - "ana" works fine. second fails. don't see errors in console. prompt doesn't appear. here snippet: <script src="/inc/jquery-1.8.3.js"></script> <script src="/inc/jquery-ui.js"></script> <link href="/inc/jquery-ui.css" rel="stylesheet" type="text/css"/> <table> <tr> <td>ticker:</td><td><input type="text" name="ana" /></td> </tr> <tr> <td>cmp: </td><td><input type="text" name="sou" /></td> </tr> </table> <div id="result" style="margin-top:25px;"></div> <script language="javascript"> $(document).ready(function() { ana = [ <% getana %>]; $("input[name='ana']").autocomplete({ source: ana }); so...

c# - Drop and replace table in Excel via OleDb -

i need replace table created oledbcommand in excel file. new table has same name, has different structure. managed deleting sheet via interop.excel there problem when other sheets refer sheet. formulas lost. noticed creating new table via oledbcommand creates new defined name in names property (names manager). i've tried create new table other name, copy table headers , change name location in: workbook.names.item(shname, type.missing, type.missing).refersto=oldsheetrange where oldsheetrange column headers range. unfortunately when try insert new data rows not insert table (no error occurs). is there option replace table saving reffering formulas? regards, kuba

ember.js - How to save model relationships with ember data -

i have following model: app.loan = ds.model.extend name: ds.attr('string'), products: ds.hasmany('app.product') then on code i'm calling save method on loan object, has many products associated, loan gets posted server, associated objects not. quickly looking @ code, seems intended, because calling save on record add record, , record in current transaction. associated objects added if embedded. in case, first create new transaction, adding record , associated objects, , calling commit on transaction. like var transaction = store.transaction(); transaction.add(loan) loan.get('products').foreach(function(product)){ transaction.add(product); }); transaction.commit() if want embed products in loan, can configuring adapter this. assuming using default rest adapter: ds.restadapter.map('app.loan', { products: { embedded: } }

html - Download a file with javascript and ignore MIME -

i wants browser download video file when server ready. i have seen download file using javascript/jquery , however,it not possible change mime on server. but browser regard video streaming media , display @ hidden iframe,instead of download it. how can fix this,make browser ignore mime , download it? thanks help! maybe, html5 download attribute need? give client link video , add attribute it. not every browser supports it, though.

php - Wrong product URLs magento -

i've been working on custom sells related products script, displaying 4 random products. problem is: normal product url is: /shop/$productname this generating url like: /$productname/ or url like: /catalog/product/view/id/$productid/4/s/$productname/category/$categoryid/ i want have urls same so: /shop/$productname <div class="upsell"> <h2>you might interested in</h2> <?php // list mode ?> <?php $_iterator = 0; ?> <?php // grid mode ?> <table class="products-grid upsell" id="upsell-product-table"> <tbody> <tr> <?php $_collectionsize = $_productcollection->count() ?> <?php $_columncount = $this->getcolumncount(); $_columncount=4; ?> <?php $i=0; foreach ($_productcollection $_product): ?> <?php if ($i++%$_columncount==0): ?> <?php endif ?> <td> ...

c - Error in calculation of the number of digits in a number -

write program using if statement calculates how many digits number contains: my code : #include <stdio.h> int main (void) { int n; printf ("enter number :"); scanf ("%d",&n); if ( n<=9) printf ("textnumber has 1 digit:"); if ( n <=99) printf ("textnumber has 2 digits:"); if (n<=999) printf ("textnumber has 3 digits:"); if (n <=9999) printf ("textnumber has 4 digits:"); return 0; } the problem when run this, , put example : 223 i have result in screen : textnumber has 3 digitstextnumberhasfourdigits... where wrong? this because compiler punishing not indenting code properly. just kidding, in fact, your logic flawed (and/or expectation doesn't match working of code): need else if s because if number greater limit, it greater smaller limits too, of them printed - erroneously.