Posts

Showing posts from July, 2010

c# - What are in SQL Server User Instances that make them impossible in non-Express Editions? -

after developing few years (or more), still not understand: what makes user instances impossible/incompatible developer (or other) edition of sql server? why has developer install more 1 (i.e. developer edition) of sql server because user instances available through express edition? update: @damien_the_unbeliever wrote in answer, "user instances pretty expected standalone databases, used single application, , meaningless without application." do understand correctly user instances: require sql server express setup cannot connected remotely the user cannot have more 1 such instance? the client apps connect them dev tools vs, ssms, webadmin, sql express utility , etc? really not understand when/why/how can used/deployed outside of development environment what non-dev cases of sql server user instances (vs ce , other embedded databases)? i don't believe there technical reasons why user instance functionality couldn't exi...

php - Setting a required value in Doctrine model -

is possible set constraint in doctrine model, queries using model include requirement? example, if have car model , want ensure results retrieved using model have active = 1 set in database. define in each individual query, seems there's better way. cheers! i take advantage of amazing pre , post hooks inside model. example: class model_car extends model_base_car { public function predqlselect(doctrine_event $event) { $event->getquery()->addwhere("active = ?", 1); } } although did not test this, should work. have used pre , post hooks lot make life easier in past. instance, had model wanted save remote_addr on each insert , update, did following make life easier: class model_example extends model_base_example { public function preinsert(doctrine_event $event) { $this->created_ip = $this->_getremoteip(); } public function preupdate(doctrine_event $event) { $this->updated_ip = ...

Implementing a DDEX provider for exposing PostgreSQL data source objects in Visual Studio 2010 -

i started implementing ddex provider postgresql in visual studio 2010. first of all, i've downloaded efsampleprovider , contains basics begin. i' ve downloaded src of npgsql 2.0.10 here contains visualstudio folder there 4 basic files (but not in there). files ones needed filled appropriate code. though, familiarized myself basic principles of ddex architecture, lack of knowledge on postgres , on data objects (and properties, parameters, etc) need continue. does have idea can these? thanks, in advance maybe npgsql api documentation can help.

Python pip - install documentation for packages? -

is there way install/generate documentation packages installed using pip? i wish install required packages project, associated documentation (e.g. django documentation when installing django, dateutil documentation dateutil etc.). pip requirements files great way of installing required packages project, better if install associated docs well. ubuntu python packages install documentation /usr/share/docs, pip not appear same. documentation these packages important me when need work on projects offline. i think you're looking equivalent way ruby automatically (unless suppressed) generates rdoc installed gems/packages. in python, there is standardized mechanism annotating code documentation -- docstrings optional formatting . there isn't standardized way of generating/storing documentation python code. each python package may have different mechanism, there couldn't way pip generate it.

How to filter Django's CommaSeparatedIntegerField -

assume model class foo(models.model): bar = models.commaseparatedintegerfield('filter me!') the content of bar like, e.g., 12,35,67,142 . i want query foo s, have 42 in bar : all_42_foos = foo.objects.filter(bar__contains="42") which doesn't give correct result, since commaseparatedintegerfield inherits charfield , filter evaluation uses string content of field (matching above example 142 , too). how can hav filter, .split(",") on bar field before checks 42 ? don't want bar become manytomany , since it'd terrible overhead. what like: from django.db.models import q all_42_foos = foo.objects.filter( q(bar__startswith='42,') | q(bar__endswith=',42') | q(bar__contains=',42,') | q(bar__exact='42') ) while it's bit of verbose query, think along lines way you're looking for. it's worth turning separate function along lines of def all_x_foos(x): return foo.objects....

javascript - remove all <br> from a string -

i have string remove occurrences of <br> i tried , did not work. productname = productname.replace("<br>"," "); however worked first <br> productname = productname.replace("&lt;br&gt;"," "); how work <br> in string. edit: string... 00-6189 start mech switch&lt;br&gt;00-6189 start mech switch&lt;br&gt;00-6189 start mech switch&lt;br&gt; my apologies being little misleading <br> should have been &lt;br&gt; looks string encoded use productname = productname.replace(/&lt;br&gt;/g," "); note g after regular expression means globally, match occurrences. demo @ http://www.jsfiddle.net/gaby/vdxhx/

inversion of control - Castle windsor logging facility -

i'm trying remove logging dependencies , stumbled across castle windsor's logging facility. however, i'm kind of skeptical whether should use or not. public class myclass { public castle.core.logging.ilogger logger { get; set; } ... } windsor's logging facility requires expose logger property. practice? feel i'm breaking encapsulation because when reuse component, don't care it's logging mechanism , don't want see exposed. if use custom wrapper uses static class create log, can keep private. example: public class myclass { private static mycustomwrapper.ilogger logger = logmanager.getlogger(typeof(myclass)); ... } i've searched web reasons why should use logging facility, i'm finding articles on how use it, not why should use it. feel i'm missing point. having logging component exposed kind of scarying me away. windsor's logging facility requires expose logger property. not necessari...

Sharepoint 2010 WSP Deployment problem. Can’t deploy new files -

