Posts

Showing posts from April, 2010

asp.net mvc - MVC JSON method returning invalid JSON to JQuery? -

i having problems jquery parsing json sending back... however, odd because using mvc's json method. here's setup. have simple function: $.ajax({ url: urld, datatype: 'json', data: { year: $('#vehicleyear').val(), value: request.term }, success: function (data, textstatus, jqxhr) { alert("success!"); }, error: function(xmlhttprequest, textstatus) { alert(textstatus + ": " + xmlhttprequest.responsetext); } }); it runs error function shows: parsererror: [{"value":"toyota","id":160}] i cannot figure out why in world doing this... it working older version of jquery - , read jquery json parser quite bit more strict now- can't figure out what's wrong json. even if wrong, that's frustrating because i'm using mvc's json function generate this: public actionresult getvehiclemodels(int year, int makeid, string value = null) { var modlmatchs =...

Is it possible to extract text by page for word/pdf files using Apache Tika? -

all documentation can find seems suggest can extract entire file's content. need extract pages individually. need write own parser that? there obvious method missing? actually tika handle pages (at least in pdf) sending elements <div><p> before page starts , </p></div> after page ends. can setup page count in handler using (just counting pages using <p> ): public abstract class mycontenthandler implements contenthandler { private string pagetag = "p"; protected int pagenumber = 0; ... @override public void startelement (string uri, string localname, string qname, attributes atts) throws saxexception { if (pagetag.equals(qname)) { startpage(); } } @override public void endelement (string uri, string localname, string qname) throws saxexception { if (pagetag.equals(qname)) { endpage(); } } protected void startpage() throws s...

python - How to use struct information from mouse/keyboard hook in ctypes -

so i've got c code looks this: #pragma comment(linker, "/section:.shared,rws") #pragma data_seg(".shared") hmodule hinstance = 0; hhook hkeyboardhook = 0; int lastkey = 0; int keyflags = 0; hhook hmousehook = 0; int mousemsgid = 0; mousehookstruct *mhookpt; mousehookstruct mhookstruct; #pragma data_seg() bool winapi dllmain(handle hmodule, dword dwfunction, lpvoid lpnot) { hinstance = hmodule; return true; } lresult callback keyboardproc(int hookcode, wparam vkeycode, lparam flags) { if(hookcode < 0) { return callnexthookex(hkeyboardhook, hookcode, vkeycode, flags); } if(!hookcode) { lastkey = (int)vkeycode; keyflags = (int)flags; } return callnexthookex(hkeyboardhook, hookcode, vkeycode, flags); } lresult callback mouseproc(int hookcode, wparam msgid, lparam pmousehookstruct) { if(hookcode < 0) { return callnexthookex(hmousehook, hookcode, msgid, pmousehookstruct); ...

silverlight 4.0 - Silverlight4 WebContext -

i have built silverlight 4 application , have hit problem. i have split application multiple xaps(different sub-systems) reduce downloading / improve performance not subsystems needed every user. however want share webcontext between xaps, rather authenticating again , setting webcontext each xap. is possible? if how can achieve it? you need share library applications. so, let's assume have 3 xap projects called project1.xap, project2.xap, , project3.xap. these projects should reference silverlight class library has shared logic. in shared project, can create interface that's implemented root application. let's call iapplicationcontext. the root application xap file loads other xaps. let's call root.xap. 1 manage authentication , create implementation of iapplicationcontext pass other xaps upon creation. // available projects (shared.dll) public interface iapplicationcontext { string username { get; } guid sessionid { get; } // ... } ...

ajax - post an image of input file using javascript to php file -

is way post image object php file using javascript can alternative regular way of uploading image using (enctype="multipart/form-data") ? i had post values of input text boxes using ajax, way post input file fields ? thanks there several techniques this. one utilize iframe upload. check out: http://www.ajaxf1.com/tutorial/ajax-file-upload-tutorial.html

java - StackOverflow error: How can I avoid it or turn this DFS into an iterative one? -

i'm using depth first search maze generation. the adjacency matrix of m*n vertices traversed in random order using dfs, i'm interested in generating random route. the thing works fine reduced number of vertices, i'm getting stackoverflow exception when using with graph thegraph = new graph(1000,1000); questions: a)how can change recursive calls iterative ones using stack? b)is there way assign more memory method call stack? class ij { int i; int j; ij (int i,int j){ = this.i; j= this.j; } } class graph { int m; int n; int adjacencymatrix[][]; arraylist <ij> orderofvisits; graph(int m,int n){ this.m=m; this.n=n; adjacencymatrix=new int[m][n]; (int i=0; i<m; i++) (int j=0;j<n;j++){ adjacencymatrix[i][j]=-1; //mark vertices not visited } orderofvisits = new arraylist<ij>(...

Displaying javascript calculation based on select menu option -

