Posts

Showing posts from April, 2013

ruby on rails - validation before attribute setters can type cast -

i have object attribute called value of type big decimal. in class definition have validates_numericality_of. however if i: a.value = 'fire' 'fire' ends getting typecast correct type before validation fires so: a.valid? => true how validation fire before typecast? thanks dan from activerecord::base docs : sometimes want able read raw attribute data without having column-determined typecast run course first. can done using <attribute>_before_type_cast accessors attributes have. example, if account model has balance attribute, can call account.balance_before_type_cast or account.id_before_type_cast . this useful in validation situations user might supply string integer field , want display original string in error message. accessing attribute typecast string 0, isn’t want.

internet explorer 8 - Jquery display problem in IE -

i have kind of "tab" solution built in jquery. when user clicks tab id of tab , shows right content tab based on id. works perfect in firefox, when tab clicked hides divs class "page" , show right page. in ie8 works in same way strange thing happens, content of page shown on content of active page. if click tab1 shows cotent of page1 awesome-buttons page2 show up. when dragging mouse on awesome-button shouldn't there disappears, seems kind of "graphic/display" problem. doesn't happen time, works should. have seen problem , there solution? this code in jquery, html , css: $(document).ready(function() { $('.pages').hide(); $('.tab').click(function() { var isactive = $(this).hasclass('tabactive'); var pages = $(this).closest('div').prev('div'); var tabs = $(this).closest('div'); $(".page").hide(); $(".page").css({ 'z-index:': '0...

virtualization - How to run Windows from an emulator on a non x86 host machine? -

windows runs on x86 based cpus only. possible make windows run on non-x86 architecture cpus power, sparc, arm, etc.... know there program viz., virtual pc 7 mac allows windows run on powerpc inside mac os not detail available.... i'm talking virtualization in sense allows host , guest machines cpu architectures different.... try qemu: http://www.qemu.org/index.html .

.htaccess can't redirect .pl files -

has had issue try , redirect of .pl file , file shows forbidden? here example of i'm trying do: ( http://www.oldsite.com/folder/sample.pl ) needs redirect to... ( http://www.newsite.com/newpage/ ) here have put in .htaccess file located in folder on old site (because don't have access web root .htaccess file): #the first line should allow pearl file extension execute options execcgi followsymlinks rewriteengine on rewriterule ^sample\.pl$ http://www\.newsite\.newpage/ [r=301,nc] though, forbidden page when go ( http://www.newsite/folder/sample.pl ). without .htaccess file in place still forbidden page. it's .pl files cause forbidden page. if go of these fake pages (sample.asp, sample.jsp) bring proper "page not found" message. can think of ideas around .pl extension issue? thank you!

Use of SVN list command without password -

when execute svn list command, requests password twice. need execute without password. is possible? i see you're using svn+ssh:// . means password prompts coming ssh, not svn itself. first thing need configure ssh passwordless authentication. common way using public keys. the svn manual has tips configuring public key access . for debugging problems ssh access, it's useful run ssh hand, this: ssh -v svn.sts.com.jo svnserve -t .

windows - Is there a way of knowing when an executable was last executed? -

in windows, there way find out when executable last executed? it seems unlikely saved, i'm open other suggestions. it enough know if executed "recently", example since computer started, last hour etc. i'm open hackish ideas, checking pagefile maybe see traces left executable? you can auditing. run gpedit.msc, computer configuration, windows settings, security settings, advanced audit policy configuration, system audit policies, detailed tracking, audit process creation. ask more questions @ superuser.com

Download link in asp.net mvc -

i have uploaded document asp.net mvc 2 application application domain. there directory name "docs". want create link download document application . how that? edited: i taking link database. "item.downloadpath". want check value null or not .i can <% if (item.downloadpath!= null) %> put as: <% if (item.downloadpath!= null) %> ">, giving error edited:- answers , tried these code working doc , docx document . if uploads .txt or image .jpg opens in browser. should ask download. have ? <a href="<%= url.content("~/docs/documentname.doc") %>"> download </a> should work.

iphone - Can I use NSAttributedString in Core Text in iOS? -

i'm trying work out how take nsattributedstring , use in core text on ipad. watched 1 of wwdc videos (110) has slides (but no source code) , describes how create nsattributedstring, put ctframesetterref: ctfontref helveticabold = ctfontcreatewithname( cfstr("helvetica-bold"), 24.0, null); nsstring* unicodestring = nslocalizedstring(@"titlestring", @"window title"); cgcolorref color = [uicolor bluecolor].cgcolor; nsnumber* underline = [nsnumber numberwithint:kctunderlinestylesingle|kctunderlinepatterndot]; nsdictionary* attributesdict = [nsdictionary dictionarywithobjectsandkeys:helveticabold, (nsstring*)kctfontattributename, color, (nsstring*)kctforegroundcolorattributename, underline, (nsstring*)kctunderlinestyleattributename, nil]; nsattributedstring* stringtodraw = [[nsattributedstring alloc] initwithstring:unicodestring attributes:attributesdict]; ctframesetterref framesetter = ctframesettercreatewithattributedstring(stringtodraw); ctframe...

PHP MVC: Where to Put Dynamically Generated Javascript -

most php mvc systems follow pattern request routed specific controller action, , controller sets bunch of variables use in view. when you're in agency/services work environment uses lot of dynamic html ui elements, patterns leads lot of javascript being generated view variables <script type="text/javascript"> jquery(document).ready(function(){ $('#ui-element).init( { 'param1':<?=$this->param1;?>, 'param2':<?=$this->param2;?>, } ); }); </script> while works, i've found leads views horrible spaghetti mix of html, php , javascript. offends class of front-end developer thinks javascript should included in external files. so, patterns/practices deal problem? specifically, when want provide default set of data javascript widget in php mvc framework, how do while keeping things clean , modular? matter of discipline...

SQL Server Replication by column mapping -

is possible use sql server's replication service replicate table on given server different schema on table b? ie, table a ---------- id int name varchar(20) data text table b ---------- id int name varchar(20) description varchar(10) replication copy "name" table table b given id. it possible choose specific columns within table article data, however, i'm not sure if possible map data on subscription side. replication services interested in issue, however, in getting lost in nice tool, overlooked simpler solution. for reference, solution ended going scheduling stored procedure job, continually updates given data set.

codeigniter - Should I use Database Sessions or Native PHP File Sessions? -

i've moved on own mvc framework community supported 1 (codeigniter). i'm converting sessions on codeigniter functions , noticing they, default, store session data in encrypted cookie. alternative offer database sessions not server-side file sessions native php library. now on site, building secure backend panel encrypted cookie doesn't seem smart option don't particually want have connect database unnecessarily it's not fast (shared hosting). i'm wondering reasoning behind them not supporting native sessions , whether database sessions or server-side file sessions regarded better option. thanks. basically, store session's data, people use 1 of 3 solutions : files (the default) database memcached files used, it's default -- , works fine in cases -- there's @ least 1 situation in doesn't work : when have several servers, , users load-balanced on (i.e. when 1 user not on same server) . in kind of situation, having c...

c# - .NET 4.0 Late Binding: Ensure Assembly Authenticity? -

i have develop .net c# application supports plugins. i’ve found lot of information on internet , doesn’t seem hard. i have specification assemblies of modules must validated on assembly level. when late binding occurs , assembly loads, host application must absolutely sure that: the assembly wasn’t changed. the assembly indeed supplied company. i read possible sign assembly using key, far understood, certify assembly wasn’t changed. what must done in order sure of assemblies authenticity? any appreciated. like said in comment, has been asked before: can strong naming assembly used verify assembly author? this link gives example of how verify public key against known set of public keys: http://blogs.msdn.com/b/shawnfa/archive/2004/06/07/150378.aspx it's kinda old, , don't know if there have been significant changes since then. edit: see answer suggests same technique link shawnfa's blog above, still stands.

build - Maven : Parent project not resolved, transitive dependencies not used for compiling -

after searching , trying lot of things need maven maven :) so, problem on development box (which windows 2003) can build maven project, on bamboo server (x86_64 x86_64 x86_64 gnu/linux) fails because 1 of modules doesn't have library , compiling doesn't find class. class found in transitive dependency, dependency seems me not resolved. i've run command "mvn -x clean install" on both boxes , compared output. change think it's relevant on dev-box [debug] retrieving parent-pom: pl.com.abg.iacsro:sapscndp-claimprocessing:pom:1.0-snapshot project: pl.com.abg.iacsro:sapscndp-claimprocessing-api:jar:dev2010 repository. on bamboo box [debug] retrieving parent-pom: pl.com.abg.iacsro:sapscndp-claimprocessing:pom:1.0-snapshot project: null:sapscndp-claimprocessing-api:jar:dev2010 repository. it seems me maven doesn't resolve parent of module, because later in build process i've seen (on bamboo box) [warning] pom 'pl.com.abg.iacsro:saps...

autosuggest - How to get auto suggestion from server -

how auto suggestion server, list of items in textbox can selected in java/j2ee ? i suggest using jquery has nice autocomplete plugin. need build simple webservice provide data. so building simple java backend deals getting data out , using autocomplete consume data on front end.

django - manage.py syncdb error, postgres_psycopg2 -

i'm trying install shopping cart plugin django having problem when run manage.py syncdb. when run, installs 4 tables, i'm getting following error message: file "(mypath)/django/db/backends/postgresql_psycopg2/base.py", line 44, in execute return self.cursor.execute(query, args) django.db.utils.databaseerror: numeric scale 127 must between 0 , precision 10 i'm guessing there problem models.py don't know line at. has ever run similar? sounds have numeric field invalid scale defined. did perhaps mix scale , precision?

c# - WebBrowser control stops focus on richtextbox -

i have problem webbrowser component. reason, when click it, disables me setting focus on richtextbox. i have 2 same forms. main difference between first , second form is, form1 modifying webbrowser documenttext , form2 using webbrowser display content of temporary file. first form working well, webbrowser not disabling focus on richtextbox. second form problematic one. when click webbrowser component, , richtextbox, never gains focus focus() method again :( i solved :) added while loop waits, until webbrowser.document property initialized. used webbrowser.document.createelement creating new html elements, , webbrowser.document.body.appendchild adding them document. (i stopped using temporary file...)

python - "Optional" backreferences in regular expression -

i have regular expression 2 groups or'd , i'm wondering if it's possible have group reference only if matched? in cases, i'm wanting match spam.eggs.com example: import re monitorname = re.compile(r"hq01 : http service - [ss][rr][vv]\d+\.\w+\.com:(\w+\.\w+\.(?:net|com|org))|(\w+\.\w+\.(?:net|com|org))") test = ["hq01 : http service - spam.eggs.com", "hq01 : http service - spam.eggs.com - disabled", "hq01 : http service - srv04.example.com:spam.eggs.com", "hq01 : http service - srv04.example.com:spam.eggs.com - disabled"] t in test: m = monitorname.search(t) print m.groups() produces: (none, 'spam.eggs.com') (none, 'spam.eggs.com') ('spam.eggs.com', none) ('spam.eggs.com', none) it'd nice if groups return 1 matched group , not both. the | operator has precedence applies everything before ( from beginning of regex in case) or after it. i...

c++ - deleting object pointer referring by two pointers -

i have object say. classa *obj1 = new classa; classa *ptr1 = obj1; classa *ptr2 = obj1; when delete ptr1; , affect ptr2 ? if can correct solution this? (assuming obj2 supposed obj1 ) classa *x defines pointer can point objects of type classa . pointer isn't object itself. new classa allocates (and constructs) actual object of type classa . so line class *obj1 = new classa; defines pointer obj1 , sets point newly allocated object of type classa . the line class *ptr1 = obj1; defines pointer ptr1 , sets point same thing obj1 pointing to, is, classa object created. after line class *ptr2 = obj1; , have 3 pointers ( obj1 , ptr1 , ptr2 ) pointing same object. if delete ptr1; (or equivalently, delete obj1; or delete ptr2; ), destroy pointed object. after doing this, pointer pointing object made invalid (which answers first question: yes, affect ptr2 in sense ptr2 won't pointing valid object afterwards). the correct solution depends on you...

.net - Communication between c# and MySql solution required -

i developing desktop application using c#.net , mysql. there solution communicate mysql out dll file. using mysql.data.dll , have put file exe file not feasible solution. alternatively try merge mysql.data.dll exe using example one of tools discussed here . or, if app doesn't use database heavily, create kind of central service application app talks (through web services, perhaps) , in turn handles database querying (using mysql.data.dll).

java - Building a mobile web site -

we in process of looking @ allowing mobile devices view our site. have targeted 3 phones - blackberry, iphone , android. being new have several questions. i going assume looking @ here browser capabilities of devices , not device (the device comes play if building mobile application - correct?) so, have on line auction site in front end build using jsf 1.1, myfaces , richfaces. going move jsf 1.2 anyway , allow make use of trinidad since appears friendly mobile site. the concern have performance. on our current site allow user search , result of search can lot of data returned. running desktop browser there wait result set now. can assume there greater wait result set when viewing mobile device unless different these request - correct? so building mobile front end still not going address performance issues face non mobile site - correct statement? are there sites out there recommended learn more how take site , make mobile ready? thanks you start http://...

Which permissions does Eclipse need to run? -

i installed eclipse , having trouble relating denied user permissions. i working on vista inside windows domain. user account restricted. boss needs grant administrator permission time install application or establish new network connection through firewall. here of problems have occurred: at eclipse startup, vista asks every time if want run it. doesn't remember decision. eclipse doesn't remember default workspace. i installed birt plugin. after second restart doesn't work anymore. birt perspective not run fine. what permissions need run eclipse on windows? this problem occurs when host eclipse application within directory protected vista or windows 7 operating system. example, %programfiles% , %programfiles(x86)% , or %programw6432% . unfortunately, of eclipse's maturity, still doesn't entirely restrict per-user activities windows operating system's user space. if don't care eclipse application resides, or don't have admin ...

python - Character encoding is violated -

i trying parse file encoded in utf-8 . no operation has problem apart write file (or @ least think so). minimum working example follows: from lxml import etree parser = etree.htmlparser() tree = etree.parse('example.txt', parser) tree.write('aaaaaaaaaaaaaaaaa.html') example.txt: <html> <body> <invalid html here/> <interesting attrib1="yes"> <group> <line> δεδομένα1 </line> </group> <group> <line> δεδομένα2 </line> </group> <group> <line> δεδομένα3 </line> </group> </interesting> </body> </html> i aware of similar previous question not solve problem either without specifying outpu...

advertising - Self-managed rich ad platform for iOS apps? -

a media publishing company has existing inventory of advertisers traditional media channels. ipad app doing well, , want use inventory in-app rich advertising. i can't find rich ad solutions allow self-management. admob closest far, it's not true rich media: http://www.admob.com/marketing/ivau i read vague references medialets partners, nothing concrete. can please recommend platform/provider can deliver this? (to cast in programming terms, need ad provider offers ios library/api serving ads in html5 or similar, , lets me upload own content). medialets contacted me, offer self-management fee per click. it's pretty expensive can't find else it. admob seems allow free self-management traditional ads.

c# - Interfaces or Attributes for Tagging Classes? -

i have couple of classes wish tag particular attribute. have 2 approaches in mind. 1 involves using attribute-extending class. other uses empty interface: attributes public class foodattribute : attribute { } [food] public class pizza { /* ... */ } [food] public class pancake { /* ... */ } if (obj.isdefined(typeof(foodattribute), false)) { /* ... */ } interface public interface ifoodtag { } public class pizza : ifoodtag { /* ... */ } public class pancake : ifoodtag { /* ... */ } if (obj ifoodtag) { /* ... */ } i'm hesitant use attributes due usage of reflection. @ same time, however, i'm hesitant on creating empty interface serving tag. i've stress-tested both , time difference between 2 3 milliseconds, performance not @ stake here. well, attributes, can create attribute in such way function doesn't propagate descendant types automatically. with interfaces, that's not possible. i go attributes.

Quick way to remove surrounding backet/parenthese/block in Visual Studio 2010 + Resharper ? (Reverse surround with) -

is there can reverse "surround with"? from: ( (type)myobject ) ; to: (type)myobject; from: if/while/try/using... { lots of code here.... } to: lots of code here.... try structural search , replace (see jetbrains .net tools blog , jetbrains tv additional guidance) for first example, can use following pair of patterns: search pattern: (($type$) $var$) replace pattern: ($type$) $var$ where $type$ type placeholder, , and $var$ identifier placeholder. to play bit more structural search , replace, might want download sample ssr pattern catalog resharper web site

tortoisesvn - SVN: What to do if the empty folders in your working directory are deleted -

alright, working on small app recursively deletes empty directories. have under source control @ codeplex , use tortoisesvn access it. so, 1 day, ran on directory have code. , ran fine. empty directories gone. when tried commit latest changes in of subversion hosted project, wouldn't it! complaining missing folders or something. apparently there hidden folders called .svn spread around in working directory (which kind of knew about) contains, among other things, crucial empty directories (which didn't know about). apparently, crucial cannot when gone. things stop working... i tried svn update, clean up, update revision, revert, , on. nothing worked. got error messages of sort. ended having move folder, create new one, stuff codeplex again, , manually move on changes old folder. tedious , annoying. so, going on there? why can't work without empty folders? , there way fix if happens again? the .svn folders , contents (even if empty) tells subversion working...

CSS: How to make this topheader? -

Image
saw www.workatplay.com/ website, , got fascinated on how simple , nice stuff can look. wish make header above. with header reffering this: http://img227.imageshack.us/img227/619/header1o.png and how links + "[workatplay.com]" logo set @ right. i tried looking @ source & css/source learning, doesnt seem there. part nav-sub(the pink bar) gets colordefined(css) , splitted. is whole header background itself? why cant find in css or anywhere else know how have done. how can make header this? here go.. http://jeaffreygilbert.com/workatplayheader.html preview: css: /* resetter */ ol, ul, li, { background: transparent; border: 0px; font-size: 100%; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; } ul, li { list-style-type: none; } /* body */ body { background-image: url(http://www.workatplay.com/sites/all/themes/play/css/schemes/pink/b...

java - My KeyEvents don't get registered while the Timer is firing events. How to fix this? -

java noob here. in application class, have jpanel focusable set true , keylistener class added it. have timer registered timerlistener class set in application's main function. keyevents work, once press jbutton call timer.start(), keyevents stop firing , timer's actionperformed executes. when timer.stop() gets called, keyevents still don't work. know i've set wrong, can't figure out how fix it. can help? but once press jbutton call timer.start(), keyevents stop firing , timer's actionperformed executes. keyevents passed component focus. if click on button, has focus, not panel. try resetting focus on panel in button actionlistener code. or better solution use key bindings . can set key bindings action still invoked when focus on panel or component on panel.

java - Access annotated fields -

i made custom annotation project used fields, @myannotation int myvariable i have class in charge of performing actions according variables values.the project has undetermined number of classes annotations included. how can access them using annotations processor in order access values? i can check annotated variables going though each class, not modifying value since not object. any suggestion on how it? thanks in advance!! :) int getmyvariable(foo foo) throws illegalargumentexception, illegalaccessexception{ for(field f:foo.getclass().getdeclaredfields()){ /** * ensure retentionpolicy of 'myannotation' runtime. */ if(f.isannotationpresent(myannotation.class)){ return f.getint(foo); } } return -1; }

My Javascript does not execute, does anyone know why? -

could please me code? <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>welcome daily news</title> <script type="text/javascript" src="scripts.js"> </script> <link href="homepage.css" rel="stylesheet" type="text/css" /> </head> <body> <div class="body"> <div class="header"> <a href="#" title="home"><img id="header-image" src="news_logo.png" /></a> <form id="login-form" action="customerlogin.html" method="post" onsubmit="return validate(this)"> <table> <tr> <...

java - interface extends comparable -

possible duplicate: java: difference between implementing comparable , comparator? difference between comparable interface , comparator interface , use?example? comparable makes object intrinsically comparable other objects. comparator allows implement external comparison logic, can applied objects not comparable , or require different logic default comparison logic. for example, have collections.sort(list) , can sort lists of objects implement comparable , while there method - collections.sort(list, comparator) , can sort list.

soap - Trouble connecting to SSL-encrypted web service with PHP -

i got 2 certificate files provider, 1 in .cer-format , 1 in .p7b-format. converted p7b-certificate p12-certificate. certificate i'm able connect wsdl browser. proceeded convert certificate .pem-format, using instructions found on site. openssl pkcs12 -clcerts -nokeys -out test.pem -in mycert.p12 openssl pkcs12 -nocerts -out key.pem -in mycert.p12 then combing cert key using following command: cat test.pem key.pem > cert.pem heres construct web service class: public function __construct() { $wsdl_url = 'https://url.to/web_service?wsdl'; $pass = 'passphrase'; $cert = 'cert.pem'; try { $this->client = new soapclient($wsdl_url, array('local_cert' => $cert, 'passphrase' => $pass)); } catch(soapfault $e) { print_r($e); } } and here error: ssl operation failed code 1. openssl error messages: error:14094418:ssl routines:ssl3_read_bytes:tlsv1 alert unknown ca in /var/www/html/.. ...

sql - Ruby on Rails get records by highest price -

i have model rails model called orders has type_id, location, , price. each type can have multiple orders @ same location different prices. check below idea of table structure. id | type_id | location_id | price ----------------------------------- 1 | 1 | 1 | 12 2 | 1 | 1 | 14 3 | 1 | 1 | 9 4 | 2 | 1 | 1 5 | 2 | 1 | 4 6 | 3 | 1 | 15 7 | 3 | 1 | 7 i wanting select records type_id using in example: type_ids = "1,2,3" location_id = 1 order.find(:all, :conditions => ["location_id = ? , type_id in (?)", location_id, type_ids]) i want select record highest price each type in location, result set bring records id 2, 5 , 6. i can not seem work out find query this, hope understand mean. if not ask can try , explain better. cheers eef if want single highest-price conditions, use order.find(:first, :conditions => ["...

What do I need for a Windows C# quickstart? -

what bits , pieces need able compile , run simple windows console application written in c#? version of windows matter? you need a c# compiler compile application the .net framework execute application a c# compiler comes free (as in beer) visual c# express edition . command-line c# compiler ( csc.exe ) included in every .net framework installation. the .net framework included in different versions in recent versions of windows. see: what version of .net framework included in version of os? more recent versions of .net framework can downloaded free from microsoft website . the .net framework version needs match version application compiled against.

model view controller - ASP.net MVC Get only the selected rows (checkbox) -

we using asp.net mvc , having trouble in selecting list of approved orders. the orders approved selecting checkbox against each order. eg.. order id product approved 1 book (depends if user selects checkbox or not) 2 pen (depends if user selects checkbox or not) so doing this: , want know if there better way of implementating view: our false (as generated microsoft) on post in controller action method: loop through orders (which list of order object) in response(order id) = true,false: select order or else dont select but u see want avoid writing logic in controller. so ideas ? recently answered similar problem: asp.net mvc checkbox group you (it propable foreach loop): <% int = 0; foreach(order o in model.orders) { %> <%= html.checkbox("orders[" + + "].checked") %> <%= html.hidden("orders[" + "].id",order[i].id) %> <%= html.hidden(...

sql - mysql JOIN ON IF()? -

i trying use sql such this: select t.*, t2.* templates t left join if(t.t_type = 0,'templates_email', if(t.t_type = 1,'templates_sms','templates_fax')) t2 on t.t_id = t2.t_id; is possible that? basically want join on 1 of 3 tables based on value row. is recommended if possible? update so, basically templates table table contains information every template must have, eg name, id, description then have templates_x tables these tables contain fields unique each template type. (there quite few , having single table null fields not applicable not practical). the tables called templates_x appropriate x stored in templates table int flag. the join between templates_x tables , templates table through t_id . so suggest? is possible that? no, can't use dynamically assigned tables (join or otherwise) without using dynamic sql syntax (see mysql's preparedstatement syntax ). this non-dynamic re-write of pseudo-query assume...

winforms - C# Using Multiple Forms -

i have application has 2 forms. when click button on form 2 want able change text in form1: public partial class form2 : form { public form2() { initializecomponent(); } private void button1_click(object sender, eventargs e) { form1.label1.text = "fred"; } } the compiler throws error how do this? you confusing forms , form instances. form class. when form1 displays, what's displaying instance of form1 class. when form2 displays, instance of form2 displaying. you're trying use form1.label1.text = "fred"; but can set field or member of instance . you're referring class "form1". you need 2 things. i'll assume form2 launched button on form1. add constructor form2 accepts instance of form1: private form1 _starter; public form2(form1 starter) : this() { _starter = starter; } then add property form1 exposes label text: not directly expose controls - given form should know...

.net - How to call Assembly.Load(Bytes[]) in SL 4 app? -

i'm trying use assembly.load(byte[]) in silverlight 4 app , i'm getting methodaccessexception. far understand that's because app code transparent , method critical. there safecritical api load assembly byte array? then want create instance of type (sl app doesn't have compile time reference it) inside dynamically loaded assembly , make instance current item datafrom control. try this:- assemblypart assemblypart = new assemblypart(); assemblypart.load(new memorystream(yourbytearray));

internet explorer - Weird login problem on asp.net web application in IE -

in web application when try login in mozilla or chrome, takes me correct url im redirecting after authentication, im using form-authentication. but when try in ie, puts intended url in query string return , gives me login prompt again. does 1 have ideas why might , how can fixed. to redirect im using formsauthentication.setauthcookie(username, false); response.redirect(redirecturl); this login working in ie before put code allow access external application, involves creation of new aspnet user if required. can problem. its fixed simple matter of clearing browser data. :d cookies , cache removed. i had name cookie ....lol......will never use un-named cookies ever :d

c# - Parsing HTML table inside XML document using .net -

i not familiar various xml formatting have recieved xml document part of document looks ok (i can convert dataset in .net using xmlreader etc.) however, see html table inside document? for brevity posting sample html: <table> <tr> <td>1</td> <td>a1</td> <td>100</td> <td>0</td> <td>0</td> <td>0</td> <td>57.3055058694109</td> <td>-34.25451779412</td> <td>-52.0038336686283</td> <td>58.2700128150308</td> <td>-27.6125327409403</td> <td>-34.0354177282971</td> <td>5.62354809254242</td> <td>-0.964506945619888</td> <td>-6.6419850531797</td> <td>-17.9684159403313</td> <td>5.17635156249084</td> <td>18.4441134607471</td> <td>0.984914387144844</td> </tr> </table> how parse table using .net (vb.net or c...

c++ - STL containers element destruction order -

does iso c++ standard mandate sort of destruction order of objects inside stl containers? are std::list / std::vector / std::map elements destroyed starting beginning or end of container? can rely on std::map storing elements in std::pair s internally key in pair destroyed before value (or vice versa)? unspecified in standard. yes, means key destroyed after associated value.

Android: add overlay to MapView? -

i have subclassed overlay landmarkoverlay (and implemented ontap(geopoint) method). in main activity this: setcontentview(r.layout.main); mapview mapview = (mapview) findviewbyid(r.id.mapview); mapview.setbuiltinzoomcontrols(true); landmarkoverlay = new landmarkoverlay(); //add landmarkoverlay list mapview.getoverlays().add(landmarkoverlay); what else need when user taps screen, landmarkoverlay 's ontap(geopoint) method gets called? it should called. assume method ontap(geopoint point, mapview mapview) ?

XHTML thead, tfoot and tbody importance -

does xhtml have 'opinion' regarding use of <thead> , <tfoot> , <tbody> ? is there case should used? thank you. the thead, tbody, , tfoot elements in html used group table rows logical sections based on content. there 2 main reasons you'd want this: to allow body scrolled independently of header and/or footer to make easier apply different style rules different sections of table. as stated here what benefit of <thead> if using tables make layout don't use these. if showing tabular data use it. and if don't have put in tfoot don't add this. you find answers here what benefit of <thead>

android - Repo sync hangs -

i trying sources android 1.6 release, repo sync operation keeps hanging. i pasting last part of message on terminal here: fetching projects: 19% (32/164) initializing project platform/external/freetype ... remote: counting objects: 970, done. remote: compressing objects: 100% (414/414), done. receiving objects: 57% (558/970), 1.28 mib | 26 kib/s it hangs there... no error messages or aything of sort. has faced similar issue? i wonder if using vmware run linux. experienced same problem until i've found causing it: tcp window size on our side being set 0 (full). running ubuntu 10.04 on vmware on windows 7 64-bit host. fix make sure give plenty of ram ubuntu on vmware discard memory issues. had mine set 512mb , increase 1.5m better performance. important setting (and 1 did trick actually): make sure set network adapter on vmware bridged mode. if using nat example, nat service choke , mess window size you. cause: tcp window size of client tells server number of...

javascript - Reset user geo location on page load. Delete & set a cookie -

i'm running geo-location-javascript ( http://code.google.com/p/geo-location-javascript/ ) find , set users latitude , longitude cookie. i'm running try , update cookie on each page load. <script> function del_cookie(name) { document.cookie = name + '=; expires=thu, 01-jan-70 00:00:01 gmt;'; } if(geo_position_js.init()){ geo_position_js.getcurrentposition(success,error); } else{ alert("functionality not available"); } function success(p) { del_cookie('user_latitude'); del_cookie('user_longitude'); document.cookie = "user_latitude=" + p.coords.latitude; document.cookie = "user_longitude=" + p.coords.longitude; $('body').load('pool.php'); } function error(p) { alert('error='+p.message); ...

c++ - How functions are resolved by compiler? -

how determined whether below call bound @ compile time or @ runtime? object.member_fn;//object either base class or derived class object p->member_fn;//p either base class or derived class pointer edited: #include <iostream> using namespace std; class base { public: base(){ cout<<"constructor: base"<<endl;} ~base(){ cout<<"destructor : base"<<endl;} }; class derived: public base { //doing lot of jobs extending functionality public: derived(){ cout<<"constructor: derived"<<endl;} ~derived(){ cout<<"destructor : derived"<<endl;} }; void foo() { base & var = derived(); base*pvar = new derived; delete pvar; } void main() { foo(); std::cin.get(); } out put: constructor: base constructor: derived constructor: base constructor: derived destructor : base // derived not called, // ...

Which MySQL datatype is more space efficient for scalable apps? TEXT or VARCHAR? -

i'm building highly scalable app, , need know data type use small strings (50-1000 chars). heard varchar fixed sized , therefore might faster, text, chars might stored in seperate clob, , pointer in row data. smaller, have significant performance hit? values in varchar columns variable-length strings. length can specified value 0 255 before mysql 5.0.3, , 0 65,535 in 5.0.3 , later versions. if have mysql 5.0.3 or later, , don't need more 65k characters, doesn't matter 1 use, because both text , varchar have variable size in storage. if have many texts less 255 characters, can save 1 byte choosing varchar. but on different aspect, choose data type more appropriate it. if store text, semantically text can exceed "standard" sizes easily, should use text datatype.

Using jQuery to target a specific link in the navigation -

i working dynamic navigation , need able target 1 specific link open in new window. i need jquery this. for example able target navigation item of education has link of http://www.foo.com/education , have open in new window when click on it. would appreciate assistance. thanks. try: $("a[href='http://www.foo.com/education']").attr('target', '_blank');

What does the @ sign do when preceding a variable in PHP -

i see code looks this: if(@$_post['myvar']) what @ sign in instance? it suppresses , error messages, warnings, or notifications caused expression you've prepended to. in case: if(@$_post['myvar']) being used because original author did not want notification emitted if $_post['myvar'] unset.

jquery - Dynamically set iframe scrollable -

i have make iframe element java script isn't scrollable anymore(the javascript function called iframe inside 1 have change).now works on firefox , chrome , must on ie also. i have no alternative change scroll bars parent iframe , understand why, have jquery tabs in application , each tab loads on same iframe. problem came when faced sub tabs...in case, need sub iframe scrollable. in firefox , chrome set overflow="hidden" , scrolling="no" parent iframe , works. it possible dynamically set iframe have scrollbars or not through javascript in ie? thanks, luisa with ie need set html frame being displayed via iframe "display:hidden" on body if don't have access iframe (say it's site) there's not can content independent. (if doesn't work can try putting iframe in side iframe , make 2nd level down (page being viewed though initial site) show 2nd iframe's dimensions(3rd level down) big enough initial view cuts off scroll...

ajax - jquery colorbox problem -

hi friends have showing data via ajax on page when ajax complete , click on view info colorbox not working show data without ajax , click on colorbox link working , opening why javascript not working when data comes via ajax thanks $.ajax({ url: "remote.php?act=showcontacts&id="+id, cache: false, success: function(html){ $("#displaycontacts").html(html); } }); $("#viewcontact").colorbox({width:"500px", height:"520px", iframe:true}); <a href="viewcontact.php?id=3" id="viewcontact" class="cboxelement">view details</a> when data comes ajax , click o view details colorbox not working not opening when put link without ajax working fine the ajax data loaded after .colorbox() event handlers being attahced. after completed ajax call you'll need apply colorbox event handlers new element's you've loaded. you can call .colorbox() method after comp...

jpa - How to stop handled Exceptions from being logged? -

i have implemented exception handling unique-constraint of jpa entity. working want to, when triggered dumps handled exceptions container logfile. a jpa entity managed slsb (service façade). service façade called slsb, provides remoting capabilities based on jax-rs. in service façade, entitymanager operations wrapped in try-catch-block, detecting cause of unique-constraint-violation. throws custom checked applicationexception . the rest-bean catches applicationexception , throws custom unchecked badrequestexception . an exceptionmapper outputs badrequestexception remote client. this working well. part don't understand is: (handled) exceptions logged in container's logfile (complete long stacktrace): [#|2010-09-29t18:49:39.185+0200|warning|glassfish3.0.1|org.eclipse.persistence.session.file:/users/hank/netbeansprojects/coreserver/build/classes/_coreserverpersistenceunit|_threadid=30;_threadname=thread-1;| local exception stack: exception [eclipselink-4002] (ec...

javascript - jQuery adding to css element -

i have id of element. need add given value (determined variable in javascript) 1 of element's css attributes. i.e. given element id=my_id how add x element's margin-top attribute? var x = 20; $('#my_id').css('margin-top', function(index, value) { if (isnan(parseint(value))) return x; return parseint(value) + x });

Get range address in Excel using vb.net -

i trying dynamically range of cells in excel using vs 2005 vb.net. works orange = osheet.range(osheet.cells("a1"), ("u281")).select, "u281" not last cell in range. how dynamically last cell data in same format u281. to last cell, use formula: lastcell = osheet.cells.specialcells(xlcelltype.xlcelltypelastcell) this works fine, unless have users have been strange areas of spreadsheet , done things have since deleted. above formula return last cell being wherever went on strange journeys, if blank. in case, have process every cell in lot of spreadsheets user went down row 60,741 , column 50 though there couple of hundred lines of actual data. avoid massive blank region, want search maximum row , maximum column have data , use cell bottom right corner of square of cells has data, below (it's c# shouldn't hard translate): microsoft.office.interop.excel.range maxcell = (microsoft.office.interop.excel.range)worksheet.cells[wor...

wpf - Blend Slider Control -

Image
is there free implementation of text box in blend's property grid allows change number clicking , dragging? or perhaps way ask kind of control called can google it? just try http://www.codeproject.com/kb/wpf/microsoftblendstyletextbo.aspx

math - Geometrical progression with any number row -

i can have number row consists 2 10 numbers. , row, have geometrical progression. for example: given number row: 125 5 625 have answer 5 . row: 128 8 512 have answer 4 . can give me hand? don't ask program, hint, want understand myself , write code myself, damn, have been thinking whole day , couldn't figure out. thank you. don't write whole program! guys, don't it, can't simple make division. have geometrical progression + show numbers. in 128 8 512 row numbers be: 8 32 128 512 seth's answer right one. i'm leaving answer here elaborate on why answer 128 8 512 4 because people seem having trouble that. a geometric progression's elements can written in form c*b^n b number you're looking ( b greater 1), c constant , n arbritrary number. so best bet start smallest number, factorize , @ possible solutions writing in c*b^n form, using b on remaining numbers. return largest result works. so examples: 125 5 625 ...

url - ASP.NET - Avoid hardcoding paths -

i'm looking best practice solution aims reduce amount of urls hard-coded in asp.net application. for example, when viewing product details screen, performing edit on these details, , submitting changes, user redirected product listing screen. instead of coding following: response.redirect("~/products/list.aspx?category=books"); i have solution in place allows me this: pages.gotoproductlist("books"); where pages member of common base class. i'm spit-balling here, , love hear other way in has managed application redirects. edit i ended creating following solution: had common base class, added pages enum (thanks mark), each item having system.componentmodel.descriptionattribute attribute containing page's url: public enum pages { [description("~/secure/default.aspx")] landing, [description("~/secure/modelling/default.aspx")] modellinghome, [description("~/secure/reports/default.aspx")...

A good Html rendering engine -

i looking html rendering engine has: support in designer tool helps me syntax, understand objects (warns me of type errors , non existing names of classes/methods) , validate html. a nice readable way of mixing html markup common programming syntax, each, if then support sub - templates / functions (in same file or in file) use same syntax possibility use variables common way, = 1 ... = + b ... if > c ... support larger commonly used class libraries / mature languages (.net / java / ror / django / php etc) produce pure clean markup i think that's ... shouldn't hard think, haven't found perfect 1 yet. you might want check 'asp.net mvc' out. visual studio 2010 great web development tool. happy javascript support. haven't seen better far in editors tried (which best known free editors). supports auto-complete languages used. warns html validation errors. has express edition free. you can use pick server-side language. vb.net or c#. it...

What's the advantage of using drupal's module_load_include vs. just including a file? -

what's advantage of using drupal's module_load_include vs. including file? module_load_include find path module listed , file inside module's folder, in multi-site (or now, installation profiles) can different. it's step reduce code needed generalized enough entire community.

wpf - CollectionViewSource Filtering Event vs Property -

what of practical differences between using collectionviewsource.view.filter property opposed collectionviewsource.filter event? there situations use 1 on other or matter of preference? cheers, berryl edit: see docs "if view object comes collectionviewsource object, apply filtering logic setting event handler filter event." although nothing stops setting property on view, , doesn't why so. the advantage have found far in setting event on collectionviewsource can implement of filtering logic in 1 event handler , use view.refresh (or view.deferrefresh) invoke user changes filtering criteria. setting filter event in collectionviewsource mean event called when there no filtering needed make process less efficient. the official way of using filter event adding on filtering , removing later when filter cleared. viewsource.filter += viewsource_filter; then: viewsource.filter -= viewsource_filter; //how know how many events there are!? if use eve...

delphi - Why doesn't TApplicationEvents.OnIdle get called? -

in app have main form button. clicking button, form (not auto-created in dpr) created , displayed; on form, placed tapplicationevents component , defined onidle event handler. event handler doesn't called! may depend because derived second form not tform other class, tchartbasicform (by means of vfi)? thank replies. massimo. hooking application's idle event can lead lot of debugging woes , other maintenance headaches, on form other main form. realize may not answer specific question (which hard @ point given vagueness), sure can't accomplish you're trying ttimer or tthread instead?

bash - How to loop over directories in Linux? -

i writing script in bash on linux , need go through subdirectory names in given directory. how can loop through these directories (and skip regular files)? for example: given directory /tmp/ has following subdirectories: /tmp/a, /tmp/b, /tmp/c i want retrieve a, b, c. cd /tmp find . -maxdepth 1 -mindepth 1 -type d -printf '%f\n' a short explanation: find finds files (quite obviously) . current directory, after cd it's /tmp (imho more flexible having /tmp directly in find command. have 1 place, cd , change, if want more actions take place in folder) -maxdepth 1 , -mindepth 1 make sure, find really, looks in current dir , doesn't include ' . ' in result -type d looks directories -printf '%f\n prints found folder's name (plus newline) each hit. e voila!

c# - How do I get the color from a hexadecimal color code using .NET? -

how can color hexadecimal color code (e.g. #ffdfd991 )? i reading file , getting hexadecimal color code. need create corresponding system.windows.media.color instance hexadecimal color code. there inbuilt method in framework this? i'm assuming that's argb code... referring system.drawing.color or system.windows.media.color ? latter used in wpf example. haven't seen mention yet, in case looking it: using system.windows.media; color color = (color)colorconverter.convertfromstring("#ffdfd991");

Questions every good Java/Java EE Developer should be able to answer? -

i going through questions every .net developer should able answer , highly impressed content , approach of question, , in same spirit, asking question java/java ee developer. what questions think should java/java ee programmer able answer? i marking question community wiki not user specific , aims serve programming community @ large. looking forward amazing responses. edit : please answer questions too, suggested in comments, people learn new regarding language, too. what relationship between hashcode() , equals()? significance of these methods? requirements implementing them?

winforms - Customized sorting on DataTable in C#? -

this c# winform question. have datagridview bounded datatable. construct datatable myself, several datacolumn instances. when datatable bound datagridview, default, every column sortable clicking headers of datagridview. but sorting behavior "by default". seems sorted string. true if put code: datacolumn dc = new datacolumn("myobjectcolumn", typeof(myobject)); and myobject has overriden tostring() , has implemented icomparable interface. means if have told datatable how sort special column implementation of icomparable interface, datagridview still doesn't way expect. so how can let datatable sort data in way want? thanks answers. i recommend using defaultview of datatable. has built in sorting features little more extendable. easiest rowfilter, i'm not sure if you're looking if data types overridden .tostring() @ table level. edit: added code snippet a custom method maybe overrides or called during sort event of datagridview m...

Java Imports Error -

i'm trying import org.apache.commons.fileupload.* being told not exist. i downloading jar: http://commons.apache.org/fileupload/ and placing on classpath. doing wrong here? most you're thinking of %classpath% environment variable. shouldn't that. jar file has go in /web-inf/lib folder of dynamic web application project. folder default covered webapp's classpath. bit decent ide (eclipse, netbeans, etc) automagically add build path whenever drop jar file in folder. when you're compiling using plain vanilla javac.exe in command console, have specify in -cp argument. update : assuming you're using windows , sitting in source root folder, here's how javac.exe should like: javac -cp .;/path/to/tomcat/lib/*;/path/to/web-inf/lib/* com/example/servlet.java note: wildcard works on jdk 1.6 or newer. otherwise you've specify libraries separately.

python - What side effects should one expect when method decorator replaces self? -

i want execute method copy of original self passed while execution. here code i'm talking about: def protect_self(func): copy import copy functools import wraps @wraps(func) def decorated(self, *args, **kwargs): self_copy = copy(self) return func(self_copy, *args, **kwargs) return decorated in understanding copy function creates new object of same type , copies __dict__ of old 1 new object (using references, changes actual object instances in __dict__ still affect original object). does mean can sure decorated method cannot modify __dict__ of original instance? just make sure: don't need secure sandbox behaviour. purpose have single object instanciated use factory. protected method should possible modify passed self should reseted afterwards. as op clarified in comment purpose threadsafe, there's obvious issue -- copy.copy isn't threadsafe, in addition issue pointed out, copy.copy makes shallow copy , ...