instruction
stringlengths
0
30k
Essentially I have a PHP page that calls out some other HTML to be rendered through an object's method. It looks like this: MY PHP PAGE: // some content... <?php $GLOBALS["topOfThePage"] = true; $this->renderSomeHTML(); ?> // some content... <?php ...
I'm looking for the best way to take a simple input: echo -n "Enter a string here: " read -e STRING and clean it up by removing non-alphanumeric characters, lower(case), and replacing spaces with underscores. Does order matter? Is `tr` the best / only way to go about this?
if you want a "stash" that runs off a branch do something like this to store your changes on a new branch off your current branch. git checkout -b new_stash git commit -a -m "stashed changes" to undo the stash git reset HEAD^ git stash is especially useful because you can pull changes into a di...
if you want a "stash" that runs off a branch do something like this to store your changes on a new branch off your current branch. git checkout -b new_stash git commit -a -m "stashed changes" to undo the stash git reset HEAD^ git branch -d new_stash git stash is especially useful because y...
Manipulating cookies on the client side is rather the opposite of "best practice". And it shouldn't be necessary, either. HttpOnly cookies weren't introduced for nothing.
Since you're using Ubuntu, and not Kubuntu, I assume you're using GNOME. You might be interested in [Nautilus Subversion Integration][1] described on that link. [1]: http://www.harecoded.com/nautilus-subversion-integration-tool-execute-svn-commands-with-gnome-scripts-96355
A great way to manage large sets of configuration is to create custom configuration sections. Phil Haack discusses this very nicely in this article <a href="http://haacked.com/archive/0001/01/01/custom-configuration-sections-in-3-easy-steps.aspx">Custom configuration sections in 3 easy steps</a>
The trick is to select "Run test(pause before starting)" Then when the test opens up, click the little link that says "Edit run settings" A dialog boxes opens allowing you to choose "One run per datasource row"
The trick is to select "Run test(pause before starting)" Then when the test opens up, click the little link that says "Edit run settings" A dialog boxes opens allowing you to choose "One run per datasource row"
Pojos could still contain logic errors.
App_Code folder issues
|app-code|c#|visual-studio|
So I'm having a really weird issue with my App_Code folder on a new website I'm designing. I have a basic class inside of a namespace in the App_Code folder. Everything works fine in the IDE when I setup the namespace and make an object from the class. It brings up the class summary on hover, and when you click ...
Option #1 matches the ASP.NET MVC model. The [Model View Controller][1] model has a verb followed by parameters. [1]: http://www.asp.net/mvc/default.aspx?wwwaspnetrdirset=1 "Model View Controller information"
Option #1 matches the common ASP.NET MVC examples. Some of the examples at [Model View Controller][1] model have the form {controller}/{action}/{id}. The [.NET 3.5 quickstart on routing][2] has a table showing some valid route patterns: **Route definition -- Example of matching URL** {controller}/{action}/{i...
It may be worth taking a look at [C5][1], it's a generic collection library for .NET which includes sets. Note that I haven't looked into it much, but it seems to be a pretty fantastic collection library. [1]: http://www.itu.dk/research/c5/
I would suggest to load the contents of the selects that don't depend on any other select boxes on page load. Then in the onchange event of those selects load the contents of the rest of the selects that depend on them. Your idea is sound from a programming point of view, but you will get that lag between clicking ...
I note you are on Oracle 9, but just for the record in Oracle 10g+ the dbms\_obfuscation\_toolkit was deprecated in favour of dbms\_crypto. [dbms_crypto][1] does include CLOB support: DBMS_CRYPTO.ENCRYPT( dst IN OUT NOCOPY BLOB, src IN CLOB CHARACTER SET ANY_CS, ...
Is the host localhost always available for the own system?
|localhost|ping|
Is it always possible to ping localhost and it resolves to 127.0.0.1? I know Windows Vista, XP, Ubuntu and Debian do it but does everyone do it?
Win32 services are designed to be system-wide, and start running before any user is logged in. If you want something to run on a per-user basis, it's probably better to design it as a regular application and run it from the user's Startup group.
I think you should ask yourself why you have to go through the hassle of maintaining multiple databases across several platforms and have them in sync with one another. Sounds like there's a lot of redundancy there. Why not just have one instance of that database, since I'm sure it can be made accessible (e.g. via SOA ...
Actually, having a look at the MinimumSize and MaximumSize (.NET 3.5) in reflector its pretty clear that the designed behaviour is not quite the same as the docs suggest. There is some minimum width constraints determined from a helper class and 0 has no special meaning (i.e. no limit. Another note, I see in your co...
NTP is definitely the way to go. Basically fire-and-forget, as long as you let it out the firewall on your local master (which is typically the firewall or router machine.)
As you've already suggested, NTP is the industry standard solution to this problem, but it either requires Internet connectivity or a stratum 0 source (an accurate hardware clock, like a GPS receiver with a computer interface). If you're using Internet connectivity, consider using the <a href="http://www.pool.ntp.or...
I have used this String class for years. [http://www.robertnz.net/string.htm][1] It provides practically all the features of the STL string but is implemented as a true class not a template and does not use STL. [1]: http://www.robertnz.net/string.htm "String class"
RM -rf equivalent for Windows?
|cmd|wsh|
I need a way to recursively delete a folder and its children, is there a prebuilt tool for this, or do I need to write one? DEL /S doesn't delete directories. DELTREE was removed from Windows 2000+
and always remember this venerable explanation of Spaces + Tabs: [http://www.jwz.org/doc/tabs-vs-spaces.html][1] [1]: http://www.jwz.org/doc/tabs-vs-spaces.html
I hear it's getting better, but I still disable it. For servers, it doesn't really make any sense unless you're an ISP or large corporation wanting to implement fine-grain access level controls across multiple local users. Using it on a web server, I had a lot of problems with apache permissions. I'd constantly ...
The best answer for you is some sort of DVCS (popular ones being [Git][1], [Mercurial][2], [Darcs][3], [Bazaar][4]...). The reason is that you have a full copy of the whole repository on any machine you are using. I haven't used these systems personally, so others will be best at recommending a DVCS with a small foot...
Assuming you are talking about code documentation versus user documentation, an internal wiki is great if you do not need to distribute the documentation for the code outside of your organization, to contractors or partners. Javadoc or DOxygen is more suitable if you want distributable code documentation. If you ...
Does writing and speaking on software make you a better programmer?
|blogs|writing|public-speaking|speaking|
Do you think that writing about software (i.e. having a blog) and speaking on software (and concepts) make you a better programmer?
Yeah, we use a wiki, we also use Google documents. I find that Google documents is better than most wikis I've tried and, if you don't need to track all changes, you lose nothing. Google docs provides a good collaboration framework.
That's a very open ended question, and depends on many factors. Generally speaking, if you use a language that has good documentation generation tools (javadoc, doxygen, MS's C# stuff), you should write your documentation above your methods and have your tools generate the pages. The advantage is that you keep the ...
[NSFileManager fileExistsAtPath:isDirectory:] Returns a Boolean value that indicates whether a specified file exists. - (BOOL)fileExistsAtPath:(NSString *)path isDirectory:(BOOL *)isDirectory Parameters path The path of a file or directory. If path begins with a tilde (~), it must...
Absolutely, for one simple reason: It challenges your preconditions. You could write an article about how perfect .NET is for a given situation, only to find someone has used it, and it turned out badly.
I think the main thing these activities do is force one to more thoroughly research things and research new things. Does this make you a better programmer? I think so.
Is there a zip-like method in .Net?
|c#|list|
In Python there is a really neat function called `zip` which can be used to iterate through two lists at the same time: list1 = [1, 2, 3] list2 = ["a", "b", "c"] for v1, v2 in zip(list1, list2): print v1 + " " + v2 The above code shoul produce the following: <pre>1 a 2 b 3 c</pre> I...
|.net|list|iteration|
|.net|python|list|iteration|
I know the question was specifically about C# and I assume from that Windows Server of some flavour. Since I don't know either of those technologies well, I'll give an answer that'll work in PHP and Apache, and you may get something from it. As suggested earlier, just set an ID or a class on the body of the page dep...
Unit Test should focus only to its corresponding class under testing. All attributes of class that are not of same type should be mocked. Suppose you have a class (CarRegistry) that uses some kind of data access object (for example CarPlatesDAO) which loads/stores car plate numbers from Relational database. When ...
Let's not forget that C++ has virtual calls (significantly more expensive, about x10) and on WIndows you can expect VS to inline calls (0 cost by definition, as there is no call left in the binary)
Just for information, - you can add -Dcom.sun.management.jmxremote to your eclise.ini file, launch eclipse and then monitor its memory usage through 'jconsole.exe' found in your jdk installation. C:\[jdk1.6.0_0x path]\bin\jconsole.exe Choose 'Connection / New connection / 'eclipse' to monitor ...
I think localhost pretty much resolves to 127.0.0.1 for most platforms but all IPs that start with 127.*.*.* resolve to localhost as well. Try pinging 127.255.255.254 and it'll still respond.
Code generators if used widely without correct argumentation make code less understandable and decrease maintainability (the same with dynamic SQL by the way). Personally I'm using it with some of ORM tools, because their usage here mostly obvious and sometimes for things like searcher-parser algorithms and grammatic ...
I'm assuming you will be using SQL Server 2000 / 2005. I have a standard pattern for 1-to-1 relationships which I use, which is not too dissimilar to your 2nd idea, but here are the differences: - Every entity must have its own primary key first, so your Bravo, Charlie, etc tables should define their own surrogate k...
In theory, there are cases where it might not exist. In practice, it's always there.
Ok. The reason why it resolves it is record in %WINDOWS_DIR%\System32\drivers\etc\hosts file like this: 127.0.0.1 localhost
Is it possible to perhaps have the service create child processes which then adopt the user credentials (or be started with them)? This way you're still limited to a single instance of the service, but it is able to do its per-user jobs all the same. IIRC the Windows Task Scheduler service does this.
The whole concept of a service is that it is started before any user is even logged on. so even if this was possible, you wouldn't be able to choose between userA and userB when the service starts because none of them is logged on yet.
The whole concept of a service is that it is started before any user is even logged on. so even if this was possible, you wouldn't be able to choose between userA and userB when the service starts because none of them is logged on yet. --- A possible direction would be for the service to run as SYSTEM And every few...
|c#|visual-studio|app-code|
So I'm having a really weird issue with my App_Code folder on a new website I'm designing. I have a basic class inside of a namespace in the App_Code folder. Everything works fine in the IDE when I setup the namespace and make an object from the class. It brings up the class summary on hover, and when you click ...
If it hasn't been tested, it has a bug! ;)
Take a look at the Google C++ Testing Framework. It's used by Google for all of their in-house C++ projects, so it must be pretty good. <http://googletesting.blogspot.com/2008/07/announcing-new-google-c-testing.html> <http://code.google.com/p/googletest>
You're going to be hard-pressed to find a solution for your exact problem. Drive mount points aren't stored on the user level (afaik). There are a couple of workarounds that you can use that aren't guaranteed to be secure: 1. hide access to certain drive letters based on group policy. Not very secure, easy to wor...
You're going to be hard-pressed to find a solution for your exact problem. Drive mount points aren't stored on the user level (afaik). There are a couple of workarounds that you can use that aren't guaranteed to be secure: 1. hide access to certain drive letters based on group policy. Not very secure, easy to wor...
how to handle code that is deemed dangerous to change, but stable?
|c++|svn|refactoring|
What is the best way to handle a big team that has access to a stable but no so pretty code, that is easy to introduce bugs into? I'm looking for something along the lines of SVN locking the file(s).
Yes. In the work force, being able to communicate effectively is as, and sometimes more important than knowing every obscure detail about language X.
I believe that is the case. As with teaching, you develop a firmer grasp on the subject when you have to explain to someone else. You get to see what you understand and don't understand in greater detail.
Absolutely yes. You have the chance to be challenged and questioned and second-guessed in ways you'd never think of on your own. It also gives you a chance to work on the organization and presentation of your ideas. All of this will feed back into the decisions that you make when you're writing code.
Visual C++/Studio: Application configuration incorrect?
|c++|visual-studio|c|visual-c++|
My C(++) program, written and compiled using Visual C(++)/Visual Studio, runs fine on my own machine, but refuses to run on another machine. The error message I get is "This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem."
You're not missing anything. Furthermore, if you actually want any useful applications, you're going to have to do a lot more downloading than that even. The point is, the small network install CD lets you download whichever version of those components that you want, and the latest version of portage, etc, instead of p...
DUnit2 is available from http://members.optusnet.com.au/~mcnabp/ It is modified more regularly than the original dunit. It also works on Delphi 2009.
DUnit2 is available from http://members.optusnet.com.au/~mcnabp/ DUnit2 is modified more regularly than the original dunit. It also works on Delphi 2009.
I would argue the opposite: that in general the good programmers love to write and speak about software. It shows that they are passionate about it, and won't accept crap.
If you write a C++ program, it links dynamically to the C Runtime Library, or CRT for short. This library contains your printf, your malloc, your strtok, etcetera. The library is contained in the file called MSVCR80.DLL. This file is not by default installed on a Windows system, hence the application cannot run. The...
Limp aims to be a fully featured Common Lisp IDE for Vim. It defaults to SBCL, but can be changed to support most other implementations by replacing "sbcl" for your favourite lisp, in the file /usr/local/limp/latest/bin/lisp.sh When discussing Lisp these days, it is commonly assumed to be Common Lisp, the language s...
Run this SQL: select * from v$version; And you'll get a result like: BANNER ---------------------------------------------------------------- Oracle Database 10g Release 10.2.0.3.0 - 64bit Production PL/SQL Release 10.2.0.3.0 - Production CORE 10.2.0.3.0 Productio...
With those options, I manage to limit the memory used to 700Mo (which is quite high, but still workable with my 2 Go) -vmargs -Xms128m -Xmx384m -Xssv2m -XX:PermSize=128m -XX:MaxPermSize=128m -XX:CompileThreshold=5 -XX:+UseParallelGC -Dcom.sun.management.jmxremote And co...
In hardware design, it's fairly common practice to do this at several levels of the 'stack'. For instance, I wrote a code generator to emit Verilog for various widths, topologies, and structures of DMA engines and crossbar switches, because the constructs needed to express this parameterization weren't yet mature in t...
Yes, that sounds close (I'm answering comment from Greg, but comments are too short to fit my reply). I don't know the list of users beforehand, but there's a GUI control application that would be used to enter username/password pairs for each user. So, userA would log on, run the application, enter his credentials ...
there might be a lot of code generators out there , however I always create my own to make the code more understandable and suit the frameworks and guidelines we are using
Yes I've had to maintain a few. CORBA or some other object communication style of interface is probably the general thing that I think of first. You have object definitions that are provided to you by the interface you are going to talk over but you still have to build those objects up in code. Building and running ...
Do you create your own code generators?
|generators|
[The Pragmatic Programmer][1] advocates the use of code generators. Do you create code generators on your projects? If yes, what do you use them for? [1]: http://www.amazon.com/Pragmatic-Programmer-Journeyman-Master/dp/020161622X/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1222060680&sr=8-1
If you're working at a financial institution, there are probably regulations about this sort of thing, so it's most likely out of your hands. But one thing you can do is make it clear to the user when he has entered an invalid ID. And don't wait until he clicks submit; show some kind of message right next to the field,...
rmdir /s dirname
I mainly use EhCache because it used to be the default cache provider for Hibernate. There is a list of caching solutions on [Java-Source.net][1]. I used to have a link that compared the main caching solutions. If I find it I will update this answer. [1]: http://java-source.net/open-source/cache-solutions
1. [GNU] make gets angry if you don't place the output in the current directory. What you really should do is run make from the build directory, and use the VPATH make variable to locate the source code. If you lie to a compiler, sooner or later it will take its revenge. 2. If you insist on generating your objects...
Try this command: del /s foldername
RMDIR or RD: rd /s /q
I find the best thing usually dpending on how much email there is, is to just forward the mail thru your ISP's SMTP server. Less headaches. Looks like thats where you are having issues, from your smtp to external servers, not asp.net to your smtp. Just have your SMTP server set to send it to your isp, or you can con...
I find the best thing usually dpending on how much email there is, is to just forward the mail thru your ISP's SMTP server. Less headaches. Looks like thats where you are having issues, from your smtp to external servers, not asp.net to your smtp. Just have your SMTP server set to send it to your isp, or you can con...
you might want to consider using [Hazelcast][1] distributed locks. Super lite and easy. java.util.concurrent.locks.Lock lock = Hazelcast.getLock ("mymonitor"); lock.lock (); try { // do your stuff }finally { lock.unlock(); } Regards, -talip Hazelcast - Distributed Queue,...
ASP.Net application cannot Login to SQL Server Database when deployed to Web Server
|asp.net|sql-server-2005|web-deployment-project|