Posts

Showing posts from January, 2014

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.

css - Header DIV Layer Position Error in IE -

i'm having problems ie compatibility website. have parked @ http://www.verdasconews.com/tiago while test everything. make sure have compatibility major browsers. looks fine in firefox, chrome, opera & safari, in ie, i'm having problems header/content div layers. here's screenshot of looks in ie http://i.stack.imgur.com/goasx.png the post , sidebar content overlapping header when should tucked underneath, way appears in other browsers. this css positioning: /* ------ layout ------------------------ */ wrapper { background:url(img/back2.png) no-repeat center top; } contents { width:959px; margin:0 auto; text-align:left; } header { background:url(img/top.png) no-repeat bottom; height:160px; } middle-contents { background:url(img/side.png) repeat-y; padding-bottom:50px; } left-col { float:left; display:inline; width:584px; margin:0 0 0 5px; } right-col { float:right; display:inline; width:330px; margin:15px 5px 0 0; } footer

Rails 3: Why an empty nested form generates a hidden input field? -

why this: # edit.html.erb <%= form_for @product |f| %> <%= f.fields_for :shop |sf| %> # nothing here <% end %> <% end %> generates hidden input field: <input type="hidden" value="23" name="product[shop_attributes][id]" id="product_shop_attributes_id"> ? relevant controller code: def edit @product = product.find(params[:id]) end it'll because @product you're editing has shop. rails has inserted in fields_for when form submitted, knows shop nested attributes for. it's default nested attributes behaviour.

iphone - add + button before a row -