we have found problem our deployment production server runs sharepoint 2010 publishing site collection. we deploying wsp packaged visual studio sharepoint management shell (uninstall, reinstall solution). has worked charm in past. added custom masterpage, css files, images , later added custom page layouts. i have sp running locally on computer , works fine no problem adding new files via deploying feature. can add them neatly document library or create new folders elements file. however problem arise when deploy wsp production server. want add few js files , xsl file style library files won't added document library. deployment process goes smooth though no errors , when check feature in sharepoint hive, new files there on physical drive! won't added virtual document library. i can update existing files masterpage , css files feature deployed working. my guess either has permission problems or bug in code. did have done before when deploying. this how elements.x...

c# - Need more details on Enumerable.Aggregate function -

can me understand, words.aggregate((workingsentence, next) => + next + " " + workingsentence); from below code snippet? , great if explain me achive in c# 1.1. (snippet ms )- string sentence = "the quick brown fox jumps on lazy dog"; // split string individual words. string[] words = sentence.split(' '); // prepend each word beginning of // new sentence reverse word order. string reversed = words.aggregate((workingsentence, next) => next + " " + workingsentence); console.writeline(reversed); // code produces following output: // // dog lazy on jumps fox brown quick the aggregate part of example translates this: string workingsentence = null; bool firstelement = true; foreach (string next in words) { if (firstelement) { workingsentence = next; firstelement = fal...

groovy - how do I make sure a function does not return Null -

i'm trying parse xml request in soapui. , when parse node without in it, logically string null if defining func() returns null: def groovyutils = new com.eviware.soapui.support.groovyutils( context ) def request = groovyutils.getxmlholder( mockrequest.requestcontent ) def argumentstring = request.getnodevalue("/soap:envelope/soap:body[1]/emm:runapplication[1]/emm:argument[1]") now tried doing this: try{argumentstring.length()}catch(e){argumentsstring = " "} but kills process after correction, , doesn't quite give want. can't use simple if(func()!=null) i'm used in java? how can this? help! you can test null values ...: argumentstring = (argumentstring != null) ? argumentstring : " " btw, argumentstring?.length() , length() evaluated if argumentstring isn't null .

iphone - Creating an overlay view ontop of EAGLView -

creating game using opengles. game consists of view controller , eaglview. have created view controller want handle view go ontop of eaglview things menu , options. have call eaglview view controller view controller adds iboutlet uiview appdelegates window not appearing. methods being called no view being added. easy , stupid question cant work out. in advance ok have done different way. use view controller called gameviewcontroller load , add subview window in appdelegates applicationdidfinishlaunching method call method add view controllers view (my open gl view) subview. means can put other views on top. don't know why didn't before honest help

vb.net - Implementing Events in a Base Class -

consider following objects: public mustinherit class filerepository public mustoverride sub savestringtofile(byval filetext string, byval filepath string) public event filesaved(byref sender object, byval eventargs eventargs) end class public class xmlfilerepository inherits filerepository public overrides sub savestringtofile(byval filetext string, byval filepath string) end sub private sub xmlfilerepository_filesaved(byref sender object, byval eventargs system.eventargs) handles me.filesaved end sub end class i want base class raise filesaved event in it's implentation of savestringtofile once it's saved file. in vb.net can't have derived class raise base classes event. suppose can treat xmlfilerepository_filesaved standard function call , have savestringtofile implementation call directly think i'm approaching problem wrong way. great! add overridable sub in base class raises base classes filesaved-event: ...

mysql - If I specify any value for an auto-increment field, how can I get the next or previous value? -

i have mysql table auto-increment field , trying figure out how next or previous value along rest of row using purely mysql. field ai numbers aren't consecutive rows deleted time. field_id 8, 15, 17 this started with: //to next value in table: select min(member_id) val members member_id > 15 limit 1 //to previous value in table: select max(member_id) val members member_id < 15 limit 1 but returning member_id value. works next value (but doesn't make difference if use desc or asc (wtf): select min(member_id),members.* val members member_id > 15 order member_id desc limit 1 that query reversed (to the previous value) returns lowest value in table (1): select max(member_id),members.* members member_id < 15 order member_id asc limit 1 these 2 queries, however, shows want not entirely sure why: //get next lowest row select max(member_id),members.* members member_id < 15 group member_id order member_id desc limit 1 //get next hig...

javascript - Get parameters of slices in photoshop -

