Posts

Showing posts from June, 2012

Rails 3.1: Ruby idiom to prevent .each from throwing exception if nil? -

solved: commentors noted, empty phonelist nil when should have been []. is there way use .each not throw error if object nil or empty (without adding additional nil/blank test? it seems if phonelist.each |phone| if phonelist empty, block should not executed. but in view (haml) have - @myvar.phonelist.each |phone| , if phonelist empty, throws nomethoderror. i run lot, , workaround adding explicit check/branch .blank? seems there should easier way tell .each empty means nothing. you're attempting smack band-aid on larger problem. ruby has concept of nil; can't around it. if calling method on nil , assuming valid, i.e., design assumes valid. question is: hole in design? why assumption incorrect? the problem here not cannot call arbitrary methods on object not support it; problem data assumed valid when not case. but in view (haml) have - @myvar.phonelist.each |phone| , if phonelist empty, throws nomethoderror. no. if phonelist is not obje

intranet - How to setup an ASP.NET development environment? -

i intranet web developer large company , getting our webpage servers upgraded windows server 2008. stuck on windows server 2000 , did not have access run except asp classic. we going moving asp.net development , using visual studio 2010 professional. there going 2 developers working on site foreseeable future. i'm curious how setup our development environment allow work on site. currently our site consists of: online forms, blog, photo galleries, information resources, ect.. we getting 3 new servers running windows server 2008. going configured each dedicated role. development, qa , production. i clueless how should develop given our environment. here few scenarios thought of i'm sure there other options. work on files housed on development server. test completed updates on development server publish qa , repeat testing publish production , test again or develop on our local machines (if how handle pulling files needed if updating something?)

html - CSS postion looks good in IE9, cut off in IE8 -

Image
hey hoping tell me need change in order seeing in ie9 same when viewing in ie8. this looks in ie9: and looks in ie8: the css code 2 divs are: body { text-align:left; font-size:13px; font-family:arial, helvetica, sans-serif; line-height:18px; color:#6a7e8a; background:#fff; margin:0; padding:0; } #logo span { color:#fff; padding-left:50px; text-transform:none; font-family:arial, sans-serif; } #logo span.header1 { font-size:0.4em; display:block; top:0; line-height:0.8em; } .logoheader h1 { text-decoration:none !important; } .logoheader { top:22px; left:0; text-decoration:none !important; border:none !important; position:absolute; color:#fff; z-index:10; } .logoheader h1 { border:none !important; } .logoheader2 { top:5px; left:398px; text-decoration:none !important; border:none !important; position:absolute; color:#fff; z-index:10; height: 144px; width: 521px; } #line { position:absolute; right:20px; top:5em; max-wi

visual studio 2010 - Is there a tool to convert between VS2005, VS2008 and VS2010 solutions and projects (not only .NET)? -

i want convert projects , solutions between vs2005, vs2008 , vs2010. example vs2010 vs2005 or 2008 vs2010, vs2008 vs2005. there tool exist? there project converter versions 2005-2012 on codeplex . there project converter versions 2002-2008 on sourceforge .

mysql - group_concat on two different tables gives duplicate result on second table -

consider 3 entities student, course, subject below associations - student has_many courses, student has_many subjects. now want fetch student records subject names , course names using mysql group_concat, left join on courses, left join on subjects , group_by student_id. problem group_concat('subjects.name') subject_names gives me duplicate entries of subjects group_concat('students.name') student_names gives unique names. why ?? the 2 left joins multiplying rows via cartesian product of child rows per student example student 1 has 3 courses , 2 subjects generates 6 rows student 1 gives 1 course value per subject = each course repeated twice gives 1 subject value per course = each subject repeated thrice to fix: option 1: use group_concat(distinct ...) per mysql docs in mysql, can concatenated values of expression combinations. eliminate duplicate values, use distinct clause. option 2: use union + derived table select

windows - Apache server going down and then back up -

there nothing writing apache error log , can not find scheduled tasks may causing problem. restart occurs around same time, 3 times on past week @ 12:06 am. in 3-4 time frame. i running apache version 2.2.9 on windows 2003 server version. the same behavior happening prior past week, there error being written apache error log indicating maxrequestsperchild limit being reached. found article, http://httpd.apache.org/docs/2.2/platform/windows.html suggesting setting maxrequestsperchild 0, did , error stopped reporting error log, behavior of restarting continued, although not frequently.

java - AssetManager in LibGDX -

i trying use assetmanager class in libgdx , understand how works trying implement loading screen. have followed assetmanagertest.java file here , having hard time trying figure out how work correctly. can point me in right direction? goal load assets (textures, sounds, fonts, ... etc) , update bar percentage complete on screen. don't understand resolutionfileresolver , resolution[] in link provided. for? goal support static class can give me access of assets need in game screen. there preferred method this? thanks. after looking @ source resolutionfileresolver other 'resolvers', think it's way of loading textures best match screen resolution, match based on filename patterns. so in assetmanagertest , he's got textures screen sizes 320x480, 480x800, , 480x854. looks each group of textures should in directory called ".320480" or ".480800" or ".480854" (although name can want, "low", "high", , "

java ee - Difference between .classpath and MANIFEST.MF -

what difference between adding dependency jar .classpath file in rad project , adding dependency manifest.mf file? .classpath file specific ide (rad, , eclipse in general). setting classpath entry compile , execute project in ide. manifest.mf standard (independent ide used during development) way set path libraries jar needs runtime.

javascript - mobile safari 5 not responding to js events until further acton -

so check out http://www.toyota.ca/toyota/en/vehicles/yaris-hatchback/gallery using ios 5/mobile safari 5 or simulator press image on scroller @ bottom , lightbox pops. try press next button, noticed nothing happens. if zoom in/out or change orientation or scroll page, image change. the js works because next/prev become enabled/disabled press them not animation part until further action. why this? common? if try same page on ios 4 work fine. don't use click() handler, use mousedown() handler. mobile devices have hard time discerning between click() , mousedown() . the necessary change line 472 in common.js , change var o=p(f,c.prev).click(function(){b.prev()}),q=p(f,c.next).click(function(){b.next()}); to var o=p(f,c.prev).mousedown(function(){b.prev()}),q=p(f,c.next).mousedown(function(){b.next()}); either that, or, every such navigation button, on creation, use: $(selector).bind('mousedown',$(selector).data("events").click[0].han

Opensource alternative to MATLAB database toolbox -

requirement: open source alternative matlab database tool box. background: have matlab provided @ workplace unfortunately not have mathwork's database toolbox licensed. research done: though newbie have searched quite bit on internet , found working me demo version of dbtool box dbtool (http://energy.51.net/dbtool/index.htm). however, demo version of db toolbox works fine on small databases. whenever use on large databases, 'time out error'. thanks help nikhil i found answer on how connect microsoft sql server 2008 (mssql) matlab? however, not every approach works me. let me explain bit further: the jdbc driver work best. must know jdbc driver use project. ms sql, sqljdbc4.jar works fine. if connect mysql or postgresql, make sure google proper driver. (mysql-connector.jar mysql , postgresql.jdbc4.jar or postgresql) i have tried com method success through odbc. finding correct connection string pain. need install proper odbc driver related proj

How can I pass a listview from one form to another form? -

i have 2 forms. form1 , form2. there button @ form1 me access form2 , in form2, have listview2 , textboxes. manage input items listview2. when click on ok button in form2, listview1 in form1 should show listview2. guys, can suggest me way this? thanks below codes. hope don't confuse all. form1 code => namespace mainserverpage { public partial class mainserverpage : form { public listview lv; public mainserverpage() { initializecomponent(); } private void btnadd_click(object sender, eventargs e) { additem add = new additem(this); //to open form2 add.showdialog(); } } } form2 code => namespace mainserverpage { public partial class additem : form { mainserverpage currentform; //i learn way of passing form it's not working public additem(mainserverpage incomingform) { currentform = incomingform; initia

mysql - How to find matrix element with sql query? -

i have array , table referenced elements in array. array 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 and have area start point s=9,x=2,y=2 ,row count r=6 have boxes 9,10,11,15,16,17,21,22,23 trying write sql check if 16 number in area.i created logic if ((s<16<s+x) || (s+6<16<s+x+6) || (s+12<16<s+x+12) ) should write in 1 sql query? using mysql. this doesn't have sql, don't think, following condition want. since example has same value of x , y, , "row count" sounds more "number of rows" "number of items in row," may have gotten rows , columns backwards want. set @s=9, @x=2, @y=5, @r=6, @testval=16; (@testval-1)/@r between (@s-1)/@r , (@s-1)/@r - @y - 1 , (@testval-1)%@r between (@s-1)%@r , (@s-1)%@r - @x - 1

heroku - Caching signed S3 URI's with paperclip and rails -

i'm generating expiring signed uri's paperclip on s3. on every request generate new uri not ideal , forces browser download new set of images s3 on every page refresh. what i'd cache generated uri's little less time expire on s3. has done before , can suggest solution. i'm deploying on heroku if suggests solution ( or not ) there easy way quite neat. paperclip expiring_url method takes explicit time. can like def s3_expiry time.zone.now.beginning_of_day.since 25.hours end and when need expiring url user.avatar.expiring_url(s3_expiry, :thumb) the trick image expired in s3 @ end of day + 1 hour url generated until end of day. new url's generated @ 12:00 midnight every night. prevents images being used off site more 25 hours should enough prevent rampant hot linking still enough allow browsers cache images day

c# - Creating nullable class -

how create nullable (?) class in c#? like: public class hello1 { public int property1 { get; set; } } public class hello2 { public hello1? property2 { get; set; } //hello1 should work when has "?" } i wanna make hello1 class take form "hello1?" if needed. you don't need create nullable type reference types. they're nullable. need value types int, bool, decimal, etc...

mysql2 - Please install mysql adapter 'gem install activerecord-mysql-adapter' -

i'm having trouble finding solution problem. i'm getting error: please install mysql adapter: 'gem install activerecord-mysql-adapter' /users/ andy/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/rubygems_integration.rb:143:in `block in replace_gem': please install mysql adapter: `gem install activerecord-mysql-adapter` (mysql not part of bundle. add gemfile.) (loaderror) /users/ andy /mysql2/ruby/1.9.1/gems/activerecord-3.2.1/lib/active_record/connection_adapters/mysql_adapter.rb:5:in `<top (required)>' /users/ andy /mysql2/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:251:in `require' /users/ andy /mysql2/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:251:in `block in require' /users/ andy /mysql2/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:236:in `load_dependency' /users/ andy /mysql2/ruby/1.9.1/gems/activesupport-3.2.1/li

javascript - Can someone please explain this recursive JS code to calculate exponents? -

i can't understand recursion though it's simple example. when goes power(base, exponent - 1); supposed do? how things being multiplied when power keeps getting invoked until exponent equals 0? function power(base, exponent) { if (exponent === 0) { return 1; } else { return base * power(base, exponent - 1); } } let's start beginning. let's call power(base, 0) . since exponent 0, function returns 1. now, let's call power(base, 1) . since exponent isn't 0 time, function calls power(base, exponent - 1) and multiplies by base . (that's key here...it takes result recursive call, , adds own twist.) since exponent - 1 = 0, , power(base, 0) 1, result base * 1 . read: base . now on power(base, 2) . ends being base * power(base, 1) . , power(base, 1) base * power(base, 0) . end result: base * (base * 1) . read: base squared. and on. in case wasn't obvious, way, function work non-negative inte

objective c - iphone timer plist file display -

i'm going ask question again,i thought had figured out guess not. timer app gets timer info plist file. works want .plist extension not show in tableview. here 2 code snippets believe issue. these in array called nsarray *files; self.files = [[nsbundle mainbundle] pathsforresourcesoftype:@"plist" indirectory:@"timers1"]; // configure cell. cell.textlabel.text = [[files objectatindex:indexpath.row] lastpathcomponent]; return cell; thanks help nsstring *text = [[files objectatindex:indexpath.row] lastpathcomponent]; text = [text substringtoindex:[text rangeofstring:@"."].location]; cell.textlabel.text = text;

javascript - how to set a dynamic URL to the XHR POST parameter? -

note : please note question may silly i've begun client-side development. need make xhr post request dynamic link retrieved through jsonp. reasons doesn't work. post url "youtube_url_upload" becomes undefined. xhr.open("post", youtube_url_upload); here code snippet : var get_youtube_service_url ="http://video.example.com/youtubeupload?jsoncallback=?"; $.ajax({ type: "get", url: get_youtube_service_url, datatype: "jsonp", cache : false, success: function(data) { // youtube // var y_url = data.url; var token = data.token; var youtube_url_upload = data.url + "?nexturl="+encodeuricomponent("http://selling.example.com/youtube.html"); calltoken(token); uploadfile(youtube_url_upload); } }); var bytesuploaded = 0; var b

No named parameters in Ruby? -

this simple can't believe caught me. def meth(id, options = "options", scope = "scope") puts options end meth(1, scope = "meh") -> "meh" i tend use hashes argument options because how herd did it– , quite clean. thought standard. today, after 3 hours of bug hunting, traced down error gem happen using assumes named parameters honored. not. so, question this: named parameter officially not honored in ruby (1.9.3), or side effect of i'm missing? if not, why not? what's happening: # assign value of "meh" scope, outside meth , equivalent # scope = "meth" # meth(1, scope) meth(1, scope = "meh") # ruby takes return value of assignment scope, "meh" # if run `puts scope` @ point "meh" meth(1, "meh") # id = 1, options = "meh", scope = "scope" puts options # => "meh" there no support* named parameters (see below 2.0

Using apache tomcat with wamp server -

how use apache tomcat wamp server. have couple of applets need run on server appears wamp not support applets. need install tomcat wamp server. how do this. what can done between apache , tomcat using bridge named apache tomcat connector

python - how to print dict values based on key containing delimiters -

actually have dict x1={'b;0':'a1;b2;c3','b;1':'aa1;aa2;aa3','a;1': 'a1;a2;a3', 'a;0': 'a;b;c'} actually here convention 'a;0','b;0' contain tags , 'a;1','b;1' have corresponding values, based on have group , print. dict output want is <a> #this group name <a>a1</a> # tags n values <b>a2</b> <c>a3</c> </a> <b> <a1>aa1</a1> <b2>aa2</b2> <c1>aa3</c1> </b> this sample dict given many groups may come c;0:.... d;0..... i using code a=[] b=[] c=[] d=[] e=[] k,v in x1.iteritems(): if k.split(";").count('0')==1: # using bcoz a;0,b;0 contains tag checking if contain 0 split it. a=k.split(";") # contains a=['a','0','b','0'] b=v.split(";") # contains 'a;0','b;

javascript - cannot change <label> text color -

my research base html dom element says dom element's "style" property (from http://www.w3schools.com/jsref/dom_obj_all.asp ): "style -- sets or returns style attribute of element" the 'label' tag dom element. , has 'style' property. points out on w3schools link above, dom elements have 'style' property. and in fact, here i'm setting (inline) 'style' property label tag -- , works fine: <label for="itemimageid" style="color: gray" id="labelforimageuploadid">item image</label> the label text color gray @ page load time. under condition (user has indicated they're ready select image upload) -- need show upload 'enabled' changing initial gray text color of above black. do know use css class label's text color , use 'classname' property dynamically alter css class of above? bet do. tonight though i'm holding dom element's fee

c++ - Get pointer to argv element Boost Program Options -

i'm making assumption array of strings passed main function argv in void main( int argc, char* argv[] ) remains in scope duration of application. my question therefore whether possible, using boost::program_options pointer actual element in argv represents particular option. that is, rather allocating std::string when parsing, possible pointer start of string option value.

c# - How can a date that's stored in a SQL Server Express database correctly sometimes display as 01 Jan 0001? -

this newspaper website run - it's quite busy (approx 2 million page views month) - don't know if traffic significant issue here or not. but every few days seem entirely random collection of latest stories show dates monday, january 1, 0001 when formatted like: this.newsstory.datepublished.tostring("dddd, mmmm d, yyyy") but looking @ data via sql server management tools, it's stored entirely correctly. , if refresh application pool website dates go being correct. any ideas what's happening? more of iis problem sql or .net? lost this, when happens seems entirely random, , stories effects seems random. it's windows 2003 server running iis 6. website coded in c# , data in sql server 2005 express database. thank suggestions may have. more code requested - here's .net code calling stored procedure: public static datatable getnewsstorybyurl(string url) { datatable table = newsstorydata.getdatatabletemplate(); sqlconnection con =

php - Jquery Mobile - Getting an ajax result issue -

trying simple web app jquery mobile. have put simple log in form ajax results displayed. problem ajax not getting result when alert out see if url valid. there special need using jquery mobile? any thoughts/answers appreciated! here html code: <div data-role="page" id="login" data-theme="a" data-add-back-btn="true"> <div data-role="header"> <h2>log in</h2> </div> <div data-role="content" data-theme="a" data-add-back-btn="true"> <form action="mobilelogin.php" method="post"> email: <input type="text" name="email" id="useremail"> password: <input type="password" name="password" id="userpassword"> <input type="submit" value="enter"&g

caching - Hibernate 2nd level cache + Ehcache issue when trying to get data (List of object) from cache memory -

i able data cache memory 1 object using hibernatetemplate.load(class entityclass, serializable id) , [2012-03-06 04:34:18,755] [info] [com.uprr.app.rim.components.common.service.rimspringapplicationcontext] [applicationcontext set , ready use xmf service clients....] [2012-03-06 04:34:20,255] [warn] [org.hibernate.mapping.rootclass] [composite-id class not override equals(): com.uprr.app.rim.components.exinterface.domain.track] [2012-03-06 04:34:20,270] [warn] [org.hibernate.mapping.rootclass] [composite-id class not override hashcode(): com.uprr.app.rim.components.exinterface.domain.track] [2012-03-06 04:34:35,442] [debug] [org.hibernate.cache.cachefactory] [instantiating cache region: com.uprr.app.rim.components.masters.domain.commplacetypedo usage strategy: read-only] [2012-03-06 04:34:35,442] [warn] [org.hibernate.cache.cachefactory] [read-only cache configured mutable class: com.uprr.app.rim.components.masters.domain.commplacetypedo] [2012-03-06 04:34:35,646] [debug] [org.hi

Sql Server Compact Edition 4.0 performance for asp.net website -

i'm considering migrating sql ce 4.0 website projects, of sites use umbraco aren't busy websites (up 15,000 visits month). my main concern performance, wondering if had experience or knowledge on sort of performance limitations can expect. also, if running in managed host environment need concerned application pool memory limits? thanks the performance of website should no problem, because reads cache. i'm having trouble cms performance, on local environment on vps , on shared hosting environment. takes lot of waiting time before items created , edited. that's big issue customer right now. run latest version of umbraco (4.7.2.1) should include lot of performance improvements sql ce. might worse when datbase size growing (mine 92mb)

Lazy Loading / Eager fetching in Hibernate -

i have set property lazy="false" in hbm file column contact in table "employee" the below query executed retrieve employee id 5: select e employee e e.id = 5 on execution, number of queries being executed , guess due non lazy loading. how make sure 1 query executed? can change query keeping property lazy false? if not, should change in query retrieve record? i'm using spring+hibernate based on query, i'm going assume you're using hql this. i'm going assume contact reference. select e employee e left join fetch e.contact e.id = 5

Can I get a hold of Button Location Data in my Android Application -

in application, i'm (still) trying manipulate button views way want. i'd attempt experiment i'll draw android rect or rectf in same location (transparent) button highlight it's appearance. however, can't figure out how mitts on information. buttons in question defined in xml, in linear layout, inside android has know sizes , locations. right? any suggestions? thanks, r. you should able set background of button custom xml drawable drawable containing stroke element around edge. you need create custom drawable: few lines of xml. <shape xmlns:android="http://schemas.android.com/apk/res/android"> <stroke android:width="1dp" android:color="#cccccc" /> <corners android:radius="10dp" /> </shape> edit: updated include rounded corners.

Common Lisp Unbound Variable -

is possible use uninitialized variable function argument? assignment, have use clos write semantic network system, , professor included test function test our output, , 1 of them specifies: (print (def-concept human)) , which implies passing argument human function def-concept. when running test function, cannot away error (in allegro cl): error: attempt take value of unbound variable human'.` as first function in test, there no initializing of variables before this. there way around passing uninitialized variable argument of function? thanks in advance. it not possible use unitialized value function argument in regular common lisp function call. common lisp uses eager evaluation: argument expressions reduced values before function call takes place. i suspect maybe don't understand structure of homework assignment. if def-concept function expects value, , human not defined, cannot test function. perhaps expected define variable human , load file

jboss - NoClassDefFoundError for EJB Home class -

i'm using jboss 4.2.3, ejb2, xdoclet , have deployed 1 ear ejbs in it, , other ears various websites in them. when trying access ejb 1 of websites, noclassdeffounderror. seems lookup successful. can see, example, getcontext().lookup(securityserviceremotehome.jndi_name) returns of class "$proxy266". see in jboss's jndi view binding: remote (proxy: $proxy266 implements interface com.icumed.ifactory.service.session.securityserviceremotehome,interface javax.ejb.handle) fyi, securityserviceremotehome.jndi_name = "ejb/ifactory/securityservice/remote" right after lookup, call this, error thrown: home = (securityserviceremotehome)portableremoteobject.narrow(obj, securityserviceremotehome.class); i've heard might unnecessary , can straight type conversion here, don't think that's problem. i've read on web far, seems maybe securityserviceremotehome cannot loaded. perhaps ancillary classes missing? don't see errors indicating th

javascript - windows.location.href change results in POST, expecting GET -

the following method called 2 different buttons's onclick event: this.changesearch = function(obj, $tag) { var url = jquery('#admin_url').val() + '/tools.php?page=cemeteriat&cempage=' + $tag; window.location=url; return; }; in 1 instance, whether form populated or not, button press results in expected call. in other, if form populated, instead of expected url, post executed url assigned in action attribute of form. the... i've traced code, , both times url above assigned same value! have tried using document.location, window.location, , window,location.href no change in behavior. not seem t browser specific. what cause assigned of windows.location result in post of form instead of expected get? it's because 1 of buttons submit button form, it's getting submitted , it's never getting code you're showing. you should hook form's submit event , call event.preventdefault(); cannot prevent form submission

iphone - How to set the map to a particular location on map load -

i using mapkit found on github plot directions, problem when mapview loads shows @ startup , moves location route plotted. there way show australia instead @ startup? thanks i'm using initialize map view, , works me : cllocationcoordinate2d coord = {.latitude = xx.xxx, .longitude = x.xxx}; mkcoordinatespan span = {.latitudedelta = x.xx, .longitudedelta = x.xx}; mkcoordinateregion region = {coord, span}; then, use setregion method mkmapview is you're looking for?

hadoop - How to monitor the HDFS replication progress of the cluster? -

is there specific log replication ? there command use view current status, doing, copy speed, etc. ? the hadoop log directory contains 2 logs mapred-logs , hdfs-logs. although haven't done you're trying do, i'm sure find need if go through hdfs-logs.

html - Javascript - get element (button) without ID or Class? -

possible duplicate: get list of input objects using javascript, without accessing form object how can elements, buttons on page, without class or id? is there this? document.getelementsbytype(button) edit my confusion how buttons (not one) without class or id. the solution ended being var buttons = document.getelementsbytagname('button'); (var = 0, len = buttons.length; < len; ++i) { but answer led me find out didn't know ask in first place... so, everyone! document.getelementsbytagname document.getelementsbytagname('button')

c++ - SDL missing x86_64 architecture -

i'm trying sdl example code xcode working on snow leopard machine, every time attempt build receive error: "ld: warning: in /users/me/dropbox/programming/obj c/space/sdl.framework/sdl, missing required architecture x86_64 in file" "/library/frameworks/..." have copied entire sdl.framework project , linked it, error persists. this known problem pre-built binaries sdl homepage. need compile sdl work. the simplest way use homebrew . can install homebrew single command terminal. after that, run brew install sdl and should go.

gdata api - Youtube thumbnail api -

i want retrieve thumbnail videos youtube calling youtube api (gdata) using java? can guide me? youtube-videos have 4 thumbnails, accessible specific url: http://i.ytimg.com/vi/video_id/default.jpg http://i.ytimg.com/vi/video_id/1.jpg http://i.ytimg.com/vi/video_id/2.jpg http://i.ytimg.com/vi/video_id/3.jpg so knowing video id can thumbnails that.

outofmemoryerror in android -

i have 1 running methods in doinbackground in asynctask ,which calling webservices , inserting number of records database , @ same user click on other screen outofmemoryerror coming want stop background thread temporarily till screen loads , thread has resume stopped such memory release. can tell me how achieve this. in advance. the asynctask can executed once (an exception thrown if second execution attempted.).. pause , resume .. think should use backgroundthread instead...

ruby - Rails Best Gem Or Plugin For Connecting To Multiple Databases using Same Application -

i using rails 3.0.3 application. in application need interact multiple databases dynamically @ run time. requirement: 1] in future may need add more databases. should support requirement. to interact multiple databases can use connection ninja. please follow link . there can see works rails 3, install using: gem install connection_ninja hope helps,

java - How to maintain different portlet codebases for Liferay 6.0 and 6.1 -

in liferay 6.1 class servletresponseutil has been moved different package in liferay 6.0: //liferay 6.0, // class lives in util-java.jar in default tomcat web app, /webapps/root/lib. import com.liferay.util.servlet.servletresponseutil; //liferay 6.1 // class lives in portal-service.jar in directory tomcat-7.../lib/ext/ //import com.liferay.portal.kernel.servlet.servletresponseutil; the class used in our code this: string result = personcomponentimpl.process(request); response.setcontenttype("text/xml"); try { servletresponseutil.write(response, result); } catch (exception e) { if (_log.iswarnenabled()) { _log.warn(e, e); } } i have maintain , improve portlet written liferay 6.0 release. considering upgrading 6.1, during internal testing of portlet discovered there few line of code above mentioned dependency broken. there classnotfoundexceptions on 6.1 @ runtime. my eclipse project set 6.0 in mind.

json - How do you use ruby gems after they have been installed on OS X -

i able install json library using ruby gems. in case it's relevant, i'm using latest os x. usr$ sudo gem install json password: building native extensions. take while... installed json-1.6.5 1 gem installed installing ri documentation json-1.6.5... installing rdoc documentation json-1.6.5... however, attempting require 'json' doesn't work. doing wrong? touakas-macbook-pro:tmp jacob$ ruby x.rb x.rb:3:in `require': no such file load -- json (loaderror) x.rb:2 the x.rb follows: #!/usr/bin/env ruby require 'json' x = { "a"=>"b" } print x.to_json you need load rubygems first: require 'rubygems' require 'json' edit: according comment below, you'd better use ruby -rubygems x.rb rather require rubygems directly (suppose you're writing module resue). credit to: @injekt , @ingenu

android - Widget is not loaded on AVD -

i'm trying create widget android. contains such files: res/xml/widgetinfo.xml: <?xml version="1.0" encoding="utf-8"?> <appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" android:minwidth="146dip" android:minheight="146dip" android:updateperiodmillis="3600000" android:initiallayout="@layout/main" /> res/layout/main.xml: <?xml version="1.0" encoding="utf-8"?> <framelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <linearlayout > <textview android:text="my widget" /> </linearlayout> </framelayout> androidmanifest.xml: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:a

dataframe - Multiply column values in one data.frame by column in another data.frame on a condition in R -

i have 2 data frames in r trying combine based on values in column each. df1=data.frame(comp=c("comp1", "comp2", "comp3","comp1"), state1=c(1,0,0,1), state2=c(1,1,0,1), state3=c(0,1,1,0), state4=c(0,0,1,0),year=c(1,1,1,2)) comp state1 state2 state3 state4 year 1 comp1 1 1 0 0 1 2 comp2 0 1 1 0 1 3 comp3 0 0 1 1 1 4 comp1 1 1 0 0 2 df2=data.frame(state=c("state1","state2", "state3", "state4", "state1","state2", "state3", "state4"), var1=c(1,0,0,1,0,0,1,1), var2=c(0,1,0,0,0,1,1,0), year=c(1,1,1,1,2,2,2,2)) df2 state var1 var2 year 1 state1 1 0 1 2 state2 0 1 1 3 state3 0 0 1 4 state4 1 0 1 5 state1 0 1 2 6 state2 0 1 2 7 state3 1 1 2 8 state4 1 0 2 i'

javascript - Jquery modification to add 1 and save the number in a txt file on every click -

i using following click function purpose. can add add 1 in txt file when clicked? counter on how many times clicked. thank you $("#clearme").click(function(e) { e.preventdefault(); // have stuff here }); you can't access or edit files front-end. you'll need php or something. can save in variable , pass , process ajax. this, untested: var num = 0; $button.click(function(){ $.ajax({ url: 'bla.php', type: 'post', data: { num: ++num } //... }); }); and in php: $num = $_post['num']; // add file stuff

qt creator - Create Vanilla C++ project in QtCreator from existing .cpp and .h files -

i want start using qtcreator c++ coding... however, need understand how can create new project - straight c++ project (not qt) - bunch of existing .cpp , header files. how import these new c++ project...? how built...? how qtcreator build neccessary make files etc...? been googling ages without finding straight answer. many thanks c++ uses compiler (like gcc ) compiling , linker (like ld aka gcc ) linking. typically compiling multiple c++ files of need linked together. the script of makefile executed using make program. qt has tool called qmake can of leg-work you. go directory source, run qmake -project generate qt project run qmake generate standard makefile. call make build source.

How to input a character in windows form application? -

how can input character(name) in windows form application textbox? in c, char name[256]; printf("what name: "); gets(name); in windows form application using c (i don't want use c#), how can same way? name.add(textbox1->text)?? name->add(textbox1->text)?? it not reasonable use c to use .net windows forms. i don't know modern gui library windows pure c. there plenty c++ native libraries build window gui mfc, qt it possible use .net framework c++ using managed c++. if want go pure native c route... here link start win32 programming: creating win32-based applications code like: hwnd hwnd = createwindow( szwindowclass, sztitle, ws_overlappedwindow, cw_usedefault, cw_usedefault, 500, 100, null, null, hinstance, null );

python - Working with Twisted -

i'm working on twisted program inherited. have code that's in tap.py file, doesn't belong there. i'm moved out it's own file in same directory, tap file can't find classes. how go fixing that? i'm pretty green when comes python / twisted don't assume because trivial didn't on it. traceback (most recent call last): file "/usr/local/bin/twistd", line 5, in <module> pkg_resources.run_script('twisted==10.2.0', 'twistd') file "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 461, in run_script self.require(requires)[0].run_script(script_name, ns) file "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 1194, in run_script execfile(script_filename, namespace, namespace) file "/usr/local/lib/python2.6/dist-packages/twisted-10.2.0-py2.6-linux-i686.egg/egg-info/scripts/twistd", line 19, in <module> run() file "/usr/local/lib/python2.6/dist-pa

android - how to move an image on xml layout when user on touch event? -

i have implemented application image. in application have used on image when ever user touch on image move image along finger touch. have implemented application follows: ((imageview)findviewbyid(r.id.imageview1)).setontouchlistener(new ontouchlistener() { @override public boolean ontouch(view v, motionevent event) { switch (event.getaction()) { case motionevent.action_move: //i move image along user finger touch code break; default: break; } return false; } }); from above code not able move image along user finger. there sample achieve see: http://blahti.wordpress.com/2011/01/17/moving-views-part-2/

error when accessing a uart device from a cgi python script -

i'm trying access uart device /dev folder control robot. i'm trying internet using cgi python script. code works fine when execute on command line when executes through server 500 error. i'm pretty sure sort of permissions problem don't know how solve it. if knows going on here or how fix it, appreciated. i can post python code if liked see don't think problem in code, rather in execution of code. thanks in advance, michael, maybe solotion can checking group of device file: adam@sabayon ~ $ ls -lash /dev/ttys* 0 crw-rw---- 1 root uucp 4, 64 03-10 13:20 /dev/ttys0 0 crw-rw---- 1 root uucp 4,

php - Implement SHA 512 Hash with Code Igniter -

i have controller: landingpage.php <?php if ( ! defined('basepath')) exit('no direct script access allowed'); class landingpage extends ci_controller { public function index(){ $data = array( 'head' => $this->load->view('landing_header', '', true), 'guts' => $this->load->view('landing_guts', '', true), 'foot' => $this->load->view('landing_footer', '', true) ); $this->load->view('index', $data); } public function validateinput(){ #load libraries use $this->load->helper("form"); $this->load->helper("form_validation"); ///////////////////////////////////////////////////////////////// /////////////////////// new user validation ///////////////////// /////////////////////// format validation : /

python - GAE Data Models for Events and shared Resources -

i'm having trouble coming data models , queries scale modeling data similar google calendar's events , resources. resources shared among users , resource can in 1 event @ time. resource have multiple events, events cannot overlap or happening @ same time. event can have multiple resources. class event(db.model): #user created/owns event user = db.referenceproperty(user, collection_name='events',required=true) #an event can have multiple resources resources = db.stringlistproperty() # resource key(s) #when event opens , closes (start/stop) opendt = db.datetimeproperty() closedt = db.datetimeproperty() class resource(db.model): name = db.stringproperty(required=true) with these data models, have not been able come quick, scalable way list of available resources when creating event. get resources (simple query) get events overlap new event (multiple queries) find events start before , end after new event find events start before , end dur

c++ - Variadic Templates - different types of expansion -

andrei alexandrescu gave excellent talk entitled: variadic templates funadic . he presents following 3 expansions subltey different: template <class... ts> void fun( ts... vs ) { gun( a<ts...>::hun(vs)...); gun( a<ts...>::hun(vs...)); gun( a<ts>::hun(vs)...); } he explains: call 1: expands ts instatiation of class a , calls hun(vs) expands parameters again when passing them gun call 2: expands ts , vs separately call 3: expnads in lock step, ie: expand argument 1 of ts , argument 1 of vs expand argument 2 of ts , argument 2 of vs expand argument n of ts , argument n of vs other discussion on variadic templates seem cover simple variadic class templates , variadic functions such typesafe printf etc. unsure how these different types of expansion effect code , each type useful. does have examples demonstrate application of each type of expansion? #include <iostream> #include <memory> #include <typ

css - How can I get my page headers to resize using responsive layout? -

so have site need functional both on mobile devices , on computers. i'm using bootstrap-responsive , have gotten lot of things work. i'm working on hero-unit front page. have page header auto-scale according screen size. main bootstrap site (http://twitter.github.com/bootstrap/) makes use of want main page header. appreciated. relevant code: <div class="container"> <div class="hero-unit"> <div class="page-header"> <h1>page header</h1> </div> <p>lorem ipsum dolor sit amet, consectetur adipiscing elit. mauris arcu dolor, dictum scelerisque gravida nec, vulputate in odio. pellentesque sagittis ipsum et mauris elementum vitae molestie ipsum blandit. mauris tempus hendrerit arcu, sed vestibulum justo tempor a. praesent sit amet odio ligula. morbi sit amet leo vestibulum neque bibendum ullamcorper sed ut ante. vestibulum id diam quis ipsum alique