Posts

razor - Is this a bug in WebMatrix PageData? -

i think may have found bug in webmatrix's pagedata, not sure. concerns how pass data partial page calling page. in webmatrix documentation (tutorials, e.g. " 3 - creating consistent look ", , example code), pagedata recommended mechanism pass data between pages (e.g. content page layout page, or partial page). however have found not work other way, pass data partial page calling page. modifying or adding entries in pagedata in partial page, not seem calling page. cutting right down simplest possible example, in test page may have this: @{ pagedata["test"] = "initial entry"; } <p>before calling partial page, test value @pagedata["test"]</p> @renderpage("_testpartial.cshtml") <p>after returning calling page, test value @pagedata["test"]</p> and in _testpartial.cshtml page might have this: @{ pagedata["test"] = "modified entry"; } <p>in partial page...

iphone - Requiring the presence of a method in an id -

the situation my custom controller class has following method: - (void)requestviewcontrollerwithidentifier:(nsstring *)identifier fromobject:(id)object; this causes object receive message: - (uiviewcontroller *)viewcontrollerwithidentifier:(nsstring *)identifier; the problem right now, object id there's no guarantee implements method, , compiler warning when send message. the solution i came 2 solutions myself: use protocol. make id nsobject , create category nsobject . they both fine solutions , don't mind choosing 1 of them, but... the question ...i noticed apple doing odd in gamekit api. gksession has following method: - (void)setdatareceivehandler:(id)handler withcontext:(void *)context handler id , apple requires implement method: - (void) receivedata:(nsdata *)data frompeer:(nsstring *)peer insession: (gksession *)session context:(void *)context; without making use of protocol or category! i'm wondering how , why thi...

Bug Silverlight Intelliscence in VS 2010 does not recognize new controls on page -

silverlight intelliscence in vs 2010 not recognize new controls on page. solution needs built intelliscense recognized newly placed control (textbox label extra) is bug? edit: controls not custom, siple label , textbox , button controls. edit: button toolbox dragged designer, switched home.xml.cs types button1 error, intelliscence doesnot recognize button1 added. must build each time. what solution problem its not bug, feature. custom controls must compiled before can use it.

c++ - Template metaprogramming rules of thumb -

what rules of thumb should considered whenever might use template metaprogramming accomplish goal? , good example using template metaprogramming more efficient plain old code other libraries boost ? one helpful rule can think of have compilation error thrown close "true" problem possible. ways it's easier not deduce issue easier others use library deduce issue. here's contrived version of mean: template<typename type> struct convert{}; template<> struct convert<double>{ static const int value = d_coord; }; template<> struct convert<degree>{ static const int value = angle_coord; }; template<> struct convert<radian>{ static const int value = radian_coord; }; for you'll not salient description of compiler error attempting convert<int> when if had made first declaration forward declaration tell there no type defined "convert." as far example, i'm afraid i'll have defer else. how...

xslt - Is it possible to select a node that just includes a subset of the child nodes? -

i have xpath: //tbody/tr[2]/td/div/table/tbody/tr[2]/td[position() > 1] which gives me first child node. however, gives me nodelist of td notes result. want select parent tr node, first child td node removed. is possible using xpath? xpath query language xml documents. such cannot modify structure source xml document or create new xml document. the task of creating new, modified document cannot done xpath only. this easy accomplish xslt : <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:xs="http://www.w3.org/2001/xmlschema"> <xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> <xsl:template match="tr[2]/td[1]"/> </xsl:...

Suppressing sign-extension when upcasting or shifting in Java -

i have feeling rather trivial question, i'm stumped. in application i'm keying things in lookup table pair of ints. thought easier concatenate 2 ints 1 long , use single long key instead. coming c background, hoping work: int a, b; long l = (long)a << 32 | b; my attempts replicate in java have frustrated me. in particular, because there no unsigned integral types, can't seem avoid automatic sign-extension of b (a gets left-shifted irrelevant). i've tried using b & 0x00000000ffffffff surprisingly has no effect. tried rather ugly (long)b << 32 >> 32 , seemed optimized out compiler. i hoping strictly using bit manipulation primitives, i'm starting wonder if need use sort of buffer object achieve this. i use utility class with public static long compose(int hi, int lo) { return (((long) hi << 32) + unsigned(lo)); } public static long unsigned(int x) { return x & 0xffffffffl; } public static int high(long x)...

