Posts

Showing posts from January, 2010

c# - Xsl: xsl:value-of and email addresses -

it has been long time since have written xsl, have template: <xsl:template match="teammember" mode="author"> <xsl:element name="author"> <xsl:attribute name="email"> <xsl:value-of select="email" /> </xsl:attribute> <xsl:value-of select="email" /> <xsl:value-of select="displayname" /> </xsl:element> </xsl:template> which seems work ok, except 1 thing. output "email" within element not attribute. xml snippet beign matched against looks like: <teammember sequence="1" primaryindicator="yes" personid="102"> <role rank="1">analyst</role> <lastname>yyy</lastname> <firstname>xxx</firstname> <middlename /> <position /> <clientcode /> <division id="1" code="equity resear

python - How can a custom icon be used in an image menu item? -

i can create menu items icons: new = gtk.imagemenuitem(gtk.stock_new, 'new') but how can use custom icon - file? http://library.gnome.org/devel/pygtk/stable/class-gtkimagemenuitem.html#method-gtkimagemenuitem--set-image img = gtk.image() img.set_from_file(filename) new = gtk.imagemenuitem(gtk.stock_new, 'new') new.set_image(img)

iphone - CoreData Save Permanently? -

i have been working core data in ipad app , can save , fetch data inside app. when closing application, fully, quit, take out of multitasking, , data disappears. so core data in anyway keep data anywhere when app closed? or need somewhere else? edit: in app delegate didfinishlaunchingwithoptions : [[[uiapplication sharedapplication] delegate] managedobjectcontext]; , have this: context_ = [(prototypeappdelegate *)[[uiapplication sharedapplication] delegate] managedobjectcontext]; in uiview subclass. this nspersistentstorecoordinator code premade in app delegate: - (nspersistentstorecoordinator *)persistentstorecoordinator { if (persistentstorecoordinator_ != nil) { return persistentstorecoordinator_; } nsurl *storeurl = [[self applicationdocumentsdirectory] urlbyappendingpathcomponent:@"prototype.sqlite"]; nserror *error = nil; persistentstorecoordinator_ = [[nspersistentstorecoordinator alloc] initwithmanagedobjectmodel:[self mana

vb.net - How to scale controls on a form to fit the form proportionately? -

i have visual basic 2010 form various group boxes, buttons, , labels. want able have form maximized, when controls stay @ , not resize form. want them resize proportionately form. appreciated. you can set position , size of controls form resizeend or resize event, based on form's size. need make sure doesn't crash when form minimized or made small.

Character replacement in strings in VB.NET -

how fast can replace characters in string? so background on question this: have couple of applications communicate each other , clients' applications through sockets. these socket messages contain non-printable characters (e.g. chr(0)) need replaced predetermined string (e.g "{nul}"}, because socket messages kept in log file. on side note, not every log message need have characters replaced. now started off on little adventure reading this msdn link found different post site. the current method used...at beginning of day...was using stringbuilder check possible replacements such as... public function replacesb(byval p_message string) string dim sb new system.text.stringbuilder(p_message) sb.replace(chr(0), "{nul}") sb.replace(chr(1), "{soh}") return sb.tostring end function now blog post points out leaving stringbuilder out , using string.replace yield faster results. (actually, using stringbuilder slowe

redirect - How do I track the route to my destination page from various 301s? -

simple question might know, difficult thing in world me: there's url: http://hstgb.tradedoubler.com/file/118779/banners/searchboxes/holidays_search_8sep09.html?url=http://clkgb.tradedoubler.com/click?p=118779&a=1868402&g=18436588 it's affiliate url (i'm not trying buy ;) ) now when click search, takes me intermediary page, sends parameters lastminute open destination page. the second page goes cannot view or anyhow read it's source code. how track page , parameters sent? you use packet sniffer such wireshark or browser add-on monitors network traffic, capture every request gets send , every page gets received.

orm - Nhibernate SQL named queries and projection -

i've mapped class sql server table , use sql named query retrieve rows it. don't want of columns on pages (e.g. if it's document, want display full content on "view details" page only, while title can on list , "view details" page. if don't select of columns of table in question, indexoutofrangeexception on columns i've left out. is there way project columns i'm interested in on named queries or have create pocos different scopes of application? regards, f. you want nhibernate ad-hoc mapping . p.s.: others have said, should @ least take @ hql , criteria or nhibernate.linq . , handle generated sql, uses nhibernate profiler .

NServiceBus: Exception thrown when not using non-XML configuration with Generic host -

i want use nservicebus generic host running subscriber service. subscriber uses no-xml configuration, there no need app.config. problem since don't have app.config, error generic host: no configuration file found at: c:\my dev\nservicebus2.0.0.1145\samples\pubsub\subscriber2\bin\debug\subscriber2.dll.config is there way disable default behavior of generic host not search .config file? looks there no way around except host nsb on own(from host source): string endpointconfigurationfile = getendpointconfigurationfile(endpointconfigurationtype); if (!file.exists(endpointconfigurationfile)) { throw new invalidoperationexception("no configuration file found at: " + endpointconfigurationfile); }

I have an exception in android application and i don't know the reason? -

the exception 11-30 22:53:18.017: error/zygote(32): setreuid() failed. errno: 2 11-30 22:53:27.508: error/zygote(32): setreuid() failed. errno: 17 11-30 22:53:29.578: error/batteryservice(65): usbonlinepath not found 11-30 22:53:29.578: error/batteryservice(65): batteryvoltagepath not found 11-30 22:53:29.578: error/batteryservice(65): batterytemperaturepath not found 11-30 22:53:29.618: error/surfaceflinger(65): couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake 11-30 22:53:36.538: error/eventhub(65): not driver version /dev/input/mouse0, not typewriter 11-30 22:53:36.538: error/eventhub(65): not driver version /dev/input/mice, not typewriter 11-30 22:53:36.708: error/system(65): failure starting core service 11-30 22:53:36.708: error/system(65): java.lang.securityexception 11-30 22:53:36.708: error/system(65): @ android.os.binderproxy.transact(native method) 11-30 22:53:36.708: error/system(65): @ android.os.servicemanagerproxy.addservice(serv

List of interactions of friends with a facebook app -

is there way fql or fb.api methods list of interactions of friends inside application ? i don't believe so... @ least not unless you're using facebook widgets or whatever, in case maybe, don't know. if it's app (interactions using code you've written) you'll need track interactions on end believe.

Position box in firefox extension -

trying hand @ simple firefox extensions... i trying create second "bar" width of browser window directly above default status bar @ bottom of browser. placing simple hbox element in overlay places second "bar" below default status bar cant seem find way move about. have tried "insertbefore='status-bar'" , such. i have been searching while cant seem find answer seemingly simple problem... update...heres overlay in psuedocode(im not @ machine right now)... <overlay> //this want second "bar" above status bar <hbox> //random text in here displayed in bar below default bar // tried "insertbefore='status-bar'" in hbox tag...but had no effect.. </hbox> //default status bar...i placed button here... <statusbar id="status-bar"> //button element goes here , placed on right side of default status bar // works expected </statusbar> </overlay>

java - Is there a FilterInputStream to convert \r to the local system newline? -

i 1 of developers on platform that, among other features, allows users upload data files (from disparate sources) processing various scripts. an issue keeps popping tab-separated data files excel mac. excel mac (even os x) ends lines cr characters (\r); linux (and modern mac) standard lf (\n). (windows cr lf, aka \r\n.) scripts run on linux machine, absolutely fail identify single \r characters line terminators. on backend, we're feeding inputstream jcr node via usual api. i'd filterinputstream line feed conversion us. it's not code write ourselves, that's obvious cases; if there's canned library this, we'd prefer it, on grounds other people have worked out edge conditions us. is there open-source library converts pretty of standard line-feed formats lf (or system line feed character) inside filterinputstream or other inputstream? few google searches didn't turn obvious, i'd astonished if there isn't something. if there isn't, edge co

security - Securing anonymous image uploads -

sites www.ebayclassifieds.com let users upload images in order see thumbnail previews , make image adjustments before posting content. visitors able upload images sites anonymously without authorization beforehand. can same type of image previews done smaller site has bandwidth , disk space constraints? i'd guess 1 set cron job periodically delete images anonymously uploaded. other measures can taken bandwidth usage , disk space don't out of hand, in case tries spam site bogus image uploads? here ideas off top of head: use session state keep track of uploaded files , delete them automatically when session expires. limit uploads per session/visitor (ie. 1 per anonymous visitor) limit maximum size of file can uploaded. limit image types compressed (ie. don't allow bmps) scale images down reasonable size uploaded. don't need full size.

html - postback to server executing different queries -

i have few <div> inside forms, each thing inside div contains specific form. when user presses submit button, want execute different action based on <form method="get" action="addprogramtodb.jsp"> <select name="cid" style="display: none;"> <option>1</option> <option>2</option> </select> <div id="1"> </div> <div id="2"> </div> <div id="3"> </div> <input type="submit"/> </form> when user presses submit button want program execute different queries based on div in.... based on div id, or somehow.. give submit button name , value usual way. <input type="submit" name="action" value="action1"> ... <input type="submit" name="action" value="action2"> ... <input type="submit" name="action" value="a

asp.net - PageMethod and URl Rewrite -

i having issue pagemethod + url rewrite. when using regular url: http://myweb.com/mypages/abc.aspx call pagemethod works fine. but when use friendly url : http://myweb.com/abc work. no error though. any appreciated. you can set right path aspx file javascript using pagemethods.set_path method: <script type="text/javascript"> pagemethods.set_path("/mypages/abc.aspx"); </script> the answer taken official asp.net forum: http://forums.asp.net/p/1599846/4066920.aspx#4066920

java - can i set the url before returning the ModelAndView? -

is possible set url before returning model? for example, current url http://localhost/home.html @ homecontroller, return modelandview page, example modelandview model = new modelandview("contact"); model.addobject("contactno", "12345"); return model; then after returning model, contact.jsp has been loaded browser it's url still http://localhost/home.html , want change http://localhost/contact.html , how can able that? thanks try instantiating modelandview this, modelandview model = new modelandview(new redirectview("contact"));

How to remove a MapType from google map using Google Maps Javascript V3 API? -

here snippet using display google map on app using v3 javascript api. var myoptions = { zoom: 15, maptypeid: google.maps.maptypeid.roadmap } var map = new google.maps.map(document.getelementbyid("map_canvas"), myoptions); but map shows terrain, hybrid , satellite don't want. how remove controls map. you can remove default ui var mapoptions = { zoom: 15, maptypeid: google.maps.maptypeid.roadmap, disabledefaultui: true }; var map = new google.maps.map(document.getelementbyid("map_canvas"), mapoptions); and can add own controls or can add maptypecontrol: false

iphone - Openflow touchAtIndex delegate method not triggered -

i followed tutorial (http://github.com/tupps/openflow) creating cover-flow , but in open flow openflow library 'touchatindex' delegate method not being called when taping images. any suggestions on trigger method? here found way detect single tap on image . created custom button , placed image zoomed area n given tag value each image n presented view on each image touch...

javascript - JQuery - .animate <img> -

morning mr. stackoverflow. is possible .animate between 2 img ? like, change img src & fade new img src? html <img class="classimg" src="images/example.png" /> my pseudo jquery/javascript code: on click animate .classimg height 50 width 100 opacity 1, 600 animate .classimg height 200 width 450, 400 animate .classimg change img src url(images/example_with_green.png), 700 thank affort - , 1st dec! as robert said can this: <script type="text/javascript"> $(function () { // find div.fade elements , hook hover event $('div.fade').hover(function() { // on hovering on find element want fade *up* var fade = $('> div', this); // if element being animated (to fadeout)... if (fade.is(':animated')) { // ...stop current animation, , fade 1 current position

c# - Translating query comprehension to Enumerable extension methods in LINQ -

how translate following query functional calls? know compiler behind scenes don't know how view result var query = item in enumerable.range(0, 10) item2 in enumerable.range(item, 10) item3 in enumerable.range(item2, 10) select new { item, item2, item3 }; in case, uses selectmany , , concept called transparent identifiers preserve existing range variables. query translate to: var query = enumerable.range(0, 10) .selectmany(item => enumerable.range(item, 10), (item, item2) => new { item, item2 }) .selectmany(z => enumerable.range(z.item2, 10), (z, item3) => new { z.item, z.item2, item3 }); (in case z transparent identifier. if there'd been where clause or other select after last from clause, transparent identifier have been introduced.) the translations de

iphone - xml parsing from web service image's -

i need parse xml. xml have image links..... example xml.. <root> <child id='1'> child one</child> <childe2> child 2 </child2> <image>http://website........link.</image> <image>http://website........link.</image> <image>http://website........link.</image> </root> now have taken nsmutablearray loading images.... is procedure correct. alternative can implement. thanks in advance. i think approach correct , shouldn't cause problem. thanks

Drupal - rules - if URL is present -

ive setup following rule in drupal: not condition - logged in user has profile created do condition - redirect user profile creation page but want rule run, if following present in url. user?destination=og%2fsubscribe%2f67 ( forwards users group after register, o allow reqest join) the reason wanting this, because have logintoboggan setup, forwards new user specific page, after registration, takes them through setup. dont want users have been asked join group, follow same procudure, why have setup rule. unfortunatelly rule overrides logintoboggan. which why want somehow tell rules module run rule, when "user?destination=og" present in url any appreciated add condition using custom php statement. return arg(0) == "user" && $_get['destination'] == "og/subscribe/67'; if want check whether og in destination, modify return arg(0) == "user" && stripos($_get['destination'], "og&qu

mysql - JDBC Connector with Tomcat6 and CentOS5? -

i've got 2 servers, 1 centos , other debian . in debian i've installed tomcat6 last mysql in lenny. downloaded mysql jdbc driver , drop in $catalina_home/lib . worked perfectly. now, in centos5, want same doesn't work. i've installed tomcat6 (it's working) , mysql-server (it's working too). i've tried same /lib folder , nothing (of course i've got same jdk , , same tomcat version). the error same: org.apache.tomcat.dbcp.dbcp.sqlnestedexception: cannot load jdbc driver class 'com.mysql.jdbc.driver' it's doesn't find mysql connector, it's in place. any suggestion? resolved! before of put manually connector in $catalina_home/lib installed yum mysql-connector-java package. i've deleted /usr/share/java/ bin, restarted tomcat , , worked!. thanks all!

apache - Django: WSGI delays -

i've deployed django-application, works fine. problem have there requests hanging, , can't find reason this. "hanging" means, e.g. if click on link in admin backend, browser loads (and apache access log not show get-request @ time), gets no answer. if request again, gets answered. i tried out many different wsgi-configurations, including daemon/embedded mode changes, changes in amount of processes , threads etc. don't have idea search further. here current apache configuation: <virtualhost myserver.com:80> servername myserver.com alias /media/ /opt/myserver/static_media/admin/ alias /favicon.ico /opt/myserver/static_media/img/favicon.ico wsgiscriptalias / /opt/myserver/myproject.wsgi wsgidaemonprocess myserver.com user=www-data group=www-data processes=2 threads=15 errorlog /var/log/apache2/myserver-error.log customlog /var/log/apache2/myserver.log common </virtualhost> and wsgi-file: import os, sys sys.path.a

javascript - Browser & OS as body class -

i have os , browser in body class. need pixelperfect styling, because fonts not behave same way in different os / browser configurations. after googling , experimenting. way think of use indexof... var osname="unknown os"; if (navigator.appversion.indexof("win")!=-1) osname="windows"; if (navigator.appversion.indexof("mac")!=-1) osname="macos"; if (navigator.appversion.indexof("x11")!=-1) osname="unix"; if (navigator.appversion.indexof("linux")!=-1) osname="linux"; var agt=navigator.useragent.tolowercase(); if (agt.indexof("opera") != -1) return 'opera'; if (agt.indexof("firefox") != -1) return 'firefox'; if (agt.indexof("safari") != -1) return 'safari'; if (agt.indexof("webkit") != -1) return 'webkit'; if (agt.indexof("msie") != -1) return 'internet explorer'; if (agt.indexof("mozilla/5.0")

html - Do external javascript references cause the browser to wait until they are downloaded? -

when page being parsed, , comes across <script src='someexternalsite/jquery.js'></script> or whatever, page wait until file downloaded , available before continuing parse? added: do browsers simultaneously download scripts save time (even if execute them in order)? each tag blocks page further rendering until js file downloaded. idea place js file in end of body tag

sql server trigger referencing last row -

i want write trigger in sql server insert 2 rows table2 when row inserted table1 . want use column value table1 . so trigger looks create trigger triggername on table1 begin insert insert end how value of column last inserted row (the row insertion fires trigger). i.e. equivalent of 'referencing row' in oracle triggers in sql server fire per statement not per row. there 2 pseudo tables inserted , deleted can use (for insert trigger 1 of interest inserted ) create trigger yourtrigger on table1 insert insert table2 select * inserted /*this contain multiple rows if multi-row insert*/

jquery - Why so much problem with IE and Ajax? -

$.ajax({ type: 'post', url: url +'/foo/', data: {'pass': pass}, datatype: "json", jsonp:'jsonp_callback', success: function(data) { if (data["success"] === "false") { $("#password").val(""); $('.error-message').removeclass('hide') $('.error-message').addclass('show') } else { var tempurl="http://10.0.1.101:9000/bar/" location.href=tempurl; } }, }); return false this working fine in mozilla, chrome, safari. not in ie. reason. returning suucess value server. if success true redirect tempurl . nothing happing here in ie. seems ajax not @ working in ie. you're running "dangling comma" problem (the comma after closing } of success parameter). ie doesn't dangling commas in object literals, treats them syntax errors , script dies. (this isn't ie bug, it's reasonable int

c# - Most reliable way to clean List<T> depending on Predicate<T> -

i have list<t> data , predicate<t> condition. what way should use clear data depending on condition result? option 1: var del = data.where(i => condition); data.removeall(i => del.contains(i)); option 2: var del = data.where(i => condition); (int = 0; < del.count; i++) data.remove(del[i]); option 3: var del = data.where(i => condition); foreach (var in del) data.remove(i); option 4: data = data.where(i => !condition); any other? how about: data.removeall(condition); note fourth option won't work without call tolist() .

amazon web services - Not able to get HTTP GET for Freebase search url -

i using freebase search url know query classification. have send jquery request in javascript follows, not getting response. var searchvalue = document.getelementbyid("searchtext").value; var url = "http://www.freebase.com/api/service/search?query=india"; $.getjson(url,function(data){alert(data)}); if place url (http://www.freebase.com/api/service/search?query=india) in browser able json response. 1 faced problem. thanks, sathi you won't able use $.getjson because of browsers' same origin policy . however, freebase.com apis support jsonp should able this: $.ajax({ url: "http://api.freebase.com/api/service/search" data: {query:"india"}, datatype: "jsonp", success: function(data) { console.log("success", data); } });

xforms - How to create a grouped XBL control -

i trying create xbl control groups xform date, drop down , text box in orbeon following code snippet: <xbl:binding id="fb-generalform" element="fr|generalform"> <metadata xmlns="http://orbeon.org/oxf/xml/form-builder"> <display-name lang="en">general form</display-name> <display-name lang="fr">bouton navigateur</display-name> <icon lang="en"> <small-icon>/forms/orbeon/builder/images/button.png</small-icon> <large-icon>/forms/orbeon/builder/images/button.png</large-icon> </icon> <datatype>xs:string</datatype> <template> <xforms:select id="" appearance="xxforms:tree" ref="" xmlns=""> <xforms:label ref=""/> <xforms:hint ref=""/>

C# .NET Write XML File from SQL Dataset with Custom Schema -

i have following code in c# visual studio 2010. string connectionstring = "provider=microsoft.jet.oledb.4.0;data source=c:\\database\\db.mde"; string sql = "select * customer"; oledbconnection connection = new oledbconnection(connectionstring); oledbdataadapter adapter = new oledbdataadapter(sql, connection); dataset ds = new dataset(); connection.open(); adapter.fill(ds, "test table"); connection.close(); datagridview1.datasource = ds; datagridview1.datamember = "test table"; ds.writexml("c:\\users\\desktop\\testfile.xml"); now want need modify format of xml file when exports. can done? gather need provide schema file fine i'm not sure how implement dataset. currently xml looks this. <?xml version="1.0" standalone="yes"?> <newdataset> <test_x0020_table> <name>customer1</name> <address>25 big st</address> <suburb>sydney nsw</suburb>

What's the proper way to install pip, virtualenv, and distribute for Python? -

short question what proper way install pip , virtualenv , , distribute ? background in my answer so question 4314376 , recommended using ez_setup install pip , virtualenv follows: curl -o http://peak.telecommunity.com/dist/ez_setup.py sudo python ez_setup.py sudo easy_install pip sudo pip install virtualenv i pulled these instructions jesse noller's blog post so want use python on mac? . idea of keeping clean global site-packages directory, other packages install there virtualenvwrapper , distribute . (i added distribute toolbox because of this python public service announcement . install these 2 packages, used: sudo pip install virtualenvwrapper curl -o http://python-distribute.org/distribute_setup.py sudo python distribute_setup.py no more setuptools , easy_install to follow that python public service announcement , on fresh python install, following: curl -o http://python-distribute.org/distribute_setup.py sudo python distribute_setup.py sudo easy_

mysql - my.cnf changing datadir, 2days and still no luck -

hi have been trying hours upon hours, forum last resort sfter googling hundreds of pages. problem: sorry length supplying in detail of have tried i have set mysql , working fine, need change data-storage point @ external hd. with mac osx there no default my.cnf copied my-huge.cnf /usr/local/mysql-5.1.53-osx10.6-x86/support-files, if makes odds have 'mysql' folder in local also. when place , rename my-huge.cnf /etc renamed my.cnf instructed, works normal if dont add datadir field looks this datadir= /volumes/elements/database, have copied old data new location using sudo cp -r -p /var/lib/mysql /volumes/elements/database everything workds fine unless add field datadir = /volumes/elements/database my.cnf file, if error error 2002 (hy000): can't connect local mysql server through socket '/var/lib/mysql/mysql.sock' (2) my.cnf file looks following macintosh-100:support-files seanf$ cd /etc macintosh-100:etc seanf$ sudo nano my.cnf password

.net - how to detect application crashes? -

if running .net application , application crashes frequently. want offer crash recovery process such after crash, message displayed user offering restart application. how possible write code inside application , still run after had crashed! sounds weird loop of code i'd know experience on this. you can subscribe appdomain.currentdomain.unhandledexception event , stuff event handler.

windows phone 7 - Can i use this Barcode library on WP7? -

greeting, can use this library in windows phone 7? there exists c# or vb.net version. here used namspaces: using system; using system.drawing; using system.drawing.imaging; using system.text; using system.collections.specialized; using system.collections; or how can know can use library or can't. not without changes - system.drawing isn't available in wp7 (or silverlight in general, matter). the simplest way find out though create new wp7 class library project, try add existing source it, , try add assemblies original code references.

sql server - How can have a SQL connection that is sleeping a pending transaction? -

Image
i'm facing locks @ our db server created our application. don't understand how process sleeping having open transaction (that process 71 1 creating lock). as far know when process finishes closes opened transactions. rigth? thanks in advance mates. as far know when process finishes closes opened transactions. right? no. if explicitly open transaction must explicitly commit or rollback . until time transaction remains open possible connection idle (not processing task) still have uncommitted transaction. many people expect error automatically roll transaction not case unless have set xact_abort on

javascript - jQuery: Read all domain cookies if you don't know their names -

i'm using jquery cookie plugin read/write/delete cookies. i'm using cookies store points on graph user plotted on top of canvas. i'm allowing user store plotted points along name in cookie, i'm listing saved cookies can redraw saved points on graph. i saving , reloading points cookies naming each cookie sequential number $.cookie("_1") , $.cookie("_2") , etc , worked. problems start when user deletes cookie , sequential numbering breaks. i save cookie using name user gives plotted points, saving cookies arbitrary names. if is possible read domain cookies if don't know names? you don't need jquery this. can read cookies accessing document.cookie , parsing accordingly. see example here .

PHP MySQL Error Log Function -

what thoughts of using following function log mysql errors? <?php function sql_query($query) { $q = mysql_query($query); if(!$q) { mysql_query('insert mysql_errors (error_query, error_about) values ('. $query.', '.mysql_error().' )'); } return $q; } ?> do find useful? how can improved? should be: mysql_query("insert mysql_errors (error_query, error_about, error_date) values ('". mysql_real_escape_string($query)."', '".mysql_real_escape_string(mysql_error())."',now())"); i added date field , sanitised input. there needs way differentiate new , old errors , date field that.

ruby on rails - Virtual columns in a model -

is possible add virtual column model (not virtual attribute!)? i have following situation: product(id, name) has many productvariant(id, price, offer_price, product_id,...) when select products want have minimum product price productvariants in products result. @products = product.with_min_price.order('min_price asc') i calculate minimum price in sql query ( with_min_price ) , want add min_price value each product in @products result . this method in product class assuming product has_many productvarients #product model def min_product_price product_variants.map(&:price).min end

MySQL struggling with query in one to many relationship matching multiple conditions -

i have 2 tables set out follows: products product_attributes ================== ======================================== | id | name | | id | product_id | attribute | value | ================== ======================================== | 1 | product 1 | | 1 | 1 | size | big | | 2 | product 2 | | 2 | 1 | colour | red | | 3 | product 3 | | 3 | 2 | size | medium | | 3 | product 3 | | 4 | 2 | age_range | 3-5 | | .. | ... | | 5 | 2 | colour | blue | ================== | 6 | 3 | size | small | | .. | ... | ... | ... | ======================================== there potentially infinite amount of attributes product why kept in separate table. i want able pull out distinct products match multiple (also infinite) attribute conditions cant think how without maybe using or condition , sort of count check of

Toggle Text with jQuery -

i've found a few articles here on topic none seem answer i'm looking for. here current code: $(".email-slide").click(function(){ $("#panel").slidetoggle("slow"); $(this) .text("close") .toggleclass("active"); }); when select word "email" has class "email-slide" top panel slides down, , word "email" turns white, , word "email" turns word "close". all far. when clicking "close" though color , panel go normal, word "close" not turn word "email". instead of .text("close") tried .toggletext("class") seems not work. there similar accomplish adding least amount of code possible? thank you! update - able accomplish using following code, hoping more efficient/shorter way of doing it. if not, let me know. thanks! $(".email-slide").click(function(){ $("#panel").slidetoggle("slo

multithreading - Silverlight Background Thread using WebClient -

i'm using webclient infos asynchronously web service : wc.downloadstringcompleted += downloadstringcompleted; wc.downloadstringasync(service); i works fine, think downloadstringcompleted method working on ui thread, , since i'm doing lot of parsing there, page takes few seconds appear. however, since have fixed data , progress bar, would'nt mind have appearing instantly. how perfom ? thanks ! use httpwebrequest rather webclient . hwr doesn't return on ui thread , doesn't block updating.

cocoa - Programmatically Retrieve OSX Network/Proxies configuration values -

considering application has user id , password admin user logged in, possible retrieve configuration values osx network settings? particularly interested in "advanced/proxies" tab content. did settings api. here's example fetch pac url string osx network settings. static char url[257] = {0}; nsdictionary * proxies = (nsdictionary *)scdynamicstorecopyproxies(null); nsstring * pacurl = [proxies objectforkey:(nsstring *)kscpropnetproxiesproxyautoconfigurlstring]; if (null != pacurl) { strncpy((char*) (&(url)[0]), [pacurl cstringusingencoding:nsasciistringencoding], sizeof(url)); } return url;

django - Return a http response before actual function is completed -

i have form on site uploads file. upload file amazon s3 before sending response user. there way in django send "success" response user after file saved on local server, before i start saving s3? you should use distributed task queue . since using aws already, might want consider alternative: amazon sqs .

javascript - How to use jQuery within PHP -

i'm using php tree browser got http://www.lateralcode.com/directory-trees-with-php-and-jquery/ <?php $path = "."; function createdir($path = '/') { if ($handle = opendir($path)) { echo "<ul>"; while (false !== ($file = readdir($handle))) { if (is_dir($path.$file) && $file != '.' && $file !='..') printsubdir($file, $path, $queue); else if ($file != '.' && $file !='..') $queue[] = $file; } printqueue($queue, $path); echo "</ul>"; } } function printqueue($queue, $path) { foreach ($queue $file) { printfile($file, $path); } } function printfile($file, $path) { echo "<li><a style=\"cursor:pointer\" ". "onclick=\"parent.right.document.getelementbyid('file_path').value='". "$file_path'\">$file_path</a></li>&

Declare Multiple Java Arrays on Same Line? -

is possible initialize and/or declare multiple arrays in same line in java? ie. int a, b, c, d, e = 4 works but int[] a, b, c, d, e, = new int[4] doesn't seem work (size of array 4) bear in mind int a, b, c, d, e = 4; is declaring 5 ints initialising 'e'. in same way, int[] a, b, c, d, e = new int[4]; will initialise e. you'd need int[] a=new int[4], b=new int[4], etc... which frankly, isn't worth one-lining...

Local/remote access synchronization for an ftp site -

i writing code update application fetching new dlls ftp site, according manifest file, @ ftp site, specifies versions of each dll. basic idea is, updater program runs @ startup, checks manifest @ ftp site, downloads dll's newer used application, , starts application , shuts down. this leads following problem, not sure of best way handle: want put new dll on ftp site, @ same time updater application instance tries read dll. if delete dll, , copy on new one, updater might not see file, though manifest says should there. i have idea of sort of marker file, act synchronization object, , existence , updater instance can use lock, not moving problem? there still time between checking if lock there, , making lock, in else make lock, , start modifying ftp files. plus, if updater crashes before deleting marker, there no way of telling, whether leftover marker should deleted. edit: saw suggestion upload files folder, , rename folder, since renames supposed atomic operation in ftp,

documentation - Is it possible to dump a mysql schema into latex tables? -

i documenting database, , great have functionality update tables automatically based on current state of database. i know phpmyadmin this, buggy gui doesn't provide many options- end having write script sed find , replace things don't want , add things do. you can accomplish via show tables , show create table command. it may not easy task reconcile has , has not changed. but, basic approach here list of tables in database, , run show create table table_name command full spec on schema. also, use explain command; however, though it's similar, contains higher-level information. i'd argue show create best since that's need see replicate schema. if had more specifics how wanted use information, i'd ammend more information. programming language you're using connect mysql. can use command line info, you'll want intelligent processing in order reconciliation against existing fields in replicated data containers.

objective c - Problem with NSNumber (double values are off by 1) -

i'm getting following output , i've no idea why!? resulting number off 1. i thought double's can handle massive numbers? i'm sure i'm not understanding correctly! appreciated. (gdb) print (double) [[nsnumber numberwithdouble:9606977671929857.0] doublevalue] $13 = 9606977671929856 many thanks! you've exhausted precision of double-precision floating point type, has room 14 significant digits in decimal notation.

actionscript 3 - JSON encoding in as3 -

i have code im using pass data in json encoded format php. there way can check @ php end if received , beamed in proper format? var people:array = new array(); var person:object = new object(); var url:string = "http://localhost/ping.php"; var request:urlrequest = new urlrequest(url); var requestvars:urlvariables = new urlvariables(); var loader:urlloader = new urlloader(); person.fullname = "jon jay junior"; person.username = "jjj"; person.role = "admin"; people.push(person); request.method = urlrequestmethod.post; requestvars.myobject = json.encode(people); request.data = requestvars; loader.load(request); as others have mentioned, should @ request firebug, livehttpheaders, or similar tool (there several firefox). let see format of data. if $_request['myobject'] indeed null in php, wrong. should attach loader.addeventlistener(ioerrorevent.io_error, handleioerror);

c# - Accessing derived class property members from base class object in CSharp -

i having trouble accessing property members of derived class using base class object. scenario: public class baseclass{ public virtual write(baseclass data){ } } public class derivedclass : baseclass{ private string name: public string name {get {return name} set {name = value;} } public override write(baseclass data){ console.println(data.name); // gives me error here } } the reason have problem accessing properties in derived classes base class not (and more importantly should not ) know them. different derived classes have different set of added properties. making base class aware of counteract important principles of object oriented design. 1 such principle comes mind liskov substitution principle .

c++ - using g++, how to deprecate virtual class member functions -

i seem having trouble getting deprecated warnings print out, functions declared virtual. i'm using "g++ (gcc) 4.1.1 20061011 (red hat 4.1.1-30)." research shows there might problems in gcc 4.x regarding deprecating pure virtual functions(i.e. class bueller{ virtual int cameron()=0;};), not... i'd guess you'd call them regular... virtual functions. we're on same page... foo.h class foo { void foo_a() __attribute__((deprecated)); //non-virtual virtual void foo_b() __attribute__((deprecated)); //virtual virtual void foo_c() __attribute__((deprecated)) = 0; //pure virtual }; say compiled this, foo.cpp file , main.cpp file using g++. 1)anything uses foo_a() indeed show warning. 2)anything uses foo_b() not show warning. 3)anything inherits foo, implements foo_c , uses not show warning. number 1: works, no problem. number 3: seems known bug/feature.. whatever.. there seems no explination #2 however. perhaps it's tied in #3, although no

asp.net - Master page and JavaScript problem -

i prepared aspx file can open new window (window.open) command. in child window, values send parent page (.innerhtml) command , can close . however, after set master page parent page , command can not send value new window parent , can not close itself. how master page can affect javascript commands? thanks edit: drachenstern (i can have ... pasted) from child code behind: <br> page.registerstartupscript("close", "<...js...><script type=\"text/javascript\">" +<br> "window.opener.document.getelementbyid('tableid').innerhtml = \"" + radionumber + "\";" +<br> "window.opener.document.getelementbyid('hiddentableid').value = \"" + radionumber + "\"; <br> self.close();" + "<...js....></script>" );<br> parent side: <br> ..a ..<br>href="javascript:window.open('selecttable.aspx'

hardware - Would an Intel Core2 Duo Processor SU7300 (1.30GHz, 3MB L2, 800MHzFSB) be okay for Java programming on the go? -

i'm looking light small laptop java/grails programming on go (travelling , work - approx 1.5 hrs each way). the intel core2 duo processor su7300 (1.30ghz, 3mb l2, 800mhzfsb) seems cost effective , battery friendly, can handle running likes of eclipse/netbeans/idea reasonably? as move i5, price , battery start getting hammered. i'm planning on having ssd drive, expect make machine snappy, i've got no idea if i'd wasting time on su7300. thanks. update went macbook air, core2duo 1.8ghz. i'll try write blog post comparing: macbook air 2.18ghz ssd (friends) macbook air 1.8ghz ssd (mine) dell inspiron 15r i5 7200rpm disk (wifes) dell inspiron 1525 core2duo 1.8ghz 7200rpm disk (my old laptop) i'll pick , compare : suitable opensource maven library build, grails application, , launch times ides, , try find other suitable programmer tasks compare etc. pity don't have su7300 available compare! yes, there entire java operating system re

flash - Is it possible to retrieve a cookie from an HTTP response in as3 without using javascript? -

my swf potentially live on sites embed codes not allow script access movie. need pull cookie response typically simple using javascript, swf not have access script, javascript not option . can access cookies or cookie header in response? if not possible there access raw response, headers , all? edit / clarification the request coming foo.com bar.com bar.com setting cookie on foo.com the request can written in way allows access cookie. currenlty using urlloader. allowscriptaccess false thank you it not possible http cookies directly in - @ least in normal swf. can listen httpstatusevent requestheaders property of event available in air :/ (and i'm not sure include cookie). use js cookie(s) needed.

python - Skip a letter in dictionary -

i need assign uppercase numbers in dictionary 1 letter s not there. ie. in alphadict = dict((x, i) i, x in enumerate(string.ascii_uppercase)) have alphabets of dictionary. what simplest way delete entry s , shift rest of values left. if there other way create dictionary tell..... i in need of this..... number user..... number in dictionary should assigned s , other dictionary items can readjusted.... ie user gives me 3 dictionary should like 0- 1- b 2- c 3- s , rest follow d z without s....... please help..... lot.... if understand properly, simplest thing seems first create list letters in order want, , convert dictionary: import string sans_s = [c c in string.ascii_uppercase if c not 's'] user_choice = 3 alphabet = sans_s[0:user_choice] + ['s'] + sans_s[user_choice:] print alphabet # ['a', 'b', 'c', 's', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k&

Looking for an expressive audio programming language or library -

i'm looking audio processing language or library allow me experiment different synthesis techniques. i've looked @ processing think great @ does, haven't found inspiring (and simple) audio libraries. as baseline, want create own sample buffers , play them (ideally in realtime). plus, ability handle midi events great. i'm experienced c++ programmer natively on had hoped there more dsl (domain specific language) approach. i have access windows, mac or linux not bothered yet platform. other languages can deal c#, java & python. thanks james depending on how want stay out of low-level housekeeping details, may want @ csound , or if want not write code, patching-based system puredata great work with. @lou points out, chuck interesting (but buggy use last time checked out). if want write code, @ synthesis toolkit , set of c++ classes audio processing , synthesis. for app framework, recommend juce , has incredibly nice cross-platform handling o

Error: Assignment makes pointer from Integer without a cast... in C Prog -

i error whenever run program " assignment makes pointer integer without cast". code written below.... please help... thankx struct student { char studentid[6]; char name[31]; char course [6]; }; struct student *array[max]; struct student dummy; int recordctr=0; int read(){ file *stream = null; int ctr; char linebuffer[45]; char delims[]=", "; char *number[3]; char *token = null; stream = fopen("student.txt", "rt"); if (stream == null) stream = fopen("student.txt", "wt"); else { printf("\nreading student list directory. wait moment please..."); while(!feof(stream)){ array[recordctr]=(struct student*)malloc(sizeof(struct student)); while(!feof(stream)) { fgets(linebuffer, 46, stream); token = strtok(linebuffer, delims); //this error appears

Problem with function in python -

i newbie in python. trying code basic function getting errors. dont know reason behind it. example code: def printme( str ): print str; return; printme("my string"); this should execute logically gives me following error: traceback (most recent call last): file "stdin", line 1, in "module" nameerror: name 'printme' not defined any suggestions welcome... the semicolons shouldn't there return statement (the execution of function ends @ last statement indented within it). not entirely sure how formated indent python relies on determine scope def printme(str): print str #this line indented, #that shows python instruction in printme printme("my string") #this line not indented. #printme's definition ends before executes currectly wikipedia's page on python syntax covers indentation rules.

java - why the TCP receiver can receive data after the Socket Server has shut down? -

i using java implement multithreaded tcp server-client application. have encountered strange problem: when shutdown server socket, receiver can still receives last sent packet continuously. since detail of socket read of kernel concern, can't figure out reason. can give guideline? in advance! edit: code involved simple: public void run() { while(runflag) { //in = socket.getsocketinputstream(); //byte[] buffer = new byte[buffersize]; try { in.read(buffer); //process buffer; }catch(ioexception e) { // } } } when shutdown server socket, read operation receive packet continuously(each time enters while loop). the tcp/ip stack inside os buffering data on both sides of connection. sender fills socket send buffer , drained device driver pushing packets onto wire. receiver accumulates packets off wire in socket receive buffer , drained application r

c - Can I pass functions as parameter and the function can hold different arguments? -

currently call function in way: typedef struct optionvaluestruct{ const char *option_name; int (*func)(char*, char**); } optionvaluestruct_t; int parse2parameter(char *opt_name, char** opt_val); int parse3parameter(char *opt_name, char** opt_val, int a); const optionvaluestruct_t option_values[] = { {"counter1", parse2parameter} }; where parse2parameter func() having 2 parameters defined in optionvaluestruct_t. how possible use const optionvaluestruct_t option_values[] = { {"counter1", parse2parameter}, {"counter2", parse3parameter} }; where parse2parameter() , parse3parameter() has different number/type of parameters? what trying do, , why? think code receive function pointer. how going know how call it?

jquery - XML not displaying -

on test site rss xml feed parsed , displayed properly. when moved production server no longer works , isn't being appended ul. shows 200 ok response , content visible in network tab, not there! request/response headers seem different dont know enough know if different server set or what. by displayed mean @ bottom of index page says "ninjatrader news" parsing xml , displaying newsticker plugin.

c# - System.IO.FileMode.Open -

for system, first need read csv file , need connect database in sql server 2008 according data in .ini file. i use system.io.filestream() read file. there no problem open , read data. but, when read csv file , connect database , cant access .ini file because system.io.filestream() function take path of ini file location of csv file. so, when read csv file desktop , system.io.filestream() function search ini file in desktop , when read document, search in document. thus, want know how control this. my function read ini file : system.io.filestream("filenameonly", system.io.filemode.open, system.io.fileaccess.read); you can set openfiledialog.restoredirectory true have dialog reset location on each use.

java - Break in nested for loops -

possible duplicate: how break main/outer loop in double/nested loop? i have following situation: for(int = 0; < schiffe.length-1; i++){ if(schiffe[i].schaden){ schlepper.fliege(schiffe[i].x, schiffe[i].y, schiffe[i].z); schlepper.wirdabgeschleppt = schiffe[i]; for(int k = 0; k < stationen.length-1; k++){ if(stationen[k].reparatur == null){ schlepper.fliege(stationen[k].x, stationen[k].y, stationen[k].z); break; } } } } i want schlepper.fliege(stationen[k].x, stationen[k].y, stationen[k].z); be performed once , break out of inner loop , continue for(int i... loop. used break in code. not s

Deploying web app on HTTPS automatically makes my AJAX calls HTTPS too? -

my application deployed on https (currently in development , running on http). will deploying web app on https automatically make ajax calls https well? using relative urls in ajax calls, thinking when absolute url constructed, https appended automatically. please let me know. response if using relative urls, yes. however, important test before running live, browsers(at least ie6) display alarming warning if try load resources images using non-https connection.