Posts

Showing posts from January, 2012

profiling - turn on mysql profiler globally -

i want profile mysql sessions using mysql profiler, how can turn on profiling globally? thanks! log mysql command line , use query logger or slow query logger. it's not same profiler, pretty performs same function. here starting tip. mysql> set global log_output='table'; mysql> set global slow_query_log=1; ...wait... mysql> use mysql; mysql> select * slow_log order query_time desc; please remember turn off when you're done. remember logging table slower file, of course, more convenient.

framebuffer - Video as voxels in OpenGL -

any references on displaying sequence of images video voxel data in opengl? want display these images @ once cuboid 50% alpha , navigate using keyboard or mouse. check out tutorial on setting 3d texture. if render slices through texture array appropriate uvw coordinates after.

javascript - How to fade in a div on hover? -

i want hover on image, , have div text in fade in. simple. sidenote: want style-able css. (kind of given.) also, tried using examples in hurry please , thankyou. if using jquery, like: $('element').hover(function() { $('div').animate({ 'opacity': 1 }); });

jquery - rails markitup/markdown or textile -

i give user's option nicely format comments. not looking super fancy, perhaps lightweight. there ton of information markup/markdown/texttile etc. way go in rails, performance , usability, compatibility jquery, security being priority? thanks ruby/rails has support both markdown & textile, markdown has less features textile has better support code comments. (it's stackoverflow uses) so if need code support in comments, use markdown, if don't need use textile. markdown libraries rdiscount - http://tomayko.com/writings/ruby-markdown-libraries-real-cheap-for-you-two-for-price-of-one maruku - http://maruku.rubyforge.org/ bluecloth - http://deveiate.org/projects/bluecloth textile library redcloth - http://redcloth.org/

c# - How can i hide "setters" from all but one assembly? -

i have alluded issue in my other question , think it's worthwhile breaking out own question, it's not dependant on other scenarios mentioned. anyways - onto q, don't know if possible. looking solution/workaround. i have class library, nothing poco's: mycompany.myproject.domain.poco this assembly has poco this: public class post { public int postid { get; set; } public int name { get; set; } ... } now, have class library, dal/repository, , uses entity framework 4.0 persistence: mycompany.myproject.repositories this assembly has reference poco project, needs perform crud operations on poco's (grab db objects, project poco's, return, modify poco's). now, have web application , has reference both poco , repository assembly. if this: somepoco.postid = 10; i sqlexception, postid identity field in database, , hence should not explicity set. is there way can hide setter these special properties, repository has access sette...

wpf - How to use enum value to set header for a tab item of a tab-control? -

i want header of selected tab-item of tab-control , activate tab-item of tab-control appropriately, eg. select tab "a"/"b" of tab-control tc1 activate tab "a"/"b" on tab-control tc2. i want "a", "b", ... enum value no string comparation used. so, how can use enum value set tab-item's header? [edit] , yes, prefer use enum value directly in xaml codes i'd use wpf valueconverter . in xaml, <tab header={binding propthatreturnstheenum, converter=enumtodisplaytextconverter}>....</tab> on other hand, if you're implying want set text of tab named member of enumeration hardcoded in xaml, use static markupextension <tab header={x:static local:myenum.member1}>... </tab>

c# - How to run a form with it's own message pump? -

i've got application need open many forms heterogeneous own , run independently. application proceeds block on long running operations (making operations asynchronous not possible). run these forms on separate thread own message pump. way that? application.run(); this should launch form on own thread, own message pump. edit: http://en.csharp-online.net/application_architecture_in_windows_forms_2.0%e2%80%94application_lifetime since new ui thread created whenever application.run invoked, should accomplish looking for. edit #2: http://msdn.microsoft.com/en-us/library/system.windows.forms.application.run(vs.71).aspx the documentation little ambiguous. i've accomplished long running operations using threadpool , periodically marshalling control form render status, sounds spawn multiple forms application.run().

c# - Should I expose Actions instead of events? -

while working wf 4.0 noticed workflowapplication class exposes action properties (aborted, complete, etc...) instead of events. there specific reason? when should prefer action properties instead of events? thank you wow; see what mean ; surprises me. however, if can't think of reason use properties here (and can't), stick event s; avoid range of problems (accidental unsubscription , inappropriate invocation being biggest). the thing can think of maybe needed serialization purposes, can think of other ways crack nut. alternatively, maybe regular events don't make sense in crazy "dependency property" / "attached property" / "routed event" world of wf.

string - how to execute an for loop till the queue is emptyin c++ -

