Posts

Showing posts from July, 2012

sql - From CURSOR to SELECT.... with an EXEC -

this example of sql query: declare cursora cursor select ida ... open cursora fetch next cursora @my_id while @@fetch_status <> -1 begin if @@fetch_status <> -2 begin insert #temp_table exec sp_mystoredprocedure @my_id end fetch next cursora @my_id end close cursora deallocate cursora how can transform select, example this: insert #temp_table exec sp_mystoredprocedure ida ... ? you can't directly query result set of stored procedure i'm afraid. presumably that's why cursor there in first place. using cursors thought inefficient, replace this: -- ids select ida #tmpids -- add row numbers , index query speed (may not needed if small) alter table #tmpids add rownum int identity(1,1) create clustered index idx_tmpids_rownum on #tmpids(rownum) declare @my_id int, @rownum int, @rowcount int set @rownum = 1 select @rowcount = count(*) #tmpids -- iterate on #tmpids while @rownum <= @rowcount begin selec

Setting UserAgent for HttpWebRequest in Silverlight 4 -

i'm using silverlight 4 , need set (override) useragent httpwebrequest . unfortunately not supported. platform notes in msdn state: "do not use member when targeting silverlight 4." and if try, system.notimplementedexception stacktrace: @ system.net.browser.clienthttpwebrequest.setuseragent(string value) @ system.net.httpwebrequest.set_useragent(string value) i've tried altering headers collection directly returns same error. is there way this? bonus question: know why not supported?

C++: Replacing Long Switch() Statement with Indexed Array? -

to create game object dynamically, take objecttypeid , unsigned int , , let compare within long switch() statement. if appropriate swith case found, create object , store it. because have 90 game objects, switch() long , growing 300 objects. to avoid long switch() statement, , improve speed, perfect candidate taking advantage of indexed array store object types (objecttypeid increases 0 upward). is there way, how store object type within array? i use this: aobjecttypesarray[objecttypeid] *pnewdynamicobject = new aobjecttypesarray[objecttypeid]; can advise me, please, how take advantage of dynamic array indexing in case, , how avoid long switch() statement? advice might differ idea, key use array indexing , remove long switch() statement. an easier way create factories use template create factory method , store using function pointer or perhaps boost::function or std::function if they're available. for example, given objects: #include <iostream&g

magento populate fields in order creation for customer -

i have external application contacts on database server db1 ,second have magento database db2 in same server. want populate customer dropdown in adminpanel contacts information how can ? try use connect db: ` $config = array( 'host' => $data['db_host'], 'username' => $data['db_user'], 'password' => $data['db_pass'], 'dbname' => $data['db_name'] ); $connection = mage::getsingleton('core/resource')->createconnection('connection_name', 'pdo_mysql', $config); ` then on $connection can use fetchall() etc. and can prepare "dropdown" items if that's want.

c# - Access wrapped object -

i'm wrapping orm entities bussines objects. public class projectmember { private readonly tfprojectmembersentity _projectmembersentity; public projectmember(tfprojectmembersentity projectmembersentity) { _projectmembersentity = projectmembersentity; } #region props public string email { { return _projectmembersentity.email; } set { _projectmembersentity.email = value; } } public datetime created { { return _projectmembersentity.created; } set { _projectmembersentity.created = value; } } } this bussines objects returned repository. way out isn't complicated. problem how access wrapped entity when wrapped object passed repository save operation. what neat way, wrapped object ? simply add method or property? you create interface so: interface iwrappedentity<t> { t getwrappedentity(); } now make bos implement interface. create base class implementing interfac

perl linux command not working -

cat t.incopt.02.20110221 | awk -f, '{print $1}' | sort | uniq got unque records but if inserted perl, @fetch_req_details = `cat t.incopt.02.20110221 | awk -f\, '{print $1}' \| sort \| uniq`; if print above array vari, getting entire file content, guess linux command not working correctly when use inside perl, i think need enclose command in tick , escape $ @fetch_req_details = `cat t.incopt.02.20110221 | awk -f, '{print \$1}' | sort | uniq;`

asp.net mvc - Defining a html5 data attribute in MVC -

i'm trying declare html.radio button in mvc app , want output data- attribute. problem c# "-" <%= html.radiobutton("defaultradiobutton", d.link, d.isdefault, new { data-link = d.link })%> is there anyway round other outputting html myself or creating helper? thanks.. if asp.net mvc 3: <%= html.radiobutton( "defaultradiobutton", d.link, d.isdefault, new { data_link = d.link } )%> and underscore automatically converted dash helper. in previous versions of mvc ugly hack appiled: <%= html.radiobutton( "defaultradiobutton", d.link, d.isdefault, new dictionary<string, object> { { "data-link", d.link } } ) %>

oracle - Any reason why this sql might cause problems? -

update tablea set tablea.column1 = 'somevalue' tablea.column2 in ( select column3 tableb tableb.column4 in ( 'valuea', 'valueb', -- 50 more records go here ) ) when run this, database seems hang. pretty new sql, want rule out (...or more rule in) possibility problem statement. running on oracle database using sqldeveloper. if db appearing "hang" may there modifications data in another, uncommited session. try... select * tablea tablea.column2 in ( select .... ) update nowait; and see if an: ora-00054: resource busy , acquire nowait specified or timeout expired make sure issue rollback after test. if error, indicates session has lock on data.