this 1 ought slam dunk somebody. total javascript novice, so i'm amazed i've gotten far. so when @ code, you'll see glaring problems , laugh @ me, because blindly guessing @ syntax @ point. please see offending code below , enjoy chuckle. i'll wait. okay, i'm trying make simple calculator displays monthly savings of buying bus pass on paying cash. i'm trying display different answer depending upon zone chosen in select menu. formulas in each if statement work when list variables outside of if statements (hence aforementioned amazement), displaying each answer in series of alert boxes, i'd display applicable answer, , syntax out of whack. i'd honored , humbled schooled in matter, bearing in mind of course less-than-rudimentary js skills. advance thanks. <!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/xht...

asp.net mvc 2 - Adding more than one key for the same ModelState error -

i've been looking solution while , i'd ask what's best way that. suppous have 2 fields filled date , period invalid. after discovering need send user error , need highlight field related error. if((seconddate.value - firstdate.value).days > 31) { modelstate.addmodelerror("firstdate", "the period must contains less 31 days"); } with this, "firstdate" field works nicelly , make "seconddate" field have same behave. is possible? wich best that? thanks ! if((firstdate.value - seconddate.value).days > 31) { modelstate.addmodelerror("firstdate", "the period must contains less 31 days"); modelstate.addmodelerror("seconddate", "the period must contains less 31 days"); }

objective c - Custom selection mechanism -

i'm trying create little slider mechanism operates box/view static line image in center , behind pins. pins marks on ruler. when slide marks left or right; keep coming continuously (a loop). , need use controller of view, selector. needs scroll through list when pins slid. how can put together? create uiview , add uiswipegesturerecogniser it. when swipe occurs update ivar , either redraw or animate bunch of repeating uiimageview subviews. the latter preferable efficiency , smoothness.

.htaccess - redirect my site from www.foo.bar to cdn.foo.bar -

is possible have htaccess rule redirect files from http://www.mydomain.com/page.html http://cdn.mydomain.com/page.html still making link http://www.mydomain.com/page.html i know masking urls isn't possible, since on same domain wondering if possible try these rules in .htaccess file: options +followsymlinks -multiviews rewriteengine on # http rewritecond %{http_host} ^www.mydomain.com$ [nc] rewritecond %{server_port} =80 rewriterule ^(.*)$ http://cdn.mydomain.com/$1 [l,r] # https rewritecond %{http_host} ^www.mydomain.com$ [nc] rewritecond %{server_port} =443 rewriterule ^(.*)$ https://cdn.mydomain.com/$1 [l,r] however 1 caveat external redirect hence url in browser change http://cdn.mydomain.com/foo because when jumping 1 host cannot have internal redirect hence r flag needed.

javascript - How to disable text selection via jQuery? -

i know question have been asked ( here ), answers i've found dealt css selector :selection (that not yet supported browsers). so, how can disable text selection on html page via jquery, not relying on css tricks? try http://code.jdempster.com/jquery.disabletextselect/jquery.disable.text.select.js

jquery - bind template data for select option -

let's have jquery template html code: <div> <span id="myfirstname"></span> <select id="mygender" multiple="multiple"> <option value="1">-select-</option> <option value="2">male</option> <option value="3">female</option> <option value="4">notspecified</option> </select> </div> my json looks : { "firstname": "john", "gender": "male" }; i can bind myfirstname using ${firstname} how bind drop down value? used ${gender} displays value , not drop down list "male" option selected. one option like: <div> <span id="myfirstname">${firstname}</span> <select id="mygender" multiple="multiple"> <option value="1">-select-</option> <option value="2" {{if gen...

javascript - KnockoutJs 1.3 beta. _destroy:false has same result on ui as _destroy:true -