i need execute loop till queue empty code queue<string> q; for(int i=0;i<q.size(),i++) { // operation goes here // datas added queue } while (!q.empty()) { std::string str = q.front(); // todo: str. q.pop(); }

c++ - Hardware accelerated audio decoding with OpenAL -

is possible use iphone's hardware accelerated decoding of mp3s , aac when using openal library? i suppose there 2 possible approaches if possible. iphone specific openal extensions. iphone apis decode audio raw bytes. i have 2 specific use cases. completely decode short sound bite. piecewise decode larger sound file can streamed openal rather loaded @ once. update boy! no one's got answer this? apple's nda stiffle these kinds of questions? what's going on? surely else using openal has wanted better audio performance. there @ least 1 hardware (or hardware assisted) decoder in iphone device models. can accessed convert mp3 , aac files raw pcm bytes using audio queue services api. thence can process bytes or send them openal.

struct - c structure problem -

thanks support solving previous problems. i'm studying self referential structures. have written following code: #include <stdio.h> int main() { system("clear"); struct node { int x; struct node *next; } p1; printf(" \nthe address of node1 = %u",& p1); printf(" \n\nthe size of node 1 = %d",sizeof( p1)); printf("\n\n size of info part = %d",sizeof(p1.x)); printf("\n\n size of pointer part = %ld",sizeof(p1.next)); printf("\nthe size of node = %d\n",sizeof(struct node)); return; } the program compiled few warning like: warning: format ‘%u’ expects type ‘unsigned int’, argument 2 has type ‘struct node *’ every time pointer such warning generated. problem? don't know that. can explain why happen on linux (specially)? my second question run program shows size of structure 16 while int take 4 byte (ubuntu 10) & pointer of 8 byte. why shows size of structure 16 byte? in c99, ...

c# - Context.Undo() error, only on Windows XP machine -

i have asynchronous socket , following error on 1 windows xp machine: the undo operation encountered context different applied in corresponding set operation. the undo operation encountered context different applied in corresponding set operation. possible cause context set on thread , not reverted(undone). mscorlib @ system.threading.synchronizationcontextswitcher.undo() @ system.threading.executioncontextswitcher.undo() @ system.threading.executioncontext.runfinallycode(object userdata, boolean exceptionthrown) @ system.runtime.compilerservices.runtimehelpers.executebackoutcodehelper(object backoutcode, object userdata, boolean exceptionthrown) @ system.runtime.compilerservices.runtimehelpers.executecodewithguaranteedcleanup(trycode code, cleanupcode backoutcode, object userdata) @ system.threading.executioncontext.runinternal(executioncontext executioncontext, contextcallback callback, object state) @ system.threading.executioncontext.run(executionc...

php - How to make search engines index search results on my website? -

i have classifieds website. it has index.html , consists of form. form 1 users use search classifieds. results of search displayed in iframe in index.html , page wont reload or anything. however, action of form php-page , work of fetching classifieds etc. very simple. my problem is, google hasn't indexed of search results yet. must links on same page index.html google index search results? (because displayed in iframe) or because content dynamic? i have sitemap works, urls classifieds in sitemap, still not indexed. i have robots.txt: disallow: /bincgi/ the php code inside /bincgi/ folder, reason why isn't being indexed? i have used rewrite rewrite urls of classifieds to /annons/classified_title_here and how sitemap made up, using rewritten urls. any ideas why isn't working? thanks if need more input let me know. if content entirely dynamic , there no other way content except submitting form, google not indexing results becaus...

javascript - How to remove the attribute "disabled" from input siblings when i click on a submit input -

i have problem: need remove "disabled" attibute siblings inputs of submit input. here html: <td> <input type="hidden" value="2000000000002_statuto_07_10_2010.gif" name="nomedocumento" disabled="true"> <input type="hidden" value="811ecdd0-65e9-49d6-8d9d-8b7c9d9b6407" name="uuid" disabled="true"> <input type="submit" value="cancella" name="cancella"> </td> i need simple way using jquery remove disable attribute when click on submit. tried: $('input[name=cancella]').click(function(){ $('this').prev().removeattr('disabled'); $('this').prev().prev().removeattr('disabled'); } but doesn't work. any suggestion? $('input[name=cancella]').click(function(){ $(this) .closest('td') .find('input[name!='+this.name+']') .attr('di...

tomcat - how to create War file for a RESTful web service developed in eclipse IDE -

i ve created sample rest web service writes data in xml file. have hard coded path xml file written. want know how declare local path of file in web.xml file servlet parameter , how path there , use in codebe . need create war file service needs deployed in tomcat. war file should take parameter web.xml file. used eclipse ide develop web service. can tell me how above things ? here have attached servlet code present inside web.xml file. <servlet> <servlet-name>jersey rest service</servlet-name> <servlet-class> com.sun.jersey.spi.container.servlet.servletcontainer </servlet-class> <init-param> <param-name>com.sun.jersey.config.property.packages</param-name> <param-value>com.sample.service</param-value> </init-param> <init-param> <param-name>filepath</param-name> <param-value>filepath value</param-value> </init-param> <load-on-startup>1</load-...

How to convert the Object[] to String[] in Java? -

i have question java. have object[] (java default, not user-defined) , want convert string[] . can me? thank you. this conversion for(int = 0 ; < objectarr.length ; ++){ try { strarr[i] = objectarr[i].tostring(); } catch (nullpointerexception ex) { // default initialization } } this casting string [] strarr = (string[]) objectarr; //this give class cast exception update: tweak 1 string[] stringarray = arrays.copyof(objectarray, objectarray.length, string[].class); tweak2 arrays.aslist(object_array).toarray(new string[object_array.length]); note :that works if objects strings; current code works if not fortweak1 :only on java 1.6 , above

c - ASCII and printf -

i have little (big, dumb?) question int , chars in c. rememeber studies "chars little integers , viceversa," , that's okay me. if need use small numbers, best way use char type. but in code this: #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int i= atoi(argv[1]); printf("%d -> %c\n",i,i); return 0; } i can use argument every number want. 0-127 obtain expected results (the standard ascii table) bigger or negative numbers seems work... here example: -181 -> k -182 -> j 300 -> , 301 -> - why? seems me it's cycling around ascii table, don't understand how. when pass int corresponding "%c" conversion specifier, int converted unsigned char , written. the values pass being converted different values when outside range of unsigned (0 uchar_max). system working on has uchar_max == 255. when converting int unsigned char: if value larger uchar_max, (uchar_max+1) ...

How to get html elements with multiple css classes -

i know how list of divs of same css class e.g <div class="class1">1</div> <div class="class1">2</div> using xpath //div[@class='class1'] but how if div have multiple classes, e.g <div class="class1 class2">1</div> what xpath then? the expression you're looking is: //div[contains(@class, 'class1') , contains(@class, 'class2')] i highly suggest xpath visualizer, can debug xpath expressions easily. can found here: http://xpathvisualizer.codeplex.com/

javascript - jQuery make divs the same height on click -

i've got problem can @ here http://jsfiddle.net/dng2p/4/ if click detail button shows information , if click "points statement" button slides layer down. my problem i'm trying make main booking details div same height points div if it's bigger , when click close put main booking details height originally. it's half working main booking details div becomes same height points div doesn't go originally can help? thanks jamie how's this? http://jsfiddle.net/dng2p/8/ all did wrong failing keep original height around properly. declared bookingdetailheight local variable means got re-declared every toggle, , removed after every toggle complete. tied original height dom element using .data() , simplifies things when might have people opening 2 of toggles simultaneously. i got on roll though, tidied bit , made outer animate along inner. oh , please proper traversal methods in jquery, parent().parent().parent().find() asking t...

c - what is the o/p of that program & how it happenes -

possible duplicate: confusion output.. #include<stdio.h> void main() { int i=1,j=-1; if(printf("%d",i)<printf("%d",j)) printf("%d",i); else printf("%d",j); } here in program output & how ? printf returns total number of characters written. "-1" longer "1". so…

Perfect Enums in PHP -

recently came solution enums in php: class enum implements iterator { private $vars = array(); private $keys = array(); private $currentposition = 0; public function __construct() { } public function current() { return $this->vars[$this->keys[$this->currentposition]]; } public function key() { return $this->keys[$this->currentposition]; } public function next() { $this->currentposition++; } public function rewind() { $this->currentposition = 0; $reflection = new reflectionclass(get_class($this)); $this->vars = $reflection->getconstants(); $this->keys = array_keys($this->vars); } public function valid() { return $this->currentposition < count($this->vars); } } example: class applicationmode extends enum { con...

Is it a good idea to use XML files to present data that is not updated often? VS MYSQL query -

i'm building website , i'd limit calls mysql database. one idea have use xml files present information not need updated regularly every page load. two example site navigation might change once week. the number of items in stock in situations need updated when item becomes out of stock. i have feeling solution, experience xml quite limited, i'd feedback before delving it. many thanks. just use memcache, xcache or other caching solution cache sql requests.

MVVM - WPF DataGrid - AutoGeneratingColumn Event -

i'm taking @ excellent toolkit laurent , have following question. from blend 4, have added eventtrigger loaded event, in viewmodel have following: public relaycommand rcautogeneratingcolumn { get; private set; } in constructor have: rcautogeneratingcolumn = new relaycommand(o => datagridautogeneratingcolumn(o)); also in viewmodel, have method wish invoked relaycommand: private void datagridautogeneratingcolumn(object o) { datagrid grid = (datagrid)o; foreach (datagridtextcolumn col in grid.columns) { if (col.header.tostring().tolower() == "id") { col.visibility = system.windows.visibility.hidden; } } } my xaml contains following (for datagrid): <i:interaction.triggers> <i:eventtrigger eventname="loaded"> <galasoft_mvvmlight_command:eventtocommand command="{binding rcautogeneratingcolumn, mode=on...

jsp - How do I use the latest version of jQuery and get back the '$' for jQuery in RichFaces? -

richfaces 3.3.3 comes baked in jquery 1.3.2 , prototype , scriptaculous well. how can try , use latest version of jquery? can use google cdn one? also $() object defaulted prorotype , use jquery have jquery() is there way $ jquery without breaking richfaces? update: can use multiple versions of jquery side side. now, i've gone ahead , used version comes baked richfaces. you can use $ jquery without breaking richfaces wrapping jquery code in manner: (function($) { /* jquery code can use $() here */ })(jquery);

delphi - TStream.Position compared to TStream.Seek -

to move "current byte" pointer in tstream class can use property position (e.g. mystream.position := 0) or using seek method (e.g. mystream.seek(0, sofrombeginning). question is, 1 more efficient (aka faster)? (i don't have source, not check myself). so far use seek in positioning said pointer. as tstream.seek overloaded function handling 32-bit or 64-bit values, depends on current stream implementation, might better choice. for instance tcustommemorystream implements 32-bit version of seek() . when set position on stream first call 64-bit version, casts value longint while calling 32-bit version. (this change 64-bit version of delphi!) on other hand thandlestream implements 64-bit version of seek() . when call seek() 32-bit value end in quite nasty mechanism calling 64-bit version. my personal advice set position . @ least better choice in future.

uitableview - Is it possible to refresh a portion of the ui table view without refresh other cells? -

is possible refresh cells without refreshing other cells in table view? i need delete , insert , add cells simultaneously. want refresh table frequently. [self.tableview reloaddata]; this code used refresh cells in table think. i'm not sure this. because table contains huge amount of cell may take time reload cells. thanks in advance.... yes, try - (void)reloadrowsatindexpaths:(nsarray *)indexpaths withrowanimation:(uitableviewrowanimation)animation . see also: insertrowsatindexpaths:withrowanimation: , deletetrowsatindexpaths:withrowanimation: .

asp.net - Why do I get a timeout when uploading files larger than 100KB? -

i have web site on iis7. can upload maximum of 100kb, if try files larger 100k timeout error. i have added following setting web.config file getting same error: <security> <requestfiltering> <requestlimits maxallowedcontentlength="2000000000"></requestlimits> </requestfiltering> </security> what wrong? you might want check <httpruntime> element in web.config ensure isn't limiting request size there.

android - Is there a way to catch the Search key so that the Google Voice Search dialog doesn't appear? -

i'm aware home key cannot caught, , i'm worried long-press on search key "android-os protected" key press. testing, tried catch keys code within activity, not stop google voice search dialog being triggered. @override public boolean dispatchkeyevent(keyevent event) { return true; } edit: tested code on nexus one, , blocks key event on phone, still have problem on droid 2. both running froyo 2.2 im not @ pc, im gonna paste search result. i think you'r looking this: activity | android developers boolean, onsearchrequested(). hook called when user signals desire start search. http://developer.android.com/reference/android/app/activity.html

asp.net - Using a Tiff image on a webpage -

i may forced using tiff image on webpage. do modern browsers handle tiffs. there gotchas? if you're using safari, you're good... otherwise, luck http://en.wikipedia.org/wiki/comparison_of_web_browsers#image_format_support here further reading using alternatiff (workaround) http://www.alternatiff.com/ http://www.alternatiff.com/howtoembed.html however, since you're using asp.net, maybe can convert tiff jpg in backend http://www.codeproject.com/kb/gdi-plus/dotnet_convertimage.aspx http://bytes.com/topic/c-sharp/answers/267798-convert-tiff-images-gif-jpeg reference so question

asp.net - How to convert DetailsView columns to uppercase -

i need able convert input fields in detailsview (insert) uppercase. how do this? sql query , whole insert statement takes place in asp.net, , not in code behind i'm not sure if can dynamically in asp. i've used text-transform in css make them look uppercase user, still enters details in lower case in field. done cheeky work around - sql query converts upper case now.

python - Run Django on multiple ports -

could tell me how can run django on 2 ports simultaneously? default django configuration listens on port 8000. i'd run instance on port xxxx well. i'd redirect requests second port particular app in django application. i need accomplish default django installation , not using webserver nginx, apache, etc. thank you let's 2 applications in django application. don't mean 2 separate django applications separate folders inside 'app' directory. let's call app1 , app2 i want requests on port 8000 go app1 , requests on port xxxx go app2 hth. just run 2 instances of ./manage.py runserver . can set port specifying directly: ./manage.py runserver 8002 listen on port 8002. edit don't understand why want this. if want 2 servers serving different parts of site, have in effect 2 sites, need 2 separate settings.py , urls.py files. you'd run 1 instance of runserver each, passing settings flag appropriately: ./manage.py runserver 800...

c++ - typeinfo / typeid output -

i'm trying debug piece of simple code , wish see how specific variable type changes during program. i'm using typeinfo header file can utilise typeid.name(). i'm aware typeid.name() compiler specific output might not particularly helpful or standard. i'm using gcc cannot find list of potential output despite searching, assuming list of typeid output symbols exist. don't want sort of casting based on output or manipulate kind of data, follow type. #include <iostream> #include <typeinfo> int main() { int = 10; cout << typeid(int).name() << endl; } is there symbol list anywhere? i don't know if such list exists, can make small program print them out: #include <iostream> #include <typeinfo> #define print_name(x) std::cout << #x << " - " << typeid(x).name() << '\n' int main() { print_name(char); print_name(signed char); print_name(unsigned cha...

javascript - "this" keyword inside closure -

i've seen bunch of examples can't seem sample code work. take following code: var test = (function(){ var t = "test"; return { alertt: function(){ alert(t); } } }()); and have function on window.load like: test.alertt(); that works fine. however, when try explicitly set context of t inside alert() in alertt , undefined. i've tried: var = this; alert(that.t); //undefined i've tried: return { that: this, alertt: function(){ alert(that.t); // undefined! } } and i've tried: var test = (function(){ var t = "test"; var myobj = this; return { alertt: function(){ alert(myobj.t); // undefined! } } }()); what missing? need able set context explicitly things callbacks etc. i've seen examples (http://stackoverflow.com/questions/346015/javascript-closures-and-this-contex...

How do I get my Java object to stop resetting its creation date to the current date? -

this basic, can't figure out why keeps resetting creation date. i'm using simple expiration cache on object. if expired, create new object. if isn't, use 1 exists. however, every time go check creation date on object, current date. public class myobjectimpl implements myobjectinterface { private static final long serialversionuid = -3542728718515350246l; // auto generated eclipse... public myobjectimpl() { this.creationdate = new date().gettime(); } public boolean hasexpired(biginteger millesecondstoexpiration) { if (millesecondstoexpiration == null) { millesecondstoexpiration = new biginteger("2592000000"); // 30 days } if (getcreationdate() + millesecondstoexpiration.longvalue() < new date().gettime()) { return true; } else { return false; } } private long creationdate; public long getcreationdate() { return this.creationdate; ...

mysql - creating a database for a photo gallery with comments -

i creating social network , want have similar photo gallery of facebook. im guessing need use ajax have comments section each photo. wondering best way design database around this. make table of comments? run performance issues because im sure each user have more 1 photo, contents tables pretty large. supposing had 10 million users , each had 100 photos 2 comments each 2 billion entries , 10 million users, happen if number grew. slow down website. know can develop simple 1 table create fast , knowledgeable future. if me out appreciated. if have 10 million users, you'll have money buy more resources handle requests :) i design table comments, , photos. 2 tables of course joined one-to-many relationship. a good, configured, rdmbs won't care store , select photos along comments. that's db job, don't worry.

date - PHP iterate days of month given month and year -

how can print (echo) days of unknown month if month , year parameters? thank you. to number of days in given month of given year can use cal_days_in_month echo cal_days_in_month(cal_gregorian, 10, 2010); // prints 31

Latex \newcommand for \end{verbatim} et.al not working -

i'm trying make latex usable, introducing timesavers, i'm having trouble defining new commands terminate environments, @ random. this works: \newcommand{\bcv}{\ensuremath{\begin{smallmatrix}}} \newcommand{\ecv}{\ensuremath{\end{smallmatrix}}} \newcommand{\be}{\begin{enumerate}} \newcommand{\ee}{\end{enumerate}} this not work: \newcommand{\bal}{\begin{align*}} \newcommand{\eal}{\end{align*}} \newcommand{\verbass}[1]{\begin{verbatim} #1 \end {verbatim}} specifically, think \end value ignored? when try use \verbass{halp} error: !file ended while scanning use of \@xverbatim. obviously can use \begin{foo} ... \end{foo} @ locations needed, really, should work! how \begin{verbatim} works. briefly , roughly. \begin{verbatim} expanded \verbatim . then \verbatim sets category code of each characters 11. chars letters. then \verbatim sets font, parindent , calls \@xverbatim . \@xverbatim catches end of verbatim using following trick: \def\@xverb...

mongodb - Mongorestore of a db causing me trouble -

i'm new mongodb , have hard time backup local db , restore on server. found link on mongo's website : http://www.mongodb.org/display/docs/import+export+tools still have problems restore. when backup call mongodump --db gen then see collections dump in /bin/dump/gen folder i copy-paste local server in same folder call mongorestore --db gen --drop --dbpath dump/gen but following : error : root directory must dump of single database when specifying db name --db ok find out i'm doing wrong : i doing mongorestore --db gen --drop --dbpath dump/gen but without --dbpath works fine! mongorestore --db gen --drop dump/gen thanks everyone!

xslt - xsl reference to external xsl file -

i have question xsl. have 1 huge xsl file (+4000 lines :p) , split file in different parts. use xsl file map schemas in biztalk , more performant if split in parts, can re-use parts. anyway, don't mind biztalk stuff, how can reference main xsl file different parts? ex.: <?xml version="1.0" encoding="utf-16"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:output omit-xml-declaration="yes" method="xml" version="1.0" /> <xsl:template match="/"> <xsl:apply-templates select="/ns1:adt_a01_231_glo_def" /> </xsl:template> <xsl:template match="/ns1:adt_a01_231_glo_def"> <ns1:adt_a01_25_glo_def> <evn_eventtype> <xsl:if test="evn_eventtypesegment/evn_1_eventtypecode"> <evn_1_eventtypecode> ...

ASP.Net MVC2 -- After posting, how to clear form if user hits Back button? -

in web app, after clicking submit button on asp.net mvc form, user displayed either error screen or success screen. in case of error, user instructed click button on browser , fix whatever didn't right , try submitting again. this works fine because when user clicks back, entered data still in screen in various fields. in case of success screen, data cleared if user clicks back, cannot accidentally re-submit data again. how 1 in asp.net mvc? the way can accomplish use post-get-redirect pattern. it's not asp-mvc specific wiki says a common design pattern web developers avoid duplicate form submissions , allow user agents behave more intuitively bookmarks , refresh button. clicking not safe way handle this. browsers don't maintain form state after submission. pattern directly address accidentally re-submit data issue. in terms of code, have @ blog post jag reehal concerning how unit test controllers. [httppost] public actionresult create(somevi...

php - Zend Mail - Email is not sent -

i have problem sending registration email via zend_mail. mail transmitted mails have @gmail.com. $email = "test@gmx.net"; $mail = new zend_mail (); $mail->setbodytext ( 'some text' ); $mail->setbodyhtml ( 'some text' ); $mail->setfrom ( 'support@mysite.net', 'mysite.net' ); $mail->addto ( $email, $email ); $mail->setsubject ( 'test' ); $mail->send (); if user has email provider email not sent. any ideas? i use smtp , works: $config = array('auth' => 'login', 'username' => '****@gmail.com', 'password' => '****', 'port' => '25', 'ssl' => 'tls'); $transport = new zend_mail_transport_smtp('smtp.googlemail.com', $config);

windows phone 7 - .NET How to find CivicAddress? -

this code returns empty string. can return please? civicaddressresolver civicresolver = new civicaddressresolver(); civicaddress c = civicresolver.resolveaddress(new geocoordinate(39,77)); textblock1.text = c.city; the msdn documentation civicaddressresolver.resolveaddress() suggests checking c.isunknown before trying access c.city idea.

iphone - Game Center Finding a Match Programmatically -

i can't figure out how works. trying let 2 players play game if third player joins can instantly join game, if fourth , last player joins can instantly join game. can leave game @ anytime whatever reason, if happens there should space open person or same person reconnect. that's idea. now got following. authenticate local player obvious reasons. search match so: if (matchrequest) [matchrequest release]; matchrequest = [[gkmatchrequest alloc] init]; matchrequest.minplayers = 2; matchrequest.maxplayers = 4; [[gkmatchmaker sharedmatchmaker] findmatchforrequest:matchrequest withcompletionhandler:^(gkmatch *match, nserror *error) { if (error) { // error occured } else { if (matchcurrent) [matchcurrent release]; matchcurrent = [match retain]; matchcurrent.delegate = self; } }]; if execute part on 3 different devices, 2 of them find each other , third still looking. figured after find match request has found mi...

c# - Force close all open popups from code -

i want cause open popups (with staysopen == false) close code. want simulate user clicking mouse (which close popups) code. i don't need simulate click, need resulting behavior. i've thought going through visual tree looking popups , closing each one, doesn't seem cleanest approach. thanks in advance or opinions. a wpf popup creates new window (a win32 window, not wpf window instance). can't find in application.windows collection, can find using win32 api enumchildwindows . once have handle, can retrieve associated hwndsource . think rootvisual of hwndsource popup (didn't check, might have deeper in visual tree). so code should similar (completely untested): public static class popupcloser { public static void closeallpopups() { foreach(window window in application.current.windows) { closeallpopups(window); } } public static void closeallpopups(window window) { intptr hand...

php - CakePHP: Accessing session data from within a controller -

i have edit action in users controller. want redirect different action if auth.user.id not equal id of user trying edit. i can access variables in views this: if($session->read('auth.user.id') != $id){ but doesn't work in controller. getting: undefined variable: session how access session data within controller? also, if has better way of achieving want do, feel free add! thanks, jonesy you must first add session component in controller: var $components= array('session'); you can access in methods via $this->session

sorting - Javascript: sort multidimensional array -

after creating multi-dim array this, how sort it? assuming 'markers' defined: var location = []; (var = 0; < markers.length; i++) { location[i] = {}; location[i]["distance"] = "5"; location[i]["name"] = "foo"; location[i]["detail"] = "something"; } for above example, need sort 'distance'. i've seen other questions on sorting arrays , multi-dim arrays, none seem work this. location.sort(function(a,b) { // assuming distance valid integer return parseint(a.distance,10) - parseint(b.distance,10); }); javascript's array.sort method has optional parameter, function reference custom compare. return values >0 meaning b first, 0 meaning a , b equal, , <0 meaning a first.

information retrieval - besides BM25, whats other ranking functions exists? -

besides bm25, what's other ranking functions exists? found information on topic? bm25 1 of term-based ranking algorithms. nowadays there concept-based algorithms well. bm25 if state-of-the-art of term based information retrieval; however, there challenges term-based cannot overcome such as, relating synonyms, matching abbreviation or recognizing homonyms. here examples: synonym : "buy" , "purchase" antonym : "professor" , "prof." homonym : bow – long wooden stick horse hair used play string instruments such violin bow – bend forward @ waist in respect (e.g. "bow down") to deal these problems, using concept-based models such this article , this article . concept-based models using dictionaries or external terminologies identify concepts , each have own representation of concepts or weighting algorithms.

Can I compare MysQL timestamp with datetime columns? is it bad? -

so, have table columns "abc" timestamp , "bcd" datetime. if this: select * mytable abc > bcd is bad? , affect performance? how compare in terms of performance? yes, can compare datetime timestamp . it's not bad, aware of following: remember although datetime , date , , timestamp values can specified using same set of formats, types not have same range of values. example, timestamp values cannot earlier 1970 utc or later '2038-01-19 03:14:07' utc. this means date such '1968-01-01' , while legal datetime or date value, not valid timestamp value , converted 0. from mysql reference manual :: datetime, date, , timestamp types . note how following test cases works fine: create table t1 (d1 datetime, d2 timestamp); insert t1 values ('1968-01-01 00:00:00', '1980-01-01 00:00:00'); insert t1 values ('2040-01-01 00:00:00', '1980-01-01 00:00:00'); select * t1 d2 < d1; +---...

Display array as raster image in python -

i've got numpy array in python , i'd display on-screen raster image. simplest way this? doesn't need particularly fancy or have nice interface, need display contents of array greyscale raster image. i'm trying transition of idl code python numpy , looking replacement tv , tvscl commands in idl. depending on needs, either matplotlib's imshow or glumpy best options. matplotlib infinitely more flexible, slower (animations in matplotlib can suprisingly resource intensive when right.). however, you'll have wonderful, full-featured plotting library @ disposal. glumpy suited quick, opengl based display , animation of 2d numpy array, more limited in does. if need animate series of images or display data in realtime, it's far better option matplotlib, though. using matplotlib (using pyplot api instead of pylab): import matplotlib.pyplot plt import numpy np # generate data... x, y = np.meshgrid(np.linspace(-2,2,200), np.linspace(-2,2,20...

objective c - NSWindowController showWindow only works once -

i have subclass of nswindowcontroller has own nib , class has ibaction show window , loads so. if (!propertiescontroller){ propertiescontroller = [[propertiescontroller alloc] init]; } [propertiescontroller showwindow:self]; it first time after close window , call method again window not displayed. sure window not getting released. possibly have override showwindow order window front? or have specify window controller uses in nib? have tried [propertiescontroller.window makekeyandorderfront:self]; ?

iphone - How do I resize a cell in a tableview with grouped cells -

i using grouped tableview , need resize 1 cell enclosed cell.detailtextlabel has exceeded size of cell (i.e. 3 lines worth). is there easy way cell auto-size it's contents or otherwise, how change size of particular cell? the uitableviewdelegate has method called tableview:heightforrowatindexpath: . have return desired height each row.

jquery - How do I make my div IDs variable in rails? -

i feel there should simple way this, don't know is. have list of data display, , want include ajax "read more" function expand information @ bottom of each segment. this, need unique div ids within each segment. have code: <% choice in @student_choices %> <div id= "student_description", style="display:none;"> <%= choice[:description]%> </div> <%= link_to_function "read more", "element.show("student_description")"%> <% end %> but since there multiple div ids, clicking "read more" displays first one. how insert variable div id? know how in php, has me stumped. if div id variable, how element.show accept variable? you can like: <% div_id = "student_description_#{choice.id}" -%> <div id="<%= div_id -%>", style="display:none;"> <%= choice.description %> </div> <%= link_to_func...

apache - Eclipse and How it Handles JARS -- Odd Case -

trying make small changes apache's velocity engine. here's can , can't do. i'm making change merge function(). change i'm making doesn't matter because haven't made yet. ;) right settling println statement firing. i have 2 references merge(). if change function mergebad() eclipse tells me can't find merge(). makes sense right? used include in class build path 2 jars when downloading velocity instead i've created project using src files provided , used project dependency. again, fact can't find merge() when rename mergebad gives me hope. but when running web server, hit breakpoint , step merge call, can't find source! point project yet again, , "finds" source, none of changes i've made (specifically println statements) hit. skipped over. :( what on god's green earth possibly causing this? it's driving me insane. i've spent entire day today trying figure out what's wrong. can't continue without be...

c# - Trick Windows To See Second Monitor -

is there anyway trick windows thinking second monitor connected computer, if there isnt one? example: laptop has external screen connected it. external screen primary screen. when screen disconnected laptop becomes primary if external screen reconnected. there way trick windows thinking monitor there? , not revert laptop screen primary screen? the way thinking work kind of low level driver? wouldnt have clue start for work, had same situation -- on embedded pc, needed second monitor available. i put considerable amount of time researching it, wasn't able find solution other hardware. if have vga port (or dvi-i), you're in luck. can find directions on how fake couple resistors ( here's 1 set of directions ). ultimately, project, had dvi-d port available. had come microcontroller solution send "fake" monitor signals (via i2c) pc. can't go more specific detail that, unfortunately.

Can Visual Studio post build events be used with ClickOnce publishing? -

in visual studio 2008, can post-build event used clickonce publishing? if so, how? out of box, looks can use pre-build events , clickonce publishing seems build project different location, before post build event launched. looking @ msbuild files visual studio uses, post build event run build target. if run msbuild command-line , call publish target directly, calls build first. if right-click on project in vs , click publish, trimmed-down target called publishonly gets run, on assumption vs has done build. your post build event should run visual studio when automatically builds project prior publishing. in build events tab of project's properties, did set event "run always"? if want more explicit happens prior publishing, there's beforepublish target publish looks for, whether it's run msbuild or visual studio. edit project file hand, , @ bottom you'll see couple of commented-out target elements. add 1 of own this: <target name="be...

html - Link to activate form field -

how can make form label activate (focus) form field coincides with? use for attribute on label. references id attribute of form input/field want focus. eg. <input type="text" id="txt1" /><label for="txt1">text 1</label>

actionscript 3 - Online video sharing AS3 API -

i'm developing web app based on videos client upload using online resource such youtube or vimeo. since youtube has 15 mn restriction length on videos 1 can upload, client has decided use vimeo instead, moogaloop(!) vimeo as3 api restrictive , offers handful of methods control video. what best as3 api online video sharing site? best , mean 1 allows control possible on site's player features. need able listen events , control fullscreen capability , enable/disable specific features such "embed" or "share" button. if client willing shell out little dough, should check out brightcove . amount of customization - both via api , web tools - impressive, , can host videos through them or on own server.

assemblies - Why do standard libraries for C# need both an assembly reference and an import? -

what reason have both of these standard libraries? every other language have used, have 1 access standard libraries. an assembly reference makes code in assembly available another assembly. using directive makes types of namespace available given source file. these separate concepts. if inclined, away never using usings directive , using fully-qualified type names. similarly, possible use usings directive refer other namespaces within same assembly . also, there perfect analog between assemblies/jars , usings/import between java , c# purposes of discussion. c# hardly unique here.

php - Should I use DomDocument for parsing html code -

i have tried best answer question myself through research still little bit worried whether using right thing. using domdocument library build jquery theme parser framework. web today html coming in different shapes , sizes e.g html 4, html 5, xhtml, xhtml 5 etc ... issue finding domdocument if give html code work if standards compliant xhtml. know can convert xhtml , can use tidy library make code acceptable main worry is: if developer using framework has theme uses cool(debatable) new html 5 features, passes framework either throw tantrum or convert down xhtml suck. so question is: domdocument convenient library need? or is there way of getting work different variants of html? domdocument can parse non-xhtml files. set proper switches: libxml_use_internal_errors ( true ); $dom = new domdocument; $dom -> formatoutput = true; $dom -> substituteentities = false; $dom -> recover = true; $dom -> stricterrorchecking = false;

Grails 1.3.5 and Spring Security Core -

i have build grails application, on login redirects users different urls based on user's role (custom roles defined in roles domain). trying integrate spring security core grails plugin application, plan use plugin's domain model. i understand auth action in logincontroller user login validation , if user logged in redirects default target uri. question how can know if logging in user of type role_admin or role_user or other role? how can check authority here , redirect different uris? i know how user validation done i.e. how & username , password validated against database in spring security? thank you. jay chandran. the redirect happens in org.springframework.security.web.authentication.savedrequestawareauthenticationsuccesshandler plugin extends class in org.codehaus.groovy.grails.plugins.springsecurity.ajaxawareauthenticationsuccesshandler support ajax logins. if want customize redirect location based on roles, i'd subclass ajaxawareauthentica...

objective c - How to find and remove unused class files from a project -

my xcode project has grown somewhat, , know there class files in there no longer being used. there easy way find of these , remove them? if class files sit in project without being part of target, click on project in tree view, see files in table. make sure see "target" column in table view, iterate through targets , find files don't have check anywhere -> no longer compiled. but if still compile classes , no longer used, case bit more difficult. check out project http://www.karppinen.fi/analysistool/#dependency-graphs you create dependency graph , try find orphaned classes way. edit: link went dead, there still seem projects of objective-c dependency graphs around, example https://github.com/nst/objc_dep

entity framework - LINQ to Entities 4: Query with calculation in where clause -

i have table datetime "timestamp" column , int "timeoutseconds" column. want retrieve records table datetime.now - timestamp > timeoutseconds. in stored proc no brainer using getdate(): select * schema.tablename mp (getdate() - mp.[timestamp]) > mp.timeout however, entity framework using either linq syntax or lambda cannot because seems lambda input variable (mp) cannot used part of calculation part of predicate, not compile: var records = context.tablename.where(mp => (datetime.now - mp.timestamp) > mp.timeout); this not compile. i don't want retrieve whole table filtering in memory , rather not use stored proc or entity sql. options here? this not compile because comparing (datetime.now - mp.timestamp) has return type system.timespan int . first solution comes mind do where(mp => (datetime.now - mp.timestamp) > new timespan(0, 0, 0, mp.timeout)) unfortunately doesn't seem work in ef, if have ms sql server db, ...

launching android widget -

i following http://www.helloandroid.com/files/xmaswidget/android_howto-hellowidget.pdf developing widget. unable launch widget on home screen. when running application getting errors no launcher activity found , launch sync application package on device! looking answer. it don't have right setup in androidmanifest.xml have seen post? android sample app not showing up

Shopping cart in jquery with php and session -

good day! i'm learning jquery creating basic shopping cart add cart buttons, remove items , clear buttons works in jquery. the function save added items on session , can remove , clear jquery. have idea on how jquery works on adding items. not on removing single item or clear of them on cart. any help, suggestion appreciated. thanks... :d here code have done far on shopping cart. in 2 files index.php , cart.php add cart button working except remove , clear. because not able run session yet. here is: <script type="text/javascript"> // ajax $(document).ready(function(){ $(".add").click(function(){ var id = $(this).attr("proid"); var item = $("#item"+id).val(); var brand = $("#brand"+id).val(); var price = $("#price"+id).val(); var quantity = $("#quantity"+id).val(); $.ajax({ type: "post", url: "cart.php", da...

java - Basicdatasource connection time out problem (using mysql) -

i using basicdatasource in application. application processing huge amount of raw data. 1 query can take more 15 minutes. (using mysql db) here question, acquire connection pool, execute several queries on it. when use same connection more 15 minutes, error below. in mysql server max_wait set 180 hours shouldn t problem keep connection alive , no firewall rule set kill connections alive more amount of time. what missing here think ? the last packet received server 928,374 milliseconds ago. last packet sent server 928,374 milliseconds ago. @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) @ sun.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl.java:39) @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl.java:27) @ java.lang.reflect.constructor.newinstance(constructor.java:513) @ com.mysql.jdbc.util.handlenewinstance(util.java:409) ...

2D Arrays and Pointers - C -

just trying head round arrays , pointers in c , differences between them , having trouble 2d arrays. for normal 1d array have learned: char arr[] = "string constant"; creates array of chars , variable arr represent memory created when initialized. char *arr = "string constant"; creates pointer char pointing @ first index of char array "string constant". pointer point somewhere else later. char *point_arr[] = { "one", "two","three", "four" }; creates array of pointers point char arrays "one, "two" etc. my question if can use both: char *arr = "constant"; and char arr[] = "constant"; then why can't use: char **pointer_arr = { "one", "two", "three", "four" }; instead of char *pointer_arr[] = { "one", "two", "three", "four" }; if try char ** thing error...

Replacing string between two string iphone sdk -

in objective c want replace string between 2 string. for example "ab anystring yz" i want replace string between "ab" , "yz". is possible do? please help thx in advance. nsstring *newstring = [(nsstring *)youroldstring stringbyreplacingoccurrencesofstring:@"anystring" withstring:@""]; otherwise you're going have copy of regexkitlite , use regex function like: nsstring *newstring = [(nsstring *)youroldstring stringbyreplacingoccurrencesofregex:@"ab\\b.\\byz" withstring:@"ab yz"];

java - HSQLDB is eating all my memory -

i'm using hsqldb application stores research data , there quite lot of data. hsqldb insists on loading tables memory. i've tried fixing setting hsqldb.default_table_type=cached in persistence.xml not work. is wrong place? persistence.xml <persistence-unit name="dvh db" transaction-type="resource_local"> <class>com.willcodejavaforfood.dvh.entity.patient</class> <class>com.willcodejavaforfood.dvh.entity.plan</class> <class>com.willcodejavaforfood.dvh.entity.dvh</class> <class>com.willcodejavaforfood.dvh.entity.importsession</class> <class>com.willcodejavaforfood.dvh.entity.project</class> <class>com.willcodejavaforfood.dvh.entity.course</class> <class>com.willcodejavaforfood.dvh.entity.property</class> <properties> <property name="javax.persistence.jdbc.url" value="jdbc:hsqldb:./mydvhdb"/> ...

c++ - init_priority attribute on variables in static libs -

this new question after long rant. problem here is, have global vector<base*> vobjs in main application , got derived obj s in each static lib linked application. if specify vobjs have init_priority of 101 , each obj in static libs have say... 1000, guaranteed vobjs constructor called before obj s in static libs? help. let me echo other responses might want reconsider using globals this. 1 possible (and i'm sure still flawed) improvement @ least removes need init priority. instead of using global vector , create function returns reference static local. c++ rules make sure function static local initialized @ latest first use, don't have worry vector not being initialized. vector<libinfo*>& get_gvlibinfo() { vector<libinfo*> gvlibinfo; return gvlibinfo; } then registration looks like: vector<libinfo*>& get_gvlibinfo(); void reglib() { get_gvlibinfo().push_back(this); }

eclipse - java pst library -

i'm wrinting junit tests , specefic actions need give path the java library "pst.dll" set eclipse->run config->vm arguments , set path pst.dll problem , have each testcase otherwise : exception in thread "thread-13" java.lang.unsatisfiedlinkerror: no pst in java.library.path . there way put path pst.dll test cases? or project avoid add each time ? thanks. set vm options jre using execute test cases in eclipse. go window -> preferences -> java -> installed jre's , configure option in respective jdk/jre.

What's this negative value in this CSS property? -

background-position: -200px 0; one site says crops image bottom , displays rest part ..another site saying shifting image left..what ? i trying implement css sprites..having problem due positioning thingy...this have implemented far...its not working right..i have few links , want diff part of image displayed when mouse moved on particular link...i geting output whole image being displayed..it wont crop it..i tried many things changing positioning, adding divs..what not..now lost , dont know began..could plz point out doing wrong here ? why image not getting cropped..sure wrong positioning x,y values.... here's code:- <style type="text/css"> #sprite ul{background:url(images/image.jpg) no-repeat; width:728px;height:1225px;display:block} #id1{background-position:0 -1000px} #id1:hover{background-position:0 -1000px} #id2{background-position:0 -1000px} #id2:hover{background-position:0-800px} #id3{background-position:0 1000px} #id3:hover{background-position:0...

objective c - How to compress an Image taken by the camera in iphone sdk? -

i getting list of contacts address book in contacts have images taken camera huge in size.i displaying contacts along images in 3x3 rows , columns format.the problem due huge size of images taking time load images.can suggest me how compress them. tried compress them in way: if ([imagedata length] > 0) { int len = [imagedata length]; if(len > 9000) { uiimage *theimage = [uiimage imagewithdata:imagedata]; imagedata = uiimagejpegrepresentation(theimage,0.5); printf("\n image data length in condition...%d",[imagedata length]); imageviewl.image = [uiimage imagewithdata:imagedata]; } else { imageviewl.image = [uiimage imagewithdata:imagedata]; } } eventhough taking time load. anyone's appreciated. thanks all, monish. you can resize image captured iphone camera using following lines of code -(uiimage *)scaleimage:(uiimage *)image tosize:(cgsize)newsize { uigraphicsbeginima...