Posts

Showing posts from June, 2014

.net - TcpClient vs MSMQ -

i'm developing application need communicate running on different machines located in different locations. going use tcplistener , tcpclient send information between applications came across msmq. the computers connected via software vpn, communicates across standard internet connection now don't know technology use, tcpclient or msmq. i want send different types of information requests , transmit files. have large amount of data in database large send across internet application. want send request 1 app other run query, save results xml, compress it, , send file back. receiving application decompress , load xml data set, saving great amount of time. (uncompressed 10mb+, compressed 0.3mb) there different types of requests information. so, want application able differentiate between requests, i'm not sure how best receive information , then determine information is, (i.e. type of request is) are situations 1 technology better other? any pointers how best impl...

objective c - Incrementing a double is never whole -

in objective-c have timer fire every 0.1 seconds , increment double value (seconds) 0.1. so should keep time counting 1/10 of second. when fires checks if - else statements see if time (seconds) equal 3, 9, 33, etc., these never triggered. suppose because of way doubles represented in bits, decimal approximation , never whole number. how can fix statements triggered? -(void)timeseconds:(nstimer*)thetimer { seconds = seconds + 0.1; nslog(@"%f", seconds); if (seconds == 3.0) { [player pause]; [secondstimer invalidate]; } else if (seconds == 9){ [player pause]; [secondstimer invalidate]; } the floating point types cannot represent numbers exactly, when these added, error compounded , floating point type becomes less , less precise. use integral type represent time difference using greater resolution, example, use nsuinteger represent milliseconds instead of seconds, , increment 100 instead of 0.1. instead of comparing seconds == 3.0 , use ...

Django popup window for Inlines -

i've got problem here. i've got 3 models, a, b , c. class class b fb = foreignkey(a) class c fc = foreignkey(b) in admin.py i'm doing like admina inlines = [inlineb] adminb inlines = [inlinec] the troubles start appearing on add page of model a. basically, model b placeholder different manytomany , foreignfields, , doesn't have internal fields of own. although i'm able add inline model b, i'm unable add features it. hoping find way popup window link in inline rows. similar popup window thats opens when 1 needs create foreginkey. ideas?

c++ - Resource conflict on ON_UPDATE_COMMAND_UI -

i have exe class contains button resource id exe_button_resource on_update_command_ui(exe_button_resource, onupdateexebuttonresource) void exe::onupdateexebuttonresource(ccmdui* pcmdui) { pcmdui->enable(exe_flag); } this exe application load dll class. dll class having menu item resource id dll_menu_resource . unfortunately, exe_button_resource , dll_menu_resource having same resource id. avoid them have conflict id pretty difficult, 2 separate projects. whenever exe_flag, member exe turn false, affect menu in dll too. clicking on dll_menu_resource menu have no effect @ all. how can avoid trap? having manual inspection on resource.h files not option me, 2 separate projects, managed 2 separate teams. once, thought might resource conflicting problem. hence, in dll code show right clicked menu, have following code load dll resource, , restore exe resource when done. void dll::oncontextmenu(cwnd* pwnd, cpoint point) { restoredllstate ext; .....

Should I use a T-SQL function, view, or stored proc? -

i've got question reusing table data view won't work in scenario have parameter needs passed in. part of system requires travellerid sent procedure , list of arrangers returned specific traveller. there around 7 business rules used determine arrangers can returned , mutually exclusive, in order accommodate these optional rules have used series of unions inside derived query. working well, , performance seems across large database, need reuse these rules (unions) in 4 other parts of system. i tried create view these unions didn't work due differing logic in each union , different parameter requirements, thinking maybe function solve issue? if created function took @travellerid param , returned list of arrangerid based on business rules, ideal/fast solution? using union , distinct in outer query proved faster using union's uniqueness of data. current procedure business rules below (sql server 2008): create procedure [dbo].[getarrangersfortraveller] @travel...

oracle - Quick-n-dirty results: View results of Procedure OUT cursor in SQL Worksheet? -

platform: oracle language: pl/sql issue: want output procedure out cursor sqldeveloper sqlwosksheet. anyone know how use oracle "select * table( pipelinedfunction( param ) ) " check procedure code output cursors? i using crsytal reports off of oracle stored procedure. crystal requires procedure return cursor, fetchs , reads. the procedure code have working, want find easiest way view effects of changes procedure code. have sqldeveloper available, , i'm doing creation , sql testing in that. quick result visible in sql developer query result window ("sql worksheet"). is there (simple) way use function read cursor procedure? (and pipe out table function?) convoluted, know, deal best when can see results of code changes. if can view record results directly, speed development of report. i know of table function , little pipelining in oracle. know little cursors in general , sys_refcursor. know diddly types , why need them. (isn't sys_regc...

XNA 4.0 runs at 50 instead of 60 fps -

i'm experimenting bit xna 4.0, following tutorials , creating basic stuff (like triangle , lines ;-)). while doing this, noticed applications never run @ more 50-51 fps (with fraps). it's not i'm running heavy programs on slow computer or graphics card (ati hd4870), must have xna (games run fine here). now, read xna says default update frequency 60 times second, , i'd that. it's same in full screen in windowed if set synchronizewithverticalretrace false or true: same if run program without visual studio, 41 fps when override update frequency using targetelapsedtime = new timespan(0, 0, 0, 0, 10); fps go significantly. noticed though still isn't correct: 10 means 10ms, yet 'only' 83 fps instead of 100. @ 1ms 850 fps. deviation of fps , should pretty consistent. looks me there's wrong timing? anyone knows might problem here and/or has suggestions stable 60 fps? thanks! isn't possible fraps isn't giving accurate result...

network programming - c++ gethostbyaddr with user input -

i writing c++ code telnet client. having problems getting host address user input. struct in_addr peers; cin>>peers; peerserver = gethostbyaddr((const char*)peers,4,af_inet); if (peerserver == null) exit(0); i new c++, can suggest better way of getting host addr user input. in advance. what you're looking gethostbyname , not gethostbyaddr . gethostbyaddr assumes you've got ip address. char peers[256]; cin >> peers; struct hostent *ent = gethostbyname(peers); printf("%04x\n", *(int *)(ent->h_addr));

Mysql add mult-column index with repeated rows -

having next table: id -> incremental field_1 -> foreignkey field_2 -> foreignkey i want add next index alter table my_table add unique index(field_1, field_2); how ever have (due bad application validation) have lot of repeated rows (by repeated mean same field_1 , same field_2, having id difference) the table has 60,000 rows so... removing field field hard. how can apply index , remove every duplicated row? create table mytable2 mytable; insert mytable2 select max(id), field_1, field_2 mytable group field_1, field_2; rename table mytable mytable_old, mytable2 mytable; alter table my_table add unique index(field_1, field_2)

php - Updating recent updates - Problem in procedure - Any other approach? -

i have section in website called recent updates. in show latest 5 updates @ first when page rendered. when new update done @ real time, new update appended top of updates list , last 1 deleted. my approach: for problem, im doing is, first renders page last 5 recent updates. fetching updates database. when update made in realtime, stored in database flag = 0. to find out whether update made, have javascript calls ajax page every 4 seconds. ajax page checks in db whether records flag=0 present. if of there, return update flag=0 , set flag 1. problem: it working fine on single system. havent tested on multiple system @ same time. i fears, each update can viewed single user , flag set 1. other users may not it. is there alternate approach in solving issue?. may changing query or may yield goodness. expecing experts here.. appreciated. each update stored timestamp of when created. javascript figures out timestamp of latest update displayed on site. ajax requ...

How do I restrict access to certain pages in ASP.NET MVC? -

i wish lock out access html page (eg. /manual/manual_a/index.html) if condition not met (eg. httpcontext.current.request.form["key"].tostring().equals("a") ), wish redirect specific view (eg. /errorpage/) else continue (eg. /index). in register route add: routes.maproute( "errorpage", "errorpage/", new { controller = "home", action = "errorpage" } ); routes.maproute( "path", "{*_request}", new { controller = "home", action = "index" } ); for read request. in controller home [customauthorize] public actionresult index() { } protected override void onactionexecuting(actionexecutingcontext filtercontext) {...

java - Parsing ksoap2 response -

i use ksoap2 lib communicating android client soap web service. great job done ksoap team, problem is, there no example how use correct in different aspects. instance in soap response following data: anytype{ statussetting=anytype{id=1; name=til afskrivning; locationid=1; editable=true; default=true; transcribed=false; }; statussetting=anytype{id=2; name=afskrevet; locationid=1; editable=false; default=false; transcribed=true; }; ... } it's complex object, or rather collection of statussetting objects. when try property of soapobject it's 1 property data string. can't parsed json too. unbelievable nobody met same problem regarding popularity android gaining. cool know if solved issue , how. thanks. here tutorial on how work array of complex objects ksoap . found out countless hours of debugging. hope hepls

Why am I getting 400 bad request when calling a .Net 2.0 web service from WCF over https? -

i have web service contains method need run generate report. web service method written in .net 2.0 , works fine on test system runs on same server live system. difference live version uses https. whenever change endpoint address live service , run application 400(bad request) errors iis. is there specific configuration setting need change in wcf settings in app.config work https? the generated app.config settings created "add service reference" follows: <system.servicemodel> <bindings> <basichttpbinding> <binding name="reportssoap" closetimeout="00:01:00" opentimeout="00:01:00" receivetimeout="00:10:00" sendtimeout="00:01:00" allowcookies="false" bypassproxyonlocal="false" hostnamecomparisonmode="strongwildcard" maxbuffersize="65536" maxbufferpoolsize="524288" maxreceivedme...

r - finding unique values from a list -

suppose have list of values x <- list(a=c(1,2,3), b = c(2,3,4), c=c(4,5,6)) i find unique values list elements combined. far, following code did trick unique(unlist(x)) does know more efficient way? have hefty list lot of values , appreciate speed-up. this solution suggested marek best answer original q. see below discussion of other approaches , why marek's useful. > unique(unlist(x, use.names = false)) [1] 1 2 3 4 5 6 discussion a faster solution compute unique() on components of x first , final unique() on results. work if components of list have same number of unique values, in both examples below. e.g.: first version, double unique approach: > unique(unlist(x)) [1] 1 2 3 4 5 6 > unique.default(sapply(x, unique)) [1] 1 2 3 4 5 6 we have call unique.default there matrix method unique keeps 1 margin fixed; fine matrix can treated vector. marek, in comments answer, notes slow speed of unlist approach potentially due names on...

problem in threading c++ -

i running 2 threads , text display first displayed after execution of thread string thread(string url) { mutex.lock(); //some function goes here mutex.unlock(); } int main() { cout<<"asd"; boost::thread t1(boost::bind(&thread)); boost::thread t2(boost::bind(&thread)); t1.join(); t2.join(); } in main program have displayed text asd displayed after execution of thread .. std::cout << "asd" << std::flush;

linq - Visual C# Express with DryadLINQ? -

can use visual c# express (instead of visual studio) dryadlinq? we know visual c# express 2010 supports linq. not sure if dryadlinq supported, because dryad might require plinq features also. if can shed light, grateful. procuring license visual studio tedious process in organization, , if dryadlinq can worked on visual c# express, can start work immediately. for beta of dryad linq (now called linq hpc) require vs can create .net 3.5 project , link our client assemblies. while we've not done testing against express vs don't know of reason why wouldn't work. ade (pm linq hpc)

c# - WPF Datagrid ItemsSource -

i have dynamic set of columns , when populate rows , know columnname of rows. possible do? a list of columns: columns[0] = "firstcol"; columns[12] = "anothercol"; and list of rows. first row rows[0][0] = "item"; rows[0][12] = "item"; second row rows[1][0] = "item"; rows[1][12] = "item"; i need populate datagrid. can done, dictionary or something, not know columns... if can manage create structure, - row - column header - cell data also expose list of column control (maybe bind it) on update of dynamically create columns , attach cell template, cell edit template (data templates, specify binding source item , paths). way dynamic columns added , binding established changes in rows or data updated between 'presenter' , 'view' (wpf datagrid control)

asp.net - Blackberry Push Service Initiator on IIS/.NET -

i need send push notifications blackberry device asp.net application. best way it? there .net libraries? need compile pap request myself or this? there open-source c# blackberry push sdk can used , consumed asp.net application. the project hosted on codeplex here .

html - Mark of the web help required -

when opening html page in ie 6 giving info bar on page , error "to protect security internet explorer has restricted webpage running scripts or activex controls access computer.click here options...." , page blank.when allowing block content page coming. have searched in google , find solution.the solution need add in page. link of page. but still showing info bar.please help. go tools/internet options . and in security tab click on trusted sites , click on sites , add website there.

jdbc - Remove padding added by legacy DB2 databases on query results -

i have following setup. 'apps/reports' <---------> 'db2 connect' <------------> 'legacy db2 on as400' `hibernate` `native calls` when data retrieved application, padded spaces if length less column length. of note when running query, if where cause parameter not padded, automatically padded spaces such query retrieve same records padded , non-padded parameter. is there way (preferably on ibm db2 connect or connection string parameter) remove whitespaces resultset? are columns in iseries defined char()? i'm assuming so, because how char() works -- it's fixed field length, not variable field length (that's varchar for).

c# - Virtual machine vs physical machines for QA/UAT? .Net Runtime bug on VM Slices -

my department pushing me use vm slices out qa , uat testing. believe should using identical physical hardware prod. our prod setup uses 5 high-spec servers. qa there 5 vm slices on single high-spec machine. apart performance difference i’ve experienced .net runtime crashes on vm slices haven’t experienced on physical machines (see this: net runtime bug : .net runtime 2.0 error - event id: 1000 crashed program. caused this? ) does else have opinion on this? vm slices or on physical machines qa? /cost isn’t issue here. correctness is. having done considerable qa/uat work, can preferable have test machine matching hardware specs. you can (and have) done qa/uat work on vm's , these should adequate testing. exception load/stress testing.

osx - Git changes files on Mac OS X -

i cloned old repository containing linux kernel modules (don't ask). if clone on linux machine, fine. on mac however, (presumably mac os x) makes binary changes modules. disabled autocrlf. here's output of git diff -p --stat directly after clone: .../kernel/net/ipv4/netfilter/ipt_ecn.ko | bin 3853 -> 4535 bytes .../kernel/net/ipv4/netfilter/ipt_ttl.ko | bin 3458 -> 3904 bytes .../kernel/net/netfilter/xt_connmark.ko | bin 4534 -> 5618 bytes .../2.6.26-2-686/kernel/net/netfilter/xt_dscp.ko | bin 4378 -> 5217 bytes .../2.6.26-2-686/kernel/net/netfilter/xt_mark.ko | bin 3679 -> 4334 bytes .../kernel/net/netfilter/xt_rateest.ko | bin 4545 -> 7137 bytes .../2.6.26-2-686/kernel/net/netfilter/xt_tcpmss.ko | bin 3841 -> 6553 bytes 7 files changed, 0 insertions(+), 0 deletions(-) diff --git a/i686/modules/2.6.26-2-686/kernel/net/ipv4/netfilter/ipt_ecn.ko b/i686/modules/2.6.26-2-686/kernel/net/ip...

Send HTTP Post with Array - PHP -

i'm trying use nice function: function do_post_request($url, $data, $optional_headers = null) { $params = array('http' => array( 'method' => 'post', 'content' => $data )); if ($optional_headers !== null) { $params['http']['header'] = $optional_headers; } $ctx = stream_context_create($params); $fp = @fopen($url, 'rb', false, $ctx); if (!$fp) { throw new exception("problem $url, $php_errormsg"); } $response = @stream_get_contents($fp); if ($response === false) { throw new exception("problem reading data $url, $php_errormsg"); } return $response; } to send post command specific url, problem i'm trying send post paramters in form of array, this login[username]: myusername login[password]: mypassword, however i'm not able that, calling function : $login_post = array('login[use...

Macro in a loop? -

for(x;x<crap;x++) { macro(x,y); } how handled preprocessor? loop unrolled or else? the macro expanded before code compiled - doesn't matter whether it's in loop or anywhere else. #define macro(x, y) dosomething(x, y) for(x;x<crap;x++){ macro(x,y); } will expand to: for(x;x<crap;x++){ dosomething(x,y); } the context surrounding macro(x,y) has no effect on how preprocessor expands it. (the preprocessor doesn't know programming language you're using - c, python, brainfuck or letter bank manager , expand macros same way.)

java - Booleans, conditional operators and autoboxing -

why throw nullpointerexception public static void main(string[] args) throws exception { boolean b = true ? returnsnull() : false; // npe on line. system.out.println(b); } public static boolean returnsnull() { return null; } while doesn't public static void main(string[] args) throws exception { boolean b = true ? null : false; system.out.println(b); // null } ? the solution way replace false boolean.false avoid null being unboxed boolean --which isn't possible. isn't question. question why ? there references in jls confirms behaviour, of 2nd case? the difference explicit type of returnsnull() method affects static typing of expressions @ compile time: e1: `true ? returnsnull() : false` - boolean (auto-unboxing 2nd operand boolean) e2: `true ? null : false` - boolean (autoboxing of 3rd operand boolean) see java language specification, section 15.25 conditional operator ? : for e1, types of 2nd , 3rd operands boolean ...

php - Mysql - Select words from text -

i have table contains 300 locations name (pris, london,...) there way (query) select locations specified text. for example: " transport london (tfl) in talks american, australian , european partners issuing single contactless card paris, new york". i want query get: london paris new york i tried: select name coutries name in ("transport london (tfl) in talks american, australian , european partners issuing single contactless card paris, new york") but no chance!, can please? select name coutries ("transport london (tfl) in talks american, australian , european partners issuing single contactless card paris, new york") concat('%', name, '%'); in different thing.

roles - Editors for different parts of Wordpress -

i'm preparing page (not published yet) , need help. didn't find answer in forums roles , capabilities. have heard plugin or other solution, allows editor publish in category/page. have 10 departments, in each of them 1 author , 1 editor. need ensure editor department 1 can not publish department 2. lot. my recommendation install wordpress multi-site network , give each department own site. can based on sudomains ( department-1.mysite.com , department-2.mysite.com , etc.) or subfolders ( mysite.com/department-1 , mysite-.com/department-2 , etc.). users can have different roles across each site in network. you, super administrator, have full access everything. if have author who's supposed author on 1 department's site, can limit them way. can grant user permission author on 1 site, editor on another, , merely subscriber on another. it's flexible system. this easiest way separate authors specific "departments" within wordpress ... , b...

http - curl + jsecurity authentication -

i have grails app using jsecurity plugin authentication. how use curl send credentials? if curl -u username mysite i prompt password, nothing. i tried anyauth command , got site. idea why returning 302? dcole@dcole-l /cygdrive/c/dev $ curl --anyauth --verbose http://localhost:8080/skillsdb * connect() localhost port 8080 (#0) * trying ::1... connected * connected localhost (::1) port 8080 (#0) > /skillsdb http/1.1 > user-agent: curl/7.20.1 (i686-pc-cygwin) libcurl/7.20.1 openssl/0.9.8o zlib/1. 2.5 libidn/1.18 libssh2/1.2.5 > host: localhost:8080 > accept: */* > < http/1.1 302 moved temporarily < server: apache-coyote/1.1 < location: http://localhost:8080/skillsdb/ < transfer-encoding: chunked < date: thu, 07 oct 2010 14:32:32 gmt < * connection #0 host localhost left intact * closing connection #0 here additional information: rob correct form based. when go address http://localhost:8080/skillsdb/auth/initiallogin this form code...

c# - Is the callBack method called before the assignment or after here? -

i have code below calling domain service in silverlight application. loadoperation<tcity> loadoperation = _datacontext.load(query,callback, true); can tell me operation done first? is callback method called before loadoperation variable assigned or after assigned? thanks assuming it's meant asynchronous operation, happen either way, in theory. asynchronous operation should occur in thread, , if finishes before load returns, callback called before assignment completes. in practice, i'd expect async call take much longer whatever housekeeping load @ end of method - wouldn't put assumption code. unless there's explicit synchronization ensure assignment occurs before callback, don't think it's idea rely on it. even if @ moment assignment happens first, consider: what happens if there's no network connection @ moment? async call fail quickly. what happens if caching added client-side? call succeed quickly. i don't know...

javascript - Editing results while being appended? -

i have following script displays data returned serverside page onto clientside page: function getresults() { var search; search = $(".txtsearch").val(); $.ajax({ url: 'search.aspx', type: 'post', data: { strphrase:search }, error: function(xhr, status, error) success: function(results) { $("#resultscontainer").empty(); $("#resultscontainer").append(results); } }); } is possible check results returned being appended , make changes it? for example, imagine results returned html follows: <div><a href="link1.xls">link 1</a></div> <div><a href="link2.xls">link 2</a></div> <div><a href="link3.doc">link 3</a></div> <div><a href="link4.xls">link 4</a></div> is possible check .doc in links , remove fu...

maven 2 - deploying a versioned WAR file to tomcat -

i wondering best practice deploy maven packaged war file tomcat. using maven release plugin versioned war file project eg: myservice-1.0.0.war i deploy tomcat can access follows eg: http://localhost:8080/myservice by default tomcat explodes war file directory name myservice-1.0.0 under catalina_home/webapps. want to explode war directory name myservice reasons mentioned above. i know can rename myservice-1.0.0.war >> myservice.war , deploy in tomcat. i wanted find out others do? i mentioning myservice artifactid , final name , using maven cargo plugin deploy tomcat. http://cargo.codehaus.org/maven2+plugin+tips

How to: remove part of a Unicode string in Python following a special character -

first short summery: python ver: 3.1 system: linux (ubuntu) i trying data retrieval through python , beautifulsoup. unfortunately of tables trying process contains cells following text string exists: 789.82 ± 10.28 for work need 2 things: how handle "weird" symbols such as: ± , how remove part of string containing: ± , right of this? currently error like: syntaxerror: non-ascii charecter '\xc2' in file ...... thank help [edit]: # dataretriveal html files detherm # -*- coding: utf8 -*- import sys,os,re beautifulsoup import beautifulsoup sys.path.insert(0, os.getcwd()) raw_data = open('download.php.html','r') soup = beautifulsoup(raw_data) numdiv in soup.findall('div', {"id" : "sec"}): currenttable = numdiv.find('table',{"class" : "data"}) if currenttable: numrow=0 row in currenttable.findall('td', {"class" : "datahead...

javascript - Setting defaults for JQuery UI datepicker on whole site -

i'm working site jquery ui datepicker displayed on lot of different pages. have set of features we'd date picker use pages - same date format, same icon, etc. what's best way set these items default datepicker() function, rather have every call datepicker() include same options? i'm thinking of either somehow modify properties of datepicker() function or create our own function wraps dataepicker() , sets defaults. you can use $.datepicker.setdefaults() once in file included on every page (if have main .js of sort example) runs before .datepicker() calls, example: $.datepicker.setdefaults({ dateformat: 'yyyy-mm-dd' }) the options passed in .datepicker() call.

DataGridView BeginEdit when form opens -

i have datagridview on form, , want specific cell in first row in edit mode when form opens , when selection changes. datagridview selectmode set "fullrowselect" , in selection change event have following code: if (dgvreconlist.selectedrows.count == 1) { dgvreconlist.currentcell = dgvreconlist.selectedrows[0].cells["colreferraldate"]; dgvreconlist.beginedit(true); } that code works charm when change selection. problem when try set desired cell in first row edit mode (using above code) when form opens. first row selected, , desired cell "current" cell, not in edit mode. have tried using above code in forms activate event, load event, , several others no luck. how can cell in edit mode form opens? do simple 3 steps. in form load event -> after loading data dgv set dgv property editmode editonenter . dgvreconlist.currentcell = dgvreconlist[desiredcolumnindex, 0]; dgvreconlist.currentcell.selected = true; this directly ...

data binding - WPF DataGrid: How do I databind the properties of the SelectedItem to trigger INotifyPropertyChangedEvents? -

i'm trying mvvm possible: model ( interesttypeentity ) implements inotifypropertychanged. viewmodel ( interesttypeallviewmodel ) has observablecollection binds datagrid. when changes made it, sends changes (add/remove) database. the problem is, want able update database when properties of objects within collection change. i'm not sure how that? here's code far... xaml: <datagrid name="testgrid" grid.row="3" grid.columnspan="2" autogeneratecolumns="false" itemssource="{binding inttypes}" selecteditem="{binding currentinttype}"> <datagrid.columns> <datagridtextcolumn header="interest id" binding="{binding inttype}" /> <datagridtextcolumn header="interested parties description" binding="{binding description}" maxwidth="500" /> </datagrid.columns> </datagrid> viewmodel code: public obs...

django: generic views + custom template tags or custom views + generic/normal template tags -

this more of best-practices question, , given i'm quite tired mightn't make sense. i've been putting blog app learning experience , actual part of website developing. i've designed apps can list blog posts multiple criteria i.e. /blog/categories/ /blog/authors/ /blog/tags/ /blog/popular/ etc. on each page above want list how many entries part of criteria i.e. "categories", want /blog/categories/ list different categories, mention how many blog posts in category, , possibly list entries. django seems give lots of ways of doing this, not indication on what's best in terms of flexibility, reusability , security. i've noticed can either a: use generic/very light views, pass queryset template, , gather remaining necessary information using custom template tags. i.e. pass queryset containing categories, , each category use template tag fetch entries category or b: use custom/heavy views, pass 1 or more querysets + necessary informati...

c# - drawing image to bigger bitmap -

basically want stretch smaller image (i.e. 300x300 bigger 1 i.e. 500x500) without space or black background. i have bitmap (let's width 500px, , height 500px). how draw (smaller) image on bitmap takes whole bitmap? i know how create bitmap (i.e. var bitmap = new bitmap(500, 500); ) , image - can loaded file (i.e. var image = image.fromfile(...); ) or obtained other source. see documentation graphics.drawimage . can specify source , destination rectangles. example code: image = image.fromfile(filename); // 300x300 bitmap b = new bitmap(500, 500); using(graphics g = graphics.fromimage(b)) { g.drawimage(i, 0, 0, 500, 500); } to use code make sure add reference system.drawing assembly , add using system.drawing file.

asp.net - SelectMethod in objectDatasource getting called multiple times with multiple datapagerfield -

ok, here setup. building page has listview, datapager, , 3 datapagerfield (2 x nextpreviouspagerfield, 1 x numericpagerfield), , objectdatasource tide of together. it working fine until put breakpoint selectmethod specified in objectdatsource control. seems each datapagerfield control, calling selectmethod , selectcount method. hence, whenever user paged, calls database 6 times instead of 2 (i don't have caching turned on atm). if remove 1 datapagerfield, remove 2 calls. now build in asp.net 3.5 sp1 in vs2008. when copied same code files asp.net 4.0 vs2010 solution, duplicate call seems gone. is bug in asp.net 3.5 sp1? thanks in advance actually should using onselecting event. what happens objectdatasource calls method selectmethod twice first time gets data. next time gets count. so think have implement onselecting event <asp:objectdatasource id="ods" runat="server" selectmethod="getlist" selectcountmethod=...

How to convert a String to an android.net.Uri -

question: have found java.net.uri has create(string uri) option android.net.uri not. more specific: trying grab output of ringtonemanager's ringtonepicker , set default ringtone setactualdefaultringtoneuri; intent intent = new intent(ringtonemanager.action_ringtone_picker); intent.putextra( ringtonemanager.extra_ringtone_type ,ringtonemanager.type_ringtone); intent.putextra( ringtonemanager.extra_ringtone_title , "select tone rainy days"); startactivityforresult(intent, 0); ringtonemanager.setactualdefaultringtoneuri(this ,ringtonemanager.type_ringtone ,ringtonemanager.extra_ringtone_picked_uri); problem being ,ringtonemanager.extra_ringtone_picked_uri returns string not uri. there might better way convert string uri. cannot find reason why java.net.uri can , android.net.uri can't. any suggestions appreciated! thanks i guess want use parse method android.ne...

date - xslt - subtracting days -

is possible xslt take date field , subtract n number of days it? if so, can please provide me example? here demonstration how in xslt 2.0: <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:xs="http://www.w3.org/2001/xmlschema"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:variable name="vtoday" select="current-date()"/> today is: <xsl:sequence select="$vtoday"/> 30 days ago was: <xsl:sequence select= "$vtoday -30*xs:daytimeduration('p1d')"/> 365 days ago was: <xsl:sequence select= "$vtoday -365*xs:daytimeduration('p1d')"/> </xsl:template> </xsl:stylesheet> when transformation applied on xml document (not used), wanted, correct result produced : today is: 2010-10-07-07:00 30 days ago was: 2010-09-07-07:00 365 days ago was: 2...

c# - How to convert AMR sound stream to PCM uncompressed stream in .NET -

i need convert amr ( adaptive multi-rate ) audio file recorded in phone (as stream object) pcm uncompressed wav audio stream can processed afterwards speech recognition. speech recognition doesn't amr format. going server application using microsoft speech platform . not sure using ffdshow or similar libraries in . right researching naudio , directshownet see if can me accomplish hoping can point in right direction. after lot of searching solution this, going use ffmpeg . provides amr-nb (nb=narrow band) decoder. there lot of c# wrappers ffmpeg around; of them abandoned efforts , 1 date not free. running ffmpeg basic parameters provides need, plus fast. i don't idea of calling external process conversion, plus need save amr stream file can converted wav file believe can make work efficiently.

c# - WPF MVVM Multithreading Issue -

i've seen other issues similar mine, haven't seen can apply make code work. so i'm new mvvm, , i'm trying stuff that's executing in background thread update on ui. i'm noticing first time bring ui, , background thread executes first time, if collection ienumerable<> ui isn't fully updated against backing data. if collection observablecollection<>, throws error. from i've read, changes collections need executed on dispatcher thread, onpropertychanged() calls not. someone, please tell me how happening: i'm altering _printers observable collection: foreach (printerviewmodel pv in _printers) { dispatcherexec(() => { var abilities = x in _serverdata.types select new printerability( new printabletype() { id = x.id, name = x.name, numinprocunit = x.numinprocunit, printersmappedto = x.printersmappedto, sy...

objective c - Why would my app not be able to "attach" an action? -

i've changed app class type nsobject nsapplication , following message when testing app: could not connect action buttonclicked: target of class nsapplication what mean , how can fix it? nsapplication not respond buttonclicked: method and, therefore, there no way target/action connection made.

algorithm - What are the standard techniques for removing a segmentation (such as a human or bird) from a video? -

let's taking video (with camera in steady position) , bird flies through view of camera. should possible image segmentation , automatically remove bird video. what these styles of algorithms called , how accomplished? there's technique called simple image object extraction (siox) - uses technique identify foreground vs. background objects in still , video images. open source gimp editor has implementation of it, , there's more information here . from overview: siox stands simple interactive object extraction , solution extracting foreground still images little user interaction. siox fast, noise robust, , can therefore used segmentation of videos. avoids many of drawbacks of graph-based segmentation methods performs equally on different benchmarks. siox open , free (apache license) , authors have intentionally not patented part of technology. result, has been integrated several open-source image manipulation programs on past years. siox underlying a...

Why does my SQL query of date fields sometimes need trunc() (Oracle)? -

i have 2 tables querying on date column in each table. in 1 case need use trunc() function on date field values back, on other not. that works on table 1: select to_char( datecol1 ,'mm/dd/yyyy hh:mm:ss') table1 datecol1 =to_date('10/07/2010', 'mm/dd/yyyy'); but on table 2 above syntax did not work , needed trunc(), such as: select to_char( datecol2 ,'mm/dd/yyyy hh:mm:ss') table2 trunc(datecol2) =to_date('10/07/2010', 'mm/dd/yyyy'); three things note: in querying table1 to_char(datecol1 ,'mm/dd/yyyy hh:mm:ss') looks if times between 12:00 , 12:10, values inserted throughout day when inserting records table1 insert mm/dd/yyyy, no time when inserting records table2 inserted time so can explain: why truncate not needed on table1 on table2? why values in table1 between 12:00 , 12:10? in table1 have no 'time-of-day' component data, date should match - observed. but, used mm formatti...

Installing a module/script in Python on OSX -

i running python 2.6.2 in mac osx 10.5.8. i trying generate scientific graphs publication , experimenting python/matplotlib that. varun hiremath created module called plot_settings.py ( link text , trying figure out how install module can import it. i'm not sure if easy_install applicable here, why i'm confused. thanks! put file in same folder script , import it: import plot_settings .

c++ - Problematic vector return value - not really updated? -

i'm having weird problem: when program reach method: //returns transpose matrix of 1 regmatrix regmatrix::transpose() const{ regmatrix result(numcol,numrow); int i,j; for(i=0;i<numrow;++i) for(j=0;j<numcol;++j){ result._matrix[j][i] = _matrix[i][j]; } return result; } it crashes... when ran vs debugger, looked fine, new matrix filled relevant values, till line return result; mysterious reason returned empty matrix vector. where go wrong?? here implementation copy constructor: //cctor of regmatrix regmatrix::regmatrix(const regmatrix &other): numrow(other.getrow()), numcol(other.getcol()){ //create _matrix = vector<vector<mydouble> >(other.getrow()); int i,j; for(i=0; < numrow; i++) _matrix[i] = vector<mydouble>(other.getcol()); //copy matrix for(i=0;i<numrow; ++i){ for(j=0;j<numcol; ++j){ _matrix[i][j] = o...

svndump - Recalculate checksum in SVN dump after manual changes -

as migrating project public source hosting, wanted remove “personal” information svn repository. did fine far removing paths or revisions using svndumptool , svndumpfilter . want remove text particular file in repository well. i removed text manually regex’ing dump , worked fine, when want use dump, checksum mismatch. because changed file didn't update checksum. is there tool recalculates checksum files in dump? or there good editing tool files (should allow regex replacements) inside svn dump updates checksum? okay, didn't want wait longer answers, wrote script myself, share you. utilizes svndumptool , or rather library. custom actions required edit source (and know bit python). simple example included , think abstraction script provides quite good. anyway, hope useful me, although took me quite while working that: svndumptooledit.py on github.

javascript - carry some extra information in an HTML select/option dropdown list -

i want carry hidden information (eg: postal code) in html select/option dropdown list , make available javascript function when user changes option box selection. this type of thing (but not work). <select id="sel_activity" onchange="selectionchange(this.info)"> <option info="" value="car">car problem</option> <option info="" value="coffee">coffee break</option> <option info="45678" value="inv">inventory count</option> <option info="23567" value="invdrop">inventory</option> <option info="" value="lunch">lunch break</option> <option info="87654" value="meet">meeting</option> </select> . . . function selectionchange(info){ alert(info); } html 5 provides data-* attributes, can define own attribute...

c# - Interface implementation overrides, etc -

here's simplest form of question: iapple requires, among other things, property flavor itoffeeapple requires property flavor the problem is, want itoffeeapple implement iapple (public interface itoffeeapple : iapple), both have same property requirement. becomes problem when, 1 purpose need collection of sweets (only itoffeeapple) itoffeeapple can recognised iapple. is ok use "new" keyword in interface, implementers have 2 flavor properties? have explained myself poorly? :\ edit: have. actual context geometry: iline requires start , end point ipoint. icurve requires start , end point icontrolpoint. icurve functionality on top of iline, yet means want return start , end icontrolpoint rather ipoint, either implement both , have return of both icontropoint , ipoint of start , end, or ignore ipoint/iline , throw dry out window. this elaboration of david culp's answer. it's quite long, i'm not posting comment. while generic interface...

iphone - What is the best way to load a custom UIView? -

in iphone app, made custom uiview use in several different view controllers display information. i'm familiar making customer table cells use in table i've never made custom view again. my question best way load view? i've tried placing view in view controllers want appear in using ib, doesn't seem enough. seems me make sense if set class identity view should load view when view controller created. or maybe doesn't because doesn't know nib (it's in own nib, of course). since it's not view controller, can't use initwithnibname. i've tried using nsbundle loadnibnamed table cells seems awfully large amount of work. code looks this: nsarray *toplevelobjects = [[nsbundle mainbundle] loadnibnamed:@"mycustomview" owner:nil options:nil]; (id currentobject in toplevelobjects) { if ([currentobject iskindofclass:[mycustomview class]]) { self.customview = currentobject; break; } } [self.view addsubview:self.custo...

c# - How to create a control with ValidationGroup and a custom validation? -

i want make panels visibility true or false based on result of func . i have page controls in following code: <asp:panel id="panel2" runat="server"> <asp:panel id="panel3" runat="server"> <c:permissionpanel id="p1" runat="server" validationgroup="val1"> validation group 1 - ok </c:permissionpanel> </asp:panel> </asp:panel> <c:permissionpanel id="p2" runat="server" validationgroup="val1"> validation group 1 - ok </c:permissionpanel> <hr /> <c:permissionpanel id="p3" runat="server" validationgroup="val2"> validation group 2 - ok </c:permissionpanel> <asp:panel id="panel4" runat="server"> <asp:panel id="panel1" runat="server"> <c:permissionpanel id="p4" runat=...

PHP Function that returns an array of values of keys -

i have array this... array ( [0] => array ( [id] => 10651 [userid] => 079eb9f4b9eb573f6aec93ce97ed1e7f ) [1] => array ( [id] => 74315 [userid] => 1283612836 ) [2] => array ( [id] => 74315 [userid] => asydk12893489123 ) ) is there php function returns me array of values of key userid if make call this... func($arr_name, $key_name); regards no, can make one. function getfromkey($array, $keyname) { $return = array(); foreach ($array $value) { if (isset($value[$keyname])) $return[] = $value[$keyname]; } return $return; }

drupal - Passing arguments using drupal_get_form() -

here custom module using hook, assume if want pass argument custom1_default_form function call, how should pass argument? <?php function custom1_block($op,$delta=0){ if($op=='list'){ $block = array(); $block[0]['info']=t('hello world'); return $block; }else if($op=='view'){ $block_content = '<p>this first block</p>'; $block['subject'] = 'hello world'; $block['content'] =drupal_get_form('custom1_default_form'); return $block; } } function custom1_default_form () { $form = array(); $form['nusoap_urls']['txt_name'] = array('#type' => 'textfield', '#title' => t('please enter name'), '#default_value' => variable_get('webservice_user_url',''), '#maxlength' => '40', '#si...