Android json parsing -

how parse type of json arrary [{'name':'john', 'age': 44}, {'name':'alex','age':11}] where can't this: jsonarray datalistarray = jobject.getjsonarray("???"); you can use string initialize json array. string json = "[{'name':'john', 'age': 44}, {'name':'alex','age':11}]"; jsonarray json = new jsonarray(json);

Java open-source web framework -

i'm working on project front-end has mobile application or website.i want back-end in java.i want use rest communication between front-end , back-end. question : there java web framework has kind of user management (with maybe webservices login , signup users). example login details can send front-end webservice , see if it's correct etc.. i suggest using grails has rich catalog of plugins, including spring security plugin should require without having write code. if must use java only, spring mvc spring security option.

Java try catch blocks -

here simple question : what think of code use try catch every instruction ? void myfunction() { try { instruction1(); } catch (exceptiontype1 e) { // code } try { instruction2(); } catch (exceptiontype2 e) { // code } try { instruction3(); } catch (exceptiontype3 e) { // code } try { instruction4(); } catch (exceptiontype4 e) { // code } // etc } i know that's horrible, want know if decreases performance. try this: (i know doesn't answer question, it's cleaner) void myfunction() { try { instruction1(); instruction2(); instruction3(); instruction4(); } catch (exceptiontype1 e) { // code } catch (exceptiontype2 e) { // code } catch (exceptiontype3 e) { // code } catch (exceptiontype4 e) { // code } // etc }

Google Maps Save Polygon and points in MySQL using PHP -

right have application allows users draw polygon on google maps. need save polygon using php , mysql i'm unsure of best practices. should enable spatial extensions , save geometry? should save each vertical (lat/lng pair) in array? approach i'm unaware of? i'm wondering best practices are. using mysql spatial extensions seem daunting. returns things in wkt , have parse text make else. seems convoluted. it's best think of usage scenarios when planning out storage layer. this figure out queries you'll want persistence layer optimize for. if you're going handle lot's of queries like, "find me objects within space". may want @ using spatial extensions. however, if of time you're drawing object given id, saving polygons json blob in db may do. create table polygons ( polygon_id int not null, vertices_json varchar(4096) )

How to know which version of ASP.net it is? -

how can know version of asp.net built in looking asp.net project. please list different ways identify version? thank you you need careful approach use here because updates .net framework under asp.net seemingly run under previous version numbers. example; asp.net 2.0 websites might running v2.0 or v3.5 frameworks and asp.net 4.0 websites might running v4.0 or v4.5 frameworks there couple of ways check exact version running, on web page add: <%= system.environment.version.tostring() %> as example; if have v4.0 installed you'll see v4.0.30319.1008 if have v4.5 installed you'll see v4.0.30319.34209 that running version. can check registry installed versions at: hkey_local_machine\software\microsoft\net framework setup\ndp\v4\full within location @ version node. if have v4.0 installated see v4.0.30319 if have v4.5 installated see v4.5.51209

python - Why does os.path.getsize() return a negative number for a 10gb file? -

i using function os.path.getsize() gives size of file in bytes. as 1 file size 10gb give me size in negative(bytes). so can give me idea why happen? this code: import os ospathsize = os.path.getsize('/home/user/desktop/test1.nrg') print (ospathsize) your linux kernel has large file support, since ls -l works correctly. thus, it's python installation lacking support. (are using distribution's python package? distribution it?) the documentation on posix large file support in python states python should typically make use of large file support if available on linux. suggests try , configure python command line cflags='-d_largefile64_source -d_file_offset_bits=64' opt="-g -o2 $cflags" \ ./configure and finally, quoting man page of stat system call : this can occur when application compiled on 32-bit platform without -d_file_offset_bits=64 calls stat() on file size exceeds (1<<31)-1 bits. (i believe l...

algorithm - chain of events analysis and reasoning -

my boss said logs in current state not acceptable customer. if there fault, dozen of different modules of device report own errors , land in logs. original reason of fault may buried somewhere in middle of list, may not appear on list (given module being damaged report), or appear way late after else finished reporting problems result original fault. anyway, there few people outside system developers can interprete logs , come happened. my current task writing module customer-friendly fault-reporting. is, gather events reported on last ~3 seconds (which max interval between origin of fault occurring , last resulting after-effects), magic processing of data, , come 1 clear, friendly line broken , needs fixed. the problem magic part: how, given number of fault reports, come original source of fault. there no simple list of cause-effect list. there commonly occurring chains of events displaying regularities. examples: short circuit detected, resulting in limited operation mod...

redirect - nginx - can't figure out location for / only -

i struggled lot how redirects , stuff when enter www.example.com or www.example.com/ couldn't. location / {} takes cases tried: location ~ ^/?$ {} or location ~ ^/$ {} and many others none worked www.example.com or www.example.com/. please help... need match exact location when enter www.example.com or www.example.com/. thanks! have tried: location = / {}

Finding circular references in VB6 -

i'm trying compile code in vb6, , tells me "circular dependencies between modules." doesn't deign tell me modules have these dependencies. is there way can find more information problem? you have projects form circular chain of references. use menu project , references see other projects references. other projects part of application. draw rough graph of links , @ point find references loop 1 of projects. you need focus on references projects created yourself. need check projects created includes custom activex controls. found under menu project->components. likely find there handful of classes referencing. in case can separate them out activex dll/library , have original projects reference instead of each other. the reason issue arises because com relies type libraries embedded in library call classes , methods. referenced libraries included in typelib in manner similar include file in c. circular references have no "bottom" com can...

c++ - Creating an object on the heap without new -

in c++, possible create object on heap without using new or malloc ? i think if use stl container vector put on heap. if do: vector<object> listobjs = vector<object>(); object x = object(...); ... listobjs.push_back(x); where objects created here reside? the object denoted x resides on stack. vector::push_back copy heap. the allocator object inside vector implemented using new or malloc , although possible uses another, low-level api. instance, both unix , windows offer memory mapping apis, in turn may used implement malloc , new , allocators.

What else i can use instead of class for Jquery selector? -

for buttons using class assigning css classes. have define selector those. know can use class jquery selector else can use , how ? they rendered input not buttons. <asp:button id="imgbtnturkish" onmouseover="this.style.cursor='pointer';" class="defaulttitle" title="turkish spoken chat section" runat="server" onclick="btnturkishchat_click" causesvalidation="false" /> there many jquery selectors choose from. 1 possibility select button wrap in div element given class: <div class="defaulttitle"> <asp:button id="imgbtnturkish" onmouseover="this.style.cursor='pointer';" title="turkish spoken chat section" runat="server" onclick="btnturkishchat_click" causesvalidation="false" /> </div> and use following selector: $('.defaultti...

Key to maxima of dictionary in python -

i have dictionary, "scores", of integers , want find key(s) of highest value. used code: key = max(scores, key=scores.get) however, gives 1 key. how deal ties in highest value? 1 number back. in case of tie? how can keys highest value? help. you run following, example: max_value = max(scores.values()) keys = [ (i,v) in scores.iteritems() if v == max_value ] "keys" hold keys correspond maximum value.

formatting - Enable grow of cross tab in crystal report -

i using cross-tab object in crystal report. having problem making data column (field row) increase dynamically in height when data size increases. since "can grow" property in format editor disabled, not let me set "can grow" true enable function. how enable "can grow" function can set true? i ran similar problem row labels did not wrap. sadly, think best solution increase height of "data" row field (probably bottom row). fix height rows means text in rows able wrap @ same height. i going post image don't have rep.

php - Website with optimal cache control -

my goal let browsers cache whole website, download static content when have changed 1 or more files. my situation after research have found way this. add far future expires header htaccess file , add querystring files using filemtime() function. the problem when click on address bar , type in website address in firefox, firebug displays 38.3 kb (36.4 kb cache) when press f5 in firefox, firebug displays: 241.1 kb (10.9 kb cache) now have tried same google , sending http header 304 back. have read lot etag , last modified header, have heard lot of people saying not reliable. my question best solution if send http header 304 static content if user presses on f5, google? i asking question because visiting website , using f5 see if there new information available. not reload images etcetera. update seems firefox controlling way cache used , use cache when user presses f5. the purpose of reload reload page. there no server-side header magic if browser witten...