Posts

Showing posts from March, 2013

uitableview - How to use a segmented control to switch or load different table view -

my goal make app similar iphone's app store app. problem have segmented control. want load different table view based on selection of segmented control. have tried had no luck yet. have tried use 1 table view , reloaddata load different data didn't work either. thank in advance. i have been looking answer similar question.... didn't mention data source, if you're using nsfetchedresultscontroller , this might you!

android - onResume() isn't triggering on TabHost items switching -

i have tabhost 2 tabs in it. first time switch second tab onresume() method of second's tab's activity invoked. have alertdialog shown , after disappears 'onresume()' method isn't called wait it. presume invocation of 'alertdialog' triggers 'onpause()' method , 'onresume()' should called before 'activity' shown , ready interaction user. in face 'onpause()' isn't called when switch first tab activity . can advice why 'onpause()' , 'onresume()' methods aren't called , methods called after showing 'alertdialog' or switching between tabs ? i presume invocation of 'alertdialog' triggers 'onpause()' method , 'onresume()' should called before 'activity' shown , ready interaction user alertdialog not affect activity's life cycle. check out activity's life cycle flow chart here. when switching between tabs, if want call method why do...

java - Apply 9-patch drawable to Button, keeping default padding -

Image
i'm attempting customise of button using 9-patch drawable no padding defined within in (no pixels on right or bottom inside 9-patch editor). is there simple way apply 9-patch drawable button , maintain button's default size. example, when apply 9-patch easy button shown below, different size other default styled buttons, share same layout, except 9-patch style. mdpi layout: hdpi layout: so basically, there way make easy button same size medium , hard, on both mdpi , hdpi screens, without making new 9-patch each density, , working out correct padding. thanks in advance help, can provide more information if required. well after more research seems isn't possible use 1 9-patch drawable screen densities. the link below states need different drawables each density: custom color buttons android 3.1. create images 9-patch images different colors need , put them drawable-hdpi , drawable-mdpi (yes, need 2 versions if want buttons on different device...

iphone - Changing an Image on TouchesBegan -

hey, trying change image when user touches imageview. @ moment imageview has image "heart1.png" when touch imageviewer on screen change "heart2.png" code, appreciated: -(void) touchesbegan:(nsset *)touches withevent:(uievent *)event { uitouch *touch = [[event alltouches] anyobject]; cgpoint location = [touch locationinview:self.view]; if (location.x >= imageview.frame.origin.x && location.x <= imageview.frame.origin.x + imageview.frame.size.height && location.y >= imageview.frame.origin.y && location.y <= imageview.frame.origin.y + imageview.frame.size.height) { imageview.image = [uiimage imagenamed:@"heart2.png"]; } } that looks problem me: if (location.x >= imageview.frame.origin.x && location.x <= imageview.frame.origin.x + imageview.frame.size. --> height <-- should width there :)

ruby on rails - accepts_nested_attributes_for and second-order associations, nested forms -

i have following models associations: class order < activerecord::base has_many :guests has_many :customers, :through => :guests accepts_nested_attributes_for :customers end class customer < activerecord::base has_many :guests has_many :orders, :through => :guests has_many :slips accepts_nested_attributes_for :slips end class slip < activerecord::base belongs_to :order belongs_to :customer end class guest < activerecord::base belongs_to :order belongs_to :customer end my nested form looks this: <!-- general form --> <%= form_for(@order) |f| %> <% f.fields_for :customers |builder| %> <%= render "customer_fields", :f => builder %> <% end %> <%= f.submit %> <% end %> <!-- partial customer_fields --> <p> <%= f.label :name%><%= f.text_field :name %> <% f.fields_for :slips |builder| %> <%= render "slip_fie...

ruby - Nokogiri vs Goliath...or, can they get along? -