Image
how can add green + button before row in group table see in image - (uitableviewcelleditingstyle)tableview:(uitableview *)atableview editingstyleforrowatindexpath:(nsindexpath *)indexpath { if(indexpath.row == 1)//type condition here { return uitableviewcelleditingstyledelete; } else{ return uitableviewcelleditingstyleinsert; } } -(void)tableview:(uitableview *)tableview commiteditingstyle:(uitableviewcelleditingstyle)editingstyle forrowatindexpath:(nsindexpath *)indexpath { if (editingstyle == uitableviewcelleditingstyledelete) { //type code here }else if(editingstyle == uitableviewcelleditingstyleinsert){ //type code here } }

javascript - localizing <asp:FileUpload>. IE problem -

what want localize <asp:fileupload> control. far understand not possible, because input file being rendered browser , there no way control server. this: create <asp:fileupload> , make transparent, create input text , input button , write function browse() { $('#fileupload').click(); } on input button onclick event. firefox , chrome fine, ie8 - not: opens fileupload 's "browse..." dialog, writes it's value input text (via $('#filepath').val($('#fileupload').val()); ), when start uploading, there problem: jquery function before postback fileupload in asp.net so question is: there other (better?) way override upload control (custom width, localized texts on button etc...), works on every browser? thanks. have tried uploadify far?

objective c - How to Get Mac Desktop size -

how discover size of desktop (or screen size) of mac? for screen size use -[nsscreen frame] on instance received through e.g. +[nsscreen mainscreen] or -[nswindow screen] . visible part without dock , menu bar, use -[nsscreen visibleframe] . keep in mind full desktop can stretch on multiple screens.

css - Text expands outside the div it's inside? -

i've got code: <html> <head> <style type="text/css"> body { text-align: center; } #content { width: 60em; margin: 0, auto; background-color: #ccc; } </style> </head> <body> <center> <div id="content">kdsjlglkdfjgolksdjflgojsdfsdoljfglsdfghsdkjfgkdhfgkhlglkdfjgolksdjflgojsdfsdoljfglsdfghsdkjfgkdhfgklglkdfjgolksdjflgojsdfsdoljfglsdfghsdkjfgkdhfgklglkdfjgolksdjflgojsdfsdoljfglsdfghsdkjfgkdhfgklglkdfjgolksdjflgojsdfsdoljfglsdfghsdkjfgkdhfgklglkdfjgolksdjflgojsdfsdoljfglsdfghsdkjfgkdhfgklglkdfjgolksdjflgojsdfsdoljfglsdfghsdkjfgkdhfgklglkdfjgolksdjflgojsdfsdoljfglsdfghsdkjfgkdhfgkkjdghkdsfjgksdjfhg</div> </center> </body> </html> why text not stay inside div, go in single line until ends? want have line breaks relative div it's inside. how can this? because word wrapping occurs between words. at least default. word-break property can change in browsers

visual c++ - DevPartner BoundsChecker breaks my program -

i working on program suspect have 1 or more memory leaks. other answer on stack overflow told me try devpartner boundschecker (one of many others tried). now when run program boundschecker running, break. @ point, windows file open dialog initiated , right before happens, non-continuable breakpoint gets triggered. happens boundschecker running. according console output, last thing program trying load c:\windows\syswow64\slc.dll devpartner recognizes "microsoft software licensing client dll". since not use software licensing in particular program, must somehow related dialog window supposed opened. anyway, want find memory leaks , that, need open file. there possibility tell boundschecker not break program because of issue (whatever issue might be)? basti, there known bug in 9.x versions of boundschecker mfc file open prompt. if post dps , visual studio versions might able tell patch or update need around this. on other hand if tripping in licensing guard d

c# - send data from action method to appear in modal dialog -

im using asp.net mvc jqueryui i have placed default logon htlm (that comes new created mvc project) , placed in jquery modal dialog. login seems work okay. im not sure how i'm meant handle errors. i'd show in modal dialog..., the modal dialog fine when errors if example required field missing, (it shows in dialog) but logon action method returns view(model); if there errors authenticating credential entered( user/password invalid) how can make these erros rendered within dialog too? add errors model , read values out in view. public class loginmodel { public string errormessage { get; set; } }

Writing computed properties with NHibernate -

i'm using nhibernate 2.1.2 + fluent nhibernate i have contactinfo class , table. name column encrypted in database (sql server) using encryptbypassphrase / decryptbypassphrase . the following relevant schema/class/mapping bits: table contactinfo( int id, varbinary(108) name) public class contactinfo { public virtual int id { get; set; } public virtual string name { get; set; } } public class contactinfomap : classmap<contactinfo> { public contactinfomap() { id(x => x.id); map(x => x.name) .formula("convert(nvarchar, decryptbypassphrase('passphrase', name))"); } } using formula approach above, values read correctly database, nhibernate doesn't try insert/update values when saving database (which makes sense). the problem able write name value using corresponding encryptbypassphrase function. i'm unsure if nhibernate supports this, , if does, haven't been able find correct words search documen

What Ruby technique does Rails use to make my controller methods render views? -

just curious if knows ruby technique used accomplish following in rails framework. if don't write, say, index method on rails controller, rails still render index view file if url matches route. makes sense, because controller inherits parent class, must have own index method. however, if do define index method, , tell set instance variable, still renders appropriate view. example: def index @weasels = weasel.all # if omit line, rails renders index anyway. # if behavior defined in parent class's index method, # seems overriding method, index wouldn't it. # i'm not explicitly calling super method # actioncontroller::base, maybe rails doing that? render :index end in pure ruby, expect have call super behavior. i assume rails uses kind of metaprogramming technique guarantee controller methods call super . if so, can explain it? can point source code this? update as mladen jablanović has pointed out, initial mental model wrong; contro

python - Math formula for first person 3d game -

i want make first person 3d game can't set camera formula right. so have rotation: 0 359. next x,y coordinates, z remains same. camera rotation : 0 - front, 90 - left, 180 - back, 270 - right can adapt it what formula camera ? platform: panda3d, python, opengl thank you ok, looks need doom style camera movement, i.e., no up-down turns. consider this: you need render "world" seen through camera. assuming positive x right , positive y front, when camera moves right world's image moves left. when camera turns positively left, world's image turns right. now, let's try construct equations: 1.first, translate world coordinates camera's position: xwt = xw - xc; ywt = yw - yc; zwt = zw; (xc,yc,zc) = camera position (xw,yw,zw) = world coordinates of object in scene (xwt,ywt,zwt) = world coordinates of object translated camera position 2.now, rotate translated coordinates angle opposite camera's rotation: xwc = xwt * cos(

c# - API architecture -

i in process of designing api. know if have come solution: i have respository type of data layer talks database converting business classes entities(generated llbl gen, didn't want use entities directly business objects because wanted keep them simple , allow me swap out entity framework or other mapper needed to) i have wcf service layer i'm using type of facade. calls respository layer , converts business objects dtos , passes them through api service call via message client. client can aspx website, silverlight app, wpf app, or wp7 app. problem keep runnnig when want run business logic have send dto wcf service , client. doesn't seem "right" me. can't put business logic in dto because defeats purpose. if want business type code run on client have lot of duplication of code throughout different clients. my business layer not know of data layer, data layer knows of business layer , facade layer knows of data layer , business layer , dtos. bad design

ruby on rails - Passing parameters into model -

rails 3.0.3 ruby 1.9.2p0 the problem: i have users table has many items, item(s) in turn therefore belongs users. in model item.rb attempt save item along value user.id have: self.user_id = @user.id this give me error called id nil, mistakenly 4 -- if wanted id of nil, use object_id this causing confusion can't find in show.html.erb 'wraps' page <%= @user.id %> displays correct id on page many in advance ** edit ** shorten action action upon want parameter passed class itemscontroller < applicationcontroller def redirect @item = item.find_by_shortened(params[:shortened]) if @item #redirect_to @item.original redirect_to @item.original else redirect_to :shorten end end def shorten @host = request.host_with_port @user = current_user you need load @user model in every action require access it. having render in show action not guarantee loaded in update action. usually need have in

computer organization -

could explain me in detail "clock cycle" is? clock cycle, duration of single, complete transition of device clock. essentially, digital electronic synchronous, i.e., there central source of timing commands synchronizing elements of processor occur simultaneously. it similar officer leading brigade of infantry, ordering them shout "left" every time put left foot forward - way, soldiers don't stumble each other. a computer has device fulfilling similar purpose - synchronizes different portions of processor, instance, memory access units, arithmetic units, etc. has direct impact on speed of computer - synchronizes execution of sequences of operations, result in speed of execution of software program.

multithreading - Java Thread: Run method cannot throw checked exception -

in java thread, 'run' method cannot throw 'checked exception'. came across in core java (vol 1) book. can please explain reasoning behind it? can please explain reasoning behind it? yes, because exception throw in run method ignored jvm. thus, throwing there mistake (unless have specific exception handler thread, see the docs that). no reason incite potentially erroneous behaviour. or, example. class mythread extends thread { public void run() { throw new runtimeexception(); } } ... new mythread().start(); // here thread dies silently no visible effects @ edit why can't parent thread 'catch' exception spawned 'child' thread? @chaotic3quilibrium has noted in comment why not: because parent thread has moved on already. new mythread().start(); // launch thread , forget // 1000 lines of code further... = + 1; // exception child thread propagated here?

c - How to remove an element found in an array and shift the array elements to the left? -

int search(int a[]) { int i,v,index; printf("enter element (v),that want find:>"); scanf("%d",&v); (i=0;i<n;i++) { if(a[i]==v) { v=a[i]; index=i; } } printf("%d located in a[%d].",v,index ) if not care ordering of elements can delete found element in o(1) time. // find element you're looking for. int index = find(a, v); // stuff last element index found. a[index] = a[n-1]; // reduce total number of elements. n--;

ruby on rails - Case insensitive sorting with Mongoid -

right got: @directories = collection.directories.all.asc(:name) but it's case-sensitive, how do case-insensitive sorting? currently cannot create case insensitive indexes in mongodb see ... http://jira.mongodb.org/browse/server-90 so, seems means cannot case insensitive "sorting" either. you can upvote feature future inclusion in mongodb via link above if find useful. eliot horowitz 10gen (the supporters of mongodb) suggest in meantime: for short term - add 2nd field call .tolower() on before inserting. can sort on that.

javascript - add click event to Jquery UI accordian Header -

when create jquery ui accordian bunch of headers, when click them div opens. however, preform additional action upon clicking header. how do this? any ideas? thanks! javascript $("#createnewuserheader").click(function() { alert("test"); }); html <h3 id = "createnewuserheader"><a >create new user</a></h3> <div>some stuff</div>

Dynamically creating asp.net with c# pages -

i struggling finding clear answers dynamically creating same page on , over. questions , samples have found seem on board on topic. have studied life cycle , still seem not have clear answer code should go. i have master page , content page. content in content area needs dynamically created (text boxes, ddl's, page tabs, buttons/onclick etc.). after user fills in data , clicks submit button, need read values off form , rebuild page again (not add/remove controls current content). my question then. put code build page? area allow me use ispostback can rebuild content request.form values? buttons _click events work? there working samples out there direct me to? thank feedback... i don't know answers questions, hope may started. when dynamically generating ui through code, happens in init. controls dynamically loaded on init key because between init , load, on postback, viewstate loaded these controls. this means need, on every postback, recreate page

jQuery getJSON Output using Python/Django -

so, i'm trying make simple call using jquery .getjson local web server using python/django serve requests. address being used is: http://localhost:8000/api/0.1/tonight-mobile.json?callback=jsonp1290277462296 i'm trying write simple web view can access url , return json packet result (worried actual element values/layout later). here's simple attempt @ alerting/returning data: $.getjson("http://localhost:8000/api/0.1/tonight-mobile.json&callback=?", function(json){ alert(json); <!--$.each(json.items, function(i,item){ });--> }); i able access url directly, either @ http://localhost:8000/api/0.1/tonight-mobile.json or http://localhost:8000/api/0.1/tonight-mobile.json&callback=jsonp1290277462296 , get valid json packet... i'm assuming it's in noob javascript:) my views.py function generating response looks follows: def tonight_mobile(request): callback = request.get.get('callback=?', '')

php - "where" + "or_where, "or_where" leaving out conditions -

how make have conditions of: $this->db->where('msgto.msgto_display', 'y'); $this->db->where('msgto.msgto_unread', 'y'); but have: $this->db->where('msgto.msgto_recipient', $userid); $this->db->or_where('msgto.msgto_recipient', 4); at moment fine apart when reads "or_where" leaves out above "conditions" results recipient 4 dont have ('msgto.msgto_display', 'y') , ('msgto.msgto_unread', 'y') flagged. thanks :) you try using codeigniters $this->db->where_in() function: $this->db->where_in('msgto.msgto_recipient', array($userid, 4)); i having similar problem needed have condition true multiple possible values, , did trick. my situation wanted find content status in published or locked state. $this->db->where_in('status', array('published','locked'));

ASP.NET Focus Scrolls Page to Input -

i have few textboxes/labels inside of updatepanel. when tab out of 1 of textboxes, label has updated text. causes focus on page reset topmost element. this data-entry form , users expect not have use mouse @ all. can set focus on correct textbox in code: page.setfocus(tbxinput); or tbxinput.focus(); in ie, browser scroll position maintained (woo hoo!). in chrome , firefox not; scroll location adjusted focused textbox last element shown on page. disturbing user. i using following rules in web.config: <pages theme="default" stylesheettheme="default" maintainscrollpositiononpostback="true" validaterequest="false"> how can achieve behavior ie has? for kind of thing update label text javascript (possibly using ajax call web service or page method).

c# - Validation on name TextBoxes -

i have grid in insert/edit mode can update item person's names. i've been asked provide validation ensure alphanumerics added. after talking colleague thinking validation length should done. the user should able enter characters like. does sound correct? understand names contain special characters etc. from security point of view, recommended constrain user input in order prevent cross-site scripting attacks msdn

Errors processing bullet point via regex replace in VB to clean up XML file -

i'm trying clean xml file have utf-8 characters i'm having issues bullet point. files have bullet point in them , if remove these characters, rest of regex replace works fine, doesn't seem replace specific bullet character. looking @ hex 0x07 , in unicode /u0007 neither of these resolved error ("hexidecimal value 0x07, invalid character") here of regex replace code (vb script in ssis) i'm using several iterations i've tried. appreciated. xmlstring = fileio.filesystem.readalltext(filelocation) 'dim rgx regex = new regex("[\x00-\x08\x0b-\x0c\x0e-\x1f\u0000-\u0007]", regexoptions.none) 'dim rgx regex = new regex("[^0-9a-za-z]", regexoptions.none) 'dim rgx regex = new regex("[[:^print:]]", regexoptions.none) 'dim rgx regex = new regex("[[:^print:][\u0007]]", regexoptions.none) dim rgx regex = new regex("[^\x09\x0a\x0d\x20-\xd7ff\xe000-\xfffd\x10000-x10ffff]", r

perl - Validate dates in XML Document before writing to database -

i'm getting user input large form xml document. i'd validate xml document against schema before database related operations. problem users input dates according own preferences (us standard, iso standard, etc.) , database expects dates iso standard. there anyway can validate xml document , change dates iso format before adding database? i'm using perl back-end, libraries can me same? cheers, for date conversion http::date for dealing xmls in general perl-xml pm processing xlst (you guessed it) xml::xlst

java - Sending multiple files to a servlet with a single connection -

i'm writing java desktop client send multiple files on wire servlet using post request. in servlet i'm getting input stream request receive files. servlet write files disk, 1 one they're read stream. the implementation has couple of requirements: only 1 http request must used server (so single stream) the servlet must use reasonable fixed amount of memory, no matter size of files. i had considered inserting markers stream know when 1 file ends , next 1 begins. i'd write code parse stream in servlet, , start writing next file appropriate. here's thing... surely there's library that. i've looked through apache commons , found nothing. commons file upload interesting since upload comes java app, not browser solves receiving end, not sending. any ideas library allows multiple file transfers across single stream fixed memory expectations large files? thanks. just use http multipart/form-data encoding on post request body. it's de

php - MySQL: Number of subsequent occurrences -

i have table 4 columns: id, from, to, msg. the rows can this: 1 - foo - bar - hello 2 - foo - bar - zup? 3 - bar - foo - hi 4 - bar - foo - going okay 5 - bar - foo - you? now wanna know how many times "bar" has tried "talk" "foo" without response. wanna count number of occurrences since "foo" on sending end. in example, before next entry, should return 3. is possible in pure (my)sql? i'm using php on server side. thanks tips , advice! =) give go. it assumes table name of convo , id autoincrementing. this mysql php calls can added quite cleanly if wrapped in function passes in , variables. select count(*) unreplied `convo` `convo`.`from` = 'bar' , `convo`.`to` = 'foo' , `convo`.`id` > (select id `convo` `convo`.`from` = 'foo' , `convo`.`to` = 'bar'

c# - How do I clear the image cache after editing an image on my site? -

i'm using outside page update image in system. when i'm redirected page i've worked in, still see old picture. don't see changes until press ctrl+f5. way redirect history delete or other solution? add query string image source, prevent browser caching it. people use date, prefer guid guid g = guid.newguid(); string guidstring = convert.tobase64string(g.tobytearray()); guidstring = guidstring.replace("=", ""); guidstring = guidstring.replace("+", ""); image1.imageurl = "/path/to/new/image.jpg?r=" + guidstring; it end making image source similar this: <img src="/path/to/image.jpg?r=vqad3w8zug6oxgfzziw" id="image1" runat="server" />

gwt - UIBinder and using event propogation -

prior uibinder in gwt, wrapped elements in htmpanel handled events child elements. instead of attaching eventlistener multiple widgets, attached parent container , used event bubbling. can in uibinder? know in backing class yourclass.ui.xml, can use uihandler handle event delegation optimal? still adding multiple listeners or gwt doing behind scenes , attaching 1 event handler. you can add htmlpanel , attach handlers using uibinder: <g:htmlpanel ui:field="myhtmlpanel"> <h1>a header</h1> <p>a paragraph</p> </g:htmlpanel> and then, in view: @uifield htmlpanel myhtmlpanel; ... @uihandler("myhtmlpanel") public void onclick(clickevent event) { // handle event. }

objective c - UISlider with ProgressView combined -

Image
is there apple-house-made way uislider progressview. used many streaming applications e.g. native quicktimeplayer or youtube. (just sure: i'm in visualization interested) cheers simon here's simple version of you're describing. it "simple" in sense didn't bother trying add shading , other subtleties. it's easy construct , can tweak draw in more subtle way if like. example, make own image , use slider's thumb. this uislider subclass lying on top of uiview subclass (mytherm) draws thermometer, plus 2 uilabels draw numbers. the uislider subclass eliminates built-in track, thermometer behind shows through. uislider's thumb (knob) still draggable in normal way, , can set custom image, value changed event when user drags it, , on. here code uislider subclass eliminates own track: - (cgrect)trackrectforbounds:(cgrect)bounds { cgrect result = [super trackrectforbounds:bounds]; result.size.height = 0; return result; }

unicode - Using Markov models to convert all-caps to mixed-case and related problems -

i've been thinking using markov techniques restore missing information natural language text. restore all-caps text mixed-case. restore accents / diacritics languages should have them have been converted plain ascii. convert rough phonetic transcriptions native alphabets. that seems in order of least difficult difficult. problem resolving ambiguities based on context. i can use wiktionary dictionary , wikipedia corpus using n-grams , hidden markov models resolve ambiguities. am on right track? there services, libraries, or tools sort of thing? examples george lost sim card in bush   ⇨   george lost sim card in bush tantot il rit gorge deployee   ⇨   tantôt il rit à gorge déployée i think can use markov models (hmms) 3 tasks, take @ more modern models such conditional random fields (crfs). also, here's boost google-fu: restore mixed case text in caps this called truecasing. restore accents / diacritics languages should have them have been

email - How many formats of mail client's address book? -

i want develop library handle mail client’s address book. and, know microsoft outlook’s address book’s format *.pst. mozilla thunderbird or others? pst isn't address book, it's archived email. you start reading source of apache tika handles formats.

Why doesn't Mercurial Eclipse auto-add files like Subclipse? -

what use case behavior, has made work unavailable 1 location next on dozen occasions? why hg this? how "not in know"? hg behaves svn in case: tracks files explicitly added svn add or hg add command. but eclipse plugins behave differently. why - ask authors.

stringtemplate - separator in string template -

i have following code in stringtemplate file: (1) module $component$ = new module(new geometrydescription[] {$shapes;separator=", "$}); which know wrong able generate multiple of line so when call list of components component1(north, part1, part2) component2(north, part1, part2,part3) following: module north = new module(new geometrydescription[] {part1,part2}); module south = new module(new geometrydescription[] {part1,part2,part3}); how can write sentence (1) able thanks you need wrap (1) in template , map template across list of components.

best practices for hibernate 3.6 and spring 3? -

any examples of integrating latest versions of hibernate , spring? template pros , cons? are looking more documentation 1 provided here spring reference ? here pros , cons of using hibernate template: spring hibernate template when use , why?

Make sure html elements are closed when showing a substring on a webpage (ruby on rails) -

let's doing this: entries.each |entry| entry[0,1000] + "..." end let's entry has <ul> , <li> not closed, because chopped entry in middle of list. how can make sure close tags out, rendering isn't messed up? i considering creating method found last index of <ul> , made sure less last index of </ul>, etc. seems cumbersome though. ideas on how solve ruby on rails? thanks! check out hpricot gem: hpricot("<ul><li>foo<ul><li>bar").to_html => "<ul><li>foo<ul><li>bar</li></ul></li></ul>"

hosting - How Google App Engine limit Python? -

does know, how gae limit python interpreter? example, how block io operations, or url operations. shared hosting in way? the sandbox "internally works" them having special version of python interpreter. aren't running standard python executable, 1 modified run on google app engine. update: and no it's not virtual machine in ordinary sense. each application not have complete virtual pc. there may virtualization going on, google isn't saying how or what. a process has in operating system limited access rest of os , hardware. google have limited more , environment allowed read specific parts of file system, , not write @ all, not allowed open sockets , not allowed make system calls etc. i don't know @ level os/filesystem/interpreter each limitation implemented, though.

Java:how to group similar strings (items) to respective array (group)? -

i have following string "0#aitem, 0#aitem2, 0#aitem3, 1#bitem, 1#bitem2, 2#citem, nitem, nitem2". the 0# shows group number. aitem, aitem2, aitem3 belong group 0 . bitem, bitem2 in group 1 . citem in group 2 . if there no group number, place in separate group. nitem, nitem2 placed in group 3 . i create array each group, , place "items" in respective group(array). end like [array("aitem,aitem2,aitem3"), array("bitem, bitem2"), array("citem"), array("nitem, nitem2")] i guessing need arraylist hold groups (arrays) respectively has appropriate elements (items). this started don't know if best approach. string dynamic, there can number of groups , has follow criteria above. string[] x = pattern.compile(",").split("0#item, 0#item2, 0#item3, 1#item, 1#item2, 2#item, item"); (int ii=0; ii<x.length; ii++) { system.out.println(i + " \"" + x[ii] + "\""

php - Joomla: How to display an article in its own page rather than in home page? -

for example, joomla website www.abc.com. when first entered, works fine. link of article www.abc.com/index.php/component/content/article/144-2010-11-16-08-35-52, , linked page. but after clicked "home" on navigation bar, url http://www.abc.com/index.php/home , link of article changed www.abc.com/index.php/home/144-2010-11-16-08-35-52. when clicked link, content of article showed on home page. how can fix that? on global configuration make sure seo settings has (use apache mod_rewrite) set on , rename htaccess.txt file on root of installation .htaccess

php - Override Doctrine_Record validate method with a Doctrine_Template -

in symfony project use new strategy manage data form. i don't want use symfony form object, want use model build them. i don't want redeclare base doctrine_record class, wrote new doctrine_template: extendedmodel. in extendemodel template i've new objects , methods, need override validate() function of doctrine_record. i tried with class extendedmodel extends doctrine_template { [...] public $validatorschema; public function setvalidatorschema(sfvalidatorschema $validatorschema) { $this->validatorschema = $validatorschema; } public function getvalidatorschema() { return $this->validatorschema; } public function validate() { $this->getinvoker()->setup(); $errorstack = $this->getinvoker()->geterrorstack(); if ($this->getvalidatorschema()) { try { $this->getvalidatorschema()->addoption('allow_extra_fields', true); $this->getvalidatorschema()->clean($this->getinvo

ruby on rails - how to do authentication on different type of users using devise -

first of all, avoid using term "role" here. because there similar post answered ---"looking cancan". the problem need sovle need authentication on 2 different type of users, , attributes of 2 users different each of them has own model , corresdonding table. if treat devise's work access control model, question can rephrased devise support multiple models authentication?i'm quite suspious of that, because @ file name, under app/views/devise/ , none of them contails "model" info in it. anyway, need confirmative answer guys. all explain on todo : https://github.com/plataformatec/devise/wiki/how-to:-add-an-admin-role the model in devise library include can include on several model of application.

Auto logout using sessions in Django (outside views) -

i'm trying build auto-logout function in django application. basically, each request site want set current timestamp in session (if not set), , checking value current time. if difference great, should redirect logout. is there easy way set session on each request without adding function each of views? know it's possible use sessions outside views, have supply session_key, , i'm not sure should from, or generate myself. i'm not sure timestamp comparing here, or why. the usual way manage auto-logout set short expiry on session cookie, via session_cookie_age setting. if cookie expires, user automatically redirected login page if try , access page requires authentication.

Check if a file is available (not used by another process) in Python -

i'm looking code check if file in file system available (not used process). how in python? thanks! how i'll use it: cylically check if file available , when (processes don't need anymore) delete it. while true: try: os.remove(yourfilename) # try remove directly except oserror e: if e.errno == errno.enoent: # file doesn't exist break time.sleep(5) else: break

Custom android preference type loses focus when typing -

i created simple preference class shows autocompletetextview control , displays when focus on autocompletetextview , start typing brings keyboard loses focus on control. any idea why loses focus? here's did create view. inflated layout basic linear layout title textview in it. i change dialog preference instead guess it'd smoother if part of base view. @override protected view oncreateview(viewgroup parent) { layoutinflater inflater = (layoutinflater) getcontext().getsystemservice(context.layout_inflater_service); linearlayout layout = (linearlayout) inflater.inflate(r.layout.base_preference, null); if (mhint != null) { textview hintview = (textview) layout.findviewbyid(r.id.preferencehinttextview); hintview.settext(mhint); } textview titleview = (textview) layout.findviewbyid(r.id.preferencetitletextview); titleview.settext(gettitle()); autocompletetextview inputview = new autocompletetextview(getcontext()); inputv

Send message from server at specific time in php? -

is there way send mail @ specific time in php? please give me hint file. forget file used send mail specific time. you want use cron.php file name think forget name right?

how to get synonyms list from ms word using C# -

in word automation, how synonyms list through ms word using c# language. please advice me. use synonyminfo object refer http://msdn.microsoft.com/en-us/library/bb178951.aspx

html - Two column of several divs -

i'm making 2-column layout divs. should this: http://dl.dropbox.com/u/4976861/html-demo.html but there problem. if content stretches side blocks vertically, left blocks shift downwards: http://dl.dropbox.com/u/4976861/html-demo-2.html if put sidebar wrapper div, works fine, make code quiet messy because of paddings , background issues removed simplify demo, leave option now. i don't think you're going able produce results without changing underlying html. you're trying allow elements flow (both vertically , horizontally) within page, order in have elements not going allow this. i might teaching suck eggs, preference html output this: <div class="wrap"> <div class="column1"> <div>left 1</div> <div>left 2</div> <div>left 3</div> </div> <div class="column2"> <div>right 1</div>

xmpp - logging to sasl enabled server in iphone chatting app..? -

i making chat app in can chat each other..i using xmpp framework iphone.. http://code.google.com/p/xmppframework/ i have started here.. now can login sasl disabled server cannot login sasl enabled server..it gives error "not-authorised"..what should do..?any idea..?any other app using sasl login ..?? make sure can log in sasl-enabled server existing client. in these scenarios, sasl-enabled server isn't configured correctly.

visual c++ - Why does adding a comment change compiled code (object) and executable in C++ -

i've started add doxygen comments code see comments change object code , linked executable in visual c++. i used objdump catch differences. expect date , checksum differences no more. however, adding comment line doxygen style comment on method changes object code , executable. do have idea can cause of weird behaviour or there method can verify no changes in executable after adding comments? cheers, burak if compiling debugging symbols, comments cause line references move around.

c# - Add a style to a generated TextBlock -

i add custom style generated textblock. textblock title = new textblock(); title.style = (style) application.current.resources["styletheke"]; title.text = "test"; stackmenu.children.add(title); this style defined in <phone:phoneapplicationpage.resources> <style x:key="styletheke" targettype="textblock"> <setter property="width" value="auto"/> <setter property="height" value="40"/> <setter property="fontsize" value="{staticresource phonefontsizelarge}"/> <setter property="foreground" value="{staticresource phoneaccentbrush}"/> </style> </phone:phoneapplicationpage.resources> however .. textblock appears "unstyled". if resource in same page can refer via: (style) resources["styletheke"]; the application.current.resources diction

windows phone 7 - WP7 WebBrowser control zoom -

some pages small , hard read in webbrowser control, zooming possible? if have control of html can set initial-scale of viewport. more background here. the ie mobile viewport on windows phone 7

How to pass src directory to the classpath with maven eclipse plugin -

my project structure not "src/main/java". how can give src directory manually pom.xml? ps:i tried , tags. resources applying include command but,by default act, adds exclude * . .java not working. sourceincludes doing nothing:) build <sourcedirectory>../java-path-to-source </sourcedirectory> <plugins> <plugin> <artifactid>maven-compiler-plugin</artifactid> <version>2.0.2</version> <configuration> <includes><include>**</include></includes> </configuration> </plugin> </plugins> </build> </project> http://maven.apache.org/guides/mini/guide-using-one-source-directory.html

how to display python list in django template -

i new python , django. want know how can dispaly python list in django template. list list of days in weeks e.g day_list = ['sunday','monday','tuesday'] pass template context , iterate on it. {% day in day_list %} {{ day }} {% endfor %} this documentation for tag . recommend go through django tutorial , , in part 3 go on passing stuff templates, including iterating on sequences of stuff (like lists).

iphone - Marrying Core Animation with OpenGL ES -

edit: suppose instead of long explanation below might ask: sending -setneedsdisplay instance of caeagllayer not cause layer redraw (i.e., -drawincontext: not called). instead, console message: <gllayer: 0x4d500b0>: calling -display has no effect. is there way around issue? can invoke -drawincontext: when -setneedsdisplay called? long explanation below: i have opengl scene animate using core animation animations. following standard approach animate custom properties in calayer, created subclass of caeagllayer , defined property scenecenterpoint in value should animated. layer holds reference opengl renderer: #import <uikit/uikit.h> #import <quartzcore/quartzcore.h> #import "es2renderer.h" @interface gllayer : caeagllayer { es2renderer *renderer; } @property (nonatomic, retain) es2renderer *renderer; @property (nonatomic, assign) cgpoint scenecenterpoint; i declare property @dynamic let ca create accessors, override +needsdis

java - Tomcat -- Running a web application -

i'm trying run sample app in tomcat. i've installed tomcat, set environment variable creating new system variable called java_home set c:\program files\java\jdk1.6.0_20. , i've created new dir web app in tomcat program directory. in cmd prompt navigate tomcat program directory , type in bin/startup.sh , following error: 'bin' not recognized internal or external command, operable program, or batch file. i'm using tomcat 6.0 , i'm on windows machine. problem? if try typing in bin\startup.bat on windows machine , still same error, there's possibility windows not seeing batch script should be. a-horse-with-no-name said, try installing tomcat location there no spaces in path. in case, anywhere other program files . edit: resolve space issue, can 2 things: 1) install jdk/jre common location without spaces (say, c:\java) , set java_home environment variable. 2) install tomcat location (say, c:\tomcat) , proceed there. since these in common loc

Testing for overlapping arrays in Ruby -

say have array of arrays in ruby, [[100,300], [400,500]] that i'm building adding successive lines of csv data. what's best way, when adding new subarray, test if range covered 2 numbers in subarray covered previous subarrays? in other words, each subarray comprises linear range (100-300 , 400-500) in example above. if want exception thrown if tried add [499,501], example, array because there overlap, how best test this? since subarrays supposed represent ranges, might idea use array of ranges instead of array of array. so array becomes [100..300, 400..500] . for 2 ranges, can define method checks whether 2 ranges overlap: def overlap?(r1, r2) r1.include?(r2.begin) || r2.include?(r1.begin) end now check whether range r overlaps range in array of ranges, need check whether overlap?(r, r2) true r2 in array of ranges: def any_overlap?(r, ranges) ranges.any? |r2| overlap?(r, r2) end end which can used this: any_overlap?(499..501,

asp.net mvc - Client side validation script is not generated for partial views fetched using AJAX -

i trying setup client side validation using microsoftmvcjqueryvalidation work ajax submitted forms. works fine if partial view rendered directly view. when try fetch on xhr, example show in jquery dialog, client validation javascript not generated output html. ideas? working code - partial view rendered using html.renderpartial: view: <%@ page title="" language="c#" inherits="system.web.mvc.viewpage<dynamic>" %> <asp:content id="content2" contentplaceholderid="maincontent" runat="server"> <% html.renderpartial("new"); %> </asp:content> partial view: <%@ control language="c#" inherits="system.web.mvc.viewusercontrol<product>" %> <% html.enableclientvalidation();%> <% html.beginform();%> <%= html.editfield(m => m.price)%> <%= html.validationmessagefor(m => m.price)%> <% html.endform();%> not working

What is a good programming font that looks good through Remote Desktop? -

Image
i guess i've gotten spoiled consolas working on local development machine. @ work lot of development remotely via remote desktop, fonts requiring cleartype awful . i mean, look @ this: normally i'm not big fan of courier new, in scenario beats consolas, along other otherwise great-looking programmer fonts i've found (which seem require cleartype or other rendering effect apparently isn't available through remote desktop, @ least windows xp) hands-down. can suggest high-quality fonts suitable programming still through remote desktop? follow guide - perhaps it's configuration issue: http://www.ytechie.com/2008/12/cleartype-in-remote-desktop-with-xp.html the above guide shows how every windows os supporting clear type. dave

vim - CTRL+mouse wheel in gvim (windows) not paging -

i'm loving vim, 1 thing that's bugging me when hold control key , mouse wheel or down, window scrolls when bindings telling page up/down. i'm using exact same vimrc file (and plugins) on 1 of linux machines , ctrl+mouse wheel page down (as opposed scrolling in windows). is there way force gvim response ctrl+mouseup/down event? seems ignoring in windows ='[ in insert mode, pressing <ctrl+v> , holding <ctrl> , , scrolling mouse doesn't input escape sequence, implies it's not possible remap actions scroll wheel. compare, example, <ctrl+v> <ctrl> left click, inserts <c-leftmouse> . there doesn't seem in mouse events beyond clicks either.

regex - Python - extracting a list of sub strings -

how extract list of sub strings based on patterns in python? for example, str = 'this {{is}} sample {{text}}'. expected result : python list contains 'is' , 'text' >>> import re >>> re.findall("{{(.*?)}}", "this {{is}} sample {{text}}") ['is', 'text']

c# - strange behaviour on another process via Process.Start(startInfo) -- continue -

the original location ( strange behaviour on process via process.start(startinfo) ) doesn't allow me post test code properly. have start new question here. our c#(v3.5) needs call c++ executable process raw data file , generate result files us. it worked before following code (without readtoend() or readline() call): startinfo.useshellexecute = false; startinfo.redirectstandarderror = true; startinfo.redirectstandardoutput = true; now input raw data file changed (bigger before). our call executable hang forever. based on advice, added readtoend() or readline() hang on calls. have either use startinfo.useshellexecute = true; or set startinfo.useshellexecute = false; // , startinfo.redirectstandarderror = false; startinfo.redirectstandardoutput = false; don't know why? following cases tested: working case: processstartinfo startinfo = new processstartinfo(); startinfo.createnowindow = true; startinfo.useshellexecute = false; startinfo.redirectstandarde

java - Does Jmeter run everything in its own JVM, or create a JVM for each thread group? -

it seems me jmeter might running thread group within own jvm. true or jmeter create new jvm's different thread groups and/or samplers? all in 1 jvm. can run more 1 instance of jmeter though :)

Can I throw an error in vbscript? -

i'm used programing in c#, has pretty robust error handling. i'm working on short project in vbscript. i've read error handling vbscript using "on error _______" , err global variable. however, there way can generate own errors? example if 1 of functions passed wrong type of parameter i'd rather script flat out fail @ point try continue. yes, can. use err.raise method, e.g.: err.raise 5 ' invalid procedure call or argument for list of vbscript's standard error codes, see errors (vbscript) .

ruby on rails - no method error in one to many relationship -

models/user.rb class user < activerecord::base has_many :clubs, :dependent => :destroy has_many :announcements, :dependent => :destroy end models/announcement.rb class announcement < activerecord::base belongs_to :user belongs_to :club end models/club.rb class club < activerecord::base belongs_to :user has_many :announcements, :dependent => :destroy end controllers/announcements/announcements_controller.rb def index @announcements = announcement.find(:all, :include => [:user, :club]) end problem: when type code, views/announcements/index.html.erb <% @announcements.each |announcement| %> <%= announcement.user.username %> <% end %> i error: nomethoderror in announcements#index undefined method `username' nil:nilclass when change code this, works. <% @announcements.each |announcement| %> <%= announcement.club.user.username %> <% end %> why first code not working? difference between

Remove everything except regex match in Vim -

my specific case text document contains lots of text , ipv4 addresses. want remove except ip addresses. i can use :vglobal search ([0-9]{1,3}\.){3}[0-9]{1,3} , remove lines without ip addresses, after know how search whole line , select matching text. there easier way. in short, i'm looking way following without using external program (like grep): grep --extended-regexp --only-matching --regexp="([0-9]{1,3}\.){3}[0-9]{1,3}" calling grep vim may require adapting regex (ex: removing \v). using vim's incremental search shows me i've got pattern right, , don't want verify regex in grep too. edit: peter, here's function use. (c register clobber in functions.) "" remove text except matches current search result "" opposite of :%s///g (which clears instances of current search). function! clearallbutmatches() let old = @c let @c="" %s//\=setreg('c', submatch(0), 'l')/g %d _ put

Python / Javascript -- integer bitwise exclusive or problem -

i'm proficient both languages... i'm having problems integer bitwise exclusive or logical operator. in javascript, gives me 1 result, in python gives me another.. go ahead, open python , execute (-5270299) ^ 2825379669 now javascript, same calculation, , alert result or whatever (example @ http://thorat.org/os/js.php ) the results different! have no idea why! i must missing something. javascript's integers 32-bit whereas python automatically converts unlimited length long format when values exceed 32 bits. if explicitly force python not sign extend past 32 bits, or if truncate result 32 bits, results same: >>> (-5270299 & 0xffffffff) ^ 2825379669 1472744368l >>> (-5270299 ^ 2825379669) & 0xffffffff 1472744368l

android - How to kill other apps? -

how can kill other applications? can launch other applications using intents can't find way kill them. this launches application: intent = new intent(); i.setaction(intent.action_main); i.addcategory(intent.category_launcher); i.setflags(intent.flag_activity_new_task); i.setcomponent( new componentname("com.bla.bla...", "com.bla.bla.main")); context.startactivity(i); i've tried use activity manager's kill killbackgroundprocesses(string packagename) but nothing. i've tried appcontext.stopservice(intent) but did nothing

c++ - What is causing boost::lower to fail an is_singular assertion? -

i getting odd behavior boost::lower, when called on std::wstring. in particular, have seen following assertion fail in release build (but not in debug build): assertion failed: !is_singular(), file c:\boost_1_40_0\boost/range/iterator_range.hpp, line 281 i have seen appear memory errors after calling boost::to_lower in contexts such as: void test(const wchar_t* word) { std::wstring buf(word); boost::to_lower(buf); ... } replacing calls boost::tolower(wstr) std::transform(wstr.begin(), wstr.end(), wstr.begin(), towlower) appears fix problem; i'd know what's going wrong. my best guess perhaps problem has changing case of unicode characters -- perhaps encoding size of downcased character different encoding size of source character? does have ideas might going on here? might if knew "is_singular()" means in context of boost, after doing few google searches wasn't able find documentation it. relevant software versions: boost 1.40.0;

c++ - Vector iterator not dereferencable? -

i'm getting error code: for(std::vector<aguitimedevent*>::iterator = timedevents.begin(); != timedevents.end();) { if((*it)->expired()) { (*it)->timedeventcallback(); delete (*it); = timedevents.erase(it); } else it++; } what problem? the timed event pushes new 1 in when callback called, might thanks if looping through vector , callback function causes vector added to, iterators vector may invalidated including loop variable it . in case (where callback modifies vector) better off using index loop variable. you need thorough analysis of design make sure aren't going create unexpected infinite loops. e.g. for(std::vector<aguitimedevent*>::size_type n = 0; n < timedevents.size();) { if(timedevents[n]->expired()) { timedevents[n]->timedeventcallback(); delete timedevents[n]; timedevents.erase(timedevents.begin() + n); } else

c - Convert white space to tabs -

i decided learn c, started going through k&r, got stuck on problem 21 in chapter 1. supposed write program, given string without tabs , tabwidth, converts white space equivalent spacing using tabs , white space. so far, i've got this: void entab (char from[], char to[], int length, int tabwidth) { int i, j, tabpos, flag, count; j = tabpos = flag = count = 0; (i = 0; from[i] != '\0' && j < length - count - 2; i++) { if (from[i] == ' ') { // if see space, set flag true , increment // whitespace counter. don't add characters until reach // next tabstop. count++; tabpos = (tabpos + 1) % tabwidth; flag = 1; if (count >= tabwidth - tabpos) { to[j] = '\t'; j++; count = count - tabwidth + tabpos; tabpos = 0; } } else { if (flag == 1) {

asp.net - What happens to orphaned/killed async AJAX WebMethod or PageMethod calls? -

what happens behind scenes if make ajax pagemethod or webmethod call from, say, "default.aspx" , navigate away different page, say, "settings.aspx" before initial pagemethod has returned? what kind of housekeeping, if any, takes place on either browser or asp.net end? in other words, abandoned ajax pagemethod calls go die...and funeral like? there's no magic here. made request. server presumably received request. likely, act upon request , send response. of course, if connection has been closed, server receive error when sends response, deal common occurence. i don't know whether or not browser close connections created in 1 top-level window when destroy in order navigate document. suspect will, depending on browser.