Posts

Showing posts from May, 2011

Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

How can I fetch data from a website inside a C++ program -

i want write program in c++ helps manage hockey pool, , 1 of key things need read off schedule week ahead. hoping use nhl website. there way have program download html file given url, , parse that? suppose once have file downloaded, simple file i/o do, im not sure how download file. i use library providing http abstraction. for example: cpp-netlib #include <boost/network/protocol/http/client.hpp> #include <string> #include <iostream> int main() { boost::network::http::client client; boost::network::http::client::request request("http://www.example.com"); request << boost::network::header("connection", "close"); boost::network::http::client::response response = client.get(request); std::cout << body(response); } i not think can easier that on gnu/linux compile with: g++ -i. -i$boost_root -l$boost_root/stage/lib -lboost_system -pthread my_main.cpp qhttp example quite long, since

algorithm - 2-3 trees, data storage -

hello i'm trying understand how 2-3 trees work, understood concept keys, store data itself, in leaves, or in nodes 1 key (internal node), , 2 keys (internal node) also, in advance i'm no expert on tree structure first sentence wikipedia page on 2-3 trees seems answer question data stored: a 2-3 tree in computer science type of data structure, tree every node children (internal node) has either 2 children , 1 data element (2-nodes) or 3 children , 2 data elements (3-nodes). seems me store data in each node of tree. wiki page has link java applet demonstrating inserts . edit: after reading comment, , having sample code, i'm inclined think data , key (as calling it) same thing (as chowlett has mentioned in answer). looking @ sample code (they storing ints) create twothreenode class holds pointers data storing, ensuring data class has overloaded comparison operators allow them sorted. follow algorithm before. i found interesting article,

parsing - Why does C++ not allow user-defined operators? -

i've been wondering quite time. there whole bunch of them , can overloaded, why not end , allow custom operators? think great addition. i've been told make language hard compile. makes me wonder, c++ cannot designed easy compilation anyway, undoable? of course, if use lr parser static table , grammar such e → t + e | t t → f * t | f f → id | '(' e ')' it wouldn't work. in prolog, parsed operator-precedence parser afaik, new operators can defined, language simpler. now, grammar rewritten accept identifiers in every place operator hard-coded grammar. what other solutions , parser schemes there , other things have influenced design decision? http://www2.research.att.com/~bs/bs_faq2.html#overload-operator the possibility has been considered several times, each time i/we decided problems outweighed benefits. it's not language-technical problem. when first considerd in 1983, knew how implemented. however, experience has been wh

Nullable<T> for generic method in c#? -

how can write generic method can take nullable object use extension method. want add xelement parent element, if value used not null. e.g. public static xelement addoptionalelement<t>(this xelement parentelement, string childname, t childvalue){ ... code check if value null add element parent here if not null ... } if make addoptionalelement<t?>(...) compiler errors. if make addoptionalelement<nullable<t>>(...) compiler errors. is there way can acheive this? i know can make call method: parent.addoptionalelement<mytype?>(...) but way? public static xelement addoptionalelement<t>( xelement parentelement, string childname, t? childvalue) t : struct { // ... }

When I move a Wordpress custom option menu to the top level it stop saving input settings? -

this code adds menu in settings section of wordpress' administrator right add_options_page declared, custom menu appears inside settings i changed add_options_page add_menu_page in order bring menu top-level, stopped working (when click custom menu opens, can't save settings anymore). what's remaining code have change in order make work? thanks in advance! <?php add_action('admin_menu', 'create_theme_options_page'); add_action('admin_init', 'register_and_build_fields'); function create_theme_options_page() { add_options_page('theme options', 'theme options', 'administrator', __file__, 'options_page_fn'); } function register_and_build_fields() { register_setting('plugin_options', 'plugin_options', 'validate_setting'); add_settings_section('main_section', 'main settings', 'section_cb', __file__); add_settings_field('color_sch

cocoa - NSWindow Content Border messing with CALayer's geometry -

i have nswindow 32px bottom content border. inside window's view, have 2 custom subviews. each of them layer backed, , i'm tracking mouse nstrackingarea. part of i'm doing mouseover effects coreanimation. not problem in general, noticed kind of strange , wondered if knows why happening. when setting trackingarea , mouseover method, hittest root layer , log layer's name can see if geometry of various sublayers hold water when resize window. internally, seem (and look) fine. visually, in right place, when move mouse, notice though mouse physically on layer, hittest returning whatever layer 32 px above it. however, if remove content border, works expect , correct layer returned. i need content border, have simple workaround involves offsetting hittest point 32px. works fine, seems weird presence of content border seems skewing co-ordinate system of these subviews. know why happening? nsevent returns mouse locations relative window's coordinate system,

