Posts

Showing posts from January, 2010

java - Spring from scratch - Bug on context:property-placeholder -

i'm doing test on very, simple application using spring . my app have have one bean , i'm injecting simple string class , printing value. so far working . what need: i want string configuration file, create file inside /src/main/resource what did: 1) on application-context.xml add: <context:property-placeholder location="classpath:myconfigfile.properties" /> 2) on application-context.xml change simple string use ${name_test}: <bean id="hello" class="com.dummy.sayhello"> <property name="name" value="${name_test}" /> </bean> 3) double check myconfigfile.properties , contains "name_test=jacktheripper" 4) output not 'translating' value config file, have output when run app: hello ${name_test} and i'm stuck here, clue, tips??? just fyi i use this tutorial tests, maybe help. i add log4j maven dependencies , log4j config file , works fin

c# - Creating new object then reallocating -

a question builds upon to "new" or not "new" foo object1 = new foo(); // operations later ... object1 = new foo(); is i'm attempting advisable? , if foo implements idispoable, need call dispose before calling new operator second time? yes, you're doing in example fine. the object1 variable reference object of type foo . after first new assignment refers 1 particular instance of foo ; after second new assignment refers different instance (and original instance becomes eligible garbage collection, assuming there's nothing else referencing it). and yes, if foo implements idisposable should dispose it, preferably using using block, although personal preference use separate using variables each block: using (foo first = new foo()) { // } using (foo second = new foo()) { // else }

c# - Design Guidelines for Heavy string operations -