i have slices in photoshop document. how can parameters (width, height, x-offset, y-offset, name, url, ...) via javascript > scripting in photoshop? @sublimeye, have same quest, , date, there has been no solution available. adobe scripting in javascript has no way see application model gain access slices. so, after of own research, best solution have found presented me trevor morris (http://morris-photographics.com/photoshop/scripts/index.html). paid trevor $500+ write script uses layer group of "slices" , each layer comp there corresponding shape layer. javascript can see groups, layers, , shape layers script can crop , save web nicely. downside cannot use slicing tool, adopting of script has been minimal our design team. after still having problem years, tried search again found adobe forum http://feedback.photoshop.com/photoshop_family/topics/slice_compositions_that_work_like_layer_compositions , link slicemaster tool enzo http://www.electriciris....

file download in spring mvc -

in home page want display user guide in 2 different format ( pdf , word) these documents created technical writers , want show download links these documents in home page after user logged in. can achieve putting these 2 documents in 1 folder 'web-inf' enable can download these files(without logging in). advise whats best way handle in spring mvc 2.5 i guess have security support, can check whether user logged in inside controller code. then can put files /web-inf folder , create special controller serving these files logged users. controller check user logged in , forward request target file. in typical spring mvc configurations can forward request returning forward:/web-inf/myfile.pdf view name. alternatively, if use security library, such spring security, can use features secure access files. in case don't need put them /web-inf , implement specifal controller accessing them.

php - Get posts that matches both taxonomies -

i have movie-database, want know movies actor , b has both been featured in. function getmoviefromactor(){ global $wp_query; global $wpdb; global $post; $loop = new wp_query(array( 'post_type' => 'movies', 'actors' => 'a', 'b', 'posts_per_page' =>-1, )); print_r($loop); while ( $loop->have_posts() ) : $loop->the_post(); ?> <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'permalink %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2> <?php the_content(); endwhile; } the problem code wordpress default searching actor or b , displaying every movie they've been featured in , not movie(s) they've both been featured in. thanks, marten edit: think im there, im stuck in sql-query, works...

java - Spring, Morphia and DataAccessException implementation -

i'm using morphia , mongodb spring application. see in many of example projects many of service interface methods throw dataaccessexception. can tell, exception thrown various framework classes simplify exception handling various implementations of data access. at point i'm guessing should catch errors thrown morphia , throw dataaccessexception service implementation. question is, should model approach service implementations use morphia? or perhaps i'm misunderstanding this. this makes sense if want business logic able react specific types of dataaccessexception , without being dependent on morphia/mongo types. the easiest way write class implements persistenceexceptiontranslator , , knows how translate morphia/mongo exceptions dataaccessexception . declare class bean, , spring automatically ask translate exceptions if dao class annotated @repository . however, if business logic or exception-handling logic doesn't care which exception type thrown, t...

php - MYSQL Query locking up server -

when trying execute query mysql server cpu usage goes 100% , page stalls. setup index on (client_code, date_time, time_stamp, activity_code, employee_name, id_transaction) doesn't seem help. steps can go next fix issue? there 1 index on database if matters any. thanks here query does database info id_transaction | client_code | employee_name | date_time |time_stamp| activity_code 1 | 00001 | eric | 11/15/10| 7:30am | 00023 2 | 00001 | jerry | 11/15/10| 8:30am | 00033 3 | 00002 | amy | 11/15/10| 9:45am | 00034 4 | 00003 | jim | 11/15/10| 10:30am | 00063 5 | 00003 | ryan | 11/15/10 | 12:00pm | 00063 6 | 00003 | bill | 11/14/10 | 1:00pm | 00054 7 | 00004 | jim | 11/15/10 | 1:00pm | 00045 8 | 0000...

asp.net - How to change the culture of a number in C#? -

i'm sending parameters paypal hidden form vars. but site's culture danish. "50,00" value "amount_1" <input type="hidden" name="amount_1" value="50,00" /> i'm using code converts 50 "50,00" item.pricepaid.tostring("#.00") i believe number should like: "1234.56" there way set culture en-us on process? (not side wide) or better way this? thanks! you use overload of tostring takes iformatprovider , use getcultureinfo pass in required culture info: item.pricepaid.tostring("#.00", cultureinfo.getcultureinfo("en-us")); alternatively, (probably) specify invariant culture rather "en-us": item.pricepaid.tostring("#.00", cultureinfo.invarianculture);

How do I handle an if condition in jQuery -

i have class has image <a class="proceed-btn right" onclick="validateall();" style="cursor: pointer;">proceed next step >>></a> which has css .proceed-btn { background:url("images/proceed-btn.gif") no-repeat scroll 0 0 transparent; height:35px; width:275px; } then on same page have these input fields , links <input type="text" id="name" name="name" value="" class="field left"> <input type="text" id="company" name="company" value="" class="field left"> <input type="text" id="email" name="email" value="" class="field left"> <a onclick="setindustry('3');" style="cursor: pointer;" class="industry_links highlight">retail</a> <a onclick="setsystems('5');" style="cursor: ...

Java POI exception -

these steps do: save excel file. run program reads excel file. when steps error immediately: java.lang.reflect.invocationtargetexception @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) @ sun.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl.java:39) @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl.java:27) @ java.lang.reflect.constructor.newinstance(constructor.java:513) @ org.apache.poi.hssf.record.recordfactory.createrecord(recordfactory.java:224) @ org.apache.poi.hssf.record.recordfactory.createrecords(recordfactory.java:160) @ org.apache.poi.hssf.usermodel.hssfworkbook.(hssfworkbook.java:163) @ org.apache.poi.hssf.usermodel.hssfworkbook.(hssfworkbook.java:130) at caused by: java.lang.arrayindexoutofboundsexception: 11 @ org.apache.poi.util.littleendian.getnumber(littleendian.java:491) @ org.apache.poi.util.littl...

svn - how can I tell if `hg convert` is actually doing anything? -

i'm using mercurial on win32 (server 03). i'd copy subversion repo on local drive mercurial repo on local drive can test merging abilities of mercurial vs subversion. is hg convert right command use? after this: "c:\program files\tortoisehg\hg.exe" convert c:\dev\subversionrepo\myrepo -r 123456 -s svn c:\devhg\myrepo_123456 i message says: 8 created myrepo branch again copy http://.../branches/sourcerepo. there myrepo branch in same location deleted. ok i'm nervous. branch in location deleted ? nooo don't want deleting branches. and convert command seems stalled. there no files being created in c:\devhg\myrepo_123456 beyond basic .hg folder. doing wrong? you should use '--debug' switch see what's happening. you should understand hg convert can spend long time working on first entry. number on line how many more has do. if number 600, got wait ahead of you. each line next number comment commit, not sort of status...