c++ - Are boost interprocess containers suitable for thread shared storage in the same process? -

i need vector container shared between 2 threads of same process, providing mutex protected access following methods: empty size erase push_back i collection provide iterator locks container while iterator in use. looking collection std::vector<...> interface concurrent access protection can't seem find anything. are boost::interprocess containers suitable application? if not, there alternative more suitable or have write own? the answer yes - suitable. see here

gentoo - Determining why kernel hangs on boot -

hi : building kernel gentoo linux . when start kernel , got message , , can't going on. pci_hotplug: pci hot plug pci core version: 0.5 non-volatile memory driver v1.3 don't know how solve problem . , need . . why don't try disable pci hotplug support in kernel (if recall correctly in main config menu / pci support)? don't need this.

c# - Multiple/Single *.edmx files per database -

i have project interacts database through ado.net data services. database large ( almost 150 tables dependencies ). project started few years ago , there datasets used then; we're moving towards entity model relationships. model growing since adding more tables need work with. right way manage that?. meaning should have single database model file have single data context? what drawbacks , how use entity framework large databases (or should not used large ones? the disadvantages see are: visual studio 2010 starts freeze when opening large xml in designer ( maybe not problem, because many tables doesn't freeze long time ). it becomes hard find references in model ( though f4 + properties window's combobox of object names removes search related problem ). ps, strange no 1 answers. question seems important , in simple words i'll rephrase it: better, 1 model of whole whole, large database or several models of database? i suspect aren't getting m

button - Android : How to update the selector(StateListDrawable) programmatically -

i want update selector button programmatically. i can xml file given below <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_enabled="false" android:drawable="@drawable/btn_off" /> <item android:state_pressed="true" android:state_enabled="true" android:drawable="@drawable/btn_off" /> <item android:state_focused="true" android:state_enabled="true" android:drawable="@drawable/btn_on" /> <item android:state_enabled="true" android:drawable="@drawable/btn_on" /> </selector> i want same thing programmatically. have tried given below private statelistdrawable setimagebuttonstate(int index) { statelistdrawable states = new statelistdrawable(); states.addstate

What are the available J2ME SDK using Java code? -

i java j2se developer, , want learn j2me start creating mobile applications.i see can use default oracle java me sdk. know other mobile sdks java based, want write java code ? eclipse works fine purpose. have @ mobile tools java (formerly known eclipseme ). from eclipse me link: eclipseme eclipse plugin develop j2me midlets. eclipseme "grunt work" of connecting wireless toolkits eclipse development environment, allowing focus on developing application, rather worrying special needs of j2me development.

c++ - Calling member functions of a class object which is present in header file included -

i new forum wanted call member function of included header file..here code have written #include<stdio.h> #include "abc.h" cabc *a;//cabc class present in abc.h int main(int argc,char **argv) { int i=10; float j=15.5; bool x; x=a->method(i,j);//method member function of cabc if(x) { printf("working correctly"); } else { printf("not working"); } } if compile using g++ -i/path/to/include code.cpp i error /tmp/cc5jglff.o: in function `main': code.cpp:(.text+0x3d): undefined reference `cabc::method(int,float)' collect2: ld returned 1 exit status i tried giving x=a::method(i,j); for not class or namespace please can tell me doing correctly or not? it looks though forgetting include implementation source/object. try this: g++ -i/path/to/include abc.cpp code.cpp as long implementation class abc.h corresponds abc.cpp. regards, dennis m.

gdi+ - ASP.NET convert image from PNG to jpg -

i having problem converting image png jpg. jpg jpg png jpg having pixelated problem. i've implemented compression method code still couldn't produce high quality image. any ideas guys? using system; using system.collections.generic; using system.web; using system.web.ui; using system.web.ui.webcontrols; using system.drawing.imaging; using system.drawing; using system.io; using system.drawing.drawing2d; public partial class _default : system.web.ui.page { private imagecodecinfo getencoder(imageformat format) { imagecodecinfo[] codecs = imagecodecinfo.getimagedecoders(); foreach (imagecodecinfo codec in codecs) { if (codec.formatid == format.guid) { return codec; } } return null; } protected void page_load(object sender, eventargs e) { response.contenttype = "image/jpeg";//convert tojpeg web usage // bitmap. bitmap bmp1 = new

automated tests - Regarding Automation Approach -

supposed automate application developed in powerbuilder. in order test application using rational robot functional testing tool. expect @ least 40 -50% of change control in application each release. release trends scheduled @ least 3 times in year. the product has different setup each client. accordingly scenario has been derived. although if there change occurs, in functional feature , in interface. pointing that, need proceed automation. identified few areas stabilized (i.e., no major changes occurs) automate. feasible proceeding automation? could please suggest me how go on this? i've seen answer last question involve consultant spending 2 days interviewing development team, 3 days developing report. and, in cases, i'd report preliminary, introductory, , rushed. however, let me throw out few ideas may manage expectations on team. testing automation great checking regressions in functionality allegedly isn't being touched. things framework changes

image processing - Finding number of quantizing layers in MATLAB -

i'm working on image processing, , have image has been dct'd , quantized 8 x 8 blocks of 512 x 512 matrix, have find how many quantizing levels image has. need take top left pixel , place in array , place on graph calling hist ? length(unique(x(:))) , x image array. appropriate grayscale images.

syntax - Small difference in types -

i have 3 functions ought equal: let add1 x = x + 1 let add2 = (+) 1 let add3 = (fun x -> x + 1) why types of these methods differ? add1 , add3 int -> int , add2 (int -> int) . work expected, curious why fsi presents them differently? this typically unimportant distinction, if you're curious, see arity conformance values section of f# spec. my quick summary (int -> int) superset of int -> int . since add1 , add3 syntactic functions, inferred have more specific type int -> int , while add2 function value , therefore inferred have type (int -> int) (and cannot treated int -> int ).

NHibernate returning duplicate rows -

nhibernate appears returning contents of first row multiple times. many times there actual, distinct rows in database. example, if 1 person has 3 campus affiliations this: baker college - teacher bryant elementary - teacher ohio state university - student nhibernate return this: baker college - teacher baker college - teacher baker college - teacher i'm using fluentnhibernate. here snippets of entity , mapping files: public class person { public virtual string sysid { get; set; } public virtual string fullname { get; set; } public virtual icollection<campus> campuses { get; set; } } public class campus { public virtual string sysid { get; set; } public virtual string name { get; set; } public virtual string affiliation { get; set; } } public class personmapping { table("person"); id(x => x.sysid); map(x => x.fullname).column("full_name"); hasmany(x => x.camp

javascript - How to set a Jquery Datepicker daterange -

i have 2 input text boxes bound jquery datepicker widget. when user select given date date1 (effective date), want set min date of date2 (expiry date) date1 + 1 .. how do that, see link : jquery datepicker- 2 inputs/textboxes , restricting range and use onchangemonthyear function or onselect function: $('#txtstartdate, #txtenddate').datepicker({ showon: "both", beforeshow: customrange, dateformat: "dd m yy", firstday: 1, changefirstday: false, onchangemonthyear: function(year, month, inst) { ... }, onselect: function(datetext, inst) { ... } }); and use same technique ben koehler or russ cam used.

javascript - Onsubmit doesn't work in Chrome -

i have 2 forms , button. works fine in firefox. new window, paypal payment, , in window happened send_mail form submitted send e-mail user. how can make work in chrome? why it's not working? i've tried (or think)! so: <form name="registerform" id="registerform" target="_blank" action="paypal_url" method="post" onsubmit="$('#send_mail').submit();"> ... </form> <form name="send_mail" id="send_mail" action="" method="post"> ... </form> <a onclick="$('#registerform').submit()">go paypal , send confirmation mail</a> unless have reason use javascript-only submit, why set form unusable if there javascript error? use standard form input of type submit, give id, alter or text of submit via javascript necessary, , create onclick & onsubmit events layer on top of functionality , have them return false. b

.net - Nhibernate filter not consistently applying to child collections -

i have entity child objects soft deleted. when call simple on parent, want retrieve on child objects not soft deleted. entities have base class id, audit, soft delete fields kept. in order achieve created 2 event listeners , 1 filter, 1 event listener cascade soft delete if necessary, , apply filter on preload. public class nondeletedfilter : filterdefinition { public static string filtername = "nondeletedfilter"; public nondeletedfilter() { withname(filtername).withcondition("isdeleted = 0"); } } public class parentmap : iautomappingoverride<parent> { public void override(fluentnhibernate.automapping.automapping<parent> mapping) { mapping.hasmany(x => x.children).fetch.join() .inverse() .cascade.alldeleteorphan() .applyfilter(nondeletedfilter.filtername); } } public class preloadeventlistener : defaultpreloadeventlistener { public override void o

git filter branch - git ignores $GIT_AUTHOR_DATE -- is this a bug? -

edit : summary : git not allow dates before 1973/03/03 09:46:40 (epoch+100000000s) given in "internal date format" (seconds since epoch). allow "20110224" short form of "2011-02-24". -- this no bug : not really, not documented well. -- workaround : not rely on git internal date when cannot. -- thanks to : hobbs hi all, i have issues git filter-branch have tracked down git commit-tree. consider script: #!/bin/bash # please run these commands in empty directory # (should not destroy existing repo, though. think # few dangling objects) set -e -o pipefail git init tree=$(git write-tree) commit=$(echo "my first commit -- tree empty" | env git_author_date="0 +0000" git commit-tree $tree) echo "this commit $commit:" git cat-file commit $commit note env git_author_date="0 +0000" sets date using "git internal format" -- see git-commit-tree's manpage details -- 1970-01-01. but output of

ajax - 'JSON' is undefined error in IE only -

i'm making ajax call wcf service , when pass in data use json.stringify() the call returns , works fine in ff, & chrome, not ie8. error: 'json' undefined suggestions? p.s. want work in ie7 use json2 consistent cross browser implementation. https://github.com/douglascrockford/json-js

javascript - How expensive is listening for events on the entire document? -

i want use event delegation on number of buttons in page of html. these buttons on page, , wondering how expensive listen entire document on click events, , have on click events trigger event delegation handler. more expensive having listeners on each of 20+ buttons (it can grow on 100 buttons, yes silly)? i don't see how more expensive since listening clicks on document object instead of 25 anchor objects. said, 25-30 buttons not resource-intensive don't need worry this.

Versioning a SharePoint feature -

is there best practice versioning sharepoint features? our sharepoint product gets release every 3-6 months, , need way of differentiating between new version , old version. need support simultaneous installations of new , old feature clients may test new stuff before deploying it. versioning features not supported in sharepoint 2007. in sharepoint 2010 can version features version assemblies. see following post more details: feature versioning , upgrades in sharepoint 2010

visualforce - Custom Task button "Log a Phone Call" in salesforce.com -

i'd create custom task button create new activity or task , default subject , custom field "activity.type__c" "phone call" when clicked. i got far defining button, need pointers on content source , actual code should be. sample code and/or links tutorials appreciated! you need set url button have parameters ids matching fields on page, , values. so, @ id of custom field in html, it'll 18 character string (e.g. 00nd0000003iyoe). set in url ?00nd0000003iyoe=phone%20call . note: i'm using %20 space.

c#: public when debugging, private otherwise -

is there nice way make functions public when testing nunit, private otherwise? not having generate lot of extraneous code nice. ------------------------edit------------------------ it seems solutions fall under 3 types: don't i'm attempting do. use compiler directives. try clever solution (like using internalsvisibleto). might there way programmatically? i.e. create new temporary app makes protected/private/internal functions public , plug nunit, run tests there, , go using private functions release version? you might not need if have coverage on public methods call private methods seems debate self. this link tdd , different ways it: how test private , protected methods in .net

javascript - jquery value in json -

i have json returned ajax call [ {message:"haha", type:"error"}, {message:"nice work", type:"success"}, {message:"closed.", type:"success"} ] and need find out if of items of type error. know can loop through , figure out wonder if if there function tell me need know prior parsing json, test string match. var json = '[{"message":"haha","type":"error"},{"message":"nice work","type":"success"},{"message":"closed.","type":"success"}]' if( json.indexof('"type":"error"') > -1 ) { // there error somewhere } if json little loose spaces around keys/values, use regular expression test instead.

jquery carrousel plugin not working when i add items dynamically from xml file -

i'm trying add items dynamically carousel jquery plugin.the items added bt carousel ignores them. the carousel take items show this: <div class="viewport"> <ul class="overview"> <li><img src="images/picture6.jpg" /></li> <li><img src="images/picture5.jpg" /></li> <li><img src="images/picture4.jpg" /></li> <li><img src="images/picture2.jpg" /></li> <li><img src="images/picture1.jpg" /></li> </ul> </div> i'm reading xml file , addings item overview ul. $(document).ready(function(){ $.ajax({ type: "get", url: "categories.xml", datatype: "xml", success: xmlparser }); }); function xmlparser(xml) { $(xml).find('categories').eq(0).find('c

Creating an XPath Expression in SharePoint's "Add Formula Column" based on meta data -

ok, so first post stack overflow, , did search , couldn't find looking regard question (although might terrible @ searching). essentially, first pass @ xpath expressions , having tough time creating if/else statement. i have dwvp displaying list of documents document library on separate site. have column notes whom document checked-out (if checked-out), , if document checked out, have conditional formatting highlight row. all far. have list of documents have bunch of meta data , 1 or 2 of rows in list highlighted yellow because checked-out, , users name listed in "@checkedouttouser" column. my issue want create column (i'm assuming formula column) within dvwp display link source document library (specifically view enabled filters content "checked out to" [me], that's no issue) if column "@checkedouttouser" has in it. my thought process here new formula column check see if anything written (or alternatively not written) in column

Java: Breaking Loop -

what best way implement following pseudo-code in java? method_one(): while(condition_one): execute method_two(); // (a) method_two(): while(condition_two): execute method_three(); // (b) method_three(): if (condition_three): goto execute method_two(); else: //do stuff edit: prompt replies, everybody. helped lot. figured out now. if don't need separate methods, should equivalent: boolean exit_from_three = false; while (condition_one || exit_from_three) { exit_from_three = false; while (condition_two) { if (condition_three) {exit_from_three = true; break;} // stuff } }

c++ - STL algorithms and iterators instead of "for" loops -

i guess there should someway write below piece of code without using "for" loops , using stl algorithms , iterators. if not wrong can guide me on how this? std::vector<double> a(n); std::vector<double> b(n); std::vector<double> c(n); std::vector<double> d(n); for(int = 0; < n; ++i) a[i] = myfunction1(i); for(int = 0; < n; ++i) b[i] = myfunction2(a[i], i); for(int = 0; < n; ++i) c[i] = myfunction3(a[i], b[i]); for(int = 0; < n; ++i) d[i] = myfunction4(a[i], b[i], i); typedef boost::counting_iterator<int> counter; std::transform(counter(0), counter(n), a.begin(), myfunction1); std::transform(a.begin(), a.end(), counter(0), b.begin(), myfunction2); std::transform(a.begin(), a.end(), b.begin(), c.begin(), myfunction3); now write own version of std::transform takes ternary function: template <typename in1, typename in2, typename in3, typename out, typename func> out transform3(in1 first1, in1 last1, i

Inserting the output of a query into a table created on a different server SQL Server 2008 -

i wondering if can guide me how can insert output of query table created on different server running query. for example: table located on server1 called tbl1 in database called database1 . the query running querying data located on server2. for insert command, work: server1.database1.tbl1 if need more information please let me know. as long can reach both servers, should easy enough: insert server1.database1.dbo.tbl1(list of columns) select (list of columns) server2.database2.dbo.tbl2 (some condition here)

iphone - Will building & running another iOS project disassociate existing provisioning or app id's? -

i recovered not being able test on device in xcode. after headache, turned out needed uninstall/reinstall itunes, i'd rather not frequently. (see: prior thread ) the troubles seemed begin after built , ran sample projects did not have app id, etc. case? should live in fear of compiling other projects haven't associated device and/or developer profile? i'm not sure if app id/bundle/provisioning/keychain/whatever needs done per test ad hoc app or if matters device provisioned , plist matches apple has when go upload itunes store. i've run many samples on device through xcode , never had issues. there's no reason why should happen. it's hard "no, shouldn't worried" without knowing issue is, it's not intended break in way, , doesn't of us!

c# - SQL CROSS JOIN question -

i having bit of trouble sql query. i have 2 tables: table1 id guid title d0 d1 d2 ----------------------------------------- 1 guid1 title1 0.123 -0.235 0.789 2 guid2 title2 -0.343 0.435 0.459 3 guid3 title3 0.243 -0.267 -0.934 ... 100 guid4 title100 -0.423 0.955 0.029 and table 2 (note has same schema, different data). id guid title d0 d1 d2 ---------------------------------------- 1 guid1 title1 0.233 -0.436 -0.389 2 guid2 title2 -0.343 0.235 0.789 3 guid3 title3 0.573 -0.067 -0.124 ... 100 guid4 title100 -0.343 0.155 0.005 i trying figure out how write select statement returns titles where combinations of abs(table1_d0*table2_d0)+abs(table1_d1*table2_d1)+abs(table1_d2*table2_d2) less thresholded value (hard coded probably). so far trying use cross join , not sure if correct approach. does make sense? table1, row1 against rows of table2 , table1, row2 against rows of table2 . if matters

string - linking 4 pieces of information and saving them -

saving, editing , loading information. information want load add myself. each line of information contain 4 pieces, (string, integer, string, integer). via 4 seperate edit boxes , button add information 'database' (not sure if need database or if can done via tstringlist). everytime button clicked added content typed @ moment in 'database'. the demand of saved data when type first string list place rest of information belongs in memobox or edit boxes well. suppose have able search. want keep simple possible. there 10 15 lines of information. , if possible if can load them again later time. here's basic code should on way. there's no error checking, , you'll no doubt want develop , modify further. point there should ideas write code works you. now have comma-separated fields, made no attempt handle appearance of commas in of values. if problem choose different delimiter, or escape commas. had toyed writing each field on own line (effectivel

freetype2 - FreeType 2 - Unicode Character Codes? -

the documentation freetype2 says default character map used unicode map... however, when attempt retrieve character code unicode 't', gives me unicode 'z' using: glyph_index = ft_get_char_index(face, text[n]); what need way find out how many glyphs in font face , unicode value maps per each one. there way this. i've tried every freetype function , can't results. thanks i know old but... what ask not possible. there glyphs don't match unicode codepoint, , there unicode codepoints map multiple glyphs, depending on neighboring glyph. example, "ff" in many fonts special glyph make typesetting work better. there no "ff" codepoint in unicode. it's layout system decide use "ff" glyph or not. however, if you're asking 't' character , getting 'z' glyph index, there issues font.

Firefox CSS nowrap problem -

i'm trying create horizontal (no line breaks) unordered list of images on website using code follows: <ul class="imageset"> <li> <img src="blah"> </li> <li> <img src="blah"> </li> <li> <img src="blah"> </li> </ul> in css, i'm using following rules: .imageset { white-space: nowrap; } .imageset li { display: inline; float: left; height: 100% } this working in chrome, not in firefox, reason know why? edit: clarify, problem in ff li's still wrap. i'm trying make them appear in single, unbroken horizontal line going off rightmost edge of page. try removing float:left display:inline should suffice

jquery - Want to get a Javascript stacktrace/callstack when unhandled exception occurs -

sometimes error or unhandled exception in line in jquery ui js file. know problem empty or null object or property passed jquery. example in chrome 'uncaught typeerror" error. doing manual work can find culprit , can better error handling. take time. however looking fast automatic way find culprit looking @ stacktrace when exception occurred. there modern browser has feature built in? or javascript error handler works across loaded js files in global level? i looked @ this article seems have sprinkle printstacktrace() in targetted functions. don't idea if code has many functions. in webkit (what chrome or safari uses) debug tools, click scripts section on top. hexagon icon on bottom 2 vertical lines. clicking cause javascript execution pause on error. @ right see callstack, can trace through everything.

asp.net - Html.ListBoxFor error problem asp.mvc 3 -

i have in code , getting error: exception details: system.argumentexception: value cannot null or empty. parameter name: name . doing wrong ? help @model ienumerable<nhibernatefluentproject.patient> @html.listboxfor(model => model, new selectlist(model,"id", "firstname")); @html.listboxfor used strong typed viewmodel. bind property. first part take lambda expression single item default seleced listbox, second part take item collections dispaly listbox items. example: have following 2 classes. public class hospitalviewmodel { public string selectedpatient { get; set; } public ienumerable<patient> allpatients { get; set; } } public class patient { public int id { get; set; } public string firstname { get; set; } } from view, should like @model hospitalviewmodel @html.listboxfor(model => model.selectedpatient, new selectlist(model.allpatients,"id", "firstname")); or if want bind patients l

Having trouble doing multiple cursors in a MySQL stored procedure -

i'm writing store procedure create 2 temporary tables union select of two. when using either first or second cursor alone other commented procedure works, when run query create procedure 2 cursors, fails.i've changed code reflect ike walker's suggestion. here script: delimiter // drop procedure if exists joinemailsmsdailygraph// create procedure joinemailsmsdailygraph(in previousday varchar(20), in today varchar(20)) reads sql data begin declare hours int; declare sms int; declare email int; declare smsdone int default 0; declare emaildone int default 0; declare cursorsms cursor select hour(sm.date_created) `hour of day`, count(*) smscount sms_message_delivery smd join sms_message sm on sm.sms_message_id = smd.sms_message_id date(sm.date_created) >= date(previousday) , date(sm.date_created) < date(today) group hour(sm.date_created); declare continue handler not found set smsdone =1; declare cursoremail cursor select hour(em.date_created) `hour of da

c# - Multiple Active Directory look-ups in MVC3 application -

my mvc application allows subset of users insert/edit records in table, , since i'm using windows authentication samaccountnames "for free" , can insert these in "last updated by" field in mentioned records. one of important (and used) views in application display lists of 50-100 records per page, don't want display samaccountnames. want more user-friendly display names want active directory. i've seen several posts here suggesting linking ad sql, requires installing components on sql server i'd rather not do. instead, thinking of creating following interface , derived class: public interface iuserinformationstore { userinformation findbysamaccountname(string samaccountname) } public class activedirectorystore { hashset<userinformation> _cache; public userinformation findbysamaccountname(string samaccountname) { // samaccountname in _cache , if not found // retrieve information ad directorysearcher. // store info

ios - Center MKMapView on userLocation (initially) - only works on iPhone 4? -

i implemented following mkmapview method, runs after annotations added. have mkmapview map (parishmap) set "shows user location" in interface builder, , upon loading mapview, blue dot appears within second or on mapview. here's code have in map view controller implementation: // center map on user location (initially) - (void)mapview:(mkmapview *)mapview didaddannotationviews:(nsarray *)views { for(mkannotationview *annotationview in views) { if(annotationview.annotation == parishmap.userlocation) { mkcoordinateregion region; mkcoordinatespan span; span.latitudedelta=0.03; span.longitudedelta=0.03; cllocationcoordinate2d location=parishmap.userlocation.coordinate; location = parishmap.userlocation.location.coordinate; region.span=span; region.center=location; [parishmap setregion:region animated:true]; [parishmap regionthatfits:r

accessibility - Using Aria role article and/or listitem? -

i have list of articles in ul list. reading http://www.w3.org/wai/pf/aria/roles#role_definitions can either use roles list , listitem per item, considered article . option 1: can following (have 2 roles on same element): <ul role="list"> <li role="listitem article">...<li> </ul> option 2: should use article role: <ul> <li role="article">...<li> </ul> you should use option 3 :) <ul role="list"> <li role="listitem">...<li> </ul> all want let assistive technologies understand markup of content. actually, assisted technologies, "role" attribute required on rich internet content, sliders, , many html5 elements. if worried screen readers working code, marking such list correctly suffice. good example <p> list </p> <ul role="list"> <li role="listitem"> list item 1 <li> </ul&

java - Delete element from array -

possible duplicate: removing element array (java) is there way can rid of elements in array. instance, if have array int testarray[] = {0,2,0,3,0,4,5,6} is there "fast" way rid of elements equal 0 int resultarray[] = {2,3,4,5,6} i tried function got lost using lists public int[] getridofzero(int []s){ list<> result=new arraylist<>(); for(int i=0; i<s.length; i++){ if(s[i]<0){ int temp = s[i]; result.add(temp); } } return result.toarray(new int[]); } java arrays can't resized. need create new array. count non-zero elements in array. create new array size. copy elements old new array, skipping on 0 elements. you can lists. best bet create list of integers; add non-zero elements it; use toarray create array list.

Ruby On Rails different views for same action (Based on User's role) -

i have ruby on rails controller display different form logged out user logged in user. what best way approach this? (is below way ok?) class userscontroller < applicationcontroller def index if logged_in && is_admin render 'admin_index' end #use default index end end sure thats fine except might 'cannot render action twice' type error (if im admin , logged in still try render default after rendering admin action) class userscontroller < applicationcontroller def index if logged_in && is_admin render 'admin_index' else render end end end might better

data structures - Overloading [] operator in C++ -

im trying overload [] operator in c++ can assign / values data structure dictionary used in c#: array["mystring"] = etc. is possible in c++? i attempted overload operator doesnt seem work, record& mydictionary::operator[] (string& _key) { (int = 0; < used; ++i) { if (records[i].key == _key) { return records[i]; } } } thanks. your code on right track - you've got right function signature - logic bit flawed. in particular, suppose go through loop without finding key you're looking for: for (int = 0; < used; ++i) { if (records[i].key == _key) { return records[i]; } } if happens, function doesn't return value, leads undefined behavior. since it's returning reference, going cause nasty crash second try using reference. to fix this, you'll need add behavior ensure don't fall off of end of function. 1 option add key table, return reference new table entry. behavior of st

c# - protobuf-csharp-port what version(s) of these tools are best to use today? -

on mac, using mono 2.6, , wanting started protobuf-csharp-port. i compiled protoc protobuf-2.3.0 google. or should use protobuf-2.4.0 came out? protobuf-csharp-port should use download of 0.9.1 (may 2010) or go ahead , clone git master branch? so, looks compiled addressbook tutorial using 2.3.0 + 0.9.1. wanting know if it's advisable go protoc 2.4.0 + git master? thanks in advance , looking forward digging in protobuf-csharp-port. alex i can't i've used protobuf-csharp-port on mac. it's probably best go 2.3.0 build of protobuf that's version of protoc use on windows. i suggest using latest version of protobuf-csharp-port on github; includes few new features in protogen such automatically calling protoc - although assumes protoc.exe, you'll need tinker call mac version. can specify various of generation options command line instead of "polluting" otherwise portable .proto file, nice. unfortunately don't have documentation yet

algorithm - Separating Axis Theorem - Containment and the minimum translation vector -

Image
my code calculate minimum translation vector using separating axis theorem works well, except when 1 of polygons contained polygon. have scoured internet solution problem , seems ignore ( http://www.codezealot.org/archives/55#sat-contain talks this, doesn't give full solution...) the pictures below screenshot program illustrating problem. translucent blue triangle position of rectangle before mtv applied, , other triangle mtv applied. it seems me link shared give solution this. in mtv calculation, have test complete containment in projection , change calculations accordingly. (the pseudocode in reference figure 9 on page.) perhaps if post code, can comment on why isn't working.

visual studio - MSI write the TARGETDIR to textfile -

how write msi's targetdir textfile? program can refer path written there. this depends on type of text file. if plain text file have use custom action. alternatively can use windows installer built in ini file editing support. http://msdn.microsoft.com/en-us/library/aa369282(vs.85).aspx

Rails CouchDB App not working in Production -

i deployed app on production server , following error : (there problem config/couchdb.yml file. check , make sure it's present , syntax correct.) the couchdb.yml file follows : base: &base database_prefix: database_suffix: _<%%= rails_env %> development: host: localhost port: 5984 <<: *base test: host: localhost port: 5984 <<: *base production: host: localhost port: 5984 <<: *base and in boot.rb require 'rubygems' # set gems listed in gemfile. env['bundle_gemfile'] ||= file.expand_path('../../gemfile', __file__) require 'bundler/setup' if file.exists?(env['bundle_gemfile']) require 'simply_stored/couch' couchpotato::config.database_name = "http://localhost:5984/thedatabase" the database created , works locally; problem on production server, gems installed; not sure why i'm missing should specify differently production.. tried host 127.0.0

database - Regarding multiple insertion of rows through single query.(oracle) -

is mechanism used in multiple insertion of rows in table through single query same of inserting single row single query.if not exact mechanism? if fetching data existing table, can use insert table3 ( select * table1 union select * table2 ....) fetch , insert data in single go. sql> select * scott.emp job = 'analyst1'; empno ename job mgr hiredate sal comm deptno gender ---------- ---------- --------- ---------- --------- ---------- ---------- ---------- -------- 8909 luthar analyst1 7698 22-jul-99 1232 788 50 f 8999 aman analyst1 7698 22-jul-99 8569 788 50 m 7788 scott analyst1 7566 19-apr-87 3000 150 m 7902 2 analyst1 7566 03-dec-81 3000 m sql> select * scott.emp job = 'manager'; empno ename job mgr hiredate

ruby on rails - Unable to start Mongrel (or Passenger) on Debian due to mysql2 or mysql gems -

i posted @ super user, think should here instead... i'm trying port ror webapp on dreamhost vps. i've upgraded vps --> ruby 1.9.2 1.8.7 , using rails 3.0.1 , mysql2 (0.2.6) gem. i'm getting following error when trying start mongrel: /usr/bin/ruby1.8: symbol lookup error: /home/username/.gems/gems/mysql2-0.2.6/lib/mysql2/mysql2.so: undefined symbol: rb_intern2 ...so tried using mysql (2.8.1) gem instead , following error: wrong argument type mysql (expected struct) (typeerror) 0 /home/username/.gems/gems/activerecord-3.0.1/lib/active_record/connection_adapters/mysql_adapter.rb 600 in real_connect' 1 /home/username/.gems/gems/activerecord-3.0.1/lib/active_record/connection_adapters/mysql_adapter.rb 600 in connect' 2 /home/username/.gems/gems/activerecord-3.0.1/lib/active_record/connection_adapters/mysql_adapter.rb 164 in initialize' 3 /home/username/.gems/gems/activerecord-3.0.1/lib/active_record/

jquery - Apply class to every 4th li inside a ul -

i need display 4 li elements in row, apply class="last" every 4th li element. right doing this, var licount = jquery('.explorecontentarea .listarea ul li').size(); jquery('.explorecontentarea .listarea ul li:eq(3)').addclass('last'); i need apply class every 4th item of ul. please me on same. thanks | lokesh yadav use nth-child : jquery('.explorecontentarea .listarea ul li:nth-child(4n)') .addclass('last').show();

silverlight 4.0 - Using the return type IQueryable<TABLE_1> -

i new silverlight, many posts indicate using observablecollection best. domainservice1 returns iqueryable type. how work return type in silverlight side? how convert/cast data returned observable collection? the domainservices1.cs public iqueryable<table_1> gettable_1() { return this.objectcontext.table_1; } *the home.xaml.cs*** public home() { initializecomponent(); this.title = applicationstrings.homepagetitle; web.domainservice1 dservice = new web.domainservice1(); entityquery<web.table_1> query=new entityquery<web.table_1>(); query = dservice.gettable_1query(); //convert result observablecollection //bind grid item source } the iqueryable not return results until enumerate collection. instance if wanted limit results of dservice.gettable_1query .where() could... to object observable collec

web services - Android Webservice -

hi i new android. want use ksoap2 connect web service.can give me links sample application code. it of great me. thanks in advance using ksoap2 best thing when getting soap response. here links can use ksoap2:- overview it. about using ksoap2 receiving response complex type. please visit codereview.stackexchange.com thread of mine placed code using ksoap2 link

java - Method to remove duplicates in List -

possible duplicate: remove duplicates list is there method in java list can use remove duplicates? no, there no method on java.lang.list removes duplicates. seems designers expected list not used in scenarios worried duplicates: unlike sets, lists typically allow duplicate elements. more formally, lists typically allow pairs of elements e1 , e2 such e1.equals(e2), , typically allow multiple null elements if allow null elements @ all. not inconceivable might wish implement list prohibits duplicates, throwing runtime exceptions when user attempts insert them, expect usage rare. (taken java.lang.list javadoc ) you either need use set or implement own method removing duplicates.

c# - Problem comparing items implementing IComparable -

i working on extension method finds min item specific selector. below code public static t minby<t, k>(this ienumerable<t> src, func<t, k> selector) k : struct, icomparable, iconvertible { var min = default(k); t minitem = default(t); foreach (var item in src) { var current = selector(item); if (current < min) { min = current; minitem = item; } } return minitem; } it gives error error operator '<' cannot applied operands of type 'k' , 'k' . have specified generic constraint k should struct , icomparable . believe numeric data type can satisfied this. then how come invalid operation.? icomparable doesn't (and can't) operators. should using: if (current.compareto(min) < 0) operators static, , ever overloaded rather overridden . can't require operators within

Possible to manually set ID of new rows with RedBean PHP? -

i'm using redbean php dump data web scrape database, , need retain legacy ids, preferably primary key field. possible redbean? when try set id so: $bean->id = 56; the row doesn't inserted - query ends being created instead becomes "update id =56", nothing since record doesn't exist yet. forcing specific value on auto-increment primary index asking race-condition problems. i'd suggest create new column legacy_id instead save alternative id.

jdbc - Execute anonymous pl/sql block and get resultset in java -

i execute anonymous pl/sql , need resultset object. got code can done using cursors inside pl/sql block. but pl/sql block come database text. can't edit pl/sql block. , return 2 values column names same always. return list of 2 column combination values. here giving sample pl/sql. begin return 'select distinct fundname d, fundname r <table> condition order 1'; exception when others return 'select ''not available'' d, ''not available'' r dual'; end; any reply helpful. here self contained example of how "execute anonymous pl/sql , resultset object" import java.sql.callablestatement; import java.sql.connection; import java.sql.drivermanager; import java.sql.resultset; import java.sql.types; import oracle.jdbc.oracletypes; public class callplsqlblockwithoneinputstringandoneoutputstringparameterandoneoutputcursorparameter { public static void main(string[] args) throws exception {

android - Is it possibile to create a custom keyboard for my app? -

in android, possible create keyboard application (no need other applications use it)? i found project http://code.google.com/p/android-misc-widgets/ , creates scratch virtual keyboard view, wonder if way... i found project http://code.google.com/p/android-misc-widgets/ , creates scratch virtual keyboard view, wonder if way... yes. input method editor (ime) system keyboards available whole device.

PHP Kohana include problem -

i dealing strange , rather simple problem 2 days now. bet solutions obvious dont know else do. i working in kohana framework. in c:/wamp/www folder have 2 different sites: mysite1 , mysite2. so have fckeditor working in mysite1 site included this: include(url::base(false)."static/scripts/fckeditor/fckeditor.php"); -> include(mysite/web/admin/static/scripts/fckeditor/fckeditor.php) and works charm! well decided incorporate fckeditor in mysite2, , use same command.. , not work , there erro message: no such file or directory.. i assure fckeditor exists in mysite2/web/admin/static/scripts/fckeditor/fckeditor.php the full path (c:/wamp/www/mysite2/web/admin/static/scripts/fckeditor/fckeditor.php ) path include works. want include(url::base(false)."static/scripts/fckeditor/fckeditor.php") working... what possibly wrong?? thanks! if full path works fine, path using url helper doesn't work, it's site configuration error. d

ms access - sql query to select week,month, days -

please guys, need sql query select data access database using vb6. query provide current date , filed been compaired curr_date in database. for example select * table curr_date between firstoflastmonth , endoflasthmonth; select * table curr_date between firstoflastweek , endoflasthweek; select * table curr_date between firstofthismonth , endofthismonth; select * table curr_date between firstofthsiweek , tilldate; the problem have figuring ot how specify 2 dates in comparison is not easiest check wich month/week want in then? from examples: select * table curr_date between firstoflastmonth , endoflasthmonth; this become (with month function used) select * table month(curr_date) = month(dateadd("m",-1,date())); this compares month of curr_date month of date (the current date) minus 1 month, last month. can done using datediff : select * table datediff ( "m", curr_date, date()) = 1 , curr_date &