using asp.net mvc, passing viewmodel down , getting knockout map viewmodel , bind this. this working fine me, trying track deletions. i thought able adding _destroy property setting false. i hoped ui ignore until destroy set true. but not seem case , mere presence of property causing treated destroyed. is bug or handling wrong? many thanks, kohan var model = [{"id":1,"name":"bikes","parent":null,"_destroy":false}, {"id":2,"name":"components","parent":null,"_destroy":false}, {"id":3,"name":"clothing","parent":null,"_destroy":false}, {"id":4,"name":"accessories","parent":null,"_destroy":false}, {"id":5,"name":"mountain bikes","parent":1,"_destroy":false}, {"id":6,"name":"road bikes",...

c# object generic use without casting? -

object s; s = "abc"; int n = ((string)s).length; is there way of avoiding having use cast in 3rd line? edit: "string" , "length" examples , different. edit: further clarified regarding var , dynamic breaking first line more requirements. dynamic s = "abc"; int n = s.length;

objective c - How do I keep the user's iPhone's display on? -

so, looking way keep user's iphone display on clock app. found [uiapplication sharedapplication].idletimerdisabled = yes; keeps device locking of time. tried [uiapplication sharedapplication].idletimerdisabled = no; when application goes background, doesn't work. how can safely keep user's device sleeping while app running ? alter idletimerdisabled property whenever app changes active state - if you're going backgrounded, re-enable timer, , when regain control, disable timer again.

c++ - Isn't boost::asio fully UNICODE compliant? -

i writing c++ application using boost::asio http operations. chose boost::asio assuming unicode compliant. however, unable compile in unicode because part of asio hardcoded char. case in point: #ifndef tchar #ifdef _unicode #define tchar wchar_t #else #define tchar char #endif #endif // following lines complile in mbcs , not in unicode. boost::asio::basic_streambuf<std::allocator<tchar> > request; std::basic_ostream<tchar, std::char_traits<tchar> > requeststream(&request); the boost::asio::read_until function accepts char delimiter. doing wrong here? please note new unicode, never needed before. boost::asio::basic_streambuf derives std::streambuf instead of std::basic_streambuf, suspect boost::asio not unicode compliant. correct, boost::asio not unicode compliant.

Multiple Instances of Tomcat -

i facing weird problem follows. scenario- i have 2 instance of tomcat 6.0 running on machine i making call 1 instance via service calls. there few system.out.println() calls on 2nd server check whether call reached or not. problem - have 2nd instance running , there call 1st instance cannot see output on tomcat console. tried changing swallowout = true / false. nothing works knows might problem be. thanks any suspision messages in log files? incorrect port binding (tomcat typically use 3 ports different connections. each instance must have own unique ports.).

python - SQLAlchemy mapping table with non-ascii columns to class -

item = table('item', metadata, autoload=true, autoload_with=engine, encoding = 'cp1257') class item(object): pass sqlalchemy.orm import mapper mapper(item, item) i error: line 43, in <module> mapper(item, item) file "c:\python27\lib\site-packages\sqlalchemy\orm\__init__.py", line 890, in mapper return mapper(class_, local_table, *args, **params) file "c:\python27\lib\site-packages\sqlalchemy\orm\mapper.py", line 211, in __init__ self._configure_properties() file "c:\python27\lib\site-packages\sqlalchemy\orm\mapper.py", line 578, in _configure_properties setparent=true) file "c:\python27\lib\site-packages\sqlalchemy\orm\mapper.py", line 618, in _configure_property self._log("_configure_property(%s, %s)", key, prop.__class__.__name__) file "c:\python27\lib\site-packages\sqlalchemy\orm\mapper.py", line 877, in _log (self.non_primary , "|non-primary" ...

c# - The designer could not be shown for this file because none of the classes within it can be designed -

yes searched , solution on post didnt work, scenario different. i have winform application, simple, working, , error on title of post shown when try open form. thing have done installed vs11 developer preview , vs 2010 sp1. any idea how fix this?> i managed solve it, checked on properties of project , framework selected .net 4.0 client profile. i changed .net 4.0 , worked. by way mean client profile, for??

javascript switch vs loop on array -

i have these 2 functions , want know 1 faster. assume first one, if have hundreds of cases evaluate? function isspecialkey(k) { switch (k) { case 9: return true; break; case 16: return true; break; case 17: return true; break; case 18: return true; break; case 20: return true; break; case 37: return true; break; case 38: return true; break; case 39: return true; break; case 40: return true; break; default: return false; break; } } function isspecialkey(k) { var arr = [9, 16, 17, 16, 8, 20, 37, 38, 39, 40] (i = 0; < arr.length; i++) { if (k == arr[i]) { return true; } } return false; } it unlikely matter, not hundreds of cases. might start mattering thousands or tens of thousands in case, shouldn't using javascript anyway! @ least not in web browser. generally - second way way makes sense maintenance perspective. absolutely take that. however, specific case, there better solution.

windows - C++: keeping track of elapsed time -

i'm looking way able know how time it's been since program started, @ given time. sort of timer keep running while main code doing else, , can called @ time. the context opengl application on windows, , knowing keyboard keys being pressed (using glutkeyboardfunc), i'd know when each key pressed. of info written xml file later used replay user did. (sort of replay functionality in car racing game, more simple). c++ 11: #include <iostream> #include <chrono> auto start = std::chrono::system_clock::now(); auto end = std::chrono::system_clock::now(); std::chrono::duration<double> elapsed_seconds = end - start; std::cout << "elapsed time: " << elapsed_seconds.count() << "s\n"; code taken en.cppreference.com , simplified . old answer: gettickcount() in windows.h returns ticks(miliseconds) elapsed. when app starts, call function , store value, whenever need know elapsed time since program start, c...

python - __getattr__ in parent class causing subclass __init__ recursion error -

following advice in answer: subclassing beautifulsoup html parser, getting type error , i'm trying use class composition instead of subclassing beautifulsoup . the basic scraper class works fine on it's own (at least limited testing). the scraper class: from beautifulsoup import beautifulsoup import urllib2 class scrape(): """base class subclassed wrapper providers basic url fetching urllib2 , basic html parsing beautifulsoup×¥ useful methods provided class composition beautifulsoup. direct access soup class can use _soup property.""" def __init__(self,file): self._file = file #very basic input validation #import re #import urllib2 #from beautifulsoup import beautifulsoup try: self._page = urllib2.urlopen(self._file) #fetching page except (urllib2.urlerror): print ('please enter valid url starting http/https/ftp/file') ...

Offending Command error while Printing EPS -

i printing eps file generated following credentials. %-12345x@pjl job @pjl enter language = postscript %!ps-adobe-3.0 %%title: invoicedetail_combine %%creator: pscript5.dll version 5.2.2 %%creationdate: 10/7/2011 4:46:59 %%for: administrator %%boundingbox: (atend) %%pages: (atend) %%orientation: portrait %%pageorder: special %%documentneededresources: (atend) %%documentsuppliedresources: (atend) %%documentdata: clean7bit %%targetdevice: (hp color laserjet 4500) (2014.200) 0 %%languagelevel: 2 %%endcomments while doing selection printing on ricoh afficio 2090 or other drivers/printers following error printed on sheets error: undefined offending command: f4s47 stack: . kindly review , suggest turn around same stuck in hell. have tried convert/extract in ps in vain. using gsview print , view these files. this problem: %%pageorder: special a ps document "special" page order can not re-ordered. cannot selection or range file because broken use. mus...

java - Managing several EditTexts in Android -

possible duplicate: android: how elegantly set many button ids everyone. i'm trying build first android app doing rms (root mean square) error calculation. need several experimental points inputs, done manually in edittexts. have 40 edittexts in 1 layout. problem when comes managing them, have this: public class insertardata extends activity implements onclicklistener { edittext x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16,x17; edittext y1,y2,y3,y4,y5,y6,y7,y8,y9,y10,y11,y12,y13,y14,y15,y16,y17; float [] datosx; float [] datosy; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.insertardatos); x1=(edittext)findviewbyid(r.id.x1et); x2=(edittext)findviewbyid(r.id.x2et); x3=(edittext)findviewbyid(r.id.x3et); x4=(edittext)findviewbyid(r.id.x4et); x5=(edittext)findviewbyid(r.id.x5et); x6=(edittext)findviewbyid(r.id.x6et); x7=(edittext)findviewbyid(r.id.x7et); ...

exception - RichFaces 4.0 TagException for recursiveTreeNodesAdaptor/treeNodesAdaptor tags -

i having problems when using recursivetreenodesadaptor , treenodesadaptor in richfaces 4.0 along mojarra 2.0. when use them, tagexception: tag library supports namespace: http://richfaces.org/rich , no tag defined name: recursivetreenodesadaptor i haven't had problems when using rich:tree or other richfaces tags. any clue? it has been renamed , called treemodelrecursiveadaptor now. however functionality has been changed, may have change backing bean code.

Variable number of textedits in alertdialog in android? -

is possible set variable number of textedits in alertdialog? i've tried fill container views such stackview or linearlayout dynamically method addview said not supported in adapterview(exception). what's solution? added: want build alertdialog dynamic information. alertdialog.builder alert = new alertdialog.builder(context); now can set view this: alert.setview(v); but v element can simple textview or edittext. if want create container view may contain variable number of elements, example 2 textviews , 3 edittexts? how can this? create separate layout file , inflate view bit it's not solution. can do? why need variable number of textview s? use single 1 display multiple lines. if need more complicated, create own dialog-like activity theme @android:style/theme.dialog , constraining dimensions not cover entire display area. update: here example of how dialog-like subactivity: :: complexdialog.java public class complexdialog extends activity { ...

c++ - GCC problem - invalid conversion from 'void (*)(MyObject*, bool)' to 'const void*' -

i don't want to, have emulate com logic in program , i'm using standard com_addref macros, keep getting following error: invalid conversion 'void ( )(myobject , bool)' 'const void*' ... should do? #define com_addref(pobj, pmaster) ((pobj)->addref((pmaster), __file__, __line__, pobj)) class basecomobject { public: inline dword addref (const void* pmaster, const char* pfilename, int line, const void* pobj) const { irefcount++; return irefcount; }; inline dword getrefcount() const { return irefcount; }; private: long irefcount; }; class myobject: public basecomobject { }; void test (myobject* pobject, bool bvalue) { if (pobject) { com_addref (pobject, bvalue);// error: invalid conversion 'void (*)(myobject*, bool)' 'const void*' } } error: invalid conversion 'void ( )(myobject , bool)' 'const void*' error: initializing argument 1 of 'dword ...

svn - how to update from two sources using subversion? -

in our production environment have jboss running in clustered mode 4+ nodes. base jboss present in subversion , have local changes on each nodes. what should strategy can have base jboss @ 1 location, , local changes versioned @ location. is possible have updates 2 subversion sources @ same folder? or there other strategy used such versioning use cases? this solution used: all configuration of local variables has been converted use system properties. system property names made designed in following manner ${nodename}_${nodenumber}_${propertyname} and every server has variables defined nodename , nodenumber in .profile file. the properties file define combinations. example: needed separate values of connection_count property file has 8 variables(4 qa , 3 prod) prod_1_max_connection_count=15 prod_2_max_connection_count=15 prod_3_max_connection_count=20 qa_1_max_connection_count=12 qa_2_max_connection_count=6 qa_3_max_connection_count=10 qa_4_max_connection_co...

javascript - Smooth scrolling when clicking an anchor link -

i have couple of hyperlinks on page. faq users read when visit section. using anchor links, can make page scroll towards anchor , guide users there. is there way make scrolling smooth? but notice he's using custom javascript library. maybe jquery offers somethings baked in? $(document).on('click', 'a[href^="#"]', function (event) { event.preventdefault(); $('html, body').animate({ scrolltop: $($.attr(this, 'href')).offset().top }, 500); }); and here's fiddle: http://jsfiddle.net/9sdlw/ if target element not have id, , you're linking name , use this: $('a[href^="#"]').click(function () { $('html, body').animate({ scrolltop: $('[name="' + $.attr(this, 'href').substr(1) + '"]').offset().top }, 500); return false; }); for increased performance, should cache $('html, body') selector, doesn't ru...

php - StackExchange OAuth and OpenID Authentication? -

i have been having goosey around login functions of stackexchange, , have noticed depends on click, adjusts form either oauth information, or openid information in form of query submits form script inside of stackexchange, , wondering if had information how script communicate particular service , use returned information login, fetching additional information account service. if has scripts or snippets, php preferred. the janrain openid libraries pretty good. have few quirks when comes extending them, think purposes fine. facebook not openid. facebook need use different library (and have not done, cannot comment on it).

android - ANR Exception handling -

i have application, providing remote ui(which contains buttons control media server). the problem when click of button, executing corresponding action, long upnp network operation. so when press buttons continuously , device comes anr exception , force close application. made research on anr exception , found that, can use thread or asynctask solve problem. but in application since providing many buttons, when user presses buttons continuously , may inturn lead lot of threads created in application. please give me suggestions on this. how overcome problem? thanks one of many advantages of using asynctask manages threading (and thread pooling) you. if use asynctask, shouldn't have problem of creating many threads. in addition, if you're concerned creating many asynctasks, consider putting tasks in member variable (such queue or arraylist) , keeping track of state. if 1 still processing might not necessary start another. or can remove tasks results n...

php - Customize a field output -

i have field named "field_enroll_link." want remove surrounding divs , print field content (it go href of anchor tag). created files "field--field_enroll_link-course.tpl.php" , "field--field-enroll-link-course.tpl.php," , put template folder. contained <?php print render($item); ?> , when cleared cached , switched themes, i'm still getting surrounding divs , markups. how override field.tpl.php in drupal 7? in theme's template.php file define function , clear cache. assuming have devel module installed. function your-theme_name_field($variables){ dsm($variables['items'][0]['#markup']); return ; } you able access value looking for.

SWT: set radio buttons programmatically -

when create couple of radio buttons ( new button(parent, swt.radio) ) , set selection programmatically using radiobutton5.setselection(true) selected radio button remains selected. have iterate on other radio buttons of same group unselect them or there simpler alternative? in advance. unfortunately, have iterate on options. first time when ui comes bn_clicked event fired. if shell or group or whatever container of radio buttons not created swt.no_radio_group option following method called: void selectradio () { control [] children = parent._getchildren (); (int i=0; i<children.length; i++) { control child = children [i]; if (this != child) child.setradioselection (false); } setselection (true); } so eclipse depends on iterating on radio buttons , toggling state. every time manually select radio button bn_clicked event fired , hence auto toggling. when use button.setselection(boolean) no bn_clicked event fired. therefore ...

c# - Silverlight 4: REST API call data retrieval layer? -

i'm working in .net 4 , sl 4. i'm wanting abstract out data retrieval portion of dal silverlight page's code behind. ideally own dll interface layer between silverlight application , rest api calls. intent not use ria services have existing dal that's making use of dll makes rest api calls. the issue asynchronous "webclient" call process. know can utilize webclient class make rest call , register asynchronous handler bind results call ui. in case, want abstract out own dll. basically....making synchronous. by definition asynchronous call has issues here being can't , directly return ienumerable of type. can point me sample/tutorial being done? ria makes method call separate dll ienumerable data collection that method makes rest api call retrieve data, returns ienumerable ria , bound ui. boling right down fundementals asking able make synchronous call api performs asynchronous task returns when asynchronous task complete. state way w...

audio - j2me record and stream without gap? -

is possible record voice , stream in j2me,like record , use commit() byte array,but commit() takes @ least 250ms ,even record length 10 ms,and irrationally takes 280ms if record length 10s etc, device tested nokia 6300 s40 device. how can prevent gap? need record voice in packets of time intervals small possible 100ms,200ms,etc. each time commit() takes @ least 250ms. afaik not possible. because have commit() after recording audio. should takes sometime commit() .

asp.net mvc 3 - Implement an @html.myTelerikGrid extension -

i’m trying html extension render telerik grid common settings if declare code view fine. @imports telerik.web.mvc @imports telerik.web.mvc.ui @code dim gridbuilder telerik.web.mvc.ui.fluent.gridbuilder(of tmodel) = html.telerik().grid(of tmodel)().name("mylist") @end code but move class library project implement html extension imports system.web.mvc imports telerik.web.mvc imports telerik.web.mvc.ui namespace helpers module helperlist <system.runtime.compilerservices.extension()> _ public sub myteleriklist(of tmodel class)(helper htmlhelper) dim gridbuilder telerik.web.mvc.ui.fluent.gridbuilder(of tmodel) = html.telerik().grid(of tmodel)().name("mylist") … … end sub i'm having error that 'html' ambiguous, imported namespaces or types 'telerik.web.mvc.ui, system.web.mvc'. regards in advance try using helper instance extending: <system...

c# - How to best parallelize parsing of webpages? -

i using html agility pack parse individual pages of forum website. parsing method returns topic/thread links on page link, passed argument. gather these topic links of parsed pages in single collection. after that, check if on dictionary of already-viewed urls, , if not, add them new list , ui shows list, new topics/threads created since last time. since these operations seem independent, best way parallelize this? should use .net 4.0's parallel.for/foreach ? either way, how can gather results of each page in single collection? or not necessary? can read centralized dictionary whenever parse method finishes see if there, simultaneously? if run program 4000 pages, takes 90 mins, great if use 8 cores finish same task in ~10 mins. after that, check if on dictionary of already-viewed urls, , if not, add them new list , ui shows list, new topics/threads created since last time. since these operations seem independent, best way parallelize this? you can...

web scraping - Python Post to form with anti-scrape protection -

trying scrape content off site python, has simple form authentication username , password, has hidden field called "foil" contains looks randomly generated string each time page loaded. in order login value must included in content header of post. i've tried scraping out random string after login page loads still redirects me login. have valid username , password site works, update sporadically , send myself email when changes. here code i've been working far... import urllib, urllib2, cookielib,subprocess url='https://example.com/login.asp' username='blah' password='blah' request = urllib2.request(url) opener = urllib2.build_opener(urllib2.httphandler(debuglevel=1)) predata = opener.open(request).readlines() line in predata: if("foil" in line): foils = line.split('"') notfoiled = foils[3] query_args={'location':'','qstring':'','absr_id':notfoiled,...

.net - how to use count on a groupby using extension methods? -

i need use count(*) sql server on linq, how can use extenstion methods ? here trying var test = empire.case_offence.join( empire.offences , w => w.offenceid , x => x.id , ( w , x ) => new { w.id , w.offenceid , x.name } ) .groupby( ww => new {ww.name, ww.id,ww.offenceid } ) ; tnx :) try: var test = empire.case_offence.join( empire.offences , w => w.offenceid , x => x.id , ( w , x ) => new { w.id , w.offenceid , x.name } ) .groupby( ww => new {ww.name, ww.id,ww.offenceid } ) .select ( g => new { key = g.key, count = g.count() } ); test set of anonymous types 2 parameters - key - group-by key, , count - number of items key.

android - get all strings defined in an apk -

is there quick way strings defined in apk? i doing this: aapt d --values resources app.apk i not sure if gives me strings. if there easier way parse strings please let me know. you can change "resources" "strings" , have it. use: aapt d --values strings [apk_file] this dump strings on apk. dump includes string resources looking for. this includes strings generated system path resources (res/drawable-hdpi/icon.png example).

c# - ProfileCommon in WAP working at run-time but not at compile-time -

i have web application project , implemented profile properties in web.config. when found couldn't access profilecommon object googled , found workarounds: how list of user/profile membership provider? how assign profile values? "the name profilecommon not exist in current context" http://forums.asp.net/t/1487719.aspx/1?profile+common+non+existant+in+asp+net+4+0+ http://weblogs.asp.net/jgalloway/archive/2008/01/19/writing-a-custom-asp-net-profile-class.aspx and on. nobody said have profilecommon object @ run-time. here's example: <profile enabled="true"> <properties> <add name="adminremark"/> <add name="facilityid" type="system.int64" defaultvalue="1"/> </properties> </profile> this line compiles , works, have hard-coded property name: rcbfacilityid.selectedvalue = (profilebase.create(usercurrent.username) profilebase) .getpropertyvalue(...

view - Android keyboard hides itself, showing blank space below, after coming back from screensaver -

i working on android app , enjoying too. today, got stuck on small problem soft keyboard. i have edittext @ bottom of screen , when user clicks on keyboard pops ,resizing entire view show edittext above keyboard, should be. if user doesnt sometime, phone sleeps , screen gets locked keyboard still present in screen. when phone comes after sleep, keyboard seems hide itself, leaving views in resized state. blank space shown keyboard has been present..i happy if the keyboard remains there after coming sleep.. let keyboard hide,but views should go original size, ie without blank space.. what can achieve of these? hope question clear..any appreciated..

c# - Winform - Force user to fill out form on startup -

thanks in advance help. web developer have been tasked creating simple winforms application. have application complete exception of 1 part. application run on startup , prompt user enter reason why using machine. there easy way force user fill out form before continuing. want disable (start menu, etc) until form has been filled out , closed. could kill explorer.exe restart? seems kind of invasive me. writing custom gina add textbox login screen might it? not faint-hearted though!

urlencode - php, how to use strip_tags or urldecode on REQUEST_URI? -

i have link needs ti cleaned bit. http://'.$_server["server_name"]."".$_server["request_uri"].'" /> this link generate this: http://www.site.com/friends.php where friends.php $_server["request_uri"] . sometimes pass id link: http://www.site.com/friends.php?id=123456 what want use strip_tags or urldecode clean link , make sure whatever passed in id int , contains no letters, need on original link: http://'.$_server["server_name"]."".$_server["request_uri"].'" /> edit: i want link cleaned out can't it: http://www.site.com/friends.php?id=<script>alert(tk00000006)</script> this assumes have id in query string: echo 'http://'.$_server['server_name'] . $_server['script_name'] .'?id=' .filter_var($_get['id'], filter_sanitize_number_int); resulting id id=<script>alert(tk00000006)...

.htaccess - SEO friendly URL's: show friendly URL, load original address -

i using mod_rewrite rule create seo friendly url's. this mod_rewrite rule: rewriterule ^portfolio/portretten$ http://www.mydomain.nl/gallery.php?g=5 [l,nc] it works fine, if type 'www.mydomain.nl/portfolio/portretten' loads www.mydomain.nl/gallery.php?g=5 . it's redirect, address bar of browser shows 'www.mydomain.nl/gallery.php?g=5', want show 'www.mydomain.nl/portfolio/portretten'. so don't want redirect "replace". possible? yes—you can either drop http://www.mydomain.nl part (in case it'll default doing internal redirect) or alternatively add p (proxy) flags. actually, should work domain in there, apache must not realize current host. either that, or isn't current host, in case you'll have use proxy. the mod_rewrite documentation goes on flags.

c# - Count Rows in Linq -

i new in linq i have written following query : var duplicate = loginid in dataworkspace.v2oneboxdata.me_employees loginid.me_login_name == this.me_login_name && loginid.me_pkey != this.me_pkey select loginid; i want count rows returned in result duplicate i searched many of articles says use duplicate.count(). dont see count() in intelisense how count result how doing using extension methods: var count = me_employees.where(me => me.me_login_name == this.me_login_name && me.me_pkey != this.me_pkey).count(); even better: var count = me_employees.count(me => me.me_login_name == this.me_login_name && me.me_pkey != this.me_pkey); big note: ensure have referenced system.core. system.data.linq assume referenced it.

iphone - UIWebView:- calculating height of webview body content when relaoding html dynamically? -

when call , loadhtmlstring load content in uiwebview, , calculating height of content of webview in didfinishload() method, giving height h, if again reload other html, not returning exact height of content if smaller previous content, reloading again , again reduces height factor 12 px , reach exact height. but if new content content height greater previous content height, calculated successfully. do know root cause why happening this? if yes, please help. this did,though had webview within uitableview in case. - (void)webviewdidfinishload:(uiwebview *)webview{ float webheight; cgrect frame = webview.frame; frame.size.height = 1; webview.frame = frame; cgsize fittingsize = [webview sizethatfits:cgsizezero]; frame.size = fittingsize; webview.frame = frame; webheight=fittingsize.height; rowht=webheight; [atableview reloaddata]; } this delegate method called whenever webview reloaded. here set frame size again new value. , agai...

How to encode JSON embedded within JSON -

i have json string , 1 of fields text field. text field can contain text user enters in ui , if text enter json text, perhaps illustrate coding, need encode text not interpreted json within actual json structure sent server. when json structure received server , gets decoded, need make sure embedded json gets decoded text, ends looking json in ui. in effect, how escape embedded json string? i'm doing similar, xml instead of json: on receiving malformed or otherwise non-processable data server returns error-structure containing information , original data. prevent client parsing corrupt data again it's base64 encoded on server. so instead of sending { title : "my sample code", payload : "{ \"foo\" : \"bar\" }" } consider sending { title : "my encoded sample code", payload : "eyaizm9viia6icjiyxiiih0=" }

What are .dex files in Android? -

i have questions regarding dex files what dex file in android? how dex work android? how used in debugging android app? are similar java class files? i need specific information please on , real examples welcome! .dex file compiled android application code file. android programs compiled .dex (dalvik executable) files, in turn zipped single .apk file on device. .dex files can created automatically android, translating compiled applications written in java programming language.

php - using full zend query in while loop.And in loop i execute full query and merge them in one array -

optimize zend query takes time execute. using full zend query in while loop.and in loop execute full query , merge them in 1 array .. @ have 1 array results takes time execute .. below exact case while($str){ $db = zend_registry::get('dbadapter'); $select = new zend_db_select($db); $select = $db->select(); // business logic omitted $stmt = $select->query(); $result = $stmt->fetchall(); // after execution merge record in new array ( $final_result ) $temp_arr = $result; $final_result = array_merge($final_result,$temp_arr); unset($temp_arr); } you don't have write following code inside loop, write them outside loop... $db = zend_registry::get('dbadapter'); $select = new zend_db_select($db); $select = $db->select(); $stmt = $select->query(); then write following code inside loop: $result = $stmt->fetchall(); $final_result[] = $result; unset($result); this code might you..........

c - g_hash_table_lookup() not accepting variable as parameter -

consider following code: gtk_widget_show(g_hash_table_lookup(widgetbuffer,"togglebutton")); gtk_toggle_button_set_active(gtk_toggle_button(g_hash_table_lookup(widgetbuffer,"togglebutton"))),true); line 1 works fine, line 2 throws error: gtk-critical **: gtk_toggle_button_set_active: assertion `gtk_is_toggle_button (toggle_button)' failed why this? if g_hash_table_lookup returning gtkwidget pointer gtk_widget_show handles fine, why can't gtk_toggle_button() cast it's type properly? (also, gtk_toggle_button_set_active causes no errors on compile, @ runtime) edit: clarity, is gtktogglebutton (note dereferencer , how causes error): gtk_toggle_button_set_active(*gtk_toggle_button(g_hash_table_lookup(widgetbuffer,"togglebutton"))),true); note: expected ‘struct gtktogglebutton *’ argument of type ‘gtktogglebutton’ however printf("pointer: %p\n",gtk_toggle_button(g_hash_table_lookup(widgetbuffer,(gchar *) xmlgetprop(cu...

c# - How do I get the type with a type string when the version has changed? -

i saving list of type strings instantiated dynamically. using reflection, how type type string when version number has changed? example, have type string defined as: acmecorporation.businessobjects.customer, acmecorporation.businessobjects, version=2.0.0.0, culture=neutral, publickeytoken=dccbd7ce7d6a58c0 //this works fine type type = type.gettype(typestring, false); however when assembly version changes 2.0.0.1 saved type string not work because version numbers diferent. can find assembly name , find type name? how this? if don't care version, why include in type string? parts except first 1 optional in string passed type.gettype : type t = type.gettype("acmecorporation.businessobjects.customer, acmecorporation.businessobjects");

c# - What type of IProducerConsumerCollection<T> to use for my task? -

i have 100 sensors each "measuring" own data. have 1 datasender should send information "sensors". recent information should sent. bandwidth of channel may less data produced 100 sensors. in case data can skipped - should "roughly fair". example, skip every second measurement each sensor. i don't know how each sensor generates data, in general generate data pretty often. after other posts: how create singleton running in separate thread? modified producer/consumer example, problems it? i have decided have classical producer/consumer problem, with: 100 producers, and 1 consumer i've been suggested use blockingcollection this. problem blockingcollection - once have added item, cannot replace it. in application, if sensor produces new value, , previous value not processed consumer , value should replaced . should use use concurentdictionary or concurentbag task? conceptually, all need array of 100 elements. sensor...

Rails: using rake:notes for javascript -

is there way configure rake:notes parse javascript files , emit respective notes? thanks you can grep directly if want grep -r 'optimize:\|fixme:\|todo:' public/javascripts if wanted todo's grep -r 'todo:' public/javascripts # find on todos you use following search js in project, not files under public javascripts. grep -r 'optimize:\|fixme:\|todo:' **/*.js here how can turn rake task. # file lib/tasks/notes.rake namespace :notes task :js puts `grep -r 'optimize:\\|fixme:\\|todo:' public/javascripts` end end now can execute rake notes:js project root.