sql server - How do you reset the SA password? -

how on earth reset sa password? know how go dialogs , reset password. that's i'm asking about. runs little deeper click, click, new password, done! i have no idea sa password is. nor previous user of machine. previous user says never had sql express ever running on machine. this journey started when tried create new database , told didn't have permissions so. okay, decided give myself appropriate permissions. nope, can't give myself nor else permissions. i tried changing password using ssms. message saying don't have permissions change it. i tried using following sql script. again, no permissions. go alter login [sa] default_database=[master] go use [master] go alter login [sa] password=n'newpassword' must_change go the database sql server 2008 express (10.0.2531.0). sql server management studio ssms 2008. os windows 7 enterprise i'm local admin, , domain user. created local admin account logging ssms machine on domain. have no problems c...

using nil or [] on rails 2.3.8 -

i've strange situation rails application (2.3.8) i want assign no nil value variable in controller, wrote code: @myvalue = session[:value] or [] in view wrote: <%= @myvalue.size %> when display page, have nil error. i've tried nil or [] in irb , []. question if know why working different in rails? p.s.: gem i'm using cell version 3.3.3. thanks! the idiom session[:value] || [] , using || , not or . can try session[:value].to_a . works because nil.to_a becomes [] .

javascript - HDI: Disable postback on html input box -

i have input box don't want postback occur on striking enter key i want javascript event take place instead. <input type="text" id="addressinput" onkeydown="inputenter()" autopostback="false"/> function inputenter() { if (event.keycode == 13) { seachlocations(); return false; } else { return false; } } just return false form js function, add return false; @ end of function. or <input type="text" id="addressinput" onkeydown ="return (event.keycode!=13)" autopostback="false"/> update: how this..? <asp:textbox id="textbox1" runat="server" onkeydown="return callenterkeyfunc(event.keycode);"> </asp:textbox> <script type="text/javascript"> function callenterkeyfunc(key) { if (key == 13) { //for ff, think have use e...

c# - Functional Tests getting a file from App_Data Folder -

i writing functional tests , method writing tests has access file in app_data folder. have tried system.web.httpcontext.current.server.mappath("~/app_data/test.txt"); as path.combine(environment.getfolderpath(environment.specialfolder.applicationdata), "test.txt"); both of them not working. there way achieve in functional test? any ideas in regard appreciated. thanks, raja i found solution @ last (with of solutions architect). set app config functional test project , set file name 1 of appsettings. after specified relative path actual file [deploymentitem(@"..\..\project1\app_data\test.txt")] attribute test class. added simple hack use absolute path if in test (app config) , server.mappath("test.txt") if not test. logic solution since put file deploymentitem goes straight respective testresults folder if use absolute path going able reference it. hope helps someone.

Returning a response with Ruby CGI before script is finished? -

anyone know how send cgi response in ruby before cgi script finished executing? i'm creating fire-and-forget http api. want client push data me via http , have response return successfully, , then swizzles data , processing (without client having wait response). i've tried several things don't work, including fork. following wait 5 seconds when invoked via http. #!/usr/bin/ruby require 'cgi' cgi = cgi.new cgi.out "text/plain" "1" end pid = fork if pid # parent process.detach pid else # child sleep 5 end i answered own question. turns out need close $stdin, $stdout, , $stderr in child process: #!/usr/bin/ruby require 'cgi' cgi = cgi.new cgi.out "text/plain" "1" end pid = fork if pid # parent process.detach pid else # child $stdin.close $stdout.close $stderr.close sleep 5 end

javascript - Using AJAX with jQuery -

