Posts

Showing posts from August, 2014

Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

Merge two (or more) lists into one, in C# .NET -

is possible convert 2 or more lists 1 single list, in .net using c#? for example, public static list<product> getallproducts(int categoryid){ .... } . . . var productcollection1 = getallproducts(categoryid1); var productcollection2 = getallproducts(categoryid2); var productcollection3 = getallproducts(categoryid3); you can use linq concat , tolist methods: var allproducts = productcollection1.concat(productcollection2) .concat(productcollection3) .tolist(); note there more efficient ways - above loop through entries, creating dynamically sized buffer. can predict size start with, don't need dynamic sizing... could use: var allproducts = new list<product>(productcollection1.count + productcollection2.count + productcollection3.count); allproducts.addrange(productcollection1); allproducts.addrange(product

When will PowerPivot support automatic relationships in OData? -

i've read powerpivot doesn't support automatic creation of entity relationships when consuming odata feeds. can confirm , aware of powerpivot odata roadmap? coming? thanks, mike yes correct. relationships lost when imported powerpivot. this why best practice expose foreignkey properties data services, way can rebuild relationship in powerpivot. in terms of when / if powerpivot add better support relationships - ( program manager ) on odata team hope so, there isn't firm commitment or timeframe yet.

What is the difference between the ResourceControllerFactory and the DefaultControllerFactory in ASP.NET MVC? -

