text
stringlengths
0
30.5k
title
stringclasses
1 value
embeddings
listlengths
768
768
created during the call. Be aware that you cannot see the changes from the COM+ component reflected on data queries from the .NET side until the Transaction is committed! In fact, it is possible to deadlock! Remember that DTC will make sure that the two transactions are paired, but they are still separate database transactions.
[ 0.3112247884273529, -0.4155956208705902, 0.2679941654205322, 0.09320461750030518, 0.14625559747219086, -0.24011920392513275, 0.11180026084184647, -0.09795459359884262, -0.29258325695991516, -0.5447407960891724, -0.22530202567577362, 0.7609765529632568, -0.29831403493881226, -0.042559001594...
I have a product which has been traditionally shipped as an MSI file. It is deployed through some sort of SMS push to thousands of desktops by our various clients. The software we use to create these installers is getting long in the tooth and we are looking to replace it. We have already standardized on InstallAnywhere for most of our products as we support many operating systems. Unfortunately InstallAnywhere cannot produce MSI files. I am wondering if it is required that SMS use MSI files or if it can handle other installer types (.exe). If not, are there any
[ 0.4959082305431366, 0.21659740805625916, 0.4082265794277191, -0.06019600108265877, 0.2620803713798523, 0.14715009927749634, 0.2037539780139923, 0.18861983716487885, -0.13224735856056213, -0.620046854019165, 0.01860225386917591, 0.2722962200641632, -0.36876755952835083, 0.11398686468601227,...
open source programmes for creating MSI files? If your clients are using SMS then you're in the clear... SMS supports EXE. You enter a command line when creating 'Programs' and clients are probably already calling msiexec to launch the MSI. Also I'm pretty sure SMS predates the MSI file format :) However if they're using `Active Directory / Group Policy Objects`.. then you're SOL as that does depend on MSI format for deployment. If you do want to stick with InstallAnywhere, there are a number of "MSI repackaging" tools available. Assuming you're looking at a basic application (device drivers might be an issue)
[ 0.5215774178504944, 0.12711788713932037, 0.14744634926319122, 0.0012924603652209044, -0.16231290996074677, -0.22695107758045197, 0.3577471673488617, 0.12677839398384094, -0.32195064425468445, -0.8103795647621155, -0.38688182830810547, 0.6164129376411438, -0.5155190229415894, -0.11041289567...
then repackaging should be a fairly painless process.
[ 0.313229501247406, 0.3483661115169525, -0.05152665078639984, 0.22098998725414276, -0.07926273345947266, 0.33525165915489197, 0.013244441710412502, -0.28487715125083923, -0.3501475751399994, -0.5278082489967346, -0.08448336273431778, 0.4019613564014435, 0.3255401849746704, 0.029611472040414...
I have some code that gives a user id to a utility that then send email to that user. ``` emailUtil.sendEmail(userId, "foo"); public void sendEmail(String userId, String message) throws MailException { /* ... logic that could throw a MailException */ } ``` `MailException` could be thrown for a number of reasons, problems with the email address, problems with the mail template etc. My question is this: do you create a new Exception type for every one of these exceptions and then deal with them individually or do you create one MailException and then store something in the exception (something computer-readable, not the description text)
[ 0.1966441571712494, 0.426159143447876, -0.1137516051530838, -0.19182050228118896, -0.23526877164840698, -0.052526261657476425, 0.3639329671859741, -0.3580324947834015, 0.042071953415870667, -0.7611070275306702, 0.045351676642894745, 0.39237162470817566, -0.6243338584899902, 0.0485431179404...
that allows us to do different things based on what actually happened. **Edit:** As a clarification, the exceptions aren't for logs and what-not, this relates to how code reacts to them. To keep going with the mail example, let's say that when we send mail it could fail because you don't have an email address, or it could because you don't have a **valid** email address, or it could fail.. etc. My code would want to react differently to each of these issues (mostly by changing the message returned to the client, but actual logic as well). Would it be best to have
[ 0.48862969875335693, 0.07402478158473969, 0.05697005242109299, 0.1354086846113205, -0.2032446563243866, -0.02234785631299019, 0.4911072254180908, -0.15522275865077972, -0.3103301227092743, -0.7012696266174316, 0.11055894941091537, 0.6723393797874451, -0.18501412868499756, -0.13161914050579...
an exception implementation for each one of these issues or one umbrella exception that had something internal to it (an enum say) that let the code distinguish what kind of issue it was. I usually start with a general exception and subclass it as needed. I always can catch the general exception (and with it all subclassed exceptions) if needed, but also the specific. An example from the Java-API is IOException, that has subclasses like FileNotFoundException or EOFException (and much more). This way you get the advantages of both, you don't have throw-clauses like: ``` throws SpecificException1, SpecificException2, SpecificException3 ... ``` a general ``` throws GeneralException ``` is enough. But if
[ 0.022605398669838905, -0.10768324136734009, 0.008556938730180264, -0.08047796040773392, -0.4080171287059784, -0.2731017470359802, 0.0004569975135382265, -0.10853593796491623, -0.17198128998279572, -0.5580483078956604, -0.06445004791021347, 0.5980599522590637, -0.3326195478439331, -0.192552...
you want to have a special reaction to special circumstances you can always catch the specific exception.
[ 0.5641112327575684, -0.06259186565876007, -0.37400713562965393, 0.18230268359184265, -0.20313052833080292, -0.2051602602005005, 0.2368086874485016, 0.09876593202352524, -0.3426222503185272, -0.5385265946388245, -0.13000129163265228, 0.07755384594202042, -0.19315099716186523, -0.08594542741...
I didn't get the answer to this anywhere. What is the runtime complexity of a Regex match and substitution? Edit: I work in python. But would like to know in general about most popular languages/tools (java, perl, sed). From a purely theoretical stance: The implementation I am familiar with would be to build a Deterministic Finite Automaton to recognize the regex. This is done in O(2^m), m being the size of the regex, using a standard algorithm. Once this is built, running a string through it is linear in the length of the string - O(n), n being string length. A replacement on
[ -0.03332484886050224, -0.11947473138570786, 0.13543790578842163, -0.004584395792335272, -0.20278629660606384, 0.1902584582567215, 0.1311972588300705, -0.017923779785633087, -0.08211196213960648, -0.4608684182167053, -0.030707670375704765, 0.5066991448402405, -0.6474942564964294, -0.0748557...
a match found in the string should be constant time. So overall, I suppose O(2^m + n).
[ -0.42666634917259216, 0.01339292898774147, 0.28652384877204895, -0.32642465829849243, 0.17289039492607117, 0.09750691056251526, 0.3177921175956726, -0.3888411521911621, -0.07263008505105972, -0.6372650265693665, -0.058323364704847336, 0.33176273107528687, -0.2636079490184784, 0.04317482933...
I'm currently writing an ASP.Net app from the UI down. I'm implementing an MVP architecture because I'm sick of Winforms and wanted something that had a better separation of concerns. So with MVP, the Presenter handles events raised by the View. Here's some code that I have in place to deal with the creation of users: ``` public class CreateMemberPresenter { private ICreateMemberView view; private IMemberTasks tasks; public CreateMemberPresenter(ICreateMemberView view) : this(view, new StubMemberTasks()) { } public CreateMemberPresenter(ICreateMemberView
[ -0.04171464964747429, -0.040164269506931305, 0.2972167730331421, -0.040414582937955856, -0.186517596244812, 0.07748708128929138, 0.20059455931186676, 0.05447288602590561, -0.3204391896724701, -0.8485943078994751, -0.1071835532784462, 0.396474152803421, -0.11056884378194809, 0.1464155912399...
view, IMemberTasks tasks) { this.view = view; this.tasks = tasks; HookupEventHandlersTo(view); } private void HookupEventHandlersTo(ICreateMemberView view) { view.CreateMember += delegate { CreateMember(); }; } private void CreateMember() { if (!view.IsValid) return;
[ 0.04639412462711334, -0.3317890763282776, 0.5362076759338379, -0.21012549102306366, 0.17104583978652954, 0.21325768530368805, 0.4931444525718689, -0.3911629617214203, -0.21051496267318726, -0.7433478236198425, -0.3406166434288025, 0.571458101272583, -0.23225648701190948, 0.3568213582038879...
try { int newUserId; tasks.CreateMember(view.NewMember, out newUserId); view.NewUserCode = newUserId; view.Notify(new NotificationDTO() { Type = NotificationType.Success }); } catch(Exception e) {
[ -0.030983174219727516, -0.3027818202972412, 0.2440408617258072, -0.4903566241264343, 0.23183965682983398, 0.28736376762390137, 0.637153685092926, -0.35794538259506226, -0.18806461989879608, -0.672484278678894, -0.4399775266647339, 0.32588425278663635, -0.4763595163822174, 0.142651036381721...
this.LogA().Message(string.Format("Error Creating User: {0}", e.Message)); view.Notify(new NotificationDTO() { Type = NotificationType.Failure, Message = "There was an error creating a new member" }); } } } ``` I have my main form validation done using the built in .Net Validation Controls, but now I need to verify that the data sufficiently satisfies the criteria for the Service Layer. Let's say the following Service Layer messages can show up: * E-mail account already exists (failure) * Refering user
[ 0.18697942793369293, 0.19011619687080383, 0.4360939860343933, -0.23494823276996613, 0.0690809041261673, -0.26995065808296204, 0.5979222059249878, -0.2210947871208191, -0.2477056086063385, -0.5666671991348267, -0.2307155877351761, 0.4071618914604187, -0.2578316926956177, 0.16385668516159058...
entered does not exist (failure) * Password length exceeds datastore allowed length (failure) * Member created successfully (success) Let's also say that more rules will be in the service layer that the UI cannot anticipate. Currently I'm having the service layer throw an exception if things didn't go as planned. Is that a sufficent strategy? Does this code smell to you guys? If I wrote a service layer like this would you be annoyed at having to write Presenters that use it in this way? Return codes seem too old school and a bool is just not informative enough. --- > **Edit not by OP: merging
[ 0.29663601517677307, 0.09016589820384979, 0.48702728748321533, 0.07841379195451736, -0.2430119514465332, -0.29903560876846313, 0.7443863749504089, -0.012493975460529327, -0.2616989016532898, -0.5173948407173157, -0.22983843088150024, 0.3300677537918091, -0.02282450906932354, 0.200117588043...
in follow-up comments that were posted as answers by the OP** --- Cheekysoft, I like the concept of a ServiceLayerException. I already have a global exception module for the exceptions that I don't anticipate. Do you find making all these custom exceptions tedious? I was thinking that catching base Exception class was a bit smelly but wasn't exactly sure how progress from there. tgmdbm, I like the clever use of the lambda expression there! --- Thanks Cheekysoft for the follow-up. So I'm guessing that would be the strategy if you don't mind the user being displayed a separate page (I'm primarily a web developer) if
[ 0.36061355471611023, 0.14178870618343353, 0.3107469975948334, 0.05728984996676445, -0.36776861548423767, -0.15451417863368988, 0.3858279287815094, 0.4744105339050293, -0.24948416650295258, -0.5263077616691589, 0.14310601353645325, 0.4859856069087982, -0.03338078781962395, 0.016384199261665...
the Exception is not handled. However, if I want to return the error message in the same view where the user submitted the data that caused the error, I would then have to catch the Exception in the Presenter? Here's what the CreateUserView looks like when the Presenter has handled the ServiceLayerException: ![Create a user](https://i.stack.imgur.com/HOJU7.png) For this kind of error, it's nice to report it to the same view. Anyways, I think we're going beyond the scope of my original question now. I'll play around with what you've posted and if I need further details I'll post a new question. That sounds just right to
[ 0.28302478790283203, 0.24781784415245056, 0.4841190576553345, -0.13895727694034576, -0.36429834365844727, -0.16896936297416687, 0.44060108065605164, 0.08942273259162903, -0.3849124610424042, -0.4312075972557068, -0.1023397371172905, 0.5169714689254761, -0.3008791208267212, 0.04756865650415...
me. Exceptions are preferable as they can be thrown up to the top of the service layer from anywhere inside the service layer, no matter how deeply nested inside the service method implementation it is. This keeps the service code clean as you know the calling presenter will always get notification of the problem. **Don't catch Exception** However, [don't catch Exception](https://stackoverflow.com/questions/21938/is-it-really-that-bad-to-catch-a-general-exception) in the presenter, I know its tempting because it keeps the code shorter, but you need to catch specific exceptions to avoid catching the system-level exceptions. **Plan a Simple Exception Hierarchy** If you are going to use exceptions in this way, you
[ 0.40901997685432434, 0.20316851139068604, 0.17711232602596283, -0.16300278902053833, -0.31213653087615967, -0.34885239601135254, 0.4938710033893585, 0.11895402520895004, -0.5190415382385254, -0.533299446105957, -0.12914372980594635, 0.39026957750320435, -0.29123806953430176, 0.141292020678...
should design an exception hierarchy for your own exception classes. At a minumum create a ServiceLayerException class and throw one of these in your service methods when a problem occurs. Then if you need to throw an exception that should/could be handled differently by the presenter, you can throw a specific subclass of ServiceLayerException: say, AccountAlreadyExistsException. Your presenter then has the option of doing ``` try { // call service etc. // handle success to view } catch (AccountAlreadyExistsException) { // set the message and some other unique data in the view } catch (ServiceLayerException) { // set the message in the
[ 0.0031645435374230146, -0.12868215143680573, 0.557746946811676, -0.12932246923446655, -0.3206307291984558, 0.009093648754060268, 0.2773573100566864, -0.27303940057754517, -0.3125990629196167, -0.5713590979576111, -0.17499351501464844, 0.4379832148551941, -0.3592415452003479, 0.025785058736...
view } // system exceptions, and unrecoverable exceptions are allowed to bubble // up the call stack so a general error can be shown to the user, rather // than showing the form again. ``` Using inheritance in your own exception classes means you are not required to catch multipile exceptions in your presenter -- you can if there's a need to -- and you don't end up accidentally catching exceptions you can't handle. If your presenter is already at the top of the call stack, add a catch( Exception ) block to handle the system errors with a different view. I always try and
[ 0.2277076244354248, 0.12691730260849, 0.14993174374103546, -0.11408171057701111, -0.1435716599225998, -0.16189341247081757, 0.31511759757995605, -0.043389398604631424, -0.27512165904045105, -0.5345219969749451, -0.05205414444208145, 0.6222524642944336, -0.47619137167930603, 0.0055056791752...
think of my service layer as a seperate distributable library, and throw as specific an exception as makes sense. It is then up to the presenter/controller/remote-service implementation to decide if it needs to worry about the specific details or just to treat problems as a generic error.
[ 0.2980196475982666, 0.10114385932683945, 0.3096216022968292, -0.01821705885231495, -0.09292981773614883, -0.12667012214660645, 0.3158665597438812, 0.14736823737621307, -0.09238496422767639, -0.6837538480758667, -0.30564725399017334, 0.35113784670829773, -0.18195104598999023, 0.165464013814...
Is anyone else having trouble running Swing applications from IntelliJ IDEA 8 Milestone 1? Even the simplest application of showing an empty JFrame seems to crash the JVM. I don't get a stack trace or anything, it looks like the JVM itself crashes and Windows shows me a pop-up that says the usual "This process is no longer responding" message. Console applications work fine, and my Swing code works fine when launching from Netbeans or from the command line. I'm running Windows Vista x64 with the JDK 1.6 Update 10 beta, which may be a configuration the Jetbrains guys haven't run
[ 0.39510852098464966, 0.31243419647216797, 0.3816521465778351, -0.043828368186950684, -0.23459690809249878, -0.33927032351493835, 0.1930091232061386, -0.17923381924629211, -0.3465159833431244, -0.4531806409358978, -0.12245029211044312, 0.8609062433242798, -0.08288391679525375, -0.1859694719...
into yet. I have actually experienced problems from using the JDK 6u10 beta myself and had to downgrade to JDK 6u7 for the time being. This solved some of my problems with among other things swing. Also, i have been running IJ8M1 since the 'release' and I am very satisfied with it, especially if you regard the "beta" tag. It feels snappier and also supports multiple cores which makes my development machine rejoice. ;p Anyway, i use WinXP32 and IJ8M1 with JDK 6u7 and that is afaik very stable indeed.
[ 0.3821832835674286, -0.14478422701358795, 0.10740356147289276, -0.20889772474765778, -0.4190847873687744, -0.1769408881664276, 0.3297775983810425, 0.16061162948608398, 0.16274027526378632, -0.4355713427066803, -0.05748376622796059, 0.892047643661499, 0.14484800398349762, 0.2178512811660766...
I have a Delphi 7 application that has two views of a document (e.g. a WYSIWYG HTML edit might have a WYSIWYG view and a source view - not my real application). They can be opened in separate windows, or docked into tabs in the main window. If I open a modal dialog from one of the separate forms, the main form is brought to the front, and is shown as the selected window in the windows taskbar. Say the main form is the WYSIWYG view, and the source view is poped out. You go to a particular point in the
[ 0.17740407586097717, -0.2867019772529602, 0.9054019451141357, -0.21850115060806274, 0.028117941692471504, 0.07749219238758087, 0.18092474341392517, -0.10333286225795746, -0.08888066560029984, -0.6601849794387817, -0.35553696751594543, 0.5943832397460938, -0.14486408233642578, -0.0947597250...
source view and insert an image tag. A dialog appears to allow you to select and enter the properties you want for the image. If the WYSIWYG view and the source view overlap, the WYSIWYG view will be brought to the front and the source view is hidden. Once the dialog is dismissed, the source view comes back into sight. I've tried setting the owner and the ParentWindow properties to the form it is related to: > `dialog := TDialogForm.Create( parentForm ); > > dialog.ParentWindow := parentForm.Handle;` How can I fix this problem? What else should I be trying? Given that people
[ 0.35688498616218567, -0.08680093288421631, 0.5826056003570557, -0.09215325117111206, 0.04906017333269119, -0.04229506477713585, 0.16875198483467102, -0.22269220650196075, 0.08793450891971588, -0.7905163168907166, -0.185350701212883, 0.8625237941741943, -0.15904264152050018, 0.3680764436721...
seem to be stumbling on my example, perhaps I can try with a better example: a text editor that allows you to have more than one file open at the same time. The files you have open are either in tabs (like in the Delphi IDE) or in its own window. Suppose the user brings up the spell check dialog or the find dialog. What happens, is that if the file is being editing in its own window, that window is sent to below the main form in the z-order when the modal dialog is shown; once the dialog is
[ 0.21961021423339844, -0.0708814412355423, 0.33383503556251526, -0.04517601057887077, -0.10002068430185318, -0.37878164649009705, 0.11353474855422974, -0.16776420176029205, -0.07417631149291992, -0.6650729179382324, -0.24204111099243164, 0.5225582718849182, -0.2825751304626465, -0.173989966...
closed, it is returned to its original z-order. **Note**: If you are using Delphi 7 and looking for a solution to this problem, see my answer lower down on the page to see what I ended up doing. I'd use this code... (Basically what Lars said) ``` dialog := TDialogForm.Create( parentForm ); dialog.PopupParent := parentForm; dialog.PopupMode := pmExplicit; dialog.ShowModal(); ```
[ 0.04097592830657959, -0.04626782611012459, 1.0833790302276611, -0.05277156084775925, 0.05931083485484123, 0.021639686077833176, 0.31736981868743896, -0.01358560286462307, -0.262762188911438, -0.319872111082077, -0.5147333145141602, 0.512371838092804, -0.5240710377693176, 0.1932367980480194...
I'm trying to reteach myself some long forgotten math skills. This is part of a much larger project to effectively "teach myself software development" from the ground up (the details are [here](http://www.appscanadian.ca/archives/cs-101-introduction-to-computer-science/) if you're interested in helping out). My biggest stumbling block so far has been math - how can I learn about algorithms and asymptotic notation without it?? What I'm looking for is some sort of "dependency tree" showing what I need to know. Is calculus required before discrete? What do I need to know before calculus (read: components to the general "pre-calculus" topic)? What can I cut out to
[ 0.30900630354881287, 0.36632099747657776, -0.2525632083415985, 0.16301539540290833, 0.18616865575313568, 0.14631608128547668, 0.16017736494541168, 0.24813690781593323, -0.12219977378845215, -0.788334310054779, 0.16602309048175812, 0.43126001954078674, 0.1891186535358429, -0.034025944769382...
fast track the project ("what can I go back for later")? Thank! Here's how my school did it: ``` base: algebra trigonometry analytic geometry track 1 track 2 track 3 calc 1 linear algebra
[ -0.13157503306865692, -0.07349611818790436, 0.01674162782728672, 0.5114351511001587, 0.18943479657173157, -0.32401639223098755, -0.043113064020872116, 0.37893223762512207, -0.05904550477862358, -0.39687812328338623, 0.06446437537670135, 0.7754508256912231, 0.29580628871917725, -0.623977363...
statistics calc 2 discrete math 1 calc 3 (multivariable) discrete math 2 differential equations ``` The base courses were a prerequisite for everything, the tracks were independent and taken in order. So to answer your specific question, only algebra is needed for discrete. If you want to fast track, do one of these: ``` algebra, discrete algebra, linear algebra, discrete (if you
[ -0.0731852799654007, -0.13204322755336761, -0.03683727979660034, 0.3547559082508087, -0.285834401845932, -0.21760447323322296, -0.2606848180294037, 0.07565316557884216, -0.1654331088066101, -0.44872888922691345, 0.04516640305519104, 0.7544787526130676, -0.374396413564682, -0.43805444240570...
want to cover matrices first) ``` HTH... It about killed me when I returned to school and took these, but I'm a much better programmer for it. Good Luck!
[ 0.39056509733200073, 0.5678094625473022, 0.24107469618320465, -0.04366949573159218, 0.20783250033855438, -0.24724744260311127, 0.03702092170715332, 0.07778101414442062, -0.3632069528102875, -0.5902360081672668, 0.04388447850942612, 0.4397675693035126, -0.11476602405309677, -0.1991643756628...
Python uses the reference count method to handle object life time. So an object that has no more use will be immediately destroyed. But, in Java, the GC(garbage collector) destroys objects which are no longer used at a specific time. Why does Java choose this strategy and what is the benefit from this? Is this better than the Python approach? There are drawbacks of using reference counting. One of the most mentioned is circular references: Suppose A references B, B references C and C references B. If A were to drop its reference to B, both B and C will still have a reference
[ -0.038989774882793427, 0.12276232242584229, -0.09942798316478729, 0.09622853249311447, -0.4047917425632477, -0.21131585538387299, 0.016860980540513992, -0.10989247262477875, -0.611139714717865, -0.16518086194992065, 0.14184007048606873, 0.2483631819486618, -0.6927796602249146, 0.2675098478...
count of 1 and won't be deleted with traditional reference counting. CPython (reference counting is not part of python itself, but part of the C implementation thereof) catches circular references with a separate garbage collection routine that it runs periodically... Another drawback: Reference counting can make execution slower. Each time an object is referenced and dereferenced, the interpreter/VM must check to see if the count has gone down to 0 (and then deallocate if it did). Garbage Collection does not need to do this. Also, Garbage Collection can be done in a separate thread (though it can be a bit tricky). On
[ 0.3169366717338562, -0.05917031690478325, 0.30334895849227905, -0.04350006580352783, -0.27688607573509216, -0.13189204037189484, 0.12863068282604218, -0.28972116112709045, -0.5444427728652954, -0.12221973389387131, 0.10789433866739273, 0.36048489809036255, -0.4522189795970917, 0.1667803227...
machines with lots of RAM and for processes that use memory only slowly, you might not want to be doing GC at all! Reference counting would be a bit of a drawback there in terms of performance...
[ 0.12718592584133148, 0.28778254985809326, 0.030029285699129105, 0.37809115648269653, -0.058636974543333054, 0.0551886148750782, 0.06299906969070435, -0.005632894579321146, -0.6362231969833374, -0.30136677622795105, 0.27801838517189026, 0.42130401730537415, -0.2515895664691925, 0.0794233903...
Whilst analysing some legacy code with FXCop, it occurred to me is it really that bad to catch a general exception error within a try block or should you be looking for a specific exception. Thoughts on a postcard please. Obviously this is one of those questions where the only real answer is "it depends." The main thing it depends on is where your are catching the exception. In general libraries should be more conservative with catching exceptions whereas at the top level of your program (e.g. in your main method or in the top of the action method in a controller,
[ 0.38893723487854004, -0.24088895320892334, -0.08792311698198318, 0.23299655318260193, -0.10842039436101913, -0.11476906388998032, 0.08410614728927612, -0.033465247601270676, -0.22593672573566437, -0.45586785674095154, 0.40482673048973083, 0.4080490171909332, -0.18749864399433136, -0.170122...
etc) you can be more liberal with what you catch. The reason for this is that e.g. you don't want to catch all exceptions in a library because you may mask problems that have nothing to do with your library, like "OutOfMemoryException" which you really would prefer bubbles up so that the user can be notified, etc. On the other hand, if you are talking about catching exceptions inside your main() method which catches the exception, displays it and then exits... well, it's probably safe to catch just about any exception here. The most important rule about catching all exceptions is that
[ 0.3865472972393036, 0.07980223000049591, -0.010009941644966602, 0.3526473939418793, 0.03975505381822586, -0.62240070104599, 0.3904125392436981, 0.32569578289985657, -0.5676318407058716, -0.47997328639030457, -0.007377670146524906, 0.3333296477794647, -0.42353320121765137, 0.187232077121734...
you should never just swallow all exceptions silently... e.g. something like this in Java: ``` try { something(); } catch (Exception ex) {} ``` or this in Python: ``` try: something() except: pass ``` Because these can be some of the hardest issues to track down. A good rule of thumb is that you should only catch exceptions that you can properly deal with yourself. If you cannot handle the exception completely then you should let it bubble up to someone who can.
[ 0.39437004923820496, 0.27155908942222595, -0.413500040769577, -0.2735000252723694, -0.07935982942581177, -0.47513705492019653, 0.669015645980835, 0.1873321682214737, -0.5296772718429565, -0.568553626537323, -0.2845988869667053, 0.3163938820362091, -0.5363331437110901, -0.04079573228955269,...
In Linux, what is the difference between `/dev/ttyS0` and `/dev/ttys0`? I know that the first is a serial port, but what about the second, with the small `s`? [see this](http://www.linuxselfhelp.com/HOWTO/Text-Terminal-HOWTO-6.html) > For a pseudo terminal pair such as > ptyp3 and ttyp3, the pty... is the > master or controlling terminal and the > tty... is the slave. There are only 16 > ttyp's: ttyp0-ttypf (f is a > hexadecimal digit). **To get more > pairs, the 3 letters q, r, s may be > used instead of p**. For example the > pair ttys8, ptys8 is a pseudo terminal > pair. The
[ 0.17897595465183258, -0.159393310546875, 0.24443276226520538, -0.1439375877380371, 0.07081352919340134, 0.25364065170288086, -0.16034509241580963, 0.1050306111574173, -0.08317037671804428, -0.7042946815490723, -0.06989405304193497, 0.6294328570365906, -0.45556193590164185, 0.34281075000762...
master and slave are really > the same "port" but the slave is used > by the application program and the > master is used by a network program > (or the like) which supplies (and > gets) data to/from the slave port.
[ -0.03190326318144798, -0.18770720064640045, 0.10323568433523178, 0.33102673292160034, 0.18310712277889252, -0.07286307960748672, -0.19377383589744568, 0.02012811042368412, 0.019751137122511864, -0.8745535612106323, -0.2852380573749542, 0.22771359980106354, -0.31048303842544556, 0.601369261...
I am writing a Java utility that helps me to generate loads of data for performance testing. It would be *really* cool to be able to specify a regex for Strings so that my generator spits out things that match this. Is something out there already baked that I can use to do this? Or is there a library that gets me most of the way there? **Edit:** Complete list of suggested libraries on this question: 1. [Xeger](https://code.google.com/archive/p/xeger/)\* - Java 2. [Generex](https://github.com/mifmif/Generex)\* - Java 3. [Rgxgen](https://github.com/curious-odd-man/RgxGen) - Java 4. [rxrdg](https://github.com/GoranSiska/rxrdg) - C# \* - Depends on `dk.brics.automaton` **Edit:** As mentioned in the comments, there is a library available at Google
[ 0.3034106194972992, 0.2585487365722656, 0.04301312193274498, -0.01401724386960268, -0.22573934495449066, 0.05719970911741257, 0.1558641642332077, -0.003026108257472515, -0.24227258563041687, -0.8922284841537476, -0.05430401489138603, 0.23321306705474854, -0.19597961008548737, 0.06622160971...
Code to achieve this: <https://code.google.com/archive/p/xeger/> See also <https://github.com/mifmif/Generex> as suggested by [Mifmif](https://stackoverflow.com/a/24659605/1820) **Original message:** Firstly, with a complex enough regexp, I believe this can be impossible. But you should be able to put something together for simple regexps. If you take a look at the source code of the class java.util.regex.Pattern, you'll see that it uses an internal representation of Node instances. Each of the different pattern components have their own implementation of a Node subclass. These Nodes are organised into a tree. By producing a visitor that traverses this tree, you should be able to call an overloaded generator method or some kind of Builder
[ 0.18448425829410553, 0.011773066595196724, 0.11945784091949463, 0.04491975158452988, 0.07324997335672379, -0.04660734534263611, 0.3803097903728485, -0.1772971898317337, -0.28850001096725464, -0.8204749822616577, -0.07723172008991241, 0.15015919506549835, -0.4358665347099304, 0.164214015007...
that cobbles something together.
[ 0.00985355582088232, 0.29842767119407654, -0.19038744270801544, 0.22105997800827026, -0.06787799298763275, -0.01711236871778965, 0.14263732731342316, 0.28720182180404663, -0.11659787595272064, -0.6075055003166199, 0.4462912380695343, 0.13122816383838654, 0.28390955924987793, -0.05847316607...
I've been using user controls extensively but never use a HttpHandler and was wondering if I am doing something suboptimal or wrong Expect a better answer (probably before I finish typing this) but as a quick summary. A user control is something that can be added to a page. A HttpHandler can be used instead of a page.
[ 0.22065922617912292, -0.15863953530788422, 0.10936243832111359, 0.28967922925949097, -0.3294530212879181, -0.2365015149116516, 0.07717695832252502, 0.06020025536417961, -0.07210271060466766, -0.6486667394638062, -0.06842056661844254, 0.3743079900741577, -0.2902892827987671, 0.0654213950037...
I have a need to create a "transactional" process using an external API that does not support COM+ or .NET transactions (Sharepoint to be exact) What I need to do is to be able to perform a number of processes in a sequence, but any failure in that sequence means that I will have to manually undo all of the previous steps. In my case there are only 2 types of step, both af which are fairly easy to undo/roll back. Does anyony have any suggestions for design patterns or structures that could be usefull for this ? If your changes are done
[ 0.12272121757268906, 0.10041942447423935, 0.33229607343673706, -0.01847732812166214, 0.16258105635643005, -0.04608175531029701, 0.11590132862329483, -0.05686875432729721, -0.5406160950660706, -0.6477383971214294, 0.03876960277557373, 0.382989764213562, -0.28448593616485596, 0.2240781337022...
to the SharePoint object model, you can use the fact that changes are not committed until you call the `Update()` method of the modified object, such as `SPList.Update()` or `SPWeb.Update()`. Otherwise, I would use the *Command* Design Pattern. Chapter 6 in [Head First Design Patterns](https://rads.stackoverflow.com/amzn/click/com/0596007124) even has an example that implements the undo functionality.
[ 0.03257599100470543, -0.09294992685317993, 0.4675959646701813, -0.1899460107088089, 0.18926545977592468, -0.16041527688503265, 0.14502671360969543, -0.24500976502895355, -0.5017476081848145, -0.4454568028450012, -0.0772259384393692, 0.562343955039978, -0.3449077308177948, 0.048068508505821...
I'm trying to build a C# console application to automate grabbing certain files from our website, mostly to save myself clicks and - frankly - just to have done it. But I've hit a snag that for which I've been unable to find a working solution. The website I'm trying to which I'm trying to connect uses ASP.Net forms authorization, and I cannot figure out how to authenticate myself with it. This application is a complete hack so I can hard code my username and password or any other needed auth info, and the solution itself doesn't need to be something
[ 0.39327651262283325, 0.26534512639045715, 0.30400195717811584, 0.06052739545702934, 0.20742902159690857, -0.12437693774700165, 0.42446425557136536, 0.22493617236614227, -0.018643660470843315, -0.5285323858261108, -0.10808265954256058, 0.33968424797058105, -0.19322854280471802, 0.2436733990...
that is viable enough to release to general users. In other words, if the only possible solution is a hack, I'm fine with that. Basically, I'm trying to use HttpWebRequest to pull the site that has the list of files, iterating through that list and then downloading what I need. So the actual work on the site is fairly trivial once I can get the website to consider me authorized. ``` <?php
[ 0.7850582599639893, 0.2761674225330353, 0.3341836929321289, 0.11317899823188782, 0.10544495284557343, -0.39909592270851135, 0.1832668036222458, 0.11352862417697906, -0.1640710085630417, -0.3928804099559784, -0.015193721279501915, 0.5758772492408752, 0.01284053549170494, 0.13452821969985962...
/* Resizes an image and converts it to PNG returning the PNG data as a string */ function imageToPng($srcFile, $maxSize = 100) { list($width_orig, $height_orig, $type) = getimagesize($srcFile); // Get the aspect ratio $ratio_orig = $width_orig / $height_orig; $width = $maxSize; $height = $maxSize; // resize to height (orig is portrait) if ($ratio_orig < 1)
[ 0.12229011207818985, -0.3599703311920166, 0.9673787951469421, -0.29833176732063293, -0.14743155241012573, 0.5447180867195129, -0.20819143950939178, -0.5244309902191162, -0.25239500403404236, -0.5706110000610352, -0.3344687521457672, 0.8201928734779358, -0.1019999235868454, -0.2750890851020...
{ $width = $height * $ratio_orig; } // resize to width (orig is landscape) else { $height = $width / $ratio_orig; } // Temporarily increase the memory limit to allow for larger images ini_set('memory_limit', '32M'); switch ($type) { case IMAGETYPE_GIF:
[ 0.0980115756392479, -0.202281191945076, 0.6952856779098511, -0.2869330644607544, 0.038721200078725815, 0.13059160113334656, 0.06717997044324875, -0.31075772643089294, -0.28239497542381287, -0.7468258142471313, -0.051247794181108475, 0.8306076526641846, -0.18080481886863708, 0.1061282306909...
$image = imagecreatefromgif($srcFile); break; case IMAGETYPE_JPEG: $image = imagecreatefromjpeg($srcFile); break; case IMAGETYPE_PNG: $image = imagecreatefrompng($srcFile); break;
[ -0.4279797673225403, -0.08725737035274506, 0.33627817034721375, -0.13305439054965973, 0.1479354351758957, 0.06223103404045105, 0.22734184563159943, -0.047976911067962646, -0.2143835723400116, -0.2770293056964874, -0.7608414888381958, 0.5066993236541748, -0.5209439992904663, 0.1109101623296...
default: throw new Exception('Unrecognized image type ' . $type); } // create a new blank image $newImage = imagecreatetruecolor($width, $height); // Copy the old image to the new image imagecopyresampled($newImage, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); // Output to a temp file $destFile = tempnam(); imagepng($newImage, $destFile); // Free memory
[ 0.15720045566558838, -0.31762707233428955, 0.3320092260837555, 0.06951828300952911, 0.10414917021989822, 0.18447145819664001, 0.3984237611293793, -0.23589012026786804, -0.3052239716053009, -0.7065035700798035, -0.4084624648094177, 0.7021445631980896, -0.40531444549560547, 0.109716840088367...
imagedestroy($newImage); if ( is_file($destFile) ) { $f = fopen($destFile, 'rb'); $data = fread($f); fclose($f); // Remove the tempfile unlink($destFile);
[ 0.03471421077847481, -0.3510694205760956, 0.8356541395187378, -0.15065525472164154, 0.1317438781261444, -0.07553074508905411, 0.296653687953949, -0.3010980188846588, -0.19425392150878906, -0.6523615717887878, -0.4393194019794464, 0.662133514881134, -0.6341037154197693, 0.2377493977546692, ...
return $data; } throw new Exception('Image conversion failed.'); } ```
[ 0.11499430239200592, 0.132256418466568, -0.041257549077272415, -0.03925156965851784, 0.12510161101818085, -0.07942132651805878, 0.40539348125457764, -0.0755922943353653, 0.014698922634124756, -0.43670618534088135, -0.3979501724243164, 0.6133888363838196, -0.42124053835868835, 0.23661980032...
I have a client/server application that communicates with .Net remoting. I need my clients to be able to find the server(s) on the network without requiring client-side configuration. As far as I know, there is no support for discovery in remoting. I am prepared to implement a UDP solution where the clients will be able to find the servers via broadcast messages. I want to hear the collective SO wisdom before I go ahead. Is this the best way? Any other suggestions? I've looked at both SSDP and UPnP for this type of functionality, but I'd recommend going with a custom
[ 0.5578532218933105, -0.08984065800905228, 0.25510233640670776, -0.02497192658483982, -0.15545587241649628, -0.2417578101158142, 0.1365853250026703, 0.09152839332818985, -0.41971439123153687, -0.9041946530342102, 0.11967134475708008, 0.5272535085678101, -0.05503532290458679, 0.0993721857666...
UDP [multicast](http://en.wikipedia.org/wiki/Multicast) solution. Basically, multicast is very similar to a broadcast, but only machines that have joined the multicast group (i.e. requested the broadcast) are contacted. IMHO, SSDP and UPnP and bloated and overly complicated for resource discovery... but hey, it's a standard. ;)
[ 0.22120080888271332, -0.21825812757015228, 0.5100950598716736, 0.05550516024231911, -0.1671396642923355, -0.4735908508300781, 0.035775814205408096, -0.010488282889127731, -0.6179267764091492, -0.4929159879684448, -0.2700413465499878, 0.18895430862903595, -0.5894257426261902, 0.137898936867...
I find that the .NET event model is such that I'll often be raising an event on one thread and listening for it on another thread. I was wondering what the cleanest way to marshal an event from a background thread onto my UI thread is. Based on the community suggestions, I've used this: ``` // earlier in the code mCoolObject.CoolEvent+= new CoolObjectEventHandler(mCoolObject_CoolEvent); // then private void mCoolObject_CoolEvent(object sender, CoolObjectEventArgs args) { if (InvokeRequired) { CoolObjectEventHandler cb =
[ 0.3266938626766205, 0.15730927884578705, 0.36032044887542725, -0.007480846717953682, 0.112978495657444, -0.26927533745765686, 0.26962152123451233, -0.37310996651649475, -0.4147804379463196, -0.5499199628829956, -0.16334465146064758, 0.3125404715538025, -0.15976209938526154, 0.4095928370952...
new CoolObjectEventHandler( mCoolObject_CoolEvent); Invoke(cb, new object[] { sender, args }); return; } // do the dirty work of my method here } ``` A couple of observations: * Don't create simple delegates explicitly in code like that unless you're pre-2.0 so you could use: ```cs BeginInvoke(new EventHandler<CoolObjectEventArgs>(mCoolObject_CoolEvent),
[ 0.10948437452316284, 0.13944341242313385, 0.5113704800605774, 0.16407528519630432, 0.15994887053966522, -0.3914826512336731, 0.3944912850856781, -0.40433210134506226, -0.38049933314323425, -0.6498211622238159, -0.24403473734855652, 0.4171941876411438, -0.31628313660621643, 0.11540173739194...
sender, args); ``` * Also you don't need to create and populate the object array because the args parameter is a "params" type so you can just pass in the list. * I would probably favor `Invoke` over `BeginInvoke` as the latter will result in the code being called asynchronously which may or may not be what you're after but would make handling subsequent exceptions difficult to propagate without a call to `EndInvoke`. What would happen is that your app will end up getting a `TargetInvocationException` instead.
[ 0.14711898565292358, 0.11679887026548386, 0.4065290689468384, -0.13602766394615173, -0.19749769568443298, -0.13875530660152435, 0.5811516642570496, 0.033192455768585205, -0.155955508351326, -0.5412405133247375, -0.36330485343933105, 0.5673738718032837, -0.6602434515953064, 0.14595973491668...
I'm looking at the [PHP Manual](http://www.php.net/manual/en/), and I'm not seeing a section on data structures that most languages have, such as lists and sets. Am I just blind or does PHP not have anything like this built in? The only native data structure in PHP is array. Fortunately, arrays are quite flexible and can be used as hash tables as well. <http://www.php.net/array> However, there is SPL which is sort of a clone of C++ STL. <http://www.php.net/manual/en/book.spl.php>
[ 0.13624070584774017, 0.06747103482484818, 0.2294410914182663, 0.0750938206911087, -0.7050297260284424, -0.30600905418395996, 0.11863907426595688, -0.05104030296206474, -0.42068415880203247, -0.2979913055896759, 0.03365681692957878, 0.3513031601905823, -0.40121832489967346, -0.1514338403940...
Say I have a Student table, it's got an int ID. I have a fixed set of 10 multiple choice questions with 5 possible answers. I have a normalized answer table that has the question id, the Student.answer (1-5) and the Student.ID I'm trying to write a single query that will return all scores over a certain pecentage. To this end I wrote a simple UDF that accepts the Student.answers and the correct answer, so it has 20 parameters. I'm starting to wonder if it's better to denormalize the answer table, bring it into my applcation and let my application do the
[ 0.15047197043895721, 0.31995153427124023, 0.7930022478103638, 0.3262117803096771, -0.1318492740392685, 0.3978058099746704, -0.05053749680519104, -0.2757112681865692, 0.012538590468466282, -0.4400160014629364, 0.027686137706041336, 0.2804703116416931, 0.03896861895918846, 0.2088240087032318...
scoring. Anyone ever tackle something like this and have insight? If I understand your schema and question correctly, how about something like this: ``` select student_name, score from students join (select student_answers.student_id, count(*) as score from student_answers, answer_key group by student_id where student_answers.question_id = answer_key.question_id and student_answers.answer = answer_key.answer) as student_scores on students.student_id = student_scores.student_id where score >= 7 order by score, student_name ``` That should select the students with a score of 7 or more, for
[ 0.048791781067848206, 0.16390307247638702, 0.3331587314605713, 0.1548924297094345, 0.03433000668883324, -0.10433758795261383, 0.17327141761779785, 0.1251581460237503, -0.4701163172721863, -0.6584867238998413, -0.1197742372751236, 0.5211355686187744, 0.09296054393053055, 0.14431002736091614...
example. Just adjust the where clause for your purposes.
[ 0.4292534291744232, -0.05853002518415451, -0.16434988379478455, 0.04985407739877701, 0.4415607154369354, -0.5828059315681458, 0.22634141147136688, 0.23861163854599, 0.024599889293313026, -0.4501667320728302, -0.08364226669073105, 0.4382627010345459, -0.16278424859046936, -0.268419355154037...
I am looking for information on handling search in different ORMs. Currently I am redeveloping some old application in PHP and one of requirements is: make everything or almost everything searchable, so user just types "punkrock live" and the app finds videos clips, music tracks, reviews, upcoming events or even user comments labeled that way. In environment where everything is searchable ORM need to support this feature in two ways: * providing some indexing API on "O" side of ORM * providing means for bulk database retrieval on "R" side Ideal solution would return ready made objects based on searched string. Do you know any good
[ 0.7690809965133667, 0.2505640983581543, 0.09162898361682892, 0.3168713450431824, -0.18596281111240387, -0.39963969588279724, 0.2829757332801819, 0.15739580988883972, -0.3047933280467987, -0.43918949365615845, 0.30135688185691833, 0.536976158618927, 0.10144073516130447, 0.05561976879835129,...
end-to-end solutions that does the job, not necessarily in PHP? If you dealt with similar problem it would be nice to listen what your experience is. Something more than *Use Lucene* or *semantic web is the way* oneliners, tho ;-)\* I have recently integrated the [Compass](http://www.compass-project.org/) search engine into a Java EE 5 application. It is based on [Lucene Java](http://lucene.apache.org/java/docs/index.html) and supports different ORM frameworks as well as other types of models like XML or no real model at all ;) In the case of an object model managed by an ORM framework you can annotate your classes with special annotations (e.g. @Searchable),
[ -0.27932289242744446, -0.20083020627498627, 0.4626801311969757, 0.1792924851179123, 0.08156129717826843, 0.0792597085237503, 0.11598428338766098, -0.04133583605289459, 0.05032578855752945, -0.7054876685142517, 0.061445899307727814, 0.45272621512413025, 0.07609431445598602, -0.1099673211574...
register your classes and let Compass index them on application startup and listen to changes to the model automatically. When it comes to searching, you have the power of Lucene at hand. Compass then gives you instances of your model objects as search result. It's not PHP, but you said it didn't have to be PHP necessarily ;) Don't know if this helps, though...
[ -0.25150778889656067, -0.28894108533859253, 0.4455474317073822, 0.41048482060432434, -0.15180514752864838, 0.013788895681500435, 0.2179374247789383, 0.14526721835136414, -0.029713304713368416, -0.6456896066665649, 0.25811487436294556, 0.3182700574398041, 0.15687721967697144, -0.11146935820...
I'm getting some strange, intermittent, data aborts (< 5% of the time) in some of my code, when calling `memset()`. The problem is that is usually doesn't happen unless the code is running for a couple days, so it's hard to catch it in the act. I'm using the following code: ``` char *msg = (char*)malloc(sizeof(char)*2048); char *temp = (char*)malloc(sizeof(char)*1024); memset(msg, 0, 2048); memset(temp, 0, 1024); char *tempstr = (char*)malloc(sizeof(char)*128); sprintf(temp, "%s %s/%s %s%s", EZMPPOST, EZMPTAG, EZMPVER, TYPETXT, EOL); strcat(msg, temp); //Add Data memset(tempstr, '\0', 128); wcstombs(tempstr, gdevID, wcslen(gdevID)); sprintf(temp, "%s: %s%s", "DeviceID", tempstr, EOL); strcat(msg, temp); ``` As you can see, I'm not trying to use memset with a size larger that what's originally allocated
[ -0.11167041212320328, 0.006591053679585457, 0.5528770685195923, -0.0012419603299349546, 0.341095894575119, 0.12358194589614868, 0.644385576248169, 0.1637830287218094, -0.4875267744064331, -0.7076990008354187, -0.46396636962890625, 0.09815866500139236, -0.370723694562912, 0.1270059496164322...
with `malloc()` Anyone see what might be wrong with this? `malloc` can return `NULL` if no memory is available. You're not checking for that.
[ 0.07972726225852966, 0.18592090904712677, -0.24626325070858002, 0.2030760496854782, 0.017482785508036613, -0.2777600586414337, 0.3975650668144226, 0.5824995040893555, -0.351979523897171, -0.32607144117355347, -0.341919481754303, 0.5860820412635803, -0.25727516412734985, 0.20385687053203583...
I've come to love [Amazon's EC2 service](http://en.wikipedia.org/wiki/Amazon_Elastic_Compute_Cloud) and I'm looking for something similar that supports the ability to save a running Windows server image and start new instances from it. I contacted [GoGrid](http://www.gogrid.com/) (the feature is planned in future) and [Mosso](http://www.mosso.com/) (no joy) Anyone know of any hosting/cloud providers that can dothis? I have just received a message from Amazon to the effect that that they will be [supporting Windows Server on EC2](http://aws.amazon.com/windows/) this fall. Wahaay!!
[ 0.4731594920158386, -0.28607237339019775, 0.7999353408813477, 0.014751581475138664, 0.057384733110666275, -0.13009896874427795, 0.2537649869918823, 0.37443551421165466, -0.3792881965637207, -0.7929127216339111, 0.04511333256959915, 0.42541196942329407, 0.013832543976604939, 0.1580483317375...
We've got a page with a ton of jQuery (approximately 2000 lines) that we want to trim down b/c it is a maintenance nightmare, and it might be easier to maintain on the server. We've thought about using UpdatePanel for this. However, we don't like the fact that the UpdatePanel is sending the whole page back to the server. Don't move to UpdatePanels. After coming from jQuery, [the drop in performance](http://encosia.com/2007/07/11/why-aspnet-ajax-updatepanels-are-dangerous/) would be untenable. Especially on a page as complex as yours sounds. If you have 2,000 lines of JavaScript code, the solution is to refactor that code. If you put 2,000
[ 0.3237418234348297, 0.07595192641019821, 0.3249908983707428, 0.2566168010234833, -0.15003898739814758, -0.0650244653224945, 0.37941667437553406, 0.19882556796073914, -0.3498115837574005, -0.7534396648406982, 0.13297243416309357, 0.43354105949401855, -0.18693497776985168, -0.243476465344429...
lines of C# code in one file, it would be difficult to maintain too. That would be difficult to manage effectively with **any** language or tool. If you're using 3.5 SP1, you can use the ScriptManager's new script combining to separate your JavaScript into multiple files with no penalty. That way, you can logically partition your code just as you would with server side code.
[ 0.4668058156967163, -0.18975166976451874, 0.21547234058380127, 0.32236531376838684, -0.12639044225215912, -0.20462875068187714, 0.11369488388299942, -0.11135668307542801, -0.32071390748023987, -0.8087265491485596, 0.016092734411358833, 0.2103496491909027, -0.32172828912734985, -0.014681363...
The [Wikipedia article on ANSI C](http://en.wikipedia.org/wiki/ANSI_C) says: > One of the aims of the ANSI C standardization process was to produce a superset of K&R C (the first published standard), incorporating many of the unofficial features subsequently introduced. However, the standards committee also included several new features, such as function prototypes (borrowed from the C++ programming language), and a more capable preprocessor. The syntax for parameter declarations was also changed to reflect the C++ style. That makes me think that there are differences. However, I didn't see a comparison between K&R C and ANSI C. Is there such a document? If not,
[ 0.05960284546017647, 0.1552046686410904, 0.011604169383645058, -0.15392787754535675, -0.5244131684303284, -0.15867367386817932, -0.013894924893975258, -0.2850620448589325, -0.39887285232543945, -0.15602955222129822, -0.12121511250734329, 0.49329474568367004, -0.676919162273407, -0.04877410...
what are the major differences? EDIT: I believe the K&R book says "ANSI C" on the cover. At least I believe the version that I have at home does. So perhaps there isn't a difference anymore? There may be some confusion here about what "K&R C" is. The term refers to the language as documented in the first edition of "The C Programming Language." Roughly speaking: the input language of the Bell Labs C compiler circa 1978. Kernighan and Ritchie were involved in the ANSI standardization process. The "ANSI C" dialect superceded "K&R C" and subsequent editions of "The C Programming Language" adopt
[ -0.11721374839544296, 0.4876153767108917, -0.07142485678195953, -0.46561628580093384, -0.3913074731826782, -0.03161526098847389, 0.08856560289859772, 0.07303029298782349, -0.23453082144260406, -0.03200799971818924, -0.052326977252960205, 0.8922272324562073, -0.5077089071273804, 0.085067145...
the ANSI conventions. "K&R C" is a "dead language," except to the extent that some compilers still accept legacy code.
[ 0.2620885670185089, 0.5968156456947327, -0.3172716200351715, -0.3040890395641327, 0.19351570308208466, -0.12213528901338577, 0.26716551184654236, 0.3507877588272095, -0.2168167382478714, 0.3648744523525238, -0.5971519351005554, 0.2832900881767273, -0.5122746825218201, 0.5262650847434998, ...
I have a folder in my web server used for the users to upload photos using an ASP page. Is it safe enough to give IUSR write permissions to the folder? Must I secure something else? I am afraid of hackers bypassing the ASP page and uploading content directly to the folder. I'm using ASP classic and IIS6 on Windows 2003 Server. The upload is through HTTP, not FTP. Edit: Changing the question for clarity and changing my answers as comments. also, I would recommend not to let the users upload into a folder that's accessible from the web. Even the best MIME type detection
[ 0.4426134526729584, 0.20086051523685455, 0.6377763152122498, 0.10971006006002426, -0.0446973517537117, -0.16376793384552002, 0.3494453728199005, -0.13025452196598053, -0.37989628314971924, -0.5885951519012451, -0.036707982420921326, 0.5924806594848633, -0.17769747972488403, -0.118740387260...
may fail and you absolutely don't want users to upload, say, an executable disguised as a jpeg in a case where your MIME sniffing fails, but the one in IIS works correctly. In the PHP world it's even worse, because an attacker could upload a malicious PHP script and later access it via the webserver. Always, always store the uploaded files in a directory somewhere outside the document root and access them via some accessing-script which does additional sanitizing (and at least explicitly sets a image/whatever MIME type.
[ 0.33859214186668396, 0.14598830044269562, 0.21073000133037567, 0.30322936177253723, 0.05891333520412445, -0.207431361079216, 0.6815645694732666, -0.1189638152718544, -0.2928575277328491, -0.5904534459114075, -0.3071678578853607, 0.6274468898773193, -0.26496827602386475, -0.1155338287353515...
I would like to have a reference for the pros and cons of using include **files vs objects(classes)** when developing PHP applications. I know I would benefit from having one place to go for this answer...I have a few opinions of my own but I look forward to hearing others. **A Simple Example:** Certain pages on my site are only accessible to logged in users. I have two options for implementation (there are others but let's limit it to these two) 1. *Create an authenticate.php file and include it on every page. It holds the logic for authentication.* 2. *Create a user object, which has
[ 0.43688613176345825, 0.13156147301197052, 0.14505097270011902, 0.11637789011001587, -0.2685737907886505, -0.28665709495544434, 0.34017401933670044, -0.04489683732390404, -0.012639565393328667, -0.5691741704940796, 0.23053771257400513, 0.1940820962190628, -0.04665376618504524, -0.0089303590...
an authenticate function, reference the object for authentication on every page.* **Edit** I'd like to see some way weigh the benefits of one over the other. My current (and weak reasons) follow: Includes - Sometimes a function is just easier/shorter/faster to call Objects - Grouping of functionality and properties leads for longer term maintenance. **Includes** - Less code to write (no constructor, no class syntax) call me lazy but this is true. **Objects** - Force formality and a single approach to functions and creation. **Includes** - Easier for a novice to deal with Objects - Harder for novices, but frowned upon by professionals. I look at these factors
[ 0.1373158097267151, 0.3600335717201233, 0.3037835657596588, 0.13776296377182007, -0.3813909590244293, -0.439614862203598, 0.7401130795478821, -0.19901488721370697, -0.11999060958623886, -0.5008034706115723, -0.3369150757789612, 0.598629355430603, -0.20543284714221954, -0.24753336608409882,...
at the start of a project to decide if I want to do includes or objects. Those are a few pros and cons off the top of my head. These are not really opposite choices. You will have to include the checking code anyway. I read your question as procedural programming vs. OO programming. Writing a few lines of code, or a function, and including it in your page header was how things were done in PHP3 or PHP4. It's simple, it works (that's how we did it in [osCommerce](http://www.oscommerce.com/), for example, an eCommerce PHP application). But it's not easy to maintain and modify,
[ 0.7994049787521362, -0.007948548533022404, -0.021621009334921837, 0.15869776904582977, -0.13351589441299438, -0.20849598944187164, 0.13238584995269775, -0.1311010718345642, -0.14228510856628418, -0.4220184087753296, 0.23330058157444, 0.34208300709724426, -0.18445003032684326, -0.2642513215...
as many developers can confirm. In PHP5 you'd write a user object which will carry its own data and methods for authentication. Your code will be clearer and easier to maintain as everything having to do with users and authentication will be concentrated in a single place.
[ 0.43760108947753906, 0.2462334781885147, 0.15114609897136688, 0.2188231199979782, -0.34675636887550354, -0.16966213285923004, 0.3514496386051178, -0.17450037598609924, -0.2730202376842499, -0.45704835653305054, 0.04376201704144478, 0.10362020879983902, 0.00842239335179329, 0.05059784278273...
How do we create a search plugin for Safari? Like [this post](https://stackoverflow.com/questions/20830/firefox-users-here-is-your-stackoverflow-search-plugin) If you're looking for a search plugin specifically for this site, someone will have to write one.
[ 0.23836979269981384, 0.07371243834495544, 0.2253180593252182, 0.12062711268663406, 0.2530531883239746, -0.5203508734703064, 0.0857791006565094, -0.16581608355045319, -0.5619163513183594, -0.4184570014476776, 0.028098952025175095, 0.4444597661495209, -0.449297159910202, -0.14802159368991852...
In Ruby 1.8 and earlier, ``` Foo ``` is a constant (a Class, a Module, or another constant). Whereas ``` foo ``` is a variable. The key difference is as follows: ``` module Foo bar = 7 BAZ = 8 end Foo::BAZ # => 8 Foo::bar # NoMethodError: undefined method 'bar' for Foo:Module ``` That's all well and good, but Ruby 1.9 [allows UTF-8 source code](http://pragdave.blogs.pragprog.com/pragdave/2008/04/fun-with-ruby-1.html). So is `℃` "uppercase" or "lowecase" as far as this is concerned? What about `⊂` (strict subset) or `Ɖfoo`? Is there a general rule? *Later:* Ruby-core is already considering some of the mathematical operators. For example ``` module Kernel def √(num) ... end def ∑(*args)
[ 0.08595979958772659, 0.19117285311222076, 0.3735954761505127, -0.4333230257034302, -0.342591792345047, -0.47139090299606323, 0.35528048872947693, -0.32921063899993896, -0.19348877668380737, -0.048371821641922, -0.34793850779533386, 0.6004758477210999, -0.6867743730545044, -0.12064288556575...
... end end ``` would allow ``` x = √2 y = ∑(1, 45, ...) ``` I would love to see ``` my_proc = λ { |...| ... } x ∈ my_enumerable # same as my_enumerable.include?(x) my_infinite_range = (1..∞) return 'foo' if x ≠ y 2.21 ≈ 2.2 ``` I can't get IRB to accept UTF-8 characters, so I used a test script (`/tmp/utf_test.rb`). "λ" works fine as a variable name: ``` # encoding: UTF-8 λ = 'foo' puts λ # from the command line: > ruby -KU /tmp/utf_test.rb foo ``` "λ" also works fine as a method name: ``` # encoding: UTF-8 Kernel.class_eval do alias_method :λ, :lambda end (λ { puts 'hi' }).call # from the command line: > ruby -KU /tmp/utf_test.rb: hi ``` It doesn't work as a constant, though: ``` # encoding:
[ -0.21087521314620972, 0.020405137911438942, 0.5990749597549438, -0.43737033009529114, -0.025706687942147255, 0.35464727878570557, 0.2796253263950348, -0.30120599269866943, 0.013898319564759731, -0.3698764443397522, 0.03069952130317688, 0.61421138048172, -0.36176446080207825, -0.04009827598...
UTF-8 Object.const_set :λ, 'bar' # from the command line: > ruby -KU /tmp/utf_test.rb: utf_test.rb:2:in `const_set': wrong constant name λ (NameError) ``` Nor does the capitalized version: ``` # encoding: UTF-8 Object.const_set :Λ, 'bar' # from the command line: > ruby -KU /tmp/utf_test.rb: utf_test.rb:2:in `const_set': wrong constant name Λ (NameError) ``` My suspicion is that constant names must start with a capital ASCII letter (must match `/^[A-Z]/`).
[ -0.14224669337272644, 0.4152494966983795, 0.09216960519552231, -0.40127936005592346, -0.16169345378875732, 0.30300307273864746, 0.40115293860435486, -0.13651753962039948, 0.01971234381198883, -0.40142789483070374, -0.48278921842575073, 0.4924538731575012, -0.5888475775718689, 0.21767191588...
Specifically this is regarding when using a client session cookie to identify a session on the server. Is the best answer to use SSL/HTTPS encryption for the entire web site, and you have the best guarantee that no man in the middle attacks will be able to sniff an existing client session cookie? And perhaps second best to use some sort of encryption on the session value itself that is stored in your session cookie? If a malicious user has physical access to a machine, they can still look at the filesystem to retrieve a valid session cookie and use that to hijack
[ 0.12451363354921341, -0.01927265338599682, 0.14386586844921112, 0.24890002608299255, 0.13511307537555695, -0.4063413441181183, 0.19174247980117798, -0.28375428915023804, -0.34383413195610046, -0.6131570935249329, -0.1529732644557953, 0.4627059996128082, 0.0575747974216938, 0.22085005044937...
a session? Encrypting the session value will have zero effect. The session cookie is already an arbitrary value, encrypting it will just generate another arbitrary value that can be sniffed. The only real solution is HTTPS. If you don't want to do SSL on your whole site (maybe you have performance concerns), you might be able to get away with only SSL protecting the sensitive areas. To do that, first make sure your login page is HTTPS. When a user logs in, set a secure cookie (meaning the browser will only transmit it over an SSL link) in addition to the regular
[ 0.40579473972320557, -0.21280471980571747, 0.27733656764030457, 0.20105774700641632, -0.12817302346229553, -0.5491183996200562, 0.8267794251441956, -0.16294699907302856, -0.2910870611667633, -0.5006241798400879, -0.27868616580963135, 0.6672773361206055, -0.49915000796318054, -0.08716019988...
session cookie. Then, when a user visits one of your "sensitive" areas, redirect them to HTTPS, and check for the presence of that secure cookie. A real user will have it, a session hijacker will not. **EDIT**: This answer was originally written in 2008. It's 2016 now, and there's no reason not to have SSL across your entire site. No more plaintext HTTP!
[ 0.3516368269920349, -0.052341215312480927, 0.5816094875335693, 0.24543455243110657, -0.20527370274066925, -0.5322006940841675, 0.68379807472229, 0.022527990862727165, -0.2603874206542969, -0.7629052996635437, -0.14908146858215332, 0.4871293604373932, -0.39221352338790894, 0.065391667187213...
I am going to be using C/C++, and would like to know the best way to talk to a MySQL server. Should I use the library that comes with the server installation? Are they any good libraries I should consider other than the official one? [MySQL++](http://tangentsoft.net/mysql++/)
[ 0.13245128095149994, 0.003064126009121537, 0.3343966007232666, 0.29920077323913574, 0.2002478986978531, -0.323114275932312, 0.11764154583215714, 0.847762942314148, -0.22469575703144073, -0.7771515846252441, -0.06246398016810417, 0.48332077264785767, 0.23948641121387482, -0.1062943711876869...
I know this isn't strictly a programming question but y'all must have experienced this. So...you have four or five RDP sessions open over the corp VPN, you're bashing away inside your favourite IDE, your VPN to the data centre bounces briefly then recovers, all your RDP sessions start re-establishing their connections and whilst doing so sequentially keep grabbing focus, one after the other. Pretty bloody annoying and downright rude. Any idea how to prevent this behaviour and just make the RDP client flash it's taskbar button instead of totally grabbing focus away from whatever you were doing? @[Jason](https://stackoverflow.com/questions/22903/how-do-i-stop-the-windows-rdp-client-grabbing-focus-after-a-reconnect#22911) - thanks for the
[ 0.4501276910305023, 0.08516886085271835, 0.22474776208400726, 0.2879440188407898, -0.358904093503952, -0.3699961006641388, 0.3630661964416504, 0.349348247051239, -0.43173760175704956, -0.12690550088882446, -0.2631549835205078, 0.7232073545455933, 0.03342768922448158, -0.053112924098968506,...
reply, I'm running 64 bit Vista and 64 Bit Windows 2008. Any ideas how well it plays? @[Jason](https://stackoverflow.com/questions/22903/how-do-i-stop-the-windows-rdp-client-grabbing-focus-after-a-reconnect#23049) - good idea. Done. @[Ryan](https://stackoverflow.com/questions/22903/how-do-i-stop-the-windows-rdp-client-grabbing-focus-after-a-reconnect#23139) - thanks also for the answer. I tried [Terminals](http://www.codeplex.com/Terminals) a few times before, but quite often I need to see two or three sessions side by side which the tabbing doesn't really facilitate too well, would've been nice to have a 'pop out in own window' button. I did once grab the source code to fix stuff like that, but never got the time. I also found it behaved oddly whenever there was a brief network disconnect (e.g. xDSL
[ -0.04526282846927643, -0.0031686676666140556, 0.40118083357810974, 0.08359213173389435, -0.23669089376926422, -0.24839359521865845, 0.45529600977897644, 0.33228448033332825, -0.26765987277030945, -0.47085604071617126, -0.16778458654880524, 0.697306215763092, -0.035869307816028595, -0.28250...
flapping) and it would reconnect to the wrong session (usually a new one) and leave the session I had opened in a disconnected state on the server. Otherwise Terminals would've been really cool, we have 200+ windows servers, and organising all those .rdp files can be a pain. I use [Tweak UI](http://www.microsoft.com/windowsxp/Downloads/powertoys/Xppowertoys.mspx) to configure explorer so that apps don't steal focus; you can also configure how many times they flash in the taskbar as well. EDIT: Once you are within Tweak UI, these options are found under General > Focus. EDIT: @Kev, apparently there is [a 64-bit version](http://www.softpedia.com/get/Tweak/System-Tweak/TweakUI-64-Bit-Edition.shtml) (not MS approved, apparently, I
[ 0.31162694096565247, -0.30586716532707214, 0.8465527296066284, 0.0327906534075737, -0.11364759504795074, -0.08525652438402176, 0.40095221996307373, -0.2673340141773224, -0.37104281783103943, -0.734214723110199, -0.28255710005760193, 0.5599963068962097, -0.2866617441177368, -0.2902288138866...
would scan it for viruses of course) that works successfully with the 64-bit version of XP. From what I understand, you download that and then run it in XP compatibility mode as administrator and it will do the trick. Tweak UI is basically a nice wrapper around a collection of registry hacks, so I imagine you could find the hacks themselves if you didn't care for running Tweak UI in this manner. Hope that works for you!
[ 0.6191134452819824, 0.06873719394207001, 0.07551144808530807, 0.3593332767486572, -0.010631491430103779, -0.5880403518676758, 0.5134946703910828, 0.13116973638534546, -0.08253262937068939, -0.6515483856201172, 0.0990026444196701, 0.7181477546691895, -0.23084616661071777, -0.074590928852558...
I'm looking for a way to poll different servers and check that SQL server is up and running. I'm writing my code in C#. I don't particularly care about individual databases, just that SQL server is running and responsive. Any ideas? Well, the brute force solution is to attempt to initiate a connection with the database on each server. That will tell you whether it's running, though you could have timeout issues. The more elegant (but more difficult... isn't that always the way?) solution would be to use WMI to connect to the remote machine and find out if the SQL server process
[ 0.6341110467910767, 0.07169560343027115, 0.23840533196926117, 0.2211116999387741, 0.029220469295978546, -0.09234100580215454, 0.08724233508110046, 0.19754084944725037, -0.06576593220233917, -0.7371958494186401, 0.2719305157661438, 0.6054291129112244, -0.27591344714164734, -0.02134834788739...
is running.
[ 0.09111114591360092, -0.10335808992385864, 0.28309041261672974, -0.10681259632110596, 0.12276087701320648, -0.3368159532546997, 0.6558997631072998, 0.2040216028690338, -0.23734351992607117, -0.3265185058116913, 0.0648346021771431, -0.058957599103450775, -0.1458272486925125, 0.1175077036023...
I'm using the Repeater control on my site to display data from the database. I need to do pagination ("now displaying page 1 of 10", 10 items per page, etc) but I'm not sure I'm going about it the best way possible. I know the Repeater control doesn't have any built-in pagination, so I'll have to make my own. Is there a way to tell the DataSource control to return rows 10-20 of a much larger result set? If not, how do I write that into a query (SQL Server 2005)? I'm currently using the TOP keyword to only return the
[ -0.1866954118013382, 0.28662773966789246, 0.21134713292121887, -0.07645721733570099, -0.25969019532203674, 0.17113097012043, 0.24707086384296417, 0.11448035389184952, -0.3568645715713501, -0.5821264982223511, 0.2450713813304901, 0.24409303069114685, -0.2849736511707306, 0.39564019441604614...
first 10 rows, but I'm not sure how to display rows 10-20. This isn't a way to page the data, but have you looked into the [ListView](http://msdn.microsoft.com/en-us/library/bb398790.aspx) control? It gives the flexibility of repeater / data list but with built in paging like the grid view. And for paging in sql, you would want to do something like [this](http://www.davidhayden.com/blog/dave/archive/2005/12/30/2652.aspx)
[ -0.15323156118392944, -0.17567916214466095, 0.3363962471485138, -0.2809865176677704, -0.10565892606973648, 0.21467410027980804, 0.022787494584918022, -0.11034248769283295, -0.31453946232795715, -0.49992993474006653, 0.039806876331567764, 0.3018724024295807, -0.16583724319934845, 0.03504325...
As a novice developer who is getting into the rhythm of my first professional project, I'm trying to develop good habits as soon as possible. However, I've found that I often forget to test, put it off, or do a whole bunch of tests at the end of a build instead of one at a time. My question is what rhythm do you like to get into when working on large projects, and where testing fits into it. Well, if you want to follow the TDD guys, **before you start to code** ;) I am very much in the same position as you.
[ 0.8726240396499634, 0.20333099365234375, -0.1315476894378662, -0.034078024327754974, 0.05364358052611351, -0.40170055627822876, 0.40107518434524536, 0.2551673352718353, -0.0716087743639946, -0.45782533288002014, 0.2451082468032837, 0.7344998121261597, 0.1331886351108551, -0.370170623064041...
I want to get more into testing, but I am currently in a position where we are working to "get the code out" rather than "get the code out right" which scares the crap out of me. So I am slowly trying to integrate testing processes in my development cycle. Currently, **I test as I code, trying to bust the code as I write it**. I do find it hard to get into the TDD mindset.. Its taking time, but that is the way I would *want* to work.. ### EDIT: I thought I should probably expand on this, this is my basic
[ 0.7456970810890198, 0.1781543642282486, -0.1199079304933548, 0.14112678170204163, -0.14215905964374542, -0.23326389491558075, 0.6005651354789734, 0.16940884292125702, 0.07458744943141937, -0.8442559242248535, 0.24052174389362335, 0.6263294219970703, 0.033495768904685974, -0.015254193916916...
"working process"... 1. Plan what I want from the code, possible object design, whatever. 2. Create my first class, add a huge comment to the top outlining what my "vision" for the class is. 3. Outline the basic test scenarios.. These will basically become the unit tests. 4. Create my first method.. Also writing a short comment explaining how it is *expected* to work. 5. Write an automated test to see if it does what I expect. 6. Repeat steps 4-6 for each method (note the automated tests are in a huge list that runs on F5). 7. I then create some beefy tests to emulate the class in the working
[ 0.4515377879142761, -0.15209127962589264, -0.09993690252304077, 0.03665627911686897, -0.040089622139930725, 0.18303067982196808, 0.325521320104599, -0.3088795244693756, 0.12424632906913757, -0.7748317718505859, 0.0713539645075798, 0.6384574174880981, 0.06396236270666122, -0.386556744575500...
environment, obviously fixing any issues. 8. If any new bugs come to light following this, I then go back and write the new test in, make sure it fails (this also serves as proof-of-concept for the bug) then fix it.. I hope that helps.. Open to comments on how to improve this, as I said it is a concern of mine..
[ 0.4290944039821625, 0.344699501991272, 0.21305544674396515, 0.0838361456990242, 0.3123580515384674, -0.30064570903778076, 0.5312849283218384, 0.24878063797950745, -0.2501309812068939, -0.7720669507980347, -0.05004299804568291, 0.6536821126937866, -0.3392408788204193, -0.284597247838974, ...
What's the best way to handle a user going back to a page that had cached items in an asp.net app? Is there a good way to capture the back button (event?) and handle the cache that way? You can try using the [HttpResponse.Cache property](http://msdn.microsoft.com/en-us/library/system.web.httpresponse.cache.aspx) if that would help: ``` Response.Cache.SetExpires(DateTime.Now.AddSeconds(60)); Response.Cache.SetCacheability(HttpCacheability.Public); Response.Cache.SetValidUntilExpires(false); Response.Cache.VaryByParams["Category"] = true; if (Response.Cache.VaryByParams["Category"]) { //... } ``` Or could could block caching of the page altogether with [HttpResponse.CacheControl](http://msdn.microsoft.com/en-us/library/system.web.httpresponse.cachecontrol.aspx), but its been deprecated in favor of the Cache property above: ``` Response.CacheControl = "No-Cache"; ``` Edit: OR you could really [go nuts](http://forums.asp.net/t/1013531.aspx) and do it all by hand: ``` Response.ClearHeaders(); Response.AppendHeader("Cache-Control", "no-cache"); //HTTP 1.1 Response.AppendHeader("Cache-Control", "private"); // HTTP 1.1 Response.AppendHeader("Cache-Control", "no-store"); // HTTP 1.1 Response.AppendHeader("Cache-Control",
[ -0.008815402165055275, -0.11907150596380234, 0.48949292302131653, 0.11546261608600616, 0.13031494617462158, 0.07329297810792923, 0.5366718173027039, -0.5455124974250793, -0.36127039790153503, -0.4254542589187622, -0.5081185102462769, 0.3588360548019409, -0.24103140830993652, -0.02958414889...