how get information in xml file , read array on object i'd able access function? what's best way go this? i'm using jquery , ajax. thanks, elliot bonneville edit: here's example code of have far: function getquestions() { $.ajax({ type: "get", url: "questions.xml", datatype: "xml", success: function(xml) { x = 0; x = $(xml).find('questions').length; var questionid = $.random(x); //here's need iterate through questions find 1 id specified random var above. } } } you use $.get : $.get('content/file.xml', function(data) { // convert json easier manipulation }, "xml"); as want "access function", you'd need convert xml json. there no built-in functionality - you'd need plugin 1 here . which begs question - why not return j...

iphone - Setting the zoom level for a MKMapView -

i have map shows correctly, thing want set zoom level when loads. there way this? thanks i found myself solution, simple , trick. use mkcoordinateregionmakewithdistance in order set distance in meters vertically , horizontally desired zoom. , of course when update location you'll right coordinates, or can specify directly in cllocationcoordinate2d @ startup, if that's need do: cllocationcoordinate2d nolocation; mkcoordinateregion viewregion = mkcoordinateregionmakewithdistance(nolocation, 500, 500); mkcoordinateregion adjustedregion = [self.mapview regionthatfits:viewregion]; [self.mapview setregion:adjustedregion animated:yes]; self.mapview.showsuserlocation = yes;

python - Abuse yield to avoid condition in loop -

i need search first, last, any, or occurence of in else. avoid repeating myself ( dry ) came following solution. of interest methods search_revisions() , collect_one_occurence() of both searcher classes. in searcheryield create generator in search_revisions() abandon generator in collect_one_occurence() after collecting first result. in searchercondition put condition in loop. condition have checked every iteration of loop. i can't decide whether (ab)use of yield , subsequent abandoning of generator strike of genius or hideous hack. think? have other ideas such situation? #!/usr/bin/python class revision: # revision textfile. # search() method search textfile # , return lines match given pattern. # demonstration purposes class simplified # return predefined results def __init__(self, results): self.results = results def search(self, pattern): return self.results class abstractsearcher: def __init__(self, revisions): self.revisions = ...

Why does WPF MediaElement not work on secondary monitor? -

my application uses wpf mediaelement play video (mov files). works when playing on primary monitor freezes when window moved secondary monitor. i have tried following without success: starting application on secondary monitor swapping primary & secondary monitors (problem transfers new secondary monitor) when application window spans both monitors works correctly entirely within secondary monitor video freezes. once in state, moving application primary monitor doesn't (and loading new video doesn't either). the monitors arranged co-ordinates positive (both monitors 1920x1080 , secondary monitor origin 1920,0). has else seen problem and/or found fix? edit does use wpf mediaelement multiple monitors??? this still known issue in .net framework 4.0 , ms described "the issue occurs when synchronization between wpf , underlying wmp control have resynchronize when display changes occur." happens h.264 codec video files. here 3 workaro...

javascript - POSTing data on a small embedded device -

i have mystery.html page loads javascript (as mootools). i run few calculations, , need post url. seems simple, right? except: i dont have xmlhttprequest i can't run createelement create form , dynamically add data inputs (and can have anywhere few hundred elements one, can't pre-create them in html) my current thought create form in html single input, create query string of resulting parameters, add input, , submit form. work, smells inelegant. any better suggestions/something obvious i'm missing? update: turns out document.write still works, can sort of hack way around way. you should disclose more details target. , of course, multiple fields in not reason, because document.urform.innerhtml += '<input type="text" name="foo" value="bar"><input type="text" name="baz" value="42">' work.

java - Accessing Files From Web Document Root -

i'm using spring mvc 3.0 , tomcat. i have bean has property value should path rooted web document root. example, specify value in spring configuration file following. <bean id="mybean" class="com.stackoverflow.bean"> <property name="path" value="/web-inf/foo.xml" /> </bean> where take value can read file? spring/spring mvc provide transparent way access resources within document root? in order real path resource need have access servletcontext one way achieve make com.stackoverflow.bean implement servletcontextaware interface. upon restart, server should hand on instance of servletcontext bean (you have include following code) private servletcontext ctx; public void setservletcontext(servletcontext servletcontext) { ctx = servletcontext; } finally, use ctx.getrealpath(path) real path resource.

how to query in view ruby on rails -

i have in controller @ads = ad.all(:joins => 'left join states on ads.state_id = states.id') but have problem query field of states table. idea? <% @ads.each |ad| %> <tr> <td><%= ad.title %></td> <- title ad field.no problem <td><%= ad.name %></td> <- name states field.problem @ here </tr> <% end %> i don't think work unless have associations set up. unless performance concern, may want use association without joins ad.rb class ad < activerecord::base belongs_to :state end state.rb class state < activerecord::base has_many :ads end controller @ads = ad.all view <% @ads.each |ad| %> <tr> <td><%= ad.title %></td> <td> <%= ad.state.name %> </td> </tr> <% end %>

Adding and removing markers in openlayers on Drupal after page-load -

i have change data set displayed on map according selections on page , creating several marker layers switching between them based on user input. reason cannot add layer after map has been rendered on page, seems shouldn't hard think may have syntax wrong since way drupal sets map different straight forward openlayers. can not map object var map = drupal.settings.openlayers.maps["openlayers-map-auto-id-0"]; then add , remove marker layers it? maybe there's way of getting it? any appreciated, - chris the drupal openlayers module stores settings in drupal.settings.openlayers.maps . what need this: var ol = $('#openlayers-map-auto-id-0').data('openlayers'); var max_extent = ol.openlayers.getmaxextent(); // or other openlayers method... ... the actual openlayers instance (as copy of map-specific settings) stored jquery's .data() method. when call $('#map-id').data('openlayers') you'll object map , openl...

php - Zend Framework: Setting decorators and labels - should this be done in the view or the form class? -

i notice many (most?) people when working zend framework add decorators , labels in form class itself. class user_form_add extends zend_form { public function init() { parent::init(); $username = new zend_form_element_text('username'); $username->setlabel('username:') ->setrequired(true) ->addfilter('stringtrim') ->addvalidator('stringlength', $breakchainonfailure = false, $options = array(1, 30)) ->setdecorators(array( 'viewhelper', array('description', array('tag' => 'p', 'class' => 'description')), array('label', array('requiredprefix' => '<span class="asterisk">*</span>&nbsp;', 'escape' => false)), array('htmltag',...

c++ - Get access to parent variables from child class in qt -

i have 2 class in qt. in 1 declared variables , child qframe class qpainter. now, if it's possible, how can access parent variables child class? know can pass variables signals , slots or catch child qpainter events, think nice access directly. it boils down visibility of data in base class. if data public or protected have access it. otherwise, data private , don't have direct access it.

Manual Hash Function -

i need hash function, h(x), fulfilling following: (1) inputs around 10 digits , outputs around 10 digits. (2) if change x single digit, totally different h(x). (3) easy calculate manually . people going calculate by hand . need them able , no mistakes. thank creative ideas! edit : "hash" mean in spirit of "one-way-hash". - given h(x) should hard find possible values x. hard human being. edit : for? exam. students going calculations , numbers answers. want them able know, during test, if got answers right. idea is: concatenate answers 1 number x. calculate h(x). use h(x) decipher code, digit digit, , short message indicating correctness. don't want them able figure out 4th answer after got first 3. each digit coefficient of polynomial: ie 1234 1*x^3+2*x^2+3*x+4. compute value of polynomial predetermined x, 987654321 , truncate desired number of digits.

how to fetch values from array input in javascript -

how fetch values array in javascript: <html> <head> <script type="text/javascript"> function proc() { var cost = document.yoh.coz.value; var qtybuy = document.yoh.qbuys.value; var st = cost * qtybuy; var tbox = document.yoh.subtotal; if (tbox) { tbox.value = st; } } </script> </head> <body> <?php include('conn.php'); $prodname = $_get['prodname']; $result = query_database("select * prod_table product='$prodname'", "onstor", $link); ?> <?php while ( $row = mysql_fetch_array($result) ) { ?> <form name="yoh" method="get"> product id: <input type="text" name="prodid" value=""><br/> cost: <input type="text" name="coz" value="<?php ech...

xsd - error in xml code -

i using code inxml scehma represent phone number this: abc-jhg i getting error like: values abc-jhg not allowed element name. how should make comaptile input. \d numbers, change second 2 \w .

c# - Does StringBuilder use more memory than String concatenation? -

i know obvious performance advantage using stringbuilder in c#, memory difference like? does stringbuilder use more memory? , side note, stringbuilder differently makes faster? short answer: stringbuilder appropriate in cases concatenating arbitrary number of strings, don't know @ compile time. if do know strings you're combining @ compile time, stringbuilder pointless don't need dynamic resizing capabilities. example 1: want combine "cat", "dog", , "mouse". 11 characters. allocate char[] array of length 11 , fill characters these strings. string.concat does. example 2: want join unspecified number of user-supplied strings single string. since amount of data concatenate unknown in advance, using stringbuilder appropriate in case.

iphone - Disable action - user taps on tabbar item to go to root view controller -

i want disable default action when user taps tabbar item. for example, have tabbar tab1, tab2 , tab3. in tab1, user can navigate view1 view3 (view1 > view2 > view3). if user @ view3, , taps tab1, application takes user view1 (the root view controller). want disable functionality. don't want tap on tab1 pop view controllers. how can that? edit: this behavior little strange, handy shortcut in case of deep hierarchy! you can implement following uitabbarcontrollerdelegate methods disable system wide shortcut: #pragma mark - #pragma mark uitabbarcontrollerdelegate - (bool)tabbarcontroller:(uitabbarcontroller *)tbc shouldselectviewcontroller:(uiviewcontroller *)vc { uiviewcontroller *tbselectedcontroller = tbc.selectedviewcontroller; if ([tbselectedcontroller isequal:vc]) { return no; } return yes; } if @ uitabbarcontroller delegate there method: - (bool)tabbarcontroller:(uitabbarcontroller *)tabbarcontroller shouldselectviewcontr...

why the size of struct in C is not equal the sum of all variables size; -

possible duplicate: why isn't sizeof struct equal sum of sizeof of each member? this struct , size of 40 size of variables 34. how can eliminate space of struct? typedef struct { ushort sequencenumber; ushort linkcount; ushort attributeoffset; ushort flags; ulong bytesinuse; ulong bytesallocated; ulonglong basefilerecord; ushort nextattributenumber; ushort padding; ulong mftrecordnumber; ushort updateseqnum; } file_record_header, *pfile_record_header; that's because compiler free insert padding honour alignment requirement. have couple of options. the first inherently non-portable many implementations provide like: #pragma pack which attempt pack structures tight possible. aware may slow down code, depending on architecture the other put most-aligned elements front such as: typedef struct { ulonglong basefilerecord; // 0x00 ulong bytesinuse; // 0x08 ulong bytesallocated; // 0x0...

c# - how to download file from other server using mvc asp.net -

how can download file other server , save @ own using mvc asp.net c#? i able read title, nevertheless: webclient client = new webclient(); client.downloadfile("http://your-address.com/filetodonwload.ext", "c:\pathtothefiletocreate"); should wanted.

Simplest way to add a thumb size to a model using Paperclip in Rails -

i have rails model uses paperclip , has many thumb sizes. add new thumb size , generate size if possible - it unnecessary regenerate of old thumbs again. photo.find(123).photo.reprocess!(:new_size) perfect unfortunately doesn't exist. know simple way achieve this? thanks. the thumb-size can set in model of pictures (see paperclip ): class user < activerecord::base has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" } end as far remember should possible regenerate deleting old thumbnails. however, there's rake-task it: rake paperclip:refresh class=yourmodelname

URL for svn plugin of netbeans -

according netbeans documentation check out svn: checking out files repository if want connect remote repository ide, check out files , begin working them, following: in netbeans ide, choose versioning > subversion > checkout main menu. checkout wizard opens. that's , good. however, doesn't seem option. have nice little subversion window nice little buttons refresh, commit, etc, no checkout button, or, more importantly, way enter url repo. i've gone , installed win32svn , because dos prompt, no svn in path. there's svn dos prompt, it's @ least on path. after restarting nb, still no option enter url. pebkac not impossible... try team->subversion->checkout (tested under netbeans 6.9).

bootstrapping - Who loads the code in BIOS during booting? -

i studying boot process in linux. looking through html page http://www.tldp.org/howto/bootdisk-howto/x88.html . first line under section 3.1 "the boot process" says "all pc systems start boot process executing code in rom (specifically, bios)". my doubts are who loads code in bios ? where code in bios located ? to code in bios loaded , executed ? kindly tell me references can more information thanks, linuxpenseur the code there in memory when computer powered on. in non volatile memory, meaning doesn't disappear when computer turned off. so code there in specific memory address, , processor starts running it. more info here

help with c# array -

i have datatable 2 columns. want store rows of each column in array can return rows each individual column. way believe can populate list box(the option text 1 column , option value other column). here started out with: public object dbaccess2() { arraylist arg = new arraylist(); datatable mytable = genericdataaccess.executeselectcmd("vehicle_getmakes"); foreach (datarow drow in mytable.rows) { arg.add(drow["vehiclemake"]); arg.add(drow["vehiclemakeid"]); } return arg.toarray(); } you can make class hold each individual row in case , use list<t> hold data, this: public class vehicle { public string make { get, set }; public string makeid { get, set }; } .. list<vehicle> vehicles = new list<vehicle>(); .. foreach (datarow drow in mytable.rows) { vehicles.add( new vehicle { make = arg.add(drow["vehiclemake"]),...

How can we use case insensitive propertyName in criteria in nHibernate -

in simple sql can write queries field names case insensitive. example, want query on student table , has 1 field called name . can write query (in ms sql): select * student name = "john" see here have used name instead of name , still runs properly. but when write criteria in nhibernate this session.createcriteria("student") .add(restrictions.eq("name","john")).list() it fails error could not resolve property: name of student . is there way can make field/property names case insensitive in criteria direct sql queries. thanks short answer: can't. property names case sensitive. long answer: can parse user's input , use reflection find correct property names.

android - How to set desired landscape orientation -

i know can set orientation using android:screenorientation statically , setrequestedorientation programatically. problem if use either of these set screen orientation not choose landscape or portrait want. wit, flipping phone 180 degrees not rotate view rather appears upside down user. cannot use screenorientation="sensor", because in cases want view landscape or portrait , seldom both. seems insignificant until consider external hardware. if developed app , set layout android:screenorientation="landscape", app display correctly if left side of droid sitting on desk. unforunately left side usb port is, phone not sit on side if plugged in. unless of course used docking station not kind of looking for. if right side of phone sitting on desk allow cord, display appears upside down. tried posting image being new user not able so. what know how programmatically choose landscape (surface.rotation_90,surface.rotation_270) or portrait (surface.rotation_0,sur...

delphi - OpenOffice Calc automation how alter a chart label of a scatter diagram -

hello please me following. have created scattered chart , draw chart data of column. used data not after cell determines label: column o: pwm1 <-- cell want see label 27114 <-- not used data graph 27055 <-- etc 27092 27070 <-- data graph starts here 27105 27024 27092 <-- data graph ends here i label cell appear y column label name (is 'column o'), how? far got (code delphi if me basic example that's ok too): (* turn symbol of data points off *) ochart.diagram.symboltype := _chartchartsymboltypenone; odataseries := ochart.getuseddata; odatasequences := odataseries.getdatasequences; showmessage(odatasequences[1].label.sourcerangerepresentation); sourcerangerepresentation returns current label, how change? thanks ad this did it: (* creat new datasequence range representaion provides real data , role in series odataprovider: com.sun.star.chart2.data.xdataprovider srangerepresentation: range address e.g. sheet1.a1:b2 srole: role de...

How to set the background image width using CSS? -

i need set fixed width background image. should work fine in both ie , firefox. how ? @multiplexer: can't set width/height of background image, can set width/height of container. e.g. <div style="background: url(someimage.jpg) no-repeat 0 0; height: 300px; width: 400px"> content </div> if someimage.jpg 640x480, 400px of width , 300px of height shown. can move background around playing background position properties of css -- see http://www.w3schools.com/css/css_background.asp full/short-hand reference.

replication - Distributed reading from replica sets in MongoDB -

i can read master in replica set. it's easy. know, how read secondary in replica pair? efficient scaling, didn't search it. thanks. here docs you're looking for. you'll need dig in specific driver how this.

javascript - Augmenting the prototype of DOM element nodes? -

i know how add new methods every object - augmenting object's prototype: object.prototype.foo = function() { }; but, possible define new methods dom element nodes only? dom element node objects have prototype? or there maybe prototype dom nodes in general? or prototype objects exist built-in objects? yes, not in browsers. internet explorer 8 supports dom prototypes (to extent), firefox, chrome, opera , safari. htmlelement.prototype.toggle = function () { this.style.display = this.style.display == 'none' ? '' : 'none'; } many consider bad practice extend dom objects via prototype. kangax has great article on subject: http://perfectionkills.com/whats-wrong-with-extending-the-dom/ . however, dom prototypes allow implement standards-based methods in environments don't support them yet, shims ecmascript 5th edition methods.

android webview - set referer (for version < 2.2 aka Froyo) -

i have mobile web site , mobile app android can load web site in webview. i'd set http 'referer' request header android app track android app users do. i there way set http request headers before calling loadurl() in webview ? edit: it turns out in froyo (2.2) there way loadurl() command has new parameter specify headers webview/loadurl . comments can't override common headers, i've tested 'referer' , works fine. so - still need pre froyo solution - ideas ? it not possible pre froyo. after froyo can use extraheaders parameter in loadurl pass http headers.

java - Why I cannot instantiate this variable? -

i have piece of code on jsp file : // mainhomepage pageapp = new mainhomepage(session); string pagevalue=request.getparameter("page"); if((pagevalue!=null) && (pagevalue.compareto("1")==0)) { mainhomepage pageapp = new mainhomepage(session); } else if((pagevalue!=null) && (pagevalue.compareto("2")==0)) { mainaffittaappartamenti pageapp = new mainaffittaappartamenti(session); } else { mainhomepage pageapp = new mainhomepage(session); } pageapp.somemethod(); if don't remove comment on first line said (about pageapp) "cannot find symbol"... why this? if-else instantiate it, in case. wrong? cheers actually, have should not compile since pageapp not within scope on last line. looks confused between variable declaration , variable assignment . java allows both in same statement, however, may declare variable 1 time within same scope. if uncomment first declaration still leave others inside if , el...

javascript, jquery idk -

i got array: backgrounds: { bc2: '/images/layout/images/backgrounds/bc2.jpg', codmw2: '/images/layout/images/backgrounds/codmw2_6.jpg', bf2: '/images/layout/images/backgrounds/bf2.jpg', bf2142: '/images/layout/images/backgrounds/bf2142.jpg', codbo: '/images/layout/images/backgrounds/codbo.jpg', cod5waw: '/images/layout/images/backgrounds/cod5waw.jpg' } and want access backgrounds[0] = '/images/layout/images/backgrounds/bc2.jpg' . possible or need create array in way? in case, backgrounds object, i.e., associative array. can't use numerical indexes access members. can iterate through using for( var prop in backgrounds) or can address members directly ( backgrounds.bc2 or backgrounds['bc2'] ).

xpath - C# XPathSelectElement returns null -

i trying use xpathselectelement method of system.xml.xpath namespace reason returns null, , have no idea why. here code: textreader stream = new streamreader("config.ini"); xmlreader reader = xmlreader.create(stream); xelement xml = xelement.load(reader); xelement file = xml.xpathselectelement("config/file"); here xml file trying read: <?xml version="1.0" encoding="utf-8"?> <config> <file>serp_feed.xml</file> </config> i have tried many things (adding namespace table, changing xpath, etc.) nothing works! any ideas? well xelement.load variable named xml root element, "config" element of xml sample posted. , if use path config/file on element context node looking child element named "config" having descendant "file" element. "config" element not have "config" child element, has "file" child element. want xpath file or need xdocum...

java - Loop through all "widgets"/elements in a Activity -

i started own android app few days ago since needed mobile application store bunch of data collect in hospital. i'm pretty new java , android environment, although seems easy understand , similar c++. anyway, application has bunch of "edittext" , radio buttons , question is: how can iterate through widgets (edittexts , radio buttons)? in .net "for each element in container " loop can't seem find way in java/android environment. note: don't know how many "widgets" exist in activity, since created dinamicaly, others hardcoded , others show if user preferences set any or hint appreciated. for (int = 0; < rootview.getchildcount(); i++) rootview.getchildat(i) note return view-s, have check @ runtime type of view looking at

iphone - Sqlite Prepare Failed: No such table <table_name> -

i using sqlite database in iphone app. here in app used absolute path @"/users/macos/documents/appdatabase.sql now here want run app on device. requires relative path. what needs done path database ? here getting error when try run absolute path on device. sqlite prepare failed: no such table i have checked table exist in database. what should relative path database? please , suggest. thanks you can database path using - nsarray *documentpaths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *documentsdir = [documentpaths objectatindex:0]; nsstring *databasepath = [documentsdir stringbyappendingpathcomponent:@"mydb.sqlite"]; also delete app simulator or device , run/install again.

sql server 2005 - Summation of Daily Income possible without cursor? -

i have table stores schedule of income due, number of assets. table gives date new income amount becomes effective, daily income amount. i want work out total income due between 2 dates. here's table structure , sample data: declare @incomeschedule table (asset_no int, start_date datetime, amt decimal(14,2), primary key (asset_no, start_date)) /* -- amt amount of daily income -- start_date effective date, when amt starts come in */ insert @incomeschedule (asset_no, start_date, amt) values (1, '1 jan 2010', 3) insert @incomeschedule (asset_no, start_date, amt) values (1, '1 jul 2010', 4) insert @incomeschedule (asset_no, start_date, amt) values (1, '1 oct 2010', 5) insert @incomeschedule (asset_no, start_date, amt) values (2, '1 jan 2010', 1) insert @incomeschedule (asset_no, start_date, amt) values (2, '1 jan 2012', 2) insert @incomeschedule (asset_no, start_date, amt) values (2, '1 jan 2014', 4) insert @incomes...