i have project needs parse literally hundreds of thousands of html , xml documents. i thought perfect opportunity learn ruby fibers , new goliath framework. but obviously, goliath falls flat if use blocking libraries. problem is, don't know how tell "thread safe" (if that's correct term goliath). so question is, nokogiri going cause issues goliath or multi-threading/fibers in general? if so, there safer use nokogiri? thanks goliath web framework, i'm assuming you're planning "ingest" these documents via http? each request gets mapped ruby fiber, effectively, server runs in single reactor thread. so, answer question: nokogiri thread safe best of knowledge, shouldn't matter here. thing have out for: while document being parsed, cpu pinned, , goliath wont accept new requests in meantime. so, you'll have implement correct logic handle specific case (ex: stream parse on chunks of data arriving socket, or load balance bet...

multithreading - Correct way to call XML-RPC service from an EJB -

i've got stateless ejb needs update website using xml-rpc. i've been using apache xml-rpc client (http://ws.apache.org/xmlrpc/). has been working fine, after method of called several times whole application server (glassfish v2.2) locks , need kill server respond again. after extensive reading, believe caused thread manipulating in xml-rpc client, since thread manipulation not recommended in ejb. i wondering, how 1 supposed call external services (such xml-rpc service) in ejb safe. the problem not related apache xml-rpc client, memory allocation / garbage collection misconfiguration.

java - Eclipse RCP retrieve compilation errors -

i'm developing eclipse rcp. when run project, first builded , launched. if builder failed compile project, have notify user that. which better way know if there errors during compilation? thanks one way add own builder in eclipse. go project->properties->builders , new add own builder. can have ant script or maven builder. ofcourse need know ant this.

android - recycle ui elements -

hi in activity layout use xml array of buttons <textview android:id="@+id/tab1" android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="text tab 1" android:gravity="center" android:padding="10dp" android:clickable="true" android:background="@drawable/tab_color_selector" /> <view android:layout_width="1dp" android:layout_height="fill_parent" android:background="@color/lightgrey" /> <textview android:id="@+id/tab2" android:layout_width="wrap_content" android:layout_height="fill_parent...

What are the advantages of using Node.js vs PHP -

possible duplicate: why , when use node js? can tell me why fuss node.js ? regular web site (lets blog) written in node.js faster compared same written in php framework? know web server written in node.js faster apache how real web application doesn't create threads or that? edited: there 2 main advantages: speed! (performance) node.js event-driven , non-blocking , @ handling concurrent requests . here link benchmarking test node.js against php on apache.

C# list question -

what nice way make following action: list<ienumerable<t>> listofenumerables = get...(); list<t> listofobjects = new list<t>(); // want 'listofobjects' contain every element every enumerable // in 'listofenumerables'. is there beautiful way make instead of following: foreach (var enumerable in listofenumerables) { listofobjects.addrange(enumerable); } thank you. you can use linq: list<t> listofobjects = listofenumerables.selectmany(s => s).tolist();

flex - Please explain why i am getting the following error when I use itemrenderer and itemeditor components in the datagrid column -

code: <mx:datagridcolumn id="a" headertext="notes" datafield="a" width="200" visible="true" editable="false" wordwrap="true" editordatafield="text"> <mx:itemrenderer> <mx:component> <mx:hbox> <mx:text width="100%" height="100%"/> </mx:hbox> </mx:component> </mx:itemrenderer> <mx:itemeditor> <mx:component> <mx:hbox> <renderers:editortextrenderer width="100%" /> </mx:hbox> </mx:component> </mx:itemeditor> errorstacktrace: referenceerror: error #1069: property text not found on a.mxml.a_inlinecomponent3 , there no default value. i suppose, custom component editortextrenderer should contain property text . or must set editordatafield property, responsable editing. more details read this . a simple ...

.htaccess - Change the document root of a parked domain? -

i have run problem web host doesn't appear offer addon domains. i have domain name pointing name servers. i went cpanel add addon domain points sub-directory, available in cpanel park domain @ document root 'public_html/'. so traffic coming parked domain wrong content, not good. i feeling isn't possible, can change parked domain document root 'public_html/' 'public_html/sub-directory' ? or perhaps can edit .htaccess file redirect traffic parked domain sub-directory? basically want address; www.parked-domain.com/ to show content of sub-directory; www.first-domain.com/parked-directory i hope possible otherwise need @ new web host. regards, dean. add following .htaccess file: rewriterule ^parked-directory - [l] rewritecond %{http_host} ^(www\.)?parked-domain\.com$ [nc] rewriterule ^(.*)$ parked-directory/$1 [l]

ruby on rails 3 - Heroku and Devise error -

i have updated devise 1.2 , gives med following error on heroku: "devise changed how stores objects in session. if seeing message, can fix changing 1 character in cookie secret or cleaning database sessions if using db store." how can clean database sessions in heroku db? heroku rake db:sessions:clear will empty sessions table

javascript - Get address coordinates of Google Maps API by ajax() request -

i'm trying lng , lat coordinates of google maps api next example http://jsbin.com/inepo3/7/edit . expect 'success' popup, keeps showing 'error' popup. google maps-request gives correct json feedback (checked firebug). <script type="text/javascript"> $().ready(function() { $.fn.getcoordinates=function(address){ $.ajax( { type : "get", url: "http://maps.google.com/maps/api/geocode/json", datatype: "jsonp", data: { address: address, sensor: "true" }, success: function(data) { set = data; alert(set); }, error : function() { alert("error."); } }); }; $().getcoordinates("amsterdam, netherla...

PHP MVC/ORM Frameworks that are Hyper PHP (HipHop) Ready -

is there list of php mvc/orm frameworks work facebook's hiphop? first of all, should know hiphop not have full php 5.3 support , cannot use extensions. second , if going build application comparable in size , userbase facebook ( doubt ), using orm 1 of best ways how sink project. i have no intentions of repeating same song & dance orms again , , read earlier comment . and last: in large project people not use canned frameworks. write 1 in-house , use it, because large scale project have specific requirements, while popular mvc frameworks tend have everything-but-kitchen-sink approach adding features. and if not building project large facebook, not need hiphop.

jQuery png issues in IE 8 -

i'm loving jquery cycle plugin having serious trouble getting behave appropriately in ie8. in of cycles i'm using png files transparencies (no differently other modern site on web). in every browser ie ugly black shadowing around edges of gradients , black background behind 1 of slideshows. i'm using 'cleartype: true, cleartypenobg: true,' fix in of slideshows following css fix: img { background: transparent; -ms-filter: "progid:dximagetransform.microsoft.gradient(startcolorstr=#00ffffff,endcolorstr=#00ffffff)"; /* ie8 */ filter: progid:dximagetransform.microsoft.gradient(startcolorstr=#00ffffff,endcolorstr=#00ffffff); /* ie6 & 7 */ zoom: 1; } in main slideshow have 2 overlapping - http://microstrain.com and in bottom 3 column section have cycle running in 'news update' section. any appreciated here!!! - scott i know set zoom & transparency, try setting them on div encompassing encompasses...

Java heap space on deploying with flex-plugin -

i have 1 flex project in maven. able package , install without problems, not able deploy it: [error] java heap space -> [help 1] java.lang.outofmemoryerror: java heap space @ java.util.arrays.copyof(arrays.java:2734) @ java.util.arraylist.ensurecapacity(arraylist.java:167) @ java.util.arraylist.addall(arraylist.java:474) @ org.apache.maven.project.mavenproject.setactiveprofiles(mavenproject.java:1410) @ org.apache.maven.project.mavenproject.deepcopy(mavenproject.java:1961) i have increased maximum allocated memory (set maven_opts=-xms2512m -xmx3512m), no success. this pom: <parent> <groupid>com.test</groupid> <artifactid>super-pom</artifactid> <version>1.2</version> </parent> <artifactid>services</artifactid> <name>services</name> <packaging>swc</packaging> <properties> <flex.version>4.1.0.16076</flex.version> ...

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 error in Java -

when tried running code error..i dont know went wrong.. exception in thread "main" java.lang.arrayindexoutofboundsexception: 0 @ numericalcomputatio.fibo.main(fibo.java:30) package numericalcomputatio; public class fibo { static double c = -0.618; // double c = [(1-sqrt(5))/2] = - 0.618 /** * computes fibonacci series * @param n * @return */ private static double fibo(int n){ if (n == 0) return 1; else if (n == 1) return c; else { double result = fibo(n - 1) + fibo(n - 2); return result; } } public static void main(string[] args) { int n = 0; double result = 0.0; double result1 = 1.000000000; if (args[0] != null) n = integer.parseint(args[0]); for(int = 0; i<=n; i++) { result = fibo(i); system.out.println("fib(" + + ") = ...

iphone - Is there a way for NSString to display HTML character codes? -

i have nsstring has following value: "what#39;s fellas!" is there simple way turn html char codes #39; (equivalent ') apostrophe etc? check gtmnsstring+html.h out :) it's part of google toolbox, extension ios development. taken this question

Good introduction to the Berkeley db C api installed on OS X? -

i'm looking introduction berkeley db api installed on os x. have looked @ oracle document: http://download.oracle.com/docs/cd/e17076_02/html/gsg/c/berkeleydb-core-c-gsg.pdf which seems newer version. not able compile , following error: test.c:23: error: ‘db_create’ undeclared (first use in function) test.c:23: error: (each undeclared identifier reported once test.c:23: error: each function appears in.) test.c:26: error: ‘db’ has no member named ‘open’ test.c:42: error: many arguments function ‘dbp->close’ afaik, version installed on os x old bsd licensed 1.85. db 1.85 there support system configuration files such /etc/pwd.db , shouldn't used. that being said, is simpler newer berkeley db releases. dbopen(3) start.

c# - Comparing DateTimes: DateTime.Compare() versus relational operators -

here 2 ways of comparing 2 datetimes: datetime = datetime.now; datetime = new datetime(2008, 8, 1); // method 1 if (datetime.compare(then, now) < 0) // ... // method 2 if (then < now) // ... .compare returns integer (-1,0,1) indicating whether first instance earlier than, same as, or later second instance. my question is, why use .compare when can use relational operators ( < , <= , == , >= , > ) directly? seems me, using .compare , need employ relational operators anyway (at least in above example; alternatively create switch statement examining cases -1, 0 , 1). what situations prefer or require usage of datetime.compare() ? typically, .compare methods on types used sorting, not doing direct comparisons. the icomparable<t> interface, when supported on type, allows many framework classes sort collections correctly (such list<t>.sort , example). that being said, if want able comparison within generic class or method,...

android - onStop not being called ... Home button pressed -

in main activity, under onstop, set myvar = true. in onresume, check if myvar = true , something. if hit home button while on main activity , launch again home screen/app drawer, works correctly. if hit home button while on different activity , launch again home screen/app drawer, brings main activity have cleartaskonlaunch="true" set on main activity , android:finishontasklaunch="true" set on other activities. however, doesn't appear hit onstop in main activity when home button pressed. i start other activities result. if result code = result_ok or result_canceled, set myvar = false. but... if home button pressed, shouldn't setting results , doing onactivityresult. any idea how solve this? edit: above oncreate.. set startnew = true; @override public void onstop() { super.onstop(); startnew = true; } @override public void onrestart() { super.onrestart(); if (startnew) { getcurrentda...

optimization - What is the downside of using a structure vs object in a list in C#? -

as understand, using structure value types give better performance using reference types in array or list. there downside involved in using struct instead of class type in generic list? ps : aware msdn recommends struct should maximum 16 bytes, have been using 100+ byte structure without problems far. also, when maximum stack memory error exceeded using struct, run out of heap space if use class instead. as others have pointed out, there many downsides using large structures in list. ramifications of others have said: say you're sorting list members 100+ byte structures. every time items have swapped, following occurs: var temp = list[i]; list[i] = list[j]; list[j] = temp; the amount of data copied 3*sizeof(your_struct) . if you're sorting list that's made of reference types, amount of data copied 3*sizeof(intptr) : 12 bytes in 32-bit runtime, or 24 bytes in 64-bit runtime. can tell experience copying large structures far more expensive indirection inhe...

php - Sorting a 3 dimensional array -

i've got array this array ( [0] => array ( [0] => array ( [szam] => 8 [index] => 0 ) ) [1] => array ( [0] => array ( [szam] => 1 [index] => 0 ) [1] => array ( [szam] => 7 [index] => 1 ) ) i thought last cmp work fine function maxszerintcsokkeno($item1,$item2) { if ($item1['szam'] == $item2['szam']) return 0; return ($item1['szam'] < $item2['szam']) ? 1 : -1; } with foreach foreach ($tomb $kulcs => $adat) usort($adat,"maxszerintcsokkeno"); but dosen't anything, advise? you're sorting temporary variable, meaning changes not applied. following should work you: for($i = 0,...

php - Stop new object from updating with old object's variables -

i'm trying like: $obj2 = $obj1 where $var1 object, problem want $obj2 snap shot of $obj1 - how @ moment, $obj1's variables change, $obj2's change well. possible? or going have create new "dummy" class can create clone? simply clone object, so: $obj2 = clone $obj1; any modifications members of $obj1 after above statement not reflected in $obj2 .

Finish (Close) a Android Activity on Touch -

how terminate activity in adroid on touch. here shows view described in details.xml. need dismiss activity on touch. tried following code. not working. ideas? public class details extends activity { protected void oncreate(bundle savedinstancestate){ super.oncreate(savedinstancestate); setcontentview(r.layout.details); } public boolean ontouchevent(motionevent event){ this.finish(); return true; } } your ontouchevent() called if no other views under finger in view hierarchy have consumed event. uncommon, since many views interact touch events. it wrong stuff in ontouchevent() without @ actual event is. generally should implement view reacts touches , appropriate thing.

php - Multiple Blogs in PyroCMS (or other OpenSource CMS) -

i have been looking round open-source cms framework can use basis few web projects. used use joomla, found clunky , out-dated, complicated average user faced it. my current project requires content-managed website, usual stuff, , on whole pyrocms seems suited task. core requirement of project contains 4 blogs. general 1 news relating news in client's field , 1 each 3 members of company. i can't see how stands, i'm sure must possible somehow. i'm happy write module myself if needs be, i'm trying keep project simple, , can't first person want this! i'd considered wordpress network, key requirement centralised in 1 administrator panel. in summary - there way maintain several blogs using pyrocms , addons? thanks, ian there few outstanding features have never been added pyrocms have never been needed enough interest or ability add them. the blog module basic, has been used incredibly simple sites. "mom , pap" websites, simple ...

c# - Login failed for user. Trying to access a SQL Server Express database -

i'm trying access sql server express database, every time try, receive message: login failed user. here code: sqlconnection cs = sqlconnection("data source=.\\sqlexpress; initial catalog=mydatabase#4; integrated security=true"); cs.open(); messagebox.show(cs.state.tostring()); cs.close(); how can fix problem? try write computer name instead of . after "data source". example: data source=michael-pc\\sqlexpress;initial catalog=mydatabase#4;integrated security=true";

C# Use camera microphone to record -

i making application record sound microphone , don't know how microphones installed on pc... i've tried directsound gives me audio card micin. so, how can microphones? this article looks might started: http://msdn.microsoft.com/en-us/library/dd370793%28v=vs.85%29.aspx and looks can view vlc's source code additional inspiration: http://forum.videolan.org/viewtopic.php?f=32&t=88002 hope helps!

wcf client - WCF - factories and channel objects - how to create for better performance -

i want make sure i'm following right approach. in application particular service have 1 static channelfactory (as it's instance thread safe), , every time need comunicate wcf service create channel createchannel , use channel , close it. bumped 1 opinion storing channel in static member, , reusing right (author of opinion claims creation of channels on percall basis decrease performance significantly). what's best approach? thanks,pawel well suggest own performance testing, think you'll find approach won't have problem creating many thousands of channels per second depending on hardware. in opinion use cases won't matter @ all. if interested, michele bustamante (from idesign.net) goes discussion here code samples .

apache - .htaccess from specific UNIX group -

i need create login users group users . have this: authtype basic authname "restricted files" authuserfile path?? what path .htaccess users group users ? how can solve this? assuming mean system group (you wrote "unix group"): use mod_authz_unixgroup , mod_authnz_external. addexternalauth pwauth /usr/sbin/pwauth setexternalauthmethod pwauth pipe ... <location /path/to/restricted/...> authtype basic authname "restricted area" authbasicprovider external authexternal pwauth authzunixgroup on require group ... </location>

print html tags in javascript -

thanks reading! var data = "<html><head><title>hello</title></head><body>hello body</body></html>"; i want print data including html tags without having browser rendering html tags , displaying "hello body". i tried: str = str.replace("<", ""); but in vain. data = data.replace(/</g, "&lt;").replace(/>/g, "&gt;"); when browser encounters &lt; (which known character entity), replace literal '<', enabling display html tags on page without them getting rendered. /</g regular expression says "match '<' in string", , g means globally. without g replace first '<' encounters. and 1 final note, it's better use library, such jquery, this. kind of stuff easy wrong , miss edge cases on. let hardened, tested , secure library function you.

page lifecycle - asp.net OnPreLoad doesn't fire? -

i can't figure out why onpreload function doesn't fired search.aspx.cs. * update * - ok, figured out what's causing problem, don't understand why problem. updated question. here 3 relevant files: // search.aspx -- <select runat="server"> caused problem <select runat="server" id="slctcategories"> <asp:repeater runat="server" id="optcategories"> <itemtemplate> <option value=""></option> </itemtemplate> </asp:repeater> </select> // search.aspx.cs using system; using system.collections.generic; using system.linq; using system.web; using system.web.ui; using system.web.ui.webcontrols; using system.data.sqlclient; using system.configuration; public partial class search : btpage { protected override void onpreload(eventargs e) { base.onpreload(e); } protected void page_load(object sender, eventargs e) { ...

soap - php soapclient to c# -

<?php $client = new soapclient(null, array('location' => "http://www.progez.com/demo/webservice/wshotel.sh",'uri' => "http://www.progez.com/demo/", 'encoding' =>"iso-8859-9")); $parm['login'] = "username"; $parm['pass'] = "password"; $parm['agency_code'] = "adm"; $parm['letters'] = "bodrum"; $inf =($client->__soapcall("destinationlistbyletterv2",array($parm))); print_r($inf); ?> how code convert c# ? you start generating typed proxy using svcutil.exe or add service reference dialog in visual studio pointing web service wsdl. generate typed client allowing consume service. , consume: using (var client = new someserviceclient()) { var result = client.destinationlistbyletterv2("username", "password", "adm", "bodrum"); }

winforms - C# = MenuItem.Click handler - Get the object the context menu belongs to? -

this might incredibly simple , i'm not seeing because it's end of long day, , if apologize in advance. i've got set of buttons when right-clicked pop contextmenu. menu has 2 menuitems, both of have click handler function assigned. i'm triggering contextmenu pop on right click of button so: overly simplified example: public void initiailizebuttoncontextmenu() { buttoncontextmenu = new contextmenu(); menuitem foo = new menuitem("foo"); foo.click += onfooclicked; menuitemcollection collection = new menuitemcollection(buttoncontextmenu); collection.add(foo); } public void onbuttonmouseclick(object sender, mouseeventargs e) { if (e.button == mousebuttons.left) // left click stuff handling if (e.button == mousebuttons.right) buttoncontextmenu.show((button)sender, new point(e.x, e.y)); } public void onfooclicked(object sender, eventargs e) { // need button contextmenu .show'd on in // onbuttonmo...

Help with synchronization from a unit test in C# -

i'm testing class wraps backgroundworker perform operation away ui thread in application. the test below fails if timeout exceeded , passes if progresseventcount reaches expected number of events before then. my question synchronization. asyncexecutor.progressed fired thread pool thread backgroundworker using , test thread reads in while loop. am using lock correctly? [test] [timeout(1250)] public void execute() { var locker = new object(); const int numberofevents = 10; const int frequencyofevents = 100; var start = datetime.now; int progresseventcount = 0; igradualoperation tester = new testgradualoperation(numberofevents, frequencyofevents); var asyncexecutor = new asynchronousoperationexecutor(); asyncexecutor.progressed += (s, e) => { lock (locker) progresseventcount++; }; asyncexecutor.execute(tester); while (true) { int count; l...

android - Updated Screen Sizes Chart -

google provides chart of android screen sizes , based on devices accessing android market. unfortunately, it's old; it's august 2010. is there somewhere can find fresher data? (why ask? i'm pretty sure august chart no longer accurate. shows 45.9% of users having normal/mdpi screens [i.e. 320x480 resolution], there no devices being sold in 2011 have normal/mdpi screens. plus, version chart updated in april 2011 indicates on 90% of today's android users have android 2.x, there extremely few normal/mdpi devices support android 2.x; of them stuck on android 1.6.) this chart of screen sizes current of @ least march 2012. http://developer.android.com/resources/dashboard/screens.html

asp.net - Force Cache Refresh When Editing and Redisplaying Content -

i using asp.net mvc , have view displays item , view allows editing item. when user submits edited item, redirects them view item. changes not being reflected when redirected because item view being cached. view item page can edited inline , submit button uses javascript submit , refresh page. i've noticed stackoverflow somehow makes work when edit item, redirects page changes reflected. caching set public, max-age=120 surprised browser doesn't pull local copy without reflected changes... anyway, there way force cache refresh in these cases? prefer not append random query string value, if there no other way do. there cache-control meta tag can set. put in head section <meta http-equiv="expires" content="tue, 01 jan 1980 1:00:00 gmt"> <meta http-equiv="pragma" content="no-cache"> http://www.chami.com/tips/internet/113096i.html or .net way <%@ outputcache location="none" varybyparam="no...

ruby on rails - Named Scope Extensions - Calling Method Outside Do Block -

i have following named_scope in user model: named_scope :all_stars, :joins => [:all_stars] def overall self.find(:all, :conditions => ['recordable_type = ?', 'user']) end end i want this: named_scope :all_stars, :joins => [:all_stars] def overall overall_all_stars_condition end end def overall_all_stars_condition self.find(:all, :conditions => ['recordable_type = ?', 'user']) end can done? if can make other thing named scope, can chain 2 scopes, want. named_scope :all_stars, :joins => [:all_stars] named_scope :overall, :conditions => ['recordable_type = ?', 'user'] then should able call such: object.all_stars.overall.all object.overall.all_stars.find(:all) # etc and create method same thing: def overall_all_stars_condition self.all_stars.overall.all end

Intel Parallel Studio timing inconsistencies -

i have code uses intel tbb , i'm running on 32 core machine. in code, use parallel_for(blocked_range (2,left_image_width-2, left_image_width /32) ... to spawn 32 threads concurrent work, there no race conditions , each thread given same amount of work. i'm using clock_t measure how long program takes. image, takes 19 seconds complete. then ran code through intel parallel studio , ran code in 2 seconds. result expecting can't figure out why there's such large difference between two. time_t sum clock cycles on cores? doesn't make sense. below snippet in question. clock_t begin=clock(); create_threads_and_do_work(); clock_t end=clock(); double diffticks=end-begin; double diffms=(diffticks*1000)/clocks_per_sec; cout<<"and time "<<diffms<<" ms"<<endl; any advice appreciated. it's isn't quite clear if difference in run time result of 2 different inputs (images) or 2 different run-time measuring m...

java - HtmlUnit throws many exceptions on clicking one button -

i'm trying create program signs in yahoo account. i'm using htmlunit in java, when program trying cick sign in button throws large number of various exceptions. the button form is: <form method="post" action="https://login.yahoo.com/config/login?" autocomplete="" name="login_form" onsubmit="return hash2(this)"> <input type="hidden" name=".tries" value="1"/> <input type="hidden" name=".src" value=""/> <input type="hidden" name=".md5" value=""/> <input type="hidden" name=".hash" value=""/> <input type="hidden" name=".js" value=""/> <input type="hidden" name=".last" value=""/> <input type="hidden" name="promo" value=""/> <input type=...

ios - iphone app click delete crash -

in application when press delete row crash. tried find solution problem already, hope can me solve it. my code here: firstview.h #import <uikit/uikit.h> @interface firstview : uiviewcontroller <uitextfielddelegate,uitableviewdatasource,uitableviewdelegate>{ iboutlet uitableview *tableview; iboutlet uidatepicker *datepicker; iboutlet uitextfield *eventtext; nsarray *notificationarray; nsmutablearray *array; } @property (nonatomic, retain) iboutlet uitableview *tableview; @property (nonatomic, retain) iboutlet uidatepicker *datepicker; @property (nonatomic, retain) iboutlet uitextfield *eventtext; - (ibaction) schedulealarm:(id) sender; @end firstview.m #import "firstview.h" @implementation firstview @synthesize datepicker, eventtext,tableview; - (void) viewwillappear:(bool)animated { [self.tableview reloaddata]; } - (ibaction) schedulealarm:(id) sender { [eventtext resignfirstresponder]; nscalendar *calen...

ios - code for how to perform calling and cancel the calling in iphone -

i new developing iphone applications. i looking example on calling phone numbers, starting call , ending one. is possible ? if so, how 1 accomplish ? here code make call [[uiapplication sharedapplication] openurl:[nsurl urlwithstring: @"tel:1-800-acce-ptme"]]; anything modifies user's ability block phone calls going run afoul of apple's basic approach third-party apps. there lot of things questionable , might away with. blocking calls forbidden.

compiler construction - Staticlink vs standalone quirk with F# -

in vs2010 ultimate edition if hand --standalone flag f# compiler in projects pane not link empty c# project configuration files/resource files it will, however, link assembly if explicitly declare --staticlink:config this feels bug...if intentional, may ask why be? this expected behavior: the standalone flag statically links fsharp.core.dll (f# runtime) , reference assemblies depend on (i.e. other f# assemblies). need linked because may share types primary assembly (e.g. f# list type etc.) the staticlink flag links assembly explicitly specify (and assemblies depend on it). means can use option link, example, c# library main f# assembly references. i think 2 cases handled separately, because inlining f# runtime requires special handling (almost f# code uses in way, , compiler treats differently)

internet explorer - Yii showing blank page in IE7 and FF on Windows -

i have application running on yii framework works fine when view application on ubuntu firefox , windows chrome , safari. am experiencing problems while using ie , firefox on windows. application serves blank page on 1 particular screen. screen uses db insert , selection , there no exceptions. please note able view screen on other browsers. ie shows blank page "json undefined error" javascript error. i tried removing following layout file: <meta http-equiv="content-type" content="text/html; charset=utf-8" /> i tried disabling divx add ons in ie. didn't work. i using stateful yii form on page. i made comment already, maybe can rep if post actual answer. ;) if ie showing blank page , know there javascript error, you've found problem likely. times when there js error ie fail load page, while ff , chrome recover , still load page (although the scripts might not work correctly). try using ie developer tools more deta...

unix - Effect of file creation/opening on st_mtime and st_atime -

when create or open file in unix using o_creat flag, st_mtime , st_ctime , st_atime of file changes. when create or open file using o_trunc flag, st_mtime , st_ctime changes , not st_atime . from understanding, st_atime changes when file accessed. when open or create file using o_trunc flag, not accessing file? this question bit old, answer future generations @ least... from stat(2) man page (on host linux 2.6.32 kernel): the field st_atime changed file accesses, example, execve(2), mknod(2), pipe(2), utime(2) , read(2) (of more 0 bytes). other routines, mmap(2), may or may not update st_atime. the field st_mtime changed file modifications, example, mknod(2), truncate(2), utime(2) , write(2) (of more 0 bytes). moreover, st_mtime of directory changed creation or deletion of files in directory. st_mtime field not changed changes in owner, group, hard link count, or mode. the field st_ctime changed writing or set...

javamail - How to send emails without speed limit? -

i got errors sending mails quick in 15 minutes when sending mails. seems there speed limit of sending mails. how many mails can sent in 15 minutes? standard or private rule based on vendor? it depends on both mail service provider, , target system. example gmail let send 500/1000 (or more) emails per day, per account depending on agreement them.

ruby on rails - why form_for does not work for me -

(ruby 1.9.2 rails 3.0.6) i new ror, sorry simple question. i have form , controller, when launch app, can see log have been displayed.. there exception when rendering view... everything should fine.. problem? how can fix it? thanks. undefined method `users_path' #<#<class:0x47c7678>:0x47c6118> extracted source (around line #2): 1: <h1>welcome aboard</h1> 2: <%= form_for(@user) |f| %> 3: <table> 4: <tr> 5: <td><%= f.label :username %></td> class registercontroller < applicationcontroller def sign_up logger.debug("sign_up inoked") @user = user.new logger.debug("sign_up finished") end end views/register/sign_up.html.erb <%= form_for(@user) |f| %> <table> <tr> <td><%= f.label :username %></td> <td><%= f.text_field :username %></td> </tr> <tr> <td><...

objective c - Segemented Control for iPhone not working -

i have segmented control following code in action method: -(ibaction)togglecontrols:(id)sender{ if([sender selectedsegmentindex] == kswitchessegmentindex){ leftswitch.hidden = no; rightswitch.hidden = no; dosomethingbutton.hidden = yes; } else{ leftswitch.hidden = yes; rightswitch.hidden = yes; dosomethingbutton.hidden = no; } } however, when run program i'm getting error kswitchessegmentindex . it's saying kswitchessegmentindex undeclared identifier. can me what's wrong here? you have show kswitchessegmentindex being defined. convention define variables like: #define kswitchessegmentindex 1 or, define int: int kswitchessegmentindex = 1; since shouldn't need change value first choice might best. example: #include <avfoundation/avfoundation.h> #define kmyconstant1 0 #define kmyconstant2 1 @implementation myclass

vb.net - ignore increacing font size of windows in .net -

in windows it's possible increase size of on-screen fonts. realized late , if user our programm unusable because can not see texts , controls. we're bringing out release , not have time fix that. so: how can disable or ignore increasing windows application-wide? tried setting autoscale none not working. isn't possible ignore setting whole application? how can that? know week solution because user has reason why wants increase font size. can not fix problem within 2 weeks want provide application can work. thanks help ps: use vb.net according microsoft workaround is: right-click shortcut, click on compatibility tab , tick "disable display scaling on high dpi settings" (although doesn't seem work.)

windows - How can I use findstr with newline regular expression -

i'm on windows dos prompt. have log file contains log like: timestamp: order received item no. 26551 timestamp: exception: outofrangeexception timestamp: message: inventory item not stock. item no. 23423 timestamp: order received item no. 23341 i want extract item number has give sort of exception. i'm using findstr command this. how can use newline in regular expression? want lines have exception word , next line item no. any help? i've discovered undocumented feature - findstr can match new line characters <cr> , <lf> , continue match on subsequent lines. search string must specified on command line, new line characters must in variables, , values must passed via delayed expansion. another complication in() clause of loop executed in separate implicit cmd session, , delayed expansion must re-enabled. also, ! characters must escaped make through 2nd cmd session. this little test script trick. @echo off setlocal enabledelayedexpansion...

algorithm - Problem creating a frequency array of a given array -

i trying create frequency array of given array on fortran 95. instance if have array (\1 2 4 2 4 2 5), frequency array should number of times each item appears; (\1 3 2 3 2 3 1). because there 1 of 5s in original array, last entry in new array 1 , because there 3 of 2s in original array, corresponding entries on new array 2. below sample of code have, keep getting errors. wondering if willing give me guidance , on doing wrong. appreciated. i haven't included part of code generates original array because i'm pretty sure correct here subroutine frequency array. original array sorted in ascending order outside subroutine. perhaps didn't pass original array, num(i) correctly?? integer, dimension(100)::num(100) integer, dimension(100)::freq(100) integer:: i=0, k=0, numinteger, count=0 call freqarray(num, numinteger,freq) subroutine freqarray(num, numinteger, freq) integer, intent(in):: num(100), numinteger integer, intent(out):: freq(100) i=1,9 count=0...

iphone - UIWebView loading -

i want load html data in webview. @ button click, open viewcontroller , load html data in viewcontroller (add web view in view controller using interface builder). when html data not proper loading , press button, @ time crash app. not doing allocation & init webview in coding. set iboutlet using interface builder & bind it. - (void)connectiondidfinishloading:(nsurlconnection *)connection { [connection release]; nsstring *strresponce = [[nsstring alloc] initwithdata:jsondata_info encoding:nsutf8stringencoding]; [jsondata_info release]; nserror *error; sbjson *json = [[sbjson new] autorelease]; self.jsonarray_info=[json objectwithstring:strresponce error:&error]; str_infodetail = [[self.jsonarray_info objectatindex:0] valueforkey:@"page"]; str_html = [nsstring stringwithformat:@"%@",str_infodetail]; nsstring *temp; temp = [nsstring stringwithformat:@"<html><head><style>body{background-co...

c++ - Stack of polymorphed classes -

dear c++ professionals. got problem. have program, has 1 abstract class base_class , 2 derived classes: sippeers , dbget. has 2 threads. first thread gets commands user, second thread pocesses these commands. both derived classes represent different commands. so, have create kind of stack, should put user commands first thread , them in second thread process. make 1 stack commands, got use polymorphism. first, tried use std::list. there first problem: can't make list of abstract classes. tried use boost::ptr_list, there second problem: classes, created in first thread, dissappear end of procedure, created them. pointers become illegal. question: kind of realization should use? looks must store every copy of derived class. where? an std::queue of shared_ptr<base_class> straightforward solution pass classes 1 thread without worring memory management. combined conditional variable signal queue not empty, consumer-thread can wait. for polymorphism part, have virt...

ruby - Session Problem with Rails 3 -

i'm using authlogic 2.1.6 authorization in rails 3.0.5 , have session cookie problem ajax requests. after post or put ajax call i'm getting 401 response , new session key. after every call return 401 response. before post or put call every call succeeds. this doesn't happen in test mode, in development , production mode. does know how avoid that? edit: think there problem forgery protection authenticity key, because after disabling forgery protection worked fine. this request header produce 401: accept:*/* cache-control:max-age=0 content-type:application/json; charset=utf-8 origin:http://localhost:3000 referer:http://localhost:3000/ user-agent:mozilla/5.0 (macintosh; u; intel mac os x 10_6_6; de-de) applewebkit/533.19.4 (khtml, gecko) version/5.0.3 safari/533.19.4 x-requested-with:xmlhttprequest rails log entry following: started post "/users.json" 127.0.0.1 @ tue apr 12 10:47:33 +0200 2011 processing userscontroller#create json parameter...

Programatically unchecking items in a dialog on Android -

i displaying list checkboxes in dialog. list looks like- item 1 item 2 with checkbox beside each item. requirements is- if item 1 or item 2 or both checked, , selected, item 1 & 2 should unchecked. to accomplish this, implemented dialoginterface.onmultichoiceclicklistener 's onclick listener. public void onclick(dialoginterface dialog, int which, boolean ischecked) { if(which == 2 && ischecked) { ((alertdialog)dialog).getlistview().setitemchecked(0, false); ((alertdialog)dialog).getlistview().setitemchecked(1, false); } } but not work. tried invalidating listview calling invalidate() & invalidateviews(), no success. any appreciated. thanks, akshay i found answer- how uncheck items in alertdialog (setmultichoiceitems)? thanks!

perl - Template Toolkit's somevar.substr() and UTF-8 -

we use template toolkit in catalyst app. configured tt use utf-8 , had no problems before. now call substr() method of string var. unfortunately split string after n bytes instead of n chars. if n 'th , (n+1) 'th byte build unicode char split , 1st byte part of substr() result. how fix or workaround behaviour? [% string = "fööbär"; string.length; # prints 9 string.substr(0, 5); # prints "föö" (1 ascii + 2x 2 byte unicode) string.substr(0, 4): # prints "fö?" (1 ascii, 1x 2 byte unicode, 1 unknown char) %] until had no problems unicode chars, neither ones comes database nor text in templates. edit: how configure catalyst::view::tt module in catalyst app: __package__->config( # debug => debug_all, default_encoding => 'utf-8', include_path => my::app->path_to( 'root', 'templates' ), template_extension => '.tt', wrapper => "wrapper/default.tt", re...