what difference between resourcecontrollerfactory , defaultcontrollerfactory in asp.net mvc? context: looking hook ioc container controller factory - have overriden defaultcontrollerfactory this, see resourcecontrollerfactory being used in project working with. does 1 provide improved support rest apis? code each: defaultcontrollerfactory public class defaultcontrollerfactory : icontrollerfactory { // fields private ibuildmanager _buildmanager; private controllerbuilder _controllerbuilder; private controllertypecache _instancecontrollertypecache; private static controllertypecache _staticcontrollertypecache; // methods static defaultcontrollerfactory(); public defaultcontrollerfactory(); internal static invalidoperationexception createambiguouscontrollerexception(routebase route, string controllername, icollection<type> matchingtypes); public virtual icontroller createcontroller(requestcontext requestcontext, string contro

How I Can Refresh ListView in WPF -

hi using wpf , adding 1 one record listview.itemssource data appear when data included want added 1 one show me record used listview.item.refresh() did't work. is there way.. thanks... if still need refresh listview in other case (lets assume need update 1 time after elements added itemssource) should use approach: icollectionview view = collectionviewsource.getdefaultview(itemssource); view.refresh();

Magento - Select zip code and address for customer(s) -

how can retrieve address , zip code of 1 or more customers in frontend module? thank you. use following code:- (edited after nice codes @clockworkgeek ) <?php $primaryaddress = mage::getsingleton('customer/session')->getcustomer() ->getprimaryshippingaddress(); $arrcountrylist = mage::getmodel('directory/country_api')->items(); $countryname = ''; foreach($arrcountrylist $_eachcountrylist) { if ($primaryaddress['country_id'] == $_eachcountrylist['country_id']) { $countryname = $_eachcountrylist['name']; break; } } $countryname = mage::getmodel('directory/country') ->loadbycode($primaryaddress->getcountryid()) ->getname(); echo '<br/>street address: '.$primaryaddress->getstreet(); echo '<br/>city: '.$primaryaddress->getcity(); echo '<br/>state/region: '.$primaryaddress-

How to determine if we're at the bottom of a page using Javascript/jQuery -

there nothing called scrollbottom() in jquery, can't $(window).scrollbottom()==0 hope question clear title itself. appreciated. i'm interested in ie7+, ff3.5+ (chrome etc bonus!) thanks! you use function check whether element visible (e.g. element @ bottom of page): function isscrolledintoview(elem) { var docviewtop = $(window).scrolltop(); var docviewbottom = docviewtop + $(window).height(); var elemtop = $(elem).offset().top; var elembottom = elemtop + $(elem).height(); return ((elembottom >= docviewtop) && (elemtop <= docviewbottom)); } i implemented endless scrolling effect (like in facebook) it. you can check each time, user scrolling window: function checkandload(){ if(isscrolledintoview($('#footer'))){ triggersomething(); // } } $(document).ready(function(){ checkandload(); $(window).scroll(function(){ checkandload(); }); });

java - GridBagLayout not placing components at page start -

Image
i using grid bag layout java application, problem is, not placing components in page start. here code using: import javax.swing.*; import java.awt.*; import java.awt.event.*; public class trial extends jframe { jlabel banner; container c; gridbagconstraints gbc = new gridbagconstraints(); gridbaglayout gbl; public trial() { settitle("attendence manager"); seticonimage(toolkit.getdefaulttoolkit().getimage("images/icon.png")); dimension dim= toolkit.getdefaulttoolkit().getscreensize(); setsize(new dimension(dim.width-20,dim.height-100)); c= getcontentpane(); gbl= new gridbaglayout(); setlayout(gbl); banner = new jlabel(new imageicon("images/banner.jpg")); gbc.anchor=gridbagconstraints.page_start; gbc.gridx=0; gbc.gridy=0; gbc.gridwidth=gridbagconstraints.remainder; c.add(banner,gbc); this.setvisible(true); addwindowlistener(new mywindowadapter()); } public static void main(s

Failed to convert a wmv file with ffmpeg -

this command used ffmpeg -i full.wmv -sameq -ab 128 -s 640x480 full.flv ffmpeg version svn-r13582, copyright (c) 2000-2008 fabrice bellard, et al. configuration: --prefix=/usr --libdir=${prefix}/lib --shlibdir=${prefix}/lib --bindir=${prefix}/bin --incdir=${prefix}/include/ffmpeg --enable-shared --enable-libmp3lame --enable-gpl --enable-libfaad --mandir=${prefix}/share/man --enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc --enable-libamr-nb --enable-libamr-wb --enable-x11grab --enable-libgsm --enable-libx264 --enable-liba52 --enable-libtheora --extra-cflags=-wall -g -fpic -dpic --cc=ccache cc --enable-swscale --enable-libdc1394 --enable-nonfree --disable-mmx --disable-stripping --enable-avfilter --enable-libdirac --disable-decoder=libdirac --enable-libschroedinger --disable-encoder=libschroedinger --disable-altivec --disable-armv5te --disable-armv6 --disable-vis libavutil version: 49.7.0 libavcodec version: 51.58.0 libavformat v

visual studio 2008 - _CrtDumpMemoryLeaks truncated output? -

i trying use visual studio's capability detect memory leaks, keep getting truncated output, like: dumping objects -> {174} normal block @ 0x0099adb8, 48 bytes long. data: <h:\najnovije\tru> 68 3a 5c 6e 61 6a 6e 6f 76 69 6a 65 5c 74 72 75 {170} normal block @ 0x0099ad58, 32 bytes long. data: <h:\najnovije\tru> 68 3a 5c 6e 61 6a 6e 6f 76 69 6a 65 5c 74 72 75 object dump complete. what doing wrong? added #define _crtdbg_map_alloc #include <stdlib.h> #include <crtdbg.h> to beginning of code. thank you. this output not truncated. it's meant used in way. try give deeper observation program. can find visual studio (more precisely, ~99% of time) gives same leaking address 0x0099adb8 , 0x0099ad58, if use same test steps. now, need setup data breakpoints break on changes of these 2 addresses. break @ beginning of program, select debug->new breakpoint->new data breakpoint, type in address. in case, need create 2 of them:

JQuery UI sortables display sort order -

i cannot find in jqui documentation how display sort order. want display sort order i.e. 1,2,3, 4, etc visual reference user. sort order updates on sort, not sure how find/get sort order - oh i'm not sorting <li> 's you can youself, recalculate order on each stop event of sortable element: ... stop: function (event, ui) { setorder(); }, ... function setorder() { $("#licontainerid").each(function (index,li) { // set display order here }); }

c# - Prevent Button from inheriting BackColor of Parent -

Image
when have parent control has backcolor other systemcolors.control , have buttons on parent control want drawn in system them. however, when not change backcolor of buttons, it's drawn in color of parent. when change backcolor of button systemcolors.control , isn't drawn in windows theme anymore. the left version systemcolors.control , right without changing backcolor . blown up, looks this. here can see buttons have solid background. any suggestions how can fix this? the effect in image can accomplished creating new .net 2.0 winforms project , changing constructor of form1 following: public form1() { initializecomponent(); var textbox = new textbox(); controls.add(textbox); var button = new button { text = "l", width = 23, height = 18, left = -1, top = -1 }; textbox.controls.add(button); // disable line below default behavior button.backcolor = systemcolors.control; } i unforuantely have access windows 7 @ m

plugins - map from_plugin routes in Rails 3 -

currently running app on rails 2.3.8 , decided move rails 3. have route in routes.rb . actioncontroller::routing::routes.draw |map| map.from_plugin :substruct end i not find equivalent format in rails 3. how modify ? as of rails 2.3 map.from_plugin deprecated auto handles mappings newer plugins. as glongman said in comment questions please check basic substruct app basic demo application allow new substruct plugin fork rails work.

iphone - need to drop pin at two places... current location and events locations -

i need on .... drop pins. current location.... pin drop.... blue.... event location :locations latitude:53.373812...longitude 4.890951 red pin. i did this: @interface addressannotation : nsobject<mkannotation> { cllocationcoordinate2d coordinate; nsstring *mtitle; nsstring *msubtitle; // cllocationmanager *locationmanager; // cllocation *currentlocation; } @end @interface mapviewcontroller : uiviewcontroller <cllocationmanagerdelegate> { iboutlet mkmapview *mapview; addressannotation *addannotation; nsstring *address; cllocationmanager *locationmanager; cllocation *currentlocation; } +(mapviewcontroller *)sharedinstance; -(void)start; -(void)stop; -(bool)locationknown; @property(nonatomic,retain)cllocation *currentlocation; @property(nonatomic,retain)nsstring *address; -(cllocationcoordinate2d) addresslocation; -(void)showaddress; @end //implementation file. #import "mapviewcontroller.h" @implementation a

visual studio 2010 - Compile error using C# automatically implemented properties -

a c# noob, trying use sharpdevelop utility convert vb.net application c#. i noticing automatically implemented properties generating lot of errors. example, take following property: public sqldatetime dateofbirth { get; set; } whenever try access implied underlying module level variable, _dateofbirth, error. error 699 name '_dateofbirth' not exist in current context d:\users\chad\desktop\besi csharp\besi\besi.businessobjects.convertedtoc#\chinavisa.cs 240 13 besi.businessobjects.converted i expand properties declarations out full-fledged properties, should n't necessary , i'd understand why getting error. you cannot access compiler-created backing variable - must use property. compiler-generated backing field named in such way prevent accessing (it not named _dateofbirth , named <dateofbirth>k__backingfield ). access property directly - if need manipulate backing field directly don't use automatically implemented property. jus

xml validation - why did not got any error while validating my xml? -

my xml not getting correctly validated against xsd. expect browser through atleast kind of generic error messages when open xml file my xml file below note.xml <?xml version="1.0"?> <note xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="note.xsd"> <from>jani</from> <heading>reminder</heading> <body>don't forget me weekend!</body> </note> my xsd file below note.xsd <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/xmlschema" targetnamespace="http://www.w3schools.com" xmlns="http://www.w3schools.com" elementformdefault="qualified"><xs:element name="note"> <xs:complextype> <xs:sequence> <xs:element name="from" type="xs:string"/>

deployment - deploy rails app on heroku -

hey i'm afraid should ask rookie question : after push app heroku. got error of no database this command use heroku rake db:migrate my app can run locally no problem, notice database file in development. , test evironment use rails server , localhost:3000 anyone tell me how make database in production mode in heroku. thanks here's heroku log file: here's logs started "/drummers/1" 221.9.247.14 @ sat dec 18 06:17:40 -0800 2010 processing drummerscontroller#show html parameters: {"id"=>"1"} completed in 167ms activerecord::recordnotfound (couldn't find drummer id=1): app/controllers/drummers_controller.rb:11:in `show' i think may due datebase,config file, become use sqlite3 in local test, , migration file development prefix, it's not telling you have no database. it's telling can't find specific record (couldn't find drummer id=1): it's have

php - can you gzip with zlib compression off -

i trying speed website optimization off websites lack in speed. using http://gtmetrix.com/ test website speed. one thing need use gzip compression. spent ages trying work , not figure out going wrong. if click more information in web developer toolbar said gzip enabled decieving isn’t. contacted hosting providers , got following response: unfortunately not, gzip cause load on our hosted servers therefore similar programs cause same strain. so when says enabled, think right in saying need check in php.ini file is: zlib.output_compression off off zlib.output_compression_level -1 -1 zlib.output_handler no value no value ok, assume needs set on allow gzip compression. correct? basically have go dedicated server allow gzip £70 month. so guess asking is: there way using php utillise gzip compression without being enabled hosting provider? have tried many option none successful far. thanks gzip/deflate adds no significant

Change events execution order using jQuery.live() -

i have following piece of code: <html> <head> <script src="myplugin.js" /> <script> $(document).ready(function() { $('#mytable tbody tr').live('click', function() { alert('hi'); }); }); </script> </head> <body> <script> $('#mytable').myplugin(); </script> <table id="mytable"> <tbody> <tr> <td>something</td> </tr> </tbody> </table> </body> </html> myplugin.js code ..... return this.each(function(index, id) { $(id + ' tbody tr').live('click', function() { alert('hello'); }); }); ..... under circustances, order of executiong be: alert('hi'); alert('hello'); but want inverse. it's possible change execution order this? thank you this not prettiest way, postpone first call this: $(document).ready(function() { $(

svn - Can I review incoming changes in TortoiseSVN like in Eclipse before updating? -

the synchronize view of eclipse nice see incoming changes before updating codebase. is there similar feature in tortoisesvn? can compare 2 revisions there, did not find functionality compare working copy (which mix of modified files , files various revisions) head revision easily! use check-for-modifications dialog, click on "check repository" button. show files modified in repository.

actionscript - Calling function in a mxml component from a main flex application -

in main application have viewstack 3 child views. in viewstack change handler, programmatically change selectedchild property. i understand initialize method view not called every time change selectedchild property. tried invoke init method programmatically too.. view1.mxml <fx:script> <![cdata[ public function init():void{ //something } ]]> </fx:script> main.mxml viewstack.selectedchild = viewstack.getchildbyname("viewname") navigatorcontent; var v1:view1 = new view1(); v1.init(); but null pointer error. missing anything? appreciated. beginner here. in main.mxml app, creating new instance of view1 component , need execute init() method of current instance of viewstack. why don't try doing somethig this: var view:view1 = viewstack.getchildbyname("viewname").getchildbyname("yourcomponentid") view1; view.init(); where yourcomponentid component inside navigato

android - Pause/resume mediaPlayer on notification sound -

it's easy detect when phone calls come in (via phonestatelistener), other notification sounds, such email or sms? on devices, these notification sounds mute don't pause running mediaplayer instances, annoying user. ideally, i'd listen notifications play sound, pause playback duration, , resume playback afterwards. you can notified when app wants play audio registering callback on audiomanager.onaudiofocuschangelistener (this handle case of incoming call). specifically, can audiofocus_gain , audiofocus_loss , , audiofocus_transient_loss . android music player source has example of this.

fossil - FossilSCM, ignoring files on add -

i've done research, can't seem figure out. you can set set options have fossil extras ignore files, not fossil add ? configuration options through web interface great, , i'm pleased work extras command, doesn't apply add command? how 1 configure fossil ignore files on fossil add . ? you can use settings ignore-glob command list directories/files ignore comma-separated list. on repository's web interface , go admin menu, select settings , type comma-separated list of directories ignore; example: */*.suo,*/*/bin/*,*/*/obj/* . alternatively, on command line can type fossil settings ignore-glob list applied ignore list, or fossil settings ignore-glob list-of-files . you can create/edit .fossil-settings/ignore-glob @ root of project , insert comma-separated list of files/directories ignore; have not tested this, remember reading online. for example, on command line can do: fossil settings ignore-glob "*/*.suo,*/*/bin/*,*/*/obj/*&q

using xsd.exe to generate c# files, getting error and warnings -

this command i'm running: xsd.exe -c -l:c# d:\documents\dev\sarpilot\docs\schemas\06-141r2\06-141r2.xsd these errors i'm getting: microsoft (r) xml schemas/datatypes support utility [microsoft (r) .net framework, version 2.0.50727.3038] copyright (c) microsoft corporation. rights reserved. schema validation warning: undefined complextype 'http://www.opengis.net/sps/0:parameterdescriptortype' used base comp lex type extension. line 617, position 2. schema validation warning: undefined complextype 'http://www.opengis.net/ows:getcapabilitiestype' used base complex ty pe extension. line 23, position 2. schema validation warning: undefined complextype 'http://www.opengis.net/ows:capabilitiesbasetype' used base complex t ype extension. line 35, position 2. schema validation warning: 'http://www.opengis.net/gml:point' element not declared. line 869, position 2. schema validation warning: 'http://www.opengis.net/gml:polygon' element not

autocomplete - can autocompletebox in WPF handle suggesting multiple values? -

i using autocompletebox , doing search database when value entered. valuememberpath equal "lastname". box handle if id number entered @ point different search. possible? this seems issue within toolkit itself: https://connect.microsoft.com/visualstudio/feedback/details/585770/autocompletebox-bug-valuememberpath-is-null?ppud=0&wa=wsignin1.0#tabs

Change (local) in SQL Management Studio 2008 -

during installation of sql management studio 2008, set default server (local). now, want either change (local)/mysubdirectoryname, or create new 1 located @ (local)/mysubdirectoryname, cannot see can done. is there way can this? thanks. in order change name of sql server instance, need reinstall it. there's no other way this. so in case, best bet install new instance of sql server under new specific instance name.

javascript - Make a whole div clickable in order to launch a _blank document -

how can write _blank statement in location.href call? <div onclick="location.href='http://www.test.com';" style="display:block; height:40px; width:100px; cursor:pointer;"></div> please note: need keep div , treat href container. when clicks should open new browser window, not popup box. <div onclick="window.open('http://www.test.com','new_window');" style="display:block; height:40px; width:100px; cursor:pointer;">test</div>

.htaccess - Rewriting site.com/section.php?username=xyz to site.com/xyz/section -

using following htaccess, have been able rewrite site.com/profile.php?username=xyz site.com/xyz , rewriteengine on rewriterule ^([a-za-z0-9_-]+)$ profile.php?user=$1 rewriterule ^([a-za-z0-9_-]+)/$ profile.php?user=$1 adding following above, rewriterule ^([a-za-z0-9_-]+)/section$ section.php?user=$1 rewriterule ^([a-za-z0-9_-]+)/section/$ section.php?user=$1 did not resolve site.com/section.php?username=xyz site.com/xyz/section . doing wrong here? first of all: manner of speaking rather opposite: rules showed rewrite requests /xyz internally /profile.php?username=xyz , not vice versa. now if want rewrite requests /xyz/section internally /section.php?username=xyz section , xyz variable, try these rules: rewriterule ^([a-za-z0-9_-]+)/?$ profile.php?user=$1 rewriterule ^([a-za-z0-9_-]+)/([^/]+)/?$ $2.php?user=$1

Looking for a new language that supports both interpreted and native compilation modes -

i program in perl, python, c#, c, c++, java, , few other languages, , i'm looking new language use primary when doing personal projects. my current criteria are: can run interpreted language (i.e., run without having wait compile it); can compiled native code; are typed (even if optionally); support macros/templating/code morphing/wtf want call it; has decent number of libraries it, or accessible it; ideas? suggestions? i suggest haskell suits criteria. can run interpreted language? yes, via ghci. can compiled native code? yes. is typed? so. perhaps typed language today, exception of theorem provers agda. support macros/templating/morphing? if use template haskell. optional extension of language however, libraries don't use macros. haven't used template haskell myself can't comment on if it's good. has decent library support? standard library not bad. there hackage, open repository of haskell libraries bit in style of cpan. addit

spring - MethodInvocation always returns null from pointcut expression -

i defined 1 pointcut below: <aop:pointcut id="getalldatacut" expression= "execution(* com.example.test.getalldata(com.example test.user)) , args(usr)" /> when call final object[] methodargs= methodinvocation.getarguements(); i getting null. please give hints. in advance since know arguments sent method, can them parameter aspect method: public void aspect(joinpoint joinpoint, com.example.test.user user) { // thing user } if want add aspect methods different arguments, can remove args expression

.net - BeginReceive in a separate thread -

for reason, need beginreceive on separate thread, example : public void waitfordata() { thread t = new thread(waitfordatathread); t.start(); } public void waitfordatathread() { try { csocketpacket thesocpkt = new csocketpacket(); thesocpkt.thissocket = m_socclient; m_asynresult = m_socclient.beginreceive(thesocpkt.databuffer, 0, thesocpkt.databuffer.length, socketflags.none, ondatareceived, thesocpkt); } catch (socketexception se) { messagebox.show(se.message); } } but i've received error right after beginreceive call, ondatareceived instantly raised, in event call endreceive method, , error thrown : "the i/o operation has been aborted because of either thread exit or application request". but if remove separate-thread part (like directly call waitfordatathread(), without going through waitfordata() method), works fine. if wo

c# - Simple NHibernate subquery - pulling my hair out -

all want lookup value , return in subquery select (select top 1 c.type changetypes c c.typeid = r.changetype) changetype, count(r.requestid) requestcount request r group changetype i can't work life of me... any appreciated! try similar to select (select c.type changetypes c c.type.id = r.changetype.id) rtypes, count(r.requests) rcount request r group rtypes

perl - Reading between certain lines -

i have large file need pull out pieces of information. have found lot of examples on web, cannot work particular instance. have file data.log (below), , need pull out of stats1 counters, including data above. there multiple instances of these stats. cannot seem regular expression match date , stats1, , read until 3 /n/n/n's.... appreciated!!! # data file dec 8 20:00:00 stats1 counter1: 123 counter2: 456 counter3: 789 dec 8 21:00:00 stats2 counter4: 123 counter5: 456 counter6: 789 dec 8 21:00:00 stats1 counter1: 123 counter2: 456 counter3: 789 dec 8 21:00:00 stats2 counter4: 123 counter5: 456 counter6: 789 try reading in paragraph mode: local $/ = ""; while (<>) { print "paragraph: $_"; } i leave figuring out paragraphs , processing want you. output sample data: paragraph: # data file paragraph: dec 8 20:00:00 stats1 counter1: 123 counter2:

reporting services - Adventure works DW deployment error: lgin failed -

when try deploy adventure works dw 2008 cube, following error: ole db error: ole db or odbc error: login failed user 'specialsqlserverserviceaccount'.; 28000; cannot open database "adventureworksdw2008r2" requested login. login failed.; 42000. basically, have account (specialsqlserverserviceaccount) created , used when installing sql server. account given least amount of permissions mssqlserver run of services needed. but alas, not working when try deploy adventure works dw 2008. want know permissions need given service account or roles should add , can this? need least amount of permission thing deploying. try running in ssms... use [adventureworksdw] go create user [specialsqlserverserviceaccount] login [specialsqlserverserviceaccount] go use [adventureworksdw] go exec sp_addrolemember n'db_datareader', n'specialsqlserverserviceaccount' go make sure have login created on server first.

java - GUI Framework for new Windows OSs -

is there swing framework newer windows os's? vista , & 7 apps have different menuing , taskbar thing going , wondering if there gui components utilize new application java. java provides standard , feel across platforms, unfortunately no... can use standard swing api, , classes provided in that apple provides extensions java, allowing access other kinds of buttons, don't think microsoft same.

c# - WCF - Serializing derived classes where base class is base<T> containing fields that are of type <T> -

i have domain objects defined using following pattern... public abstract class baseobject<idt> { private idt id = default(idt); private datetime dtcreatedon; public idt id { { return id; } set { id = value; } } public datetime createdon { { return this.dtcreatedon; } set { this.dtcreatedon = value; } } } public class derivedobject : baseobject<int> { private string sfield1; public string field1 { { return this.sfield1; } set { this.sfield1 = value; } } } these domain objects live in .net 2.0 assembly. have .net 4.0 based wcf service needs utilize derived objects in wcf service methods. the problem base class id field not getting serialized. instance method call public derivedobject getbyid(in

c# - How can I mock up an instance of my main Winform form to test some methods? -

i using moq (which new tdd period). , wanted moq instance of main winforms form test few methods on there. possible? constructor takes object of assembly(). i trying following attempts unsuccessful: var mockmainform = new mock<mainform>(); mockmainform.setup(x => x.assembler).returns(new assembly()); return mockmainform.object; but can't access properties or methods on object once returned. possible do? but errors ( failed: system.argumentexception : expression not method invocation: x => x.assembler @ moq.expressionextensions.tomethodcall(lambdaexpression expression)) mocking using moq mock interfaces , virtual methods of class. assembler property needs defined virtual . in case mocking windows form not mocking - has big bag of win32 stuff make tests brittle. if need unit test , mock form, create interface form needs implement , mock objects need interact form. public interface ihasassembler { foo assembler {get; set;} } public cla

jquery plugins - showing a single qtip when different events of different targets are triggered? -

i have few input , select controls in form each of them have small question mark icon in front of them show tool tip when mouse on gif of excellent jquery jquery.qtip-1.0.0-rc3.js(with jquery-1.3.2.min.js) plug-in : $('#questionmark1').qtip({ content: 'sample content' , style: { name: 'samplestyle' } , position: { corner: { target: 'bottomleft', tooltip: 'righttop'} } }); i want show tool tip when ever corresponding input field focused , hide when blurred . following 1 trick without showing tool tip when mouse on gif $('#questionmark1').qtip({ content: 'sample content' , style: { name: 'samplestyle' } , position: { corner: { target: 'bottomleft', tooltip: 'righttop'} } , show: { when: { target: $('#input1'), event: 'focus'} } , hide: { when: { target: $('#input1'), event: 'blur&#

How to convert sql query with addition and join to linq -

i have working sql query have been trying convert linq past couple of days. have read several posts both here , on various site, have not been successful in of attempts convert working linq query. the parts having problems deal math (adding individual scores total_score value) , getting values schools table can pass them view. here sql query: select bowler_name, school_name, bowler_gm1, bowler_gm2, bowler_gm3, bowler_gm4, bowler_gm5, bowler_gm6, (isnull([bowler_gm1],0)+isnull([bowler_gm2],0)+isnull([bowler_gm3],0)+isnull([bowler_gm4],0)+isnull([bowler_gm5],0)+isnull([bowler_gm6],0)) total_score bowlers join schools on schools.school_id = bowlers.school_id order total_score desc; here far linq query before things start breaking: from s in db.schools join b in db.bowlers on s.school_id equals b.school_id select b; any appreciated. thanks! something should on way. from s in db.schools join b in db.bowlers on s.school_id equals b.school_id select new { bow

abstract syntax tree - How do I add a warning with Groovy AST transformations? -

i see on sourceunit object can adderror(syntaxexception) , how add warning? edit: know how can either cstnode in compilephase.semantic_analysis , or how can add warning having know line number , column number (just adderror function works)? edit 2: tried creating cstnode myself, didn't seem work eclipse didn't show warning. can call geterrorcollector() on sourceunit add warnings 1 of addwarning(...) methods?

c# - Web Client Upload Values -

i want make desktop application enters value in textbox , performs button actions example design application enters value in google search box @ google.com , performs action when 1 presses search button wrote code threw exception remote server returned error: (405) method not allowed. webclient wc = new webclient(); string uri = "http://google.com"; namevaluecollection nvc = new namevaluecollection(); nvc.add("search", "afnan"); byte[] response = wc.uploadvalues(uri, nvc); textbox1.text=encoding.ascii.getstring(response); uploadvalues trying post (by default, @ least; other verbs allowed, still treat body payload). sounds want get query http://www.google.com/search?q=afnan - url-encode "afnan" . note, however, should always observe target site's terms , conditions - in particular section 5: you agree not access (or attempt access) of services through automated means (including use of scripts or web c

java - A problem connecting to a MySQL DB using JDBC -

here's how i'm trying connect: try { class.forname("com.mysql.jdbc.driver").newinstance(); } catch (exception e) { throw new dbconnectionexception(); } try { connection = drivermanager.getconnection(url,username,password); } catch (sqlexception e) { e.printstacktrace(); throw new dbconnectionexception(); } i'm 100% sure url, username, password strings correct. i've connected using external tool (mysql query browser). error receive: com.mysql.jdbc.communicationsexception: communications link failure due underlying exception: ** begin nested exception ** java.net.socketexception message: java.net.connectexception: connection refused ... possibly url issue. if code pointing mysql localhost , try changing localhost 127.0.0.1 on url. e.g.: jdbc:mysql://localhost:3306/my_db to jdbc:mysql://127.0.0.1:3306/my_db and see if works.

cocoa - iOS Background Audio Icon -

i've followed api docs , wwdc videos exactly, play audio in background via audio session (using audioqueue services). works fine, there no "play" indicator displayed in status bar. do have set separately or bug? i think done audio session: // before instantiating playback audio queue object, // set audio session category uint32 sessioncategory = kaudiosessioncategory_mediaplayback; audiosessionsetproperty ( kaudiosessionproperty_audiocategory, sizeof (sessioncategory), &sessioncategory ); // activate audio session immmediately before playback starts audiosessionsetactive (true);

Why is this Perl script using the File::Tail module not working? -

i'm working on simple perl script monitor log file using file::tail module, can't seem module working properly. the idea use on irc, didn't seem work after tinkering interactive interpreter i've narrowed problem down file::tail. i've cut down following basic example monitor file , nothing happens @ when new entries appended file: #!/usr/bin/perl -w use strict; use file::tail; $file = file::tail->new("/var/log/apache2/error.log"); while(defined(my $line = $file->read)) { print "$line\n"; } can suggest problem might be? i've gone through perldoc entry , virtually copied there can't see i've made glaring errors. i'm running ubuntu lucid. is possible permissions error? can user you're running script access /var/log/apache2/error.log ?

iphone - Using resources with the same name in Xcode -

is there way add multiple resources same name xcode project , have 1 of them take priority on others? example: added 2 files, both called icon.png, xcode project. on different folders in file system (folder1/icon.png , folder2/icon.png) , on different groups in xcode. there way tell xcode have folder2/icon.png take priority on folder1/icon.png? , if 1 icon.png exists, use one. thanks. edit (2010-12-23): you can have multiple files same name in xcode project if not in separate folder references, in separate groups. once compiled, app bundle (which flat no folders in it), have 1 copy of file (icon.png). how pick copy of file use? i told can blackberry. works this: compiler go down list of files in project , start adding them app bundle. if sees duplicate, overwrite (or not), files @ bottom (or @ top) have higher precedence , final bundle. this can better solved using folders within resource bundle in xcode project. take here: http://developer.apple.com/library/mac

asp.net mvc - How should I use OpenID to authenticate to WCF Data Services from a Windows Phone 7 app? -

i have windows phone application reading , writing data wcf data services service hosted in , asp.net mvc 3 application. i can configure both client , server necessary. i'd use openid if practical, , once user authenticated on phone should able browse through data associated openid. how should configure client , server make work? to use openid in app should @ using embedded webbrowser control connects provider site (or site can redirect). when openid provider returns site (embedded in browser control) you'd pass necessary identifiers app. there's example of doing twitter app (using oauth) @ http://blog.markarteaga.com/oauthwithsilverlightforwindowsphone7.aspx

r - Change the size of ggplot2 plot in Sweave without making the text/numbers disproportionately large -

i found question changing size of ggplot2 plot in sweave. added sweaveopts{width=3, height=3} , shrink size of plot, doesn't scale down text. in end, of numbers on axes overlap. is there way scale entire ggplot2 plot in sweave don't have manually scale every component in original ggplot2 call? seems should able do, can't find in ggplot2 book or on website. thanks! fwiw, here's call in sweave: \sweaveopts{width=3, height=3} \begin{figure} \begin{center} <<fig=true>>= print(plot.m) @ \end{center} \caption{stuff} \label{fig:stuff} \end{figure} and call generates ggplot2 plot: plot.m <- ggplot(temp, aes(date, spread)) + geom_bar(stat="identity") + scale_x_date(major="years", minor="months") it's sweave faq. google , find gazillion hits. one approach write file pdf (no scaling) , scale on \includegraphics command. looked @ vignette finished couple of days ago wanted approximately wide page , did:

Basic Flow Control in JavaScript -

could you, please, explain me, how write basic flow control in javascript? thank you. flow([ function(callback) { /* */ callback(); /* run next function */ }, function(callback) { /* */ callback(); /* run next function */ }, function(callback) { /* */ callback(); /* run next function */ }, function(callback) { /* */ callback(); } ], function() { alert("done."); }); would work? function flow(fns, last) { var f = last; (var = fns.length - 1; >= 0; i--) f = makefunc(fns[i], f); f(); } function makefunc(f, g) { return function() { f(g) } }

c++ - Derived class vtable corrupted? -

need in root causing vtable corruption issue(not sure if that’s happening). here simplified version of code. class cbase { public: cbase() virtual ~cbase() virtual void base_virtual_fn1() = 0; virtual void base_virtual_fn2(); private: cdata _data; }; class cderived : public cbase { public: cderived(); virtual ~cderived() virtual void base_virtual_fn1(); virtual void base_virtual_fn2(); virtual void derived_virtual_fn1(); virtual void derived_virtual_fn2(); private: // contains vectors , maps, integers, bools. }; when create instance of cderived , call derived class virtual function derived_virtual_fn2 other function gets called i.e. derived_virtual_fn1. calls base_virtual_fnx has no issues. this happens object created on heap , not local object. these classes in shared library. i’m using gcc 3.4.2 on linux (sles 10). there no pragma pack directive in of code , there mix of c , c++ code (extern c used). issue here? i

asp.net - GridView PreRender not firing after RowDeleted -

when deleting gridview row in ui (via linkbutton commandname="delete"), view not automatically refresh , continues display deleted row until take other action (manually refresh page, navigate away , again, etc). in debugger, see row deleted, , both rowdeleting , rowdeleted events fire, gridview's prerender event not fire afterwards (in contrast, prerender event does fire when first loading page, when adding new row, etc). i've used gridviews in similar configurations without having problem, don't see obvious differences. seems process aborting before prerender event, no exceptions being thrown, , stepping off end of rowdeleted event in debugger brings me ui though process completing normally. any ideas should trouble or solution? other possibly-relevant details: gridview bound sqldatasource; data source not declare deletecommand; handle deletion calling stored procedure in rowcommand handler, after rebind gridview databind(), @ point can see gridview

java - System.out.print is overlapping the questions why? -

my problem when run program runs system.out.print right when run second student of overlaps so: "enter second student's name: enter student's score: " instead of "enter second students's name: " "enter student's score: " i can not input data system.out.print method of second student my main code error is: system.out.print("enter first student's name: "); name = reader.nextline(); student1.setname(name); (int = 1; <= 3; i++){ system.out.print("enter students's score: "); score = reader.nextint(); student1.setscore(i, score); } system.out.print("enter second student's name: "); //overlaps(stays on same line) //also wont let me enter data here name = reader.nextline(); student2.setname(name); (int = 1; <= 3; i++){ system.out.print("enter students's score: "); //program skips here input //data score = reader.nextint(); student2.setscore(i, sc

javascript - How to get file creation date on server for jQuery/uploadify? -

i using jquery uploadify plugin on web page transfer files local computer asp.net mvc2 control action method. there way transfer creation date/time of file server? i can @ data in uploadify event on client, can not figure out how "package" data moved server w/ file. any thoughts appreciated. try using onselect event add values scriptdata object. update: following ad-hoc view pass data action. appears modificationdate returns unix timestamp in it's time field , you'll have convert on server side. wasn't able find documentation on modificationdate property. <%@ page language="c#" inherits="system.web.mvc.viewpage<dynamic>" %> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>home</title><l

php - save image in local machine -

i have made application convert text image format how save converted image in local machine, i assume using gd image functions create image? if getting php display image, can encourage browser download instead adding header('content-disposition: attachment; filename="filename.fileext"'); top of file. encourage browser pop download box. filename attribute name browser prompt save image as

asp.net mvc - MVC Entity Framework Model not returning correct data -

run strange problem while writing asp.net mvc site. have view in sql server database returns few date ranges. view works fine when running query in ssms. when view data returned entity framework model, returns correct number of rows of rows duplicated. here example of have done: sql server code: edited: (table a) create table [dbo].[a]( [id] [int] not null, [phid] [int] null, [fromdate] [datetime] not null, [todate] [datetime] null, constraint [pk_a] primary key clustered ( [id] asc, [fromdate] asc )) on [primary] create table [dbo].[b]( [phid] [int] not null, [fromdate] [datetime] null, [todate] [datetime] null, constraint [pk_b] primary key clustered ( [phid] asc )) on [primary] go create view c select a.id, case when a.phid null a.fromdate else b.fromdate end fromdate, case when a.phid null a.todate else b.todate end todate left outer join b on a.phid = b.phid go insert b (phid, fromdate, todate) values

python - uploading file using urllib2 -

i'm new python , i'm writing code upload file using urllib2 can't make work. here's code: class get(object): handlers = list() def __init__(self,url): self.url = url self.request = urllib2.request(url) self.request.add_header('user-agent',"mozilla/5.0 (x11; u; linux i686; en-us; rv:1.9.2.13) gecko/20101203 firefox/3.6.13") def auth(self,username,password): pass_mgr = urllib2.httppasswordmgrwithdefaultrealm() pass_mgr.add_password(none, self.url, username, password) handler = urllib2.httpbasicauthhandler(pass_mgr) self._add_handler(handler) def perform(self): try: opener = self._opener() res = opener.open(self.request) to_return = { 'code': res.code, 'contents': res.read(), 'url': res.geturl(), 'headers': dict(res.info()) }

Has Anyone Got HTTP Compression Working with ASP.NET? -

i've spent quite bit of time on seem going nowhere. have large page want speed up. obvious place start seems http compression, can't seem work me. after considerable searching, i've tried several variations of code below. kind of works, after refreshing browser, results seem fall apart. turning garbage when page used caching. if turn off caching, page seems right lose css formatting (stored in separate file) , error included js file contains invalid characters. most of resources i've found on web either old or focused on accessing iis directly. page running on shared hosting account , not have direct access iis7, it's running on. protected void application_beginrequest(object sender, eventargs e) { // implement http compression if (request["http_x_microsoftajax"] == null) // avoid compressing ajax calls { // retrieve accepted encodings string encodings = request.headers.get("accept-encoding"); if (enc

crystal reports - Access crosstab formula field in another crosstab column? -

Image
how access crosstab formula field in column? have report dues & total both formula fields: amount dues(done formula) total (done formula) ------ ------------------------- --------------------------- 500 20 % someamount formula dues: whilereadingrecords; numbervar due:={command.somefield)/100; due formula total: whilereadingrecords; numbervar total:= {command.amount} - due; total how access due field inside second formula each row of record? just use {@formulaname} (see image below) crystal syntax simple simple formulas. sample formulas, don't need declare variables or use whilereadingrecords. (both have uses, sample formulas, unneeded). again, see image below example.

domain driven design - EAV within entity framework 4 and ddd -

some tables in database designed using eav concept. use entities auto generated , represent "static" tables (not "eav" tables) orm entity framework ddd objects. how can use "eav" entities in object model (not in relational in database) using entity framework? for example, in database have static table report , eav tables me store reportproperty report. in domain model want have report that: report { icollection<reportproperty> reportproperties{get;set;} } i can use report entity generated entity framework , in partial section realise logic in getter retrieving data eav tables fill collection reportproperies. begs next question. what can if decide use nhibernate instead entity framework, because can`t use partial section realize using entity framework? if use ddd objects, can use entity framework or nhibernate, hardly me, because need call mapping procedures in each procedures in dao. eav concept of data access

regex - javascript: get url path -

var url = 'http://domain.com/file.php?id=1'; or var url = 'https://domain.us/file.php?id=1' or var url = 'domain.de/file.php?id=1'; or var url = 'subdomain.domain.com/file.php?id=1' from either 1 of these urls want only path , in case above: var path = '/file.php?id=1'; you could regex, using these native properties arguably best way it. var url = 'subdomain.domain.com/file.php?id=1', = document.createelement('a'); a.href = 'http://' + url; var path = a.pathname + a.search; // /file.php?id=1 see on jsfiddle.net

How to make an application compatible in all Android phones? -

pls me solve issue.. in of application ui design not compatible android devices.. ie..all widgets not aligning in proper order in phones.. want develop application should fit phone size , resolution ( large phones, normal ones , in small ones) ..pls resolve issue... thanks in advance... that may not possible. can @ these links , learn how provide different images(pixels , density), layouts , further on. may not possible make userinterface on low level density screen same way high density screen , can target different layouts different phones e.g. providing resources application resources

C# equivalent of C++ std::string find_first_not_of and find_last_not_of -

indexof , indexofany , lastindexof , lastindexofany dont seem these (or maybe do). i'm looking equialent of std::string's find_first_not_of , find_last_not_of . i'm thinking creating extension class i'm not sure if c# provides functionality. string source = "the quick brown fox jumps on lazy dog"; string chars = "ogd hte"; int? firstnotof = source.select((x, i) => new { val = x, idx = (int?)i }) .where(x => chars.indexof(x.val) == -1) .select(x => x.idx) .firstordefault(); int? lastnotof = source.select((x, i) => new { val = x, idx = (int?)i }) .where(x => chars.indexof(x.val) == -1) .select(x => x.idx) .lastordefault(); or, if prefer non-linq extension methods. these should have better performance, findlastnotof : int? firstnotof = source.findfirstnotof(chars); int? lastn

visual c++ - get %APPDATA% path using c++ -

hey guys, want path %appdata% folder. in win 2000 & xp it's in: c:\documents , settings\user name\application data in vista & win7 it's in: c:\users\user name\appdata\roaming i know there function shgetspecialfolderpath retrieves bool , want path string. can 1 help? the third parameter of shgetspecialfolderpath() , named lpszpath , marked __out . something should do: // beware, brain-compiled code ahead! wchar_t buffer[max_path]; bool result = shgetspecialfolderpath( hwnd , buffer , csidl_local_appdata , false ); if(!result) throw "you'll need error handling here!"; std::wcout << buffer; note: haven't done win api work in years. comes along shortly pointing out blew it.

c++ - How to define where libs are loaded from -

i trying compile omniorb on aix 6.1 gcc 4.2.0. the initialization not work picking non pthreaded library. if set libpath /opt/freeware/lib/gcc/powerpc-ibm-aix6.1.0.0/4.2.0/ omninames not work, streams interface gives exception. setting libpath /opt/freeware/lib/gcc/powerpc-ibm-aix6.1.0.0/4.2.0/pthread seems work, other non pthreaded programs pick pthreaded lib may cause problems... the link looks this: g++ -o omninames -o2 -wall -wno-unused -fexceptions -wl,-brtl -wl,-blibpath:/lib:/usr/lib:/opt/dbx/omniorb-4/lib -l../../../lib -l../../../../lib omninames.o namingcontext_i.o log.o omninameswin.o -lomniorb4-ar -lomnithread34 -lpthreads how resolve ?? note have tried change libpath using configure arguments without success. launching via wrapper script set libpath correctly easiest. then there runpath/rpath feature of elf allows embded search path dynamic libraries in executable; don't know if aix implement it. it , set same argument linux , solaris, -wl

Partition of tables in MySQL -

i have read in case table has many columns, of time 1 of them used (say title column in forum post), way increase performance partition 2 tables, 1 contain title , other 1 contain other columns (such forum post body). however, in case use select forumtitle forum; won't enough prevent load of columns (such forum post's body) memory, , eliminate need of partition? thanks, joel no. idea of partitioning table resulting table smaller; fits on fewer pages. therefore if mysql needs access data freqeuently chances requested data containting forumtitles in memory bigger. if table contains lot of fields, more pages need cached in memory cache same amount of forumtitles. mysql stores columns of row sequentially on page , cannot load nor cache part of row.