in current project, working on word processing & highlighting solution. typically every call class processing approximately 4000-5000 words long strings. the structure looks this public string parsetext(string inn) { //heavy parsing } public string highlighttext(string inn) { var cleaned = cleanuptext(inn); var parsed = parsetext(cleaned ); //highlight algorithm var formatted= parsetext(parsed); return formatted; } public string cleanuptext(string inn) { //heavy parsing } public string formattext(string inn) { //heavy parsing } so feel passing around same string around different methods decreases performance. though string reference type, creates new string , allocates new memory each passed variable due immutability nature of it. different other user generated

php - IPhone App ajax request Problem -

hello using cross domain ajax plugin send request server using iphone. but when complie code xcode behaving strange. some time send request server. time doesn't send reuest. some time got response request , time not able reponse pls. help if there other way send data server using javascript pls. tell me thanks if native app, use nsurlconnection. read on here: url loading system programming guide if it's web app, javascript best way transmit data bi-direcionally asynchronously. if doesn't matter you, can use pure php , refresh page each time, although may not optimal user experience.

android - How to sync my app with photos -

i build custom gallery photos only. taking photos sdcard class: public class photos { public static final string photo_bucket_name = environment.getexternalstoragestate().tostring() + "/dcim/camera"; public static final int photo_bucket_id = getbucketid(photo_bucket_name); public static int getbucketid(string path) { return path.tolowercase().hashcode(); } public static list<string> getphotos(context context) { final string[] projection = {mediastore.images.media.data}; final string selection = mediastore.images.media.bucket_id; cursor c = context.getcontentresolver().query(images.media.external_content_uri, projection, selection, null, null); list<string> result = new arraylist<string>(c.getcount()); if (c.movetofirst()) { int datacolumn = c.getcolumnindexorthrow(mediastore.images.media.data); { string data = c.getstring(datacolumn); result.add(data); } while (c.movetonext()

flex3 - Issue in chrome when using cursormanager(Its Displaying both custom cursor and normal mouse pointer) -

i using cursor manager set hand cursor overlay. its works fine in mozilla firefox , ie8, in chrome shows hand cursor , normal mouse pointer, here code import mx.managers.cursormanager; import mx.managers.cursormanagerpriority; [embed(source="/assets/images/cursor_hand.gif")] public var handcursor:class; renderer.addeventlistener(mouseevent.mouse_over, function(event:mouseevent):void{ cursormanager.setcursor(handcursor,cursormanagerpriority.high, 3, 2); }); renderer.addeventlistener(mouseevent.mouse_out, function(event:mouseevent):void{ cursormanager.removeallcursors(); }); am missed here? using flex builder 3 , flash player 9. access this link in chrome , check whether seeing custom cursor alone. if no, try update flash player version.i have version have version 10,0,45,2 , seeing custom cursor in chrome.

php - Get parameters and folders depth in a path -

how can take url path , break the params, in case param1=1 , param2=2 the end script, levele the middle folders in script levela, levelb, levelc, leveld . http://test.com/ levela/ levelb/ levelc/ leveld/ levele ? param1=1 & param2=2 another example this, folder depth different, , number of parameters different: http://test.com/ levela/ levelb/ levelc/ leveld ? param1=1 & param2=2 & param3=3 use parse_url() split url, , parse_str() split query string components. the levela/levelb/levelc part best split using explode() .

php - Trouble adding custom javascript to a wordpress theme -

i've got wordpress site trying add custom javascript bit of functionality. can't seem javascript work. i've stripped javascript alert. i've looked around , seems should able add following functions.php make work. <?php wp_enqueue_script('schedule', get_bloginfo('template_url') . '/schedule.js',array('jquery'),'1.0',true); ?> then current javascript function looks following now. jquery(function(){alert('asd');}); what missing/what forgetting? able add css file in exact same fashion little confused not working.

iPhone and Android monthly payment - best ways -

i have write monthly payment these 2 platforms 1 of clients. my question is: can use paypal payment iphone kind of payment? (not buying itunes, paying subscribtion). what other payment services providers recommend? (for example: in-app purchase iphone, else android, etc.) what can recommend me use library (i saw paypal x, example?) thanks in advance, danail yes. can use paypal. other services include: google checkout amazon payment services paypal x good

oracle - "audit create session by session" vs. "audit create session by access"? -

when enabling auditing create session following way: audit create session session; then querying following: select * dba_priv_audit_opts; the result is: username | proxy_name | audit_option | success | failure | ............................................................... - | - | create session | access | access| but, when enabling auditing create session following way: audit create session access; then querying following: select * dba_priv_audit_opts; the result same: username | proxy_name | audit_option | success | failure | ............................................................... - | - | create session | access | access| why? have idea? 11gr2 , above: by session disabled , auditing done per access. 11gr1 , below: the difference between by session , by access when specify by session oracle try merge multiple audit entries 1 record when session , action audited match. it works sql s

javascript - Receiving returned message from web socket in another browser -

i have 2 separate pages, each opens web socket server, 1 pages fires message server, there way other page can receive reply? appreciated. thanks first page, connects , waits message <html> <head> <script type="text/javascript" charset="utf-8"> if("websocket" in window) { var ws = new websocket("ws://localhost:12345/server.php"); } function startsocket() { if("websocket" in window) { ws.onopen = function (event) { document.getelementbyid('status').innerhtml = "open: " + this.readystate; } ws.onmessage = function (message) { alert(message.data); } } } </script> </head> <body onload="startsocket()"> <div id="status"> </div> <div id="stock"> </div> </body> </html> second page sends mes

Updating array values (Appcelerator Titanium Mobile) -

i'm using both 1.5.1 , 1.6.0 test apps on os x. i'm trying update values in array: var mytab = [ {title:'foo1',value:'bar1'}, {title:'foo2',value:'bar2'} ]; if update value field in array, doesn't (which isn't normal): titanium.api.info('before :' + mytab[0].value); mytab[0].value = 'updated!'; titanium.api.info('after :' + mytab[0].value); it displays 'bar1' instead of 'updated!'. tried next put tab property list: titanium.app.properties.setlist('proptab',mytab); and then, tried same thing: titanium.api.info('before :' + titanium.app.properties.getlist('proptab')[0].value); titanium.app.properties.getlist('proptab')[0].value = 'updated!'; titanium.api.info('after :' + titanium.app.properties.getlist('proptab')[0].value[0].value); same result: displays 'bar1' instead of 'updated!'. is there solution? t

flex4 - Workaround for AdvancedDataGrid flicker in Flex Hero 4.5.0.19786 -

since updated latest build of flex hero (4.5.0.19786) advanceddatagrids flicker in design view flash builder burrito preview. has run , if there work-around besides dropping version? update 02 19:29 did not occur in previous hero builds, e.g 18623. using default spark theme, nothing else particularly special. update 01 19:15 i tracked down problem instance of custom (default custom, i.e result of doing new->component based on advanceddatagrid) on same form. the component declaration: <?xml version="1.0" encoding="utf-8"?> <mx:advanceddatagrid xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx"> <fx:declarations> <!-- place non-visual elements (e.g., services, value objects) here --> </fx:declarations> </mx:advanceddatagrid> the custom component instantiation. note "fo&q

iphone - Mac OS .deb packaging trouble -

i've searched lot, didn't find solution. i need package ios app .deb . have installed mac ports , dpkg , have control file in debian folder in myapp folder run /opt/local/bin/dpkg-deb -b myapp , error. dpkg-deb: ignoring 3 warnings control file(s) can't use format gnu: no such format 'gnu': invalid argument there topic: how create .deb packages on mac os x , no answer question.

java - Field initialization in class constructors: direct or through "setter"? -

i working on java project after period using c++ , c#, , have doubt best practices field initialization in constructors. basically, suppose have simple point class. in c++ field initialization in constructor like: class point { public: // default constructor point(double x, double y) : x(x), y(y) { } protected: // coordinates double x, y; }; in c# ... class point { // coordinates, automatic properties public double x { get; protected set; } public double y { get; protected set; } // default constructor point(double x, double y) { x = x; y = y; } } in java ... best practices suggest define getters / setters fields must accessed outside. advisable use them inside class well? doubt comes fact eclipse seems comfortable converting each this.field = field in class code setfield(field) fields have getters / setters, if reading / writing happens inside class code (therefore wouldn't need use class interface). this

Android - how to add a dynamic image to activity -

i have activity not have xml layout file. items added when needed. not in need add image , doesnt seem anything... imageview iv = new imageview(this); iv.setscaletype(imageview.scaletype.fit_center); bitmap bm = bitmapfactory.decodefile(environment.getexternalstoragedirectory()+"/pics/pic_1.jpg"); iv.setimagebitmap(bm); ll.addview(iv); the image in correct folder...11 @ end linear view adding image view too...am missing something? you can use debugger see if image loaded correctly. , have tried set layout params on imageview. because in case wouldn't take space (i think). try like: ll.addview(iv, new linearlayout.layoutparams(layoutparams.wrap_content, layoutparams.wrap_content)); or use exact sizes instead of layoutparams.wrap_content

streaming - Stream an audio .pls in android -

i'm making radio application uses streaming. here need stream audio link ( http://somedomain/some.pls ). i have created mediaplayer , know how play audio file. don't know how stream net. edit : logcat got while used following code mediaplayer mp = new mediaplayer(); mp.setdatasource(http://somedomain/some.pls); mp.prepare(); mp.start() by log tag **mediaplayer** 02-15 05:50:11.761: verbose/mediaplayer(23715): constructor 02-15 05:50:11.761: verbose/mediaplayer(23715): setlistener 02-15 05:50:11.761: info/mediaplayer(23715): uri is:http://some:444/sdfd.pls 02-15 05:50:11.761: info/mediaplayer(23715): path null 02-15 05:50:11.761: debug/mediaplayer(23715): couldn't open file on client side, trying server side 02-15 05:50:11.765: verbose/mediaplayer(23715): setdatasource(http://some:444/sdfd.pls) 02-15 05:50:11.777: verbose/mediaplayer(23715): prepare 02-15 05:50:13.105: error/mediaplayer(23715): message received msg=3, ext1=

php - curl error: couldn't connect to host -

i trying use curl proxy. have following code: function getpage($proxy, $url, $referer, $agent, $header, $timeout) { $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_header, $header); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_proxy, $proxy); curl_setopt($ch, curlopt_httpproxytunnel, 1); curl_setopt($ch, curlopt_connecttimeout, $timeout); curl_setopt($ch, curlopt_referer, $referer); curl_setopt($ch, curlopt_useragent, $agent); $result['exe'] = curl_exec($ch); $result['inf'] = curl_getinfo($ch); $result['err'] = curl_error($ch); curl_close($ch); return $result; } $result = getpage( '75.125.147.82:3128', // use valid proxy 'http://www.google.com/', 'http://www.google.com/', 'mozilla/5.0 (windows; u; windows nt 5.1; en-us; rv:1.9.0.8) gecko/2009032609 firefox/3.0.8', 1, 5); if (empty($result['err'])) { echo $results['exe']; } else { echo $result['

.net - Rtf to WordML Convert in C# -

i have windows application generate report. has templates in rtf " {\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil\\fcharset0 arial;}}\r\n\\viewkind4\\uc1\\pard\\fs20\\tab\\tab\\tab\\tab af\\par\r\n}\r\n" , written word doc file. word saved-as xml , close. then, tags (say) extracted , new the problem here word, used converter in process , consumes valuable time in loop, opens word instance, save, close, delete. please correct mistake if have made , me alternative convert wordml . use aspose .words //your rtf string string rtfstrx = "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil\\fcharset0 arial;}}\r\n\\viewkind4\\uc1\\pard\\fs20\\tab\\tab\\tab\\tab af\\par\r\n}\r\n" //convert string bytes memory stream byte[] rtfbytex = encoding.utf8.getbytes(rtfstrx); memorystream rtfstreamx = new memorystream(rtfbytex); document rtfdocx = new document(rtfstreamx); rtfdocx.save(@"c:\temp.xml", saveformat.wor

javascript - JS function execution order -

i have 2 pages namely parent.xhtml (controls layout) , child.xhtml (displays content). child page included in parent page using <iframe> tag. i need implement onload functionality using javascript. before that, want know in order javascript functions execute? will parent page js function execute first? or child page js function execute first? awaiting answers.! in advance according previous answer , browsers might not wait iframes load before firing onload event on parent window. can't make assumptions on 1 complete first - there's possibility of race condition going on there, either 1 finish first. one solution might write function waits until it's been called number of times before executing: var runs = 0; function onload() { if (++runs < 2) return; // put code execute once both have loaded } then in html: <body onload="onload();"> ..... <iframe onload="onload();"> alternatively, set ur

java - Best REST Client Framework/Utility on Android -

i'm build android application use restful web service. don't want write rest client myself, want effective , stable possible (this first time i'm using rest). are there (free) frameworks or utilities avaibale android/java can use in project? restlet excellent rest framework , has android edition.

T4 for Sharp Architecture/Northwind Problem -

i have downloaded sharparchitecture/northwind , i'm trying crud scaffolding work. have changed nothing except adding missing reference class library. try run scaffoldinggeneratorcommand.tt , hit following 3 errors. error 1 compiling transformation: invalid token 'this' in class, struct, or interface member declaration file:basetemplate.tt error 2 compiling transformation: class, struct, or interface method must have return type file:basetemplate.tt error 3 compiling transformation: type expected file:basetemplate.tt compiler says occur in first line of basetemplate.tt don't think true reason. has had problem? have idea can fix it? thanks lot time, pk i have received using other t4 templates. problem ends being spaces @ end of file (following last '#>' ). open .tt file in vs, ctrl+end, make sure spaces removed following last #> string somemethod() { //some code return "somevalue";

osx - Qt OS 10.6 build not running on OS 10.5 and less -

this issue has been queried twice before separate people, there have been no answers. so, i'm posting, again: building qt4.7 on 10.6.6, xcode 3.2.5, g++-4.2 flag '-mmacosx-version-min=10.4', i'm presuming taking care of dirty work, underneath. when bring on 10.5, crashes right out of box this: <... process identification info removed ...> exception type: exc_breakpoint (sigtrap) exception codes: 0x0000000000000002, 0x0000000000000000 crashed thread: 0 dyld error message: symbol not found: __zst16__ostream_inserticst11char_traitsiceerst13basic_ostreamit_t0_es6_pks3_i referenced from: /applications/myapp.app/contents/macos/myapp expected in: /usr/lib/libstdc++.6.dylib has come resolution on this? you need specify -sdk /developer/sdks/macosx10.4u.sdk in configure line when building qt itself. minimum version option trigger pre-processor macros limit apis 10.4 level. note may stop building 64-bit binaries. not sure.

jaxb2 - Debugging JAXB issues -

i running issue jaxb 2 when marshaling objects. have xmljavatypeadapter working fine in unit tests, when try marshal same object graph web service (using jax-ws), xmljavatypeadapter being ignored completely. what's easiest way debug problem? i have simple standalone project checked svn repository demonstrates issue. can please take see if doing wrong? url project is: http://archfirst.googlecode.com/svn/trunk/java/examples/jaxb-jaxws-sample . there readme.txt file in root folder describes issue in detail. thanks. ok, found problem. unit test picking jaxb implementation in java runtime, whereas web service picking jaxb implementation glassfish. apparently implementation bundled glassfish (2.2.1.1) cannot handle use case. proved forcing unit test use jaxb-impl-2.2.1.1.jar. seems bug has been fixed in latest jaxb implementation (2.2.3-1), struggling figure out how replace glassfish's implementation new version (see post here ).

tfs2010 - TFS - Work Items - Is it possible to set a state from any other state without creating all the transitions? -

we have custom workflow 8 work item states... , wanted 9th 1 called "cancelled". could, in theory, cancelled @ point of development. is there way create state can come other state without having create 8 transitions ? thanks in advance ~ no, need add 8 transitions.

ruby - Problem installing RVM -

i have executed commands prescribed in instructions @ rvm website things don't seem work.. fetching code git repository runs smoothly when try use rvm notes error: /usr/local/bin/rvm: line 73: /home/cody/.rvm/scripts/rvm: no such file or directory flashes in multiple lines , doesn't stop till hit ctrl+c.. running ubuntu 8.04 , running ruby 1.9.2.. sorry, if missing out necessary information. in advance. ack, didn't mean post comment on question. anyway, if had guess, i'd installed rvm using sudo or root. if case, remove it , reinstall without sudo: sudo rm -rf $home/.rvm $home/.rvmrc /etc/rvmrc /etc/profile.d/rvm.sh \ /usr/local/rvm /usr/local/bin/rvm sudo /usr/sbin/groupdel rvm # might fail, it's not important open new terminal window/tab , make sure rvm removed: env | grep rvm the output should empty, it's needed relogin, after it's empty can continue: curl -ssl https://get.rvm.io | bash -s stable it works fine instal

Javascript Problem! Not changing the css style -

i have code in javascript: function change() { document.getelementbyid("mem").classname = 'gif'; } the fig , gif this: a.fig { background: #ffffff; } a.gif { background: #000099 ; } and function used <a class ="fig" id ="mem" onclick="javascript:change()" href="users" > where difference between gif , fig in css have different background colors. problem change noticeable in second , not permanent! any ideas? function change() { var mem = document.getelementbyid("mem"); if (mem.classname == 'fig') { mem.classname = 'gif'; } else { mem.classname = 'fig'; } }

java - Is Spring Roo only for making the skeleton of a site? -

after many problems, have set roo simple example. now want know how far should 1 go roo. i mean likes fields, classes, can done through roo shell. now, example, have 15 classes in project. i'm confused - point should make classes roo shell , when should leave roo , start working normal? also, roo has own gui , layout design. can change also? i use roo generate models, controllers , scaffold, strip out large chunk of scaffold can put own components in there , of controllers still need write hand. when reach point have interface generated roo, start hacking away , use roo add new domain models.

jquery - Unload plupload from a div -

i'm using plupload with $("#plupload_div").pluploadqueue({ // general settings runtimes : 'flash,html5', url : '/products/save_photo', max_file_size : '10mb', //chunk_size : '1mb', unique_names : true, resize : {width : 558, height : 418, quality : 90}, multipart: true, multipart_params : {"photo[variant_id]" : variant_id, authenticity_token : atoken}, filters : [ {title : "image files", extensions : "jpg,gif,png"}], flash_swf_url : '/javascripts/plupload.flash.swf', }); what have unload plupload element #plupload_div? $('#plupload_div').unbind(); does help? calling unbind() without args removes handlers attached elements

database - How to add columns to a view in SQL Server 2005 -

i have no experience sql server 2005. i've been assigned task modify views adding 4 columns view. possible without column change reflected in table view referring. if have columns in table, should drop view , create new 1 or there way alter it. you can use alter view achieve result looking for. this act dropping existing view , adding new columns new select statement. however, better dropping existing view , creating new view because alter view retain permissions granted users.

css - Collapsing a Menu with JQuery -

i working on jquery menu needs expand , collapse. however, i'm having issues getting sub-menus line like. basically, want sub menu items in-line top-menu items. however, stands now, entire sub-menu item indented. code looks following: html <ul id="themenu"> <li><a title="open or close section" href="#">info</a> <ul> <li><a href="#">basic</a></li> <li><a href="#">advanced</a></li> </ul> </li> <li><a title="open or close section" href="#">documents</a> <ul> <li><a href="#">newsletters</a></li> <li><a href="#">policies , procedures</a></li> <li><a href="#">job descriptions</a></li> </ul> </li> <

c# - Fast access to key in file (without loading whole file to memory) -

background: writing c# application windows mobile search definitions (scientific) dictionary filesystem. file looks (file has 100k+ entries): word1:meanings(2) -meaning 1 bla bla bla -meading 2 bla bla bla [...] the user should able enter word , meaning fast possible. users 1 or 2 words. this, created second file sorted list actual word , byte-offset in dictionary file. example: word1:12344 word2:32241 word3:298 i through "index" (simple loop through lines , compare if equal) , "random-access" dictionary file using byte-offset. problem is, still slow. tried loading index array/list/hashtable due slow io, takes long (about 20 seconds load index). bad because user 1 word. therefore, looking type of n-tree implementation can work directly on file (without traversing whole index). has advise how this? current solution looks (but buggy , dirty): new index has format: a:fileoffsetindictionary:fileoffsetof"ab" //the first 2 character starting b:f

ajax - Ext JS auto complete field with additional post variables -

i using ext js combobox in example: stackoverflow: how 1 html input tag autocomplete in ext.js? it works perfect sending simple query on post server. (firebug output: query=smth) but have bit different use case. want send additional information server. like: query=smth&variableid=8&somemore=xy. of course add variables url of jsonstore , send on get. wondering if there params object can specify custom variables , considered request. thank time. yes. can define store with baseparams: { thiswillbeaddedtoeachrequest: 'foo' } or can use beforeload listener listeners: { beforeload: funciton(store) { store.setbaseparam('paramtobesetbeforeeachrequest',somevariable); } }

performant ordering of keys in a MySQL compound index (WRT Rails Polymorphic associations and STI) -

previously, asked this question compound indexes on polymorphic foreign keys in activerecord . basis of question understanding indexes should based on cardinality of column, , there's pretty low cardinality on rails's sti type , polymorphic _type columns. accepting answer question right -- that's there's value indexing both high cardinality _id columns , low cardinality _type columns, because have high cardinality -- next question is: how should order compound indexes? an index of [owner_id, owner_type] places field higher cardinality first, while [owner_type, owner_id] places field higher cardinality second. query using former key more performant query using latter key, or equally performant? i ask because has particular bearing on how order compound keys tables serving sti models. sti rails finders query on type column -- again column of low cardinality. type column therefore queried more other indexes. if type column queried more often, maybe makes

Rails - Get the current url without the GET parameters -

request.url returns me : http://localhost:3000/page?foo=bar . is there method can call http://localhost:3000/page , or have parse string strip parameters? request.path should return you're looking if you're not concerned hostname. otherwise might try: url_for(:only_path => false, :overwrite_params=>nil)

android - Enter text into an EditText which then disappears when user clicks inside it -

i grateful if explain if possible enter text edittext. (this done android:text="" ) but text disappear when user clicks inside it. thanks this can done using hint: android:hint="the text want"

objective c - Re-Installing IPhone App From Inside The App -

i want find way if it's possible re-install iphone app inside it? let's users have app installed in phones , new version released, can make app such check on internet if new version available , if is, download , ask user install it. if user says yes, first un-install current version , install downloaded version. is possible anyhow? probably not because uninstall app requires app closed

php - Multiple Magento Environments -

we have magento store setup , under version control, we'd setup staging store uses same code different connection details. e.g. live details live store , staging database staging. is possible magento, there doesn't seem way default? tom, since using version control, i'd suggest not have same files both staging , production. that's bad idea. ideally, should have different environment staging , production, both having own set of files, , own database. way, don't have worry hurdle experiencing now.

c# - Capturing a Screenshot of a Flash Application loaded in the browser -

i know possible access flash application object loaded in default web browser , programatically screenshot of application only. you can use bitmapdata.draw(/*your main displayobject*/) inside swf

How can I format (pretty print) a multi-dimensional array for debugging? -

i've seen online pretty print modules code. know of 1 format multi-dimensional array readable display? example, translate this: array(83) { [0]=> array(2) { ["name"]=> string(11) "ce2 options" ["type"]=> string(5) "title" } [1]=> array(1) { ["type"]=> string(4) "open" } [2]=> array(5) { ["name"]=> string(8) "template" ["desc"]=> string(638) "test description" ["id"]=> string(9) "my_theme" ["type"]=> string(14) "selecttemplate" ["options"]=> array(13) { into this... array(83) { [0]=> array(2) { ["name"]=> string(11) "my options" ["type"]=> string(5) "title" } [1]=> array(1) { ["type"]=> string(4) "open" } [2]=> array(5) { ["name"]=> string(8) "template

c# - How does the MetadataType attribute mark a class as a validation class in MVC? -

i have ado entity generated in mvc 2 , know if want put custom validation on object can this. [metadatatype(typeof(myentity_validation))] public partial class myentity { private sealed class myentity_validation { [required] [regularexpression("[a-za-z][0-9]{5}")] public string somefield{ get; set; } } } but don't know why works. how work? sort of convention? metadata convention, yes. see http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.aspx . can add attributes fields enforce validation, display, concurrency, sorts of common usefulness. hope helps.

c# - WPF Transparency and Switching Styles between Transparent and Non-Transparent -

2 questions : firstly: possible toggle transparency on wpf window? pointers appreciated! secondly: controls on window inherit transparancy parent window, have datagrid control own style - style in external file reference (style="{dynamicresource mydgstyle}")..... in xaml code behind can switch styles? (ideally achieve using style trigger, don't think can). thanks much joe edit (can't seem reply) thanks alex, nvm regarding toggling transparency, long can set 'background' property of window @ runtime color 'transparent' @ runtime, thats fine. regarding switching styles, extending code alex, presumably can void onbuttonpress() { var transparentstyle = themes.currenttheme.mydgnontransparentstyle; var nontransparentstyle = themes.currenttheme.mydgnontransparentstyle; if (istransparent) // change non-transparent this.mygrid.style = (style)this.findresource(nontransparentstyle); else // change transpare

objective c - Limit to adding objects to a performSelector request (iOS4) -

if use code, app works: if ([self.navigationcontroller respondstoselector:@selector(showupdaterecordmodalwithfrontword:andbackword:)]) { nslog(@"seems respond"); [self.navigationcontroller performselector:@selector(showupdaterecordmodalwithfrontword:andbackword:) withobject:[currentcard frontword] withobject:[currentcard backword]]; } if add third parameter (below), sigabrt. if ([self.navigationcontroller respondstoselector:@selector(showupdaterecordmodalwithfrontword:andbackword:andnotes:)]) { nslog(@"seems respond"); [self.navigationcontroller performselector:@selector(showupdaterecordmodalwithfrontword:andbackword:andnotes:) withobject:[currentcard frontword] withobject:[currentcard backword] withobject:[currentcard notes]]; } the method here: - (id)showupdaterecordmodalwithfrontword:(nsstring *)arg_name1 andbackword:(nsstring *)arg_name2 andnotes:(ns

c# - How to get the "typeof" of a custom user control -

i have custom user control datepicker.cs. inside of piece of code have collection of controls checking type of control , doing logic based on type. problem following: typeof(datepicker) evalutes to: {name = "datepicker" fullname = "cusitecore.cedarsc.usercontrols.datepicker"} but when run debugger , @ type of control on web form is: {name = "cedarsc_usercontrols_datepicker_ascx" fullname = "asp.cedarsc_usercontrols_datepicker_ascx"} these 2 things aren't equal correct logic isn't getting evaluated. i've tried using type.gettype("asp.cedarsc_usercontrols_datepicker_ascx") returns null. edit here's i'm trying do: private readonly dictionary<type, controltype?> _controltypes = new dictionary<type, controltype?> { {typeof(checkbox), controltype.checkbox}, {typeof(checkboxlist), controltype.checkboxlist}, {typeof(dropdownlist), controltype.dropdownlist},

python - Calculating the fraction of each cell in a grid overlapped by a 2D object -

i have arbitrary rectangular cartesian grid divided potentially 10^6 or rectangular cells. (arbitrary means $x$ grid along points $x_1,...x_n$ , same goes $y$ grid.) draw arbitrary object on top of (say rotated rectangle, or circle), , efficiently calculate fraction of each cell overlapped object: if cell entirely inside bounds of object, 1.0; if cell entirely outside, 0.0; if half of cell covered object, 0.5. if displayed image , scaled 1 black , 0 white, result antialiased drawing of black object. my application question in python, , seems capability might provided existing graphics library. there python module test fractional intersection of rectangle , arbitrary object? there python library can @ least efficiently test if point inside arbitrary object rotated rectangle? you use pycairo , has fast native routines drawing. it's antialiased default. implementing drawing algorithms in python slow.

c# - How do I redirect? -

i have image hyperlink. how access "searchredirect" function redirect server side after image clicked? <input id="textsearch" runat="server" name="textsearch" type="text" /> <asp:hyperlink id="searchbutton" runat="server"> <img alt="" src="images/searchbutton.png"/> </asp:hyperlink> protected void searchredirect() { response.redirect("/newproject/home/?searchstring=" + textsearch.value; } rather hyperlink, you'll want use linkbutton , listen click event <input id="textsearch" runat="server" name="textsearch" type="text" /> <asp:linkbutton id="searchbutton" runat="server" onclick="searchredirect"> <img alt="" src="images/searchbutton.png"/> </asp:linkbutton> protected void searchredirect(sender object, e event

templates - Why does my Perl CGI program show the program code, not the output? -

code - test.cgi #!/usr/bin/perl use strict; use warnings; use cgi::fasttemplate; $tpl = new cgi::fasttemplate("/some/directory"); $tpl->no_strict(); $tpl->define(main => "test.htm"); $tpl->assign(test_content=> "test"); $tpl->parse(content => "main"); $tpl->print('content'); template file < html> < head> < title>test< /title> < /head> < body> $test_content < /body> < /html> explain why can't see desired output in browser? when navigate test.cgi file see actual code , not template. doing wrong? you seeing code instead of output of program because haven't configured webserver execute program, defaulting serving file text/plain. how configure depends on server software use. example, see apache 2.2 cgi docs . second, shebang line missing. program should start with: #!/usr/bin/perl where /usr/

C: Can't link head and tail in double linked list with external function [addressing issue] -

i made simplification of double linked list. double linked list structure has head , tail nodes. there function create list , return it. in same function linkage between tail , head nodes. problem when return list(so go outside function), links gone or point nodes of list temporarily created in function. guess correct? if how going bypass problem? here's code: #include <stdio.h> typedef struct node{ /*a node of list*/ int number; struct node *next; struct node *prev; } node; typedef struct list{ /*the list structure holds head , tail*/ node head; node tail; } list; list createlist(){ list newlist; newlist.head.prev=null; newlist.head.next=&newlist.tail; /*first node points second*/ newlist.tail.prev=&newlist.head; /*second node points first*/ newlist.tail.next=null; puts("--create list func--"); printf("head element address: %p\n", &newlist.head); printf("tail eleme

class - Qt 4 C++ Getting an error when using 3 classes that use each other, error: field `m_Employer' has incomplete type -

i'm in desperate need of , direction. been trying compile, battling due fact there 3 classes , not hundreds on how includes/forward declarations should work here. the error marked in person.h. in addition error, there warning i've marked in main.cpp. this console app. thank in advance. person.h #ifndef person_h #define person_h #include <qstring> class employer; class person { public: person(qstring name); qstring tostring() const; void setposition(employer newe, position newp); position getposition() const; private: qstring m_name; bool m_employed; position m_position; employer m_employer; //--> error: field `m_employer' has incomplete type. }; #endif // person_h person.cpp #include "employer.h" #include "position.h" #include "person.h" person::person(qstring name) : m_name(name), m_employed(false), m_position(""), m_employer(&qu

java - Android emulator, Finding mock user location coordinates. Having problems -

hey guys, i'm having trouble trying find user's longitude , location run program , set telnet command geo fix mock location. while emulator running, set mock coordinates emulator become unresponsive , have program fail in detecting input coordinates. import android.app.activity; import android.content.context; import android.location.location; import android.location.locationlistener; import android.location.locationmanager; import android.location.locationprovider; import android.os.bundle; import android.widget.textview; import android.widget.toast; public class lbsact extends activity{ /** called when activity first created. */ public double longitude; public double latitude; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); longitude = 0; latitude = 0; //creating listener , manager locationmanager lmanager = (locationmanager) this.getsyst

c# - Strange assembly behavior: FileNotFound for existing resource -

what circumstances cause embedded resource (like icon called '$this.icon') in winform throw filenotfound exception? this icon there, , appears if form's listbox not dynamically populated anything. if listbox populate however, embedded icon cannot found.

drop down menu - How to post the selected value of a selectlist to the controller using a view model? -

this question has been asked in various forms none of answers seem fit situation. trying retrieve selected value of dropdown list in controller. here code: viewmodel.cs public class viewmodel { public viewmodel() {} public viewmodel(contact contact, ienumerable<state> states) { this.contact = contact; this.states = new selectlist(states, "id", "name", contact.stateid); } public contact contact {get;set;} public selectlist states {get;set;} } controller.cs [httppost] public actionresult edit(viewmodel viewmodel) { _contactservice.updatecontact(viewmodel.contact); return redirecttoaction("item", new {id = viewmodel.contact.id}); } view.cshtml <button type="submit" onclick="javascript:document.update.submit()"><span>update</span></button>//aesthic usage. @{using (html.beginform("edit", "controller", formmethod.post, new { name = "upda

c# - Asynchronously send / receive fixed amount of data using tcp socket -

in application asynchronous communication on tcp socket. i don't fact send , receive operations (sync or async) of socket class allowed finish before requested number of bytes transmitted. example: when want read x bytes socket, don't want care how many read operations needed achieve (in application logic). want notified when it's finished (or when error occured). it nice have beginsendfixed, endsendfixed, beginreceivefixed , endreceivefixed. behave beginsend, endsend, beginreceive, endreceive, not call callback before requested number of bytes transmitted. i'm thinking implementing myself, based on: http://msdn.microsoft.com/en-us/magazine/cc163467.aspx in dotaskhelper function call many (synchronous) send or receive until data transmitted. is way go or there different (better) way hide need multiple sends / receives application logic? i recommend using taskcompletionsource class this. has advantage of not burning thread waiting i/o. easier wr

javascript - Assigning event functions with a loop in JS -

here script have: , i'm trying assign event each element in array. window.onload = sliding; function sliding() { document.getelementbyid('tag1').onmouseover = slideout; document.getelementbyid('tag1').onmouseout = slidein; } and tried using code below didn't work. trigger function buy self. window.onload = sliding; var tags = new array('tag1','tag2','tag3','tag4','tag5','tag6','tag7','tag8');// list of headings var pics = new array('popout1','popout2','popout3','popout4','popout5','popout6','popout7','popout8');// list of images slide out function sliding() { (var = 0; < tags.length; ++i) { document.getelementbyid('tag1').onmouseover = setslideout(tags[i],pics[i]); document.getelementbyid('tag1').onmouseout= setslidein(tags[i],pics[i]); } } here full code window.onloa

sql - How to transpose recordset columns into rows -

i have query code looks this: select documentid, complexsubquery1 ... complexsubquery5 document ... complexsubquery numerical fields calculated using, duh, complex subqueries. i use query subquery query generates summary following one: field documentcount total 1 dc1 s1 2 dc2 s2 3 dc3 s3 4 dc4 s4 5 dc5 s5 where: dc<n> = sum(case when complexsubquery<n> > 0 1 end) s <n> = sum(case when field = n complexsubquery<n> end) how in sql server? note: know avoid problem discarding original query , using unions: select '1' typeid, sum(case when complexsubquery1 > 0 1 end) documentcount sum(complexsubquery1) total (select documentid, blargh ... complexsubquer