javascript - Rewriting one part of a URL into a link -

i trying 1 part of url insert another. url in address bar read domain.com/test.php?/12345 link in page must become domain.com/do/login/12345 (this end number change every user) (note can't change url domain.com/test.php?/12345 has been set site owner.) for urls above had remove http://www . part above new user can't submit more 1 link spam prevention. final script should include http://www . you able see need number @ end ie 12345 i'm not sure how achieve (javascript beginner). have far: <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>path test</title> </head> <body> <script> // url eg http://www.domain.com/test.php?/12345 newurl = window.location.protocol +

JQuery - Document width/height - Different values from different browsers -

var maskwidth = $(window).width(); alert(maskwidth); i 1263 chrome , firefox (which 1280 in fact, scroll write less value). ie print 1259. how can fix problems jquery? $.clientcoords = function(){ if(jquery.browser.msie){ return { w:document.documentelement.offsetwidth, h:document.documentelement.offsetheight } } else return {w:window.innerwidth, h:window.innerheight} } this function returns height , weight of browser or current window

performance - Efficient number reading in Haskell -

i'm looking efficient way read numbers text file without installing additional packages . data.bytestring.lazy.char8.readint seems trick integers. i've read bytestring has readdouble method, when write import data.bytestring.lex.lazy.double (readdouble) compiler complains: main.hs:4:7: not find module `data.bytestring.lex.lazy.double': locations searched: data/bytestring/lex/lazy/double.hs data/bytestring/lex/lazy/double.lhs my bytestring package version 0.9.1.5. so, doing wrong? or maybe there better solution problem? thanks. update: ok, seems readdouble in package bytestring-lexer not installed default. other idea? the time encountered parsing doubles on critical path, used this: {-# language foreignfunctioninterface #-} import qualified data.bytestring.char8 b import foreign.c.types import foreign.c.string import system.io.unsafe foreign import ccall unsafe "stdlib.h atof" c_atof :: cst

iphone - How to post on Facebook wall without opening Dialog? -

i trying integrate facebook in app. had done code login , trying post on wall don't need facebook dialog. want own. after googling found code not working. not giving error not posting thing... here using : nsmutabledictionary* params = [nsmutabledictionary dictionarywithobjectsandkeys: @"facebook developer test message",@"message", @"test it!",@"name", nil]; facebook *fb = [[facebook alloc] init]; [fb requestwithgraphpath:@"me/feed" // or use page id instead of 'me' andparams:params andhttpmethod:@"post" anddelegate:self]; its not working.. fbstreamdialog *dialog = [[[fbstreamdialog alloc] init] autorelease]; dialog.usermessageprompt = @"enter message:"; dialog.attachment = [nsstring stringw

jQuery autocomplete: How to show an animated gif loading image -

i'm using jquery autocomplete plugin combined ajax. know how can show progress indicator while ajax search performed? this current code. <script type="text/javascript"> $("#autocomplete-textbox").autocomplete('http://www.example.com/autocomplete/findusers'); </script> <div> <input type="text" id="autocomplete-textbox" /> <span class="autocomplete-animation"><img id="ajaxanimation" src="../img/indicator.gif")"/></span> </div> the findusers url returns user list in content. autocomplete adds ui-autocomplete-loading class (for duration of loading) can used this... .ui-autocomplete-loading { background:url('img/indicator.gif') no-repeat right center }

javascript - RegEx question - HTML tag content -

i want replace "i" character in <body> "i" javascript. (for example: <div id="123">hi! it!</div> should change <div id="123">hi! it!</div> ). know must use regular expressions. don't know should write. can me? .. i answered similar question may you: jquery/javascript - search dom text , insert html for particular case, can simplify. update i've added filter parameter allow filter out descendants of particular nodes. should function takes single dom node parameter , returns boolean: true replace text within node , descendants , false ignore node , descendants. function replacetext(node, regex, replacementtext, filter) { if (node.nodetype == 3) { node.data = node.data.replace(regex, replacementtext); } else if (!filter || filter(node)) { var child = node.firstchild; while (child) { replacetext(child, regex, replacementtext, filter);

iphone - Can I cancel the method "applicationDidEnterBackground? -

i wanted cancel method, request confirmation user when presses button "home" on iphone go execution in background. if user accepts, enters execution in background, if not accept, not anything. i looked in forum, in documentation apple , found nothing. could me? thanks in advance! no can't override this. event fire give time clean before move background. your delegate’s applicationdidenterbackground: method has approximately 5 seconds finish tasks , return. in practice, method should return possible. if method not return before time runs out, application terminated , purged memory. if still need more time perform tasks, call beginbackgroundtaskwithexpirationhandler: method request background execution time , start long-running tasks in secondary thread. regardless of whether start background tasks, applicationdidenterbackground: method must still exit within 5 seconds ios application programming guide

Using JavaScript to perform a GET request without AJAX -

out of curiosity, i'm wondering best (easiest, fastest, shortest, etc; make pick) way perform request in javascript without using ajax or external libraries. it must work cross-browser , it's not allowed distort hosting web page visually or affect it's functionality in way. i don't care headers in request, url-part. don't care result of request. want server side effect when receives request, firing matters. if solution requires servers return in particular, that's ok well. i'll post own suggestion possible answer, love if find better way! have tried using image object? like: var req = new image(); req.onload = function() { // not required if you're interested in // making request , don't need callback function } req.src = 'http://example.com/foo/bar';

version control - Tool which monitors file changes and uploads only changed files over ftp to webserver -

is there tool(for windows) can monitor file changes , can upload modified files on ftp webserver directory. smartftp 1 such tool has synchronization feature... http://www.smartftp.com/features/

c# - Binding Combobox SelectedItem by a field's value -

combobox bind set of provinces , village object has provinceid field , want bind selecteditem of combobox province village's provinceid. my code is: <combobox itemssource="{binding provinceslist}" displaymemberpath="provincename" selectedvaluepath="provinceid" selectedvalue="{binding village.provinceid}" /> but selecteditem anything. your binding direction oneway , bindingengine of sl can't propagate ui changes object's property, hence must add mode=twoway @ end of binding expression.

Unicode library for creating/parsing Json documents (C++) -

this question has answer here: is there c++ library read json documents c++ objects? [duplicate] 4 answers i trying find unicode library creating/parsing json documents on c++. json documents come http protocol .net application's system.string objects. found libjson , nosjob . sources can manipulate unicode strings. of them more stable? did use 1 of them? or recommend one? please me choose;) thank much!!! you have @ json spirit: c++ json parser/generator implemented boost spirit

Explanation of Azul's "pauseless" garbage collector -

i've read this: http://www.artima.com/lejava/articles/azul_pauseless_gc.html although i've experience compilers, i've done nothing related garbage collection; big black box me. i've struggled understand issues mentioned article. understand problem (there's pause when executing garbage collectors), , understand claim implementation doesn't have problem. don't understand why/how problem happens in first place (that seems assumed understood on original text), , in consequence don't why solution might work. can explain me: why garbage collectors have pause in general why azul's gc doesn't have problem? i tend understand kind of things better when explained graphically - small memory schema done code editor suffice. thanks! they talk pause inevitably occurs when compacting heap. see, when allocate , deallocate lots of objects of different sizes go, fragment heap (much fragment harddrive). when fragmentation becomes extrem

com - How can I find out more about my classic ASP environment? -

i'm trying make modifications old asp pages running vbscript on server don't have lot of information about. people have information off in department/hard track down/probably wouldn't able provide complete information anyway. i run asp script server tell me itself. information know stuff like: the version number of server version of windows running on the version of vbscript using what dll's , com objects available me use bearing in mind know little asp, code put asp file run on server provide me information? based on servervariables clue provided in comment jb king, below, wrote code , put in asp: <% dim x each x in request.servervariables response.write("<p>" & x & ": " & request.servervariables(x) &"</p>") next %> this provided lot of information needed - such telling me i'm running under called chili!soft on solaris server, not windows, explains why stuff

java - Calling Button from different view in Android -

in app have 3 radiobuttons on top of view. when choose 1 'body' underneath changes xml-view defined. (if want more information + pics, asked question earlier: dynamically change view inside view in android ) now want call , change text of buttons , edittext's different views. when btnautopech = (button) findviewbyid(r.id.btnautopech); it's gives nullpointerexception. how can this? try this....... layoutinflater layoutinflater = (layoutinflater) this.getsystemservice(context.layout_inflater_service); linearlayout ll= new linearlayout(context); ll=(linearlayout)layoutinflater.inflate(r.layout.gegevens_verzekeringen, ll); btnautopech = (button) ll.findviewbyid(r.id.btnautopech); thanks.........

Android: Multiple TabActivities problem -

i have lost 2 days in problem, please provide can. have android application displays 2 android activity icons: "comp 1" , "comp 2". both "comp 1" , "comp 2" shows tabactivities tabs within. problem: right after deploying application, can enter of "comp 1" or "comp 2" tabactivity, when leave activity , when try enter other tabactivity, tabs shown same previous 1 "comp 1" or "comp 2" depends on start first. objective: of "comp n", open correctly tabs assigned on tabactivities(see code on post). please, allow me show code. show androidmanifest.xml, tabactivity "comp 1" , tabactivity "comp 2". they're bit extensive, apologize in advance , unnecessary info may contain. didn't want take risk forget provide important information on first post. androidmanifest.xml ("comp 1"=mmcomponenttabassembler, "comp 2"=tabassembler) <manifest xmlns:android

c++ - How to pass a deleter to a method in the same class that is held by a shared_ptr -

i have several classes 3rd party library similar class, stagingconfigdatabase, requires destroyed after created. using shared_ptr raii prefer create shared_ptr using single line of code rather using seperate template functor example shows. perhaps using lambdas? or bind? struct stagingconfigdatabase { static stagingconfigdatabase* create(); void destroy(); }; template<class t> struct rfadestroyer { void operator()(t* t) { if(t) t->destroy(); } }; int main() { shared_ptr<stagingconfigdatabase> psdb(stagingconfigdatabase::create(), rfadestroyer<stagingconfigdatabase>()); return 1; } i considering like: shared_ptr<stagingconfigdatabase> psdb(stagingconfigdatabase::create(), [](stagingconfigdatabase* sdb) { sdb->destroy(); } ); but doesn't compile :( help! i'll assume create static in stagingconfigdatabase because initial code wouldn't compile wit

jsp - javax.faces.FacesException: java.lang.RuntimeException: Cannot find FacesContext -

i'm trying simple project work on jboss, i'm stuck @ error (i tried using .jsf on url). application in tomcat work's fine javax.servlet.servletexception: java.lang.runtimeexception: cannot find facescontext javax.faces.webapp.facesservlet.service root cause javax.faces.facesexception: java.lang.runtimeexception: cannot find facescontext org.apache.myfaces.context.servlet.servletexternalcontextimpl.dispatch(servletexternalcontextimpl.java:425) org.apache.myfaces.application.jsp.jspviewhandlerimpl.renderview(jspviewhandlerimpl.java:211) org.apache.myfaces.lifecycle.renderresponseexecutor.execute(renderresponseexecutor.java:41) org.apache.myfaces.lifecycle.lifecycleimpl.render(lifecycleimpl.java:132) javax.faces.webapp.facesservlet.service(facesservlet.java:140) org.jboss.web.tomcat.filters.replyheaderfilter.dofilter(replyheaderfilter.java:96 my web.xml <?xml version="1.0" encoding="utf-8"?> <web-app xmlns="http://java.su

ajax - Automatic embeded script -

i have free website on 000webhost. problem automatically puts analytics code in files. not show everywhere causes me problem when use ajax calls , display returned data in div, displays data particular code. there type of method avoid or make code invisible. when used google webmaster tools, when crawls robots.txt file code shown crawler on file text file , returns error. please help! here link website: portfolio your hosting provider seems inject following line @ end of requests: <!-- www.000webhost.com analytics code --> <script type="text/javascript" src="http://analytics.hosting24.com/count.php"></script> <noscript><a href="http://www.hosting24.com/"><img src="http://analytics.hosting24.com/count.php" alt="web hosting" /></a></noscript> <!-- end of analytics code --> the injection point of code @ end of request. when checked, meant outside html tag (and broke ht

php - Login with Google OpenID or other providers -

i trying figure out how openid works, therefore trying write own simple class web app uses google openid. i wondering if there examples know, or can find details can implement own class. i not looking general class. need me write own implementation. i have made experiences lightopenid ( gitorious download ). unlike 2 other openid libraries tried php, easy use, has no external dependencies, compatible php5 , has no warnings. there example using google . and display buttons in html page: http://code.google.com/p/openid-selector/

c# - evaluating else if after an if condition is true -

consider snippet: private void button1_click(object sender, eventargs e) { if (textbox1.maxlength > 0) { textbox2.text = convert.toboolean(math.sqrt(textbox1.maxlength)).tostring(); } else if (textbox1.maxlength < 32768) { textbox2.text = convert.toboolean(math.sqrt(textbox1.maxlength)).tostring(); } } why not evaluating second condition (the lesser condition)? it's true, isn't it? if have make second 1 work in same condition, minor change must made? else if checked if first condition isn't satisfied. if want both of them true, should do if(textbox1.maxlength > 0 && textbox1.maxlength < 32768) { // stuff here }

WPF: Color under the pointer -

i have control gradiant background. on mousedown or mouseup event want capture color pixel immeidately under mouse pointer. how that? i created behavior can attached image object grab color, 100% wpf. here behavior; tweaked work "visual", not image. [note: hardcoded 96dpi creation of rendertargetbitmap... milage may vary] using system.componentmodel; using system.windows; using system.windows.controls; using system.windows.input; using system.windows.interactivity; using system.windows.media; using system.windows.media.imaging; namespace company.solution.project.utilities.behaviors { [description("used sample color under mouse image when mouse pressed. ")] public class imagebehaviormousedownpointsampletocolor : behavior<image> { public static readonly dependencyproperty selectedcolorproperty = dependencyproperty.register("selectedcolor", typeof(color), typeof(

iphone - How can I add an image to the back of a CALayer after rotate 90 degrees? -

Image
i want add image calayer when rotation transform degree higher 90. it flipboard flip animation. this current code: calayer *layer = self.view.layer; int frames = 130; layer.anchorpoint = cgpointmake(0, 0.5); catransform3d transform = catransform3didentity; transform.m34 = 1.0 / -2000.0; transform = catransform3drotate(transform, -frames * m_pi / 180.0, 0.0, 1.0, 0.0); self.view.layer.transform = transform; cakeyframeanimation *pivot = [cakeyframeanimation animationwithkeypath:@"transform"]; nsmutablearray *values = [[nsmutablearray alloc] initwithcapacity:45]; nsmutablearray *times = [[nsmutablearray alloc] initwithcapacity:45]; (int = 0; < frames; i++) { catransform3d transform = catransform3didentity; transform.m34 = 1.0 / -2000.0; transform = catransform3drotate(transform, -m_pi / 180.0 * i, 0.0, 1.0, 0.0); [values addobject:[nsvalue valuewithcatransform3d:transform]]; [times addobject:[nsnumber numberwithfloat:(float)i / (frames

c# - Reflection methods fail when types are in other assembly -

i'm making little tool analyze code dependencies recursively. found problem: if try member of class signature contains reference dll method fails. example, if have simple class in main.exe public class mainclass { public mainclass () { foo(); } public containedclass getpublicclass () { return new containedclass (); } } and containedclass defined in other file refers.dll, when try following code throw filenotfoundexception in met3.returntype() method cause .net not find refers.dll. assembly assem = assembly.loadfile(@"d:\dir\main.exe"); type typ = assem.gettype ("multiplereference.mainclass"); methodinfo met3 = typ.getmethod ("getpublicclass"); met3.returntype.tostring (); is there way indicate search dll? thanks in advance , sorry english. use loadfrom instead of loadfile because resolve , load dependent assemblies. quoting documentation: use loadfile method load , examine assembli

asp.net mvc - Convert Json response to HTML Table -

how display points in json return statement html table on view? return json( new { vol = exposure.volatility, points = point in exposure.exposurepointcollection select new { date = point.exposuredate, val = point.maximumexposure } }); if result of ajax call, need iterate on collection (presumably "points" value) , add them dom via javascript. jquery can this, there plug-ins jquery virtually of work you, jqgrid comes mind. looping through json result (assuming "points" looping over) success: function(data){ jquery.each(data.points, function(index, value){ //index index of array, value actual value }); } look here using jquery modify dom: http://api.jquery.com/html/#html2

sql - How to display a day from the Date -

using sql server 2005 table1 date 19-12-2009 20-12-2010 ..... date column datatype datetime . expected output monday tuesday how make query getting day... you can use datename function. select datename(weekday,[date]) table1

iphone - how to load nsnotification text from an array -

i wondering how possible load text displayed in nsnotifcation using array? want message shown in notification loaded array , not fixed text value. not sure question asking, if have nsstring object in array, can access using: nsstring *yourmessagestring = [yourarray objectatindex:0]; for example. edit: set alert message message in array, this: uialertview *alert = [[uialertview alloc] initwithtitle:@"your title" message:[yourarray objectatindex:0] delegate:self cancelbuttontitle:@"ok" otherbuttontitles:nil]; [alert show]; [alert release];

image magick php, install -

does image magick come bundled php? if how enable it, if not , have integrate it. many thanks default not bundled php, need install extension. maybe you: http://php.net/manual/en/imagick.setup.php btw search imagick, php , os , find how install.

asp classic - use response write to make a link -

i have urlcolumn , title column , want link automatically made in asp <td><%response.write(<a href="rs.fields.item("urlcolumn")target=_"blank">rs.fields.item("titlecolumn")</a>)%></td> at minimum, need quote output value response.write work, i.e. <td><%response.write("<a href='" + rs.fields.item("urlcolumn") + "' target='_blank'>" + rs.fields.item("titlecolumn") + "</a>")%></td> edit (updated code sample). edit #2 - make sure clean input going these links. creating links way makes vulnerable xss attack (especially since href attribute can execute javascript).

jquery autocomplete - can it be set up so that the drop down shows up on focus? -

possible duplicate: jquery autocomplete ui- i'd start search onfocus without user having type anything i noticed question jquery autocomplete ui- i'd start search onfocus without user having type anything . i have same question , same problems solution. basically, i'm trying force jquery autocomplete ui execute on focus , not require user press key or enter value. thanks what version of jqueryui using? according documentation autocomplete, way referenced should work: ("search" method documentation) ...if no value argument specified, current input's value used. can called empty string , minlength: 0 display items. i've posted example here works me in ff/chrome: http://jsfiddle.net/andrewwhitaker/b38hj/ . let me know if see weird behavior. $("input").focus(function() { $(this).autocomplete("search"); }); the example uses jquery ui 1.8.5 , jquery 1.4.4.

ASP.Net MVC, Dynamic Property and EditorFor/LabelFor -

i using mvc 3 w/ razor , using new dynamic viewbag property. use viewbag property editorfor/labelfor html helpers can't figure out syntax. the view have @model set, object trying use not part of model. aware can create viewmodel not after. can help? controller: var mymodel= _repo.getmodel(id); var newcomment = new comment(); viewbag.newcomment = newcomment; return view(mymodel); view: @model models.mymodel @(html.editorfor(viewbag.newcomment.comment)) i haven't tried it, should work think. @(editorfor(m => viewbag.newcomment) it possible use linq-to-sql syntax, use different object on right side.

asp.net - How do I apply date formatting and add attributes to a textbox in MVC3? -

in application, want dates display in mm/dd/yyyy format , want text box limited 10 characters , have class applied it. to end, made custom editor template date looks this: @modeltype system.nullable(of datetime) @html.textboxfor(function(d) d, new {.class="polkdate", .maxlength="10"}) then in view can call @html.editorfor(function(m) m.somedate) , works pretty well. however, because i'm using textboxfor , doesn't respect displayformat attribute that's applied model class (i.e. it's spitting out time instead of formatting date). i love use editorfor respect formatting want, can't add attributes class , maxlength. tried using plain old textbox helper, don't know how make generate correct id model binding still works. anybody know way make happen? don't feel want here outlandish. this appears trick: @modeltype date @if date.minvalue.equals(model) @html.textbox("", nothing, new {.class="polkda

wpf - MVVM and Databinding with UniformGrid -

i'm trying style of wpf chart rectangles. i'm using mvvm, , need rectangles uniformly sized. when defined via xaml, works fixed "bucketcount" of 4: <visualbrush> <visualbrush.visual> <uniformgrid height="500" width="500" rows="1" columns="{binding bucketcount}"> <rectangle grid.row="0" grid.column="0" fill="#22add8e6" /> <rectangle grid.row="0" grid.column="1" fill="#22d3d3d3"/> <rectangle grid.row="0" grid.column="2" fill="#22add8e6"/> <rectangle grid.row="0" grid.column="3" fill="#22d3d3d3"/> </uniformgrid> </visualbrush.visual> <visualbrush> how can bind observablecollection of rectangles? there no "itemssource" property on uniformgrid. need use itemscontrol? if so, how can this? thanks in advance.

c++ - Is it possible to specify that an options is required with boost::program_options? -

i can use other public members of class typed_value define in value_semantic.hpp such as: default_value, implicit_value, zero_tokens, multitoken, notifier, etc. but if member "required()" there, cannot use it. i got error: ‘class boost::program_options::typed_value<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, char>’ has no member named ‘required’ any ideas? is boost version maybe old? found required() in docs 1.45, not in ones 1.34 - don't know when changed.

C#: How to embed DLL into resourcefile (no dll copy in program directory) -

i have c# application (project a) requires x.dll. have added project produces x.dll reference in visual studio. have added release build of x.dll resource file in binary. have told project not copy x.dll output directory. now want a.exe load, "hey can't find file", in resource file , use assembly.load(byte[]) x.dll back. have code re-magicifies dll back, code never called. currently have bone simple project, trying work. compile ok. when run it, filenotfoundexception on x.dll. i have: [stathread] static void main() { appdomain.currentdomain.assemblyresolve += new resolveeventhandler(currentdomain_assemblyresolve); } but breakpoint in *currentdomain_assemblyresolve* never gets hit. filenotfoundexception immediately. surely there missing? this question seems similar trying achieve, , worked asker. merge .dll c# assembly? are doing differently? specifically, if you're targetting older version of .net framework, maybe that's hint unders

jackrabbit - How to intercept server restart for GWT-based application? -

i develop web-application uses gwt clients , jcr (jackrabbit) persistence. maven gwt plug-in (mvn gwt:run) launches ui communication between clients , server tracked. ui provides option restart server. i'd intercept server restart event , perform actions repository.shutdown() before server goes restart. is there way register handler , define action such server events? you can implement servletcontextlistener. contextdestroyed() method trigger when context shut down.

c# - Truncating a byte array vs. substringing the Encoded string coming out of SHA-256 -

i not familiar hashing algorithms , risks associated when using them , therefore have question on answer below received on previous question . . . based on comment hash value must, when encoded ascii, fit within 16 asci characters, solution first, choose cryptographic hash function (the sha-2 family includes sha-256, sha-384, , sha-512) then, truncate output of chosen hash function 96 bits (12 bytes) - is, keep first 12 bytes of hash function output , discard remaining bytes then, base-64-encode truncated output 16 ascii characters (128 bits) yielding 96-bit-strong cryptographic hash. if substring base-64-encoded string 16 characters fundamentally different keeping first 12 bytes of hash function , base-64-encoding them? if so, please explain (provide example code) truncating byte array? i tested substring of full hash value against 36,000+ distinct values , had no collisions. code below current implementation. thanks (and clarity) can provide. public stati

python - Find large number of consecutive values fulfilling condition in a numpy array -

i have audio data loaded in numpy array , wish segment data finding silent parts, i.e. parts audio amplitude below threshold on a period in time. an extremely simple way this: values = ''.join(("1" if (abs(x) < silence_threshold) else "0" x in samples)) pattern = re.compile('1{%d,}'%int(min_silence)) match in pattern.finditer(values): # code goes here the code above finds parts there @ least min_silence consecutive elements smaller silence_threshold. now, obviously, above code horribly inefficient , terrible abuse of regular expressions. there other method more efficient, still results in equally simple , short code? here's numpy-based solution. i think (?) should faster other options. it's clear. however, require twice memory various generator-based solutions. long can hold single temporary copy of data in memory (for diff), , boolean

Flow control in JavaScript -

is possible write flow control in javascript? mylib.get = function() { /* */ next(); }; mylib.save = function() { /* */ next(); }; mylib.alert = function() { /* */ next(); }; mylib.flow([ mylib.get(), mylib.save(), mylib.alert() ], function() { // functions executed }); yes, 2 things know: you should build array references functions. means leave off () , because want pass through reference, not result of calling function! you're going have deal fact getting references functions properties of object not "remember" relationship object. thus, "flow" code have no way know how invoke functions "mylib" this context reference. if that's important, you'll want create functions run "member" functions in right context. to run functions in right context, can cobble "bind" function supplied prototype framework (and also, among many others, functional.js), or $.proxy() jquery. it's not hard , this:

iphone - PDF Table of Contents Parsing with iOS Quartz 2D -

this question has been asked before, know. however, nobody has answered well. i'm wondering how parse pdf's "table of contents" on iphone. docs tell me use cgpdfdocumentgetcatalog not how use it. returns dictionary. also, can't find example code. suggestions? looks closest thing seen on create table of contents pdf file

wpf - Can I attach a property to a viewmodel -

i have view...and view-model associated it. in view...i have 2 list views..and 2 add/remove buttons between these list views. i have seperate view-model add/remove dual list-view. in parent view-model..i assigning dualist view-model data context dual list view. my question is...can have attached/dependency property in parentview model...which connect dual listviewmodel ... know selected item in 1 of dual listview ?

c# - Is it possible to define a one-off user control in the ASPX codebehind? -

one of big beefs asp.net makes difficult organize controls of page beyond excessive amounts of prefixing ids. have gone great , complicated lengths in past try alleviate this, solution easier implement. so, i'm wondering: is possible define user control in codebehind of .aspx, , use in .aspx? i'm thinking not... can't work. no. must create user control in it's own .ascx file. though if wish wish create web control, can define in whichever .cs/.vb file want. though sake of coworkers being able find code, might suggest live in it's own file anyways. note: question validity of "it difficult organize controls of page beyond excessive amounts of prefixing ids". templated controls (repeater, datalist, etc) for. implement inamingcontainer , enable name controls same name, different scope. there's info here ...

.net - Kind of applications that can be based on dotnet framework alone -

i intend web application , host it. since have knowledge in asp.netand c#, decided develop using dotnet. i not sure licencing microsoft dotnet. my question : is possible use dotnet framework free , use mysql backend develop webapplication , host without buying licence ? if editor can use develop application ? pls suggest me ideas. thanks. you don't need runtime licenses @ unless use sql server. for development, can use free visual web developer express edition.

How can you emulate object serialization on java in C# -

i need call servlet call automation of java applet using c#. java applet calls servlet using url connection object. url servlet = new url(servletprotocol, servlethost, servletport, "/" + servletname); urlconnection con = servlet.openconnection(); con.setdooutput(true); objectoutputstream out = new objectoutputstream(con.getoutputstream()); // write several parameters strings out.writeobject(param[0]); out.writeobject(param[1]); out.flush(); out.close(); the problem need simulate using c#. believe counterpart object httpwebrequest httpwebrequest myrequest = (httpwebrequest)webrequest.create(servletpath); myrequest.method = "post"; myrequest.contenttype="application/x-www-form-urlencoded"; myrequest.contentlength = data.length; stream newstream=myrequest.getrequeststream(); // send data. newstream.write(param[0],0,param[0].length); newstream.write(param[1],0,param[1].length); newstream.close(); how write string serialized java string? there worka

iPhone Best practices for large number of animations using UIImageView -

just requesting little advice animating images on iphone. i'm building app consists of character 5 animations. each animation consists of 50 images average duration of 3 seconds. i going create array of images each animation, have these source uiimageview , switch these needed. can guess approach kills iphone's memory , app. (250 images @ 130k each!) so got me wondering how other people around this? maybe change animations movies? thanks advice. i'd recommend movie route, if can away it. it'll cleaner , more performant. however, if you're stuck images reason, here's performance loading 5000 full-frame images in succession: [uiimage imagewithdata:...] // 44.8 seconds [uiimage imagewithcontentsoffile:...] // 52.3 seconds [[uiimage alloc] initwithcontentsoffile:…] // 351.8 seconds [uiimage imagenamed:...] // hung due caching

iphone - How to Create a Multiple Question? -

i need retrieve 6 questions plist , check answer if correct plist itself?? i use qr code scanner api scan answer, api covert string , read plist check if answer correct... there tutorial or references me @ ?? in plist there is: question ~ dictionary following strings: numberofoption ~ define if question multiple choice or qr code question question ~ question answer ~ answer option 1 ~ 4 ~ if multiple choice question thanks in advance answering questions, appreciated it cheers desmond use following code read data array of dictionaries (assuming plist in main bundle) // path plist (in application bundle) nsstring *path = [[nsbundle mainbundle] pathforresource: @"questionarray" oftype:@"plist"]; // build array plist nsmutablearray *qarray = [[nsmutablearray alloc] initwithcontentsoffile:path]; you can iterate on questions like: // iterate questions (nsdictionary *dic in qarray) { //perform reading of 'numberofoption' et

Why can't I update these custom fields in Salesforce? -

Image
greetings, bewildered. have been tasked updating php script uses bulkapi upsert data opportunity entity. this going except bulk api returning error defined custom fields: invalidbatch : field name not found : cv__acknowledged__c and similar. i thought found problem when discovered wsdl version using quite old (partner wsdl). promptly regenerated wsdl. problem? enterprise, partner, etc....all of them...do not include these fields. they're coming common ground package , start cv_ i tried find them in object explorer in workbench schema explorer in force.com ide. so, please...lend me experience. how can update these values? thanks in advance! clif screenshots prove have correct access: edit -- here code: require_once 'soapclient/sforcepartnerclient.php'; require_once 'bulkapiclient.php'; $mysforceconnection = new sforcepartnerclient(); $mysoapclient = $mysforceconnection->createconnection(app.'plugins

graphics - Constructing images in C# WPF/MVVM (drawing lines, arcs, text) -

in wpf standalone-application need draw image based on series of 'commands' such "text @ position x,y" , "draw line x1,y1 x2,y2". my problems , considerations outlined below - , comments appreciated! the image of water pump constructed our company. the commands generated proprietory system within our company. there no problems interpreting commands. my issue with a) wpf control should choose draw 'on' ? b) how can move major part of code unit-testable classes? a1) have tried pathgeometry, excellent drawing geometric shapes can't draw text. a2) have tried shape, supports drawing text, less advanced respect geometry. a3) use strength in each of two, , 'apply' pathgeometry shape? a4) need handle mouseover after drawing highlight based on mouse position. can done through computing 'behind scenes' object nearest mouse position (though possible, it's heavy!) can choice of rendering control me out? b1) not e