instruction
stringlengths 0
30k
⌀ |
---|
How to Pass Command Line Parameters in batch file |
|ms-dos|cmd|batch-file|command-line| |
I needed to pass id and password to a cmd (or bat) file at the time of running rather than hardcoding them into the file.
Here's how I do it.
echo off
fake-command /u %1 /p %2
Here's what the command line looks like:
test.cmd admin P@55w0rd > test-log.txt
The %1 applies to the first parameter the %2 (and here's the tricky part) applies to the second. You can have up to 9 parameters passed in this way.
Afterward: This is my first attempt to answer my own question which, to hear Jeff disscuss it is a "...perfectly acceptable...." way of using SO. I'm just not certain if there's already a format for doing it. |
How can you (reliably) dynamically load a javascript file? (Like C's #include) |
|javascript| |
How can you reliably and dynamically load a javascript file? Basically what I want to accomplish is implement a module or component that when you 'initialize' the component it will dynamically load all needed javascript library scripts on demand.
So the client that uses the component isn't required to load all the library script files (and manually insert <script> tags into their web page) that implement my component - just the 'main' component script file.
How do mainstream javascript libraries accomplish? I guess they have tools that merge multiple javascript files into a single redistributable 'build' version of a script file? Is Rhino one of these tools? |
How can you reliably and dynamically load a javascript file? Basically what I want to accomplish is implement a module or component that when you 'initialize' the component it will dynamically load all needed javascript library scripts on demand.
So the client that uses the component isn't required to load all the library script files (and manually insert <script> tags into their web page) that implement my component - just the 'main' component script file.
How do mainstream javascript libraries accomplish this (Prototype, jquery, etc)? Do these tools merge multiple javascript files into a single redistributable 'build' version of a script file? Or do they do any dynamic loading of ancillary 'library' scripts? |
How can you reliably and dynamically load a javascript file? Basically what I want to accomplish is implement a module or component that when you 'initialize' the component it will dynamically load all needed javascript library scripts on demand.
So the client that uses the component isn't required to load all the library script files (and manually insert <script> tags into their web page) that implement my component - just the 'main' component script file.
How do mainstream javascript libraries accomplish this (Prototype, jquery, etc)? Do these tools merge multiple javascript files into a single redistributable 'build' version of a script file? Or do they do any dynamic loading of ancillary 'library' scripts?
An addition to this question --- is there a way to handle the event after a dynamically included javascript file is loaded? |
How do you dynamically load a javascript file? (Think C's #include) |
How can you reliably and dynamically load a javascript file? This will can be used to implement a module or component that when 'initialized' the component will dynamically load all needed javascript library scripts on demand.
The client that uses the component isn't required to load all the library script files (and manually insert <script> tags into their web page) that implement this component - just the 'main' component script file.
How do mainstream javascript libraries accomplish this (Prototype, jquery, etc)? Do these tools merge multiple javascript files into a single redistributable 'build' version of a script file? Or do they do any dynamic loading of ancillary 'library' scripts?
An addition to this question --- is there a way to handle the event after a dynamically included javascript file is loaded? Prototype has document.observe for document-wide events. Example:
document.observe("dom:loaded", function() {
// initially hide all containers for tab content
$$('div.tabcontent').invoke('hide');
});
What are the available events for a script element?
|
You might want to look into using [Mono][1]. This is a open source version of .NET that runs on many plateforms...Linux,Mac, Solaris, Windows, etc..
Now about coding your expensive stuff in C/C++. Here's an article that does a very good
job explaining the differences between [C/C++ & C# performance][2].
[1]: http://www.mono-project.com
[2]: http://www.codeproject.com/KB/cs/CSharpVsCPP.aspx |
Putting your resume up online somewhere helps, I get a lot of recruitment emails from people who happened on my resume via googling. However I agree with ColinYounger in that you'll probably get more bang for your buck from LinkedIn.
My advice is this - if you want to take the time out to LEARN a CMS or something, to better yourself, then why not make your first project in one be your homepage?
Maybe enlighten us as to the "features" you want to have on a personal homepage? Outside of a link to an HTML resume and perhaps some links to things you like, not sure exactly what the features of a homepage would be... |
If you're running it on a 2k3 box, you need to install all updates for Sql Server and the 2003 server.
Check the event logs after you start the Sql Server. It logs everything well, telling you if its being blocked, and where it is listening for connections.
From a remote machine, you can use telnet to see if a sql server is listening for remote connections. You just need the IP and the port of the server (default is 1433). From the command line:
telnet 192.168.10.10 1433
If you get a blank screen, its listening. If you get thrown back to the command prompt, something is blocking you. |
It really depends on:
a) what services you provide
b) what your skill level is when it comes to web design/development
If you are primarily a web applications developer then running an off the shelf product or using blatantly using DreamWeaver to develop it may not be so smart -- or maybe your clients aren't adept enough to notice?
Likewise if you're primarily a web designer then it is probably a good idea to design your own website. |
This was the fastest I could come up with after some fiddling:
private function castMethod4(dateString:String):Date {
if ( dateString == null )
return null;
if ( dateString.length != 10 && dateString.length != 19)
return null;
dateString = dateString.replace("-", "/");
dateString = dateString.replace("-", "/");
return new Date(Date.parse( dateString ));
}
I get 50k iterations in about 470ms for castMethod2() on my computer and 300 ms for my version (that's the same amount of work done in 63% of the time). I'd definitely say both are "Good enough" unless you're parsing silly amounts of dates. |
> What specifically does that question mean?
Good question. If reversing the "ON" bits means reversing only the bits that are "ON", then you will always get 0, no matter what the input is. If it means reversing *all* the bits, i.e. changing all 1s to 0s and all 0s to 1s, which is how I initially read it, then that's just a bitwise NOT, or complement. C-based languages have a complement operator, <code>~</code>, that does this. For example:
unsigned char b = 102; /* 0x66, 01100110 */
unsigned char reverse = ~b; /* 0x99, 10011001 */
|
Yes they are one and the same |
How do you find what debug switches are available? Or given a switch find out what is being disabled? |
|.net|app-config| |
In this [question][1] the answer was to flip on a switch that is picked up by the debugger disabling the extraneous header that was causing the problem. The Microsoft help implies these switched are user generated and does not list any switches.
<configuration>
<system.diagnostics>
<switches>
<add name="Remote.Disable" value="1" />
</switches>
</system.diagnostics>
</configuration>
What I would like to know is where the value "Remote.Disable" comes from and how find out what other things can be switched on or off. Currently it is just some config magic, and I don't like magic.
[1]: http://stackoverflow.com/questions/32877/how-to-remove-vsdebuggercausalitydata-data-from-soap-message |
Visual Studio Hosting Process and "The operation could not be completed" |
|visual-studio| |
When trying to execute from within Visual Studio 2008 your application and you get the (uninformative) message "The operation could not be completed".
The solution to this is to turn off the "Visual Studio Hosting Process".
The problem with turning off this "hosting process" is that all the "run and rewrite" functionality is no longer available. OK, so this isn't a big deal, but I'm *always* getting this message no matter what machine I use (and it might be nice once in a while to use the rewrite and execute functionality).
Am I doing something wrong? How come this "feature" within VS seems to complain so readily? Do other people have success with enabling the hosting process and making use of it? |
A quick google reveals that this should get rid of it, get them to add it to the web.config or app.config for their application.
<configuration>
<system.diagnostics>
<switches>
<add name="Remote.Disable" value="1" />
</switches>
</system.diagnostics>
</configuration>
The information is debug information that the receiving service can use to help trace things back to the client. (maybe, I am guessing a little)
|
A quick google reveals that this should get rid of it, get them to add it to the web.config or app.config for their application.
<configuration>
<system.diagnostics>
<switches>
<add name="Remote.Disable" value="1" />
</switches>
</system.diagnostics>
</configuration>
The information is debug information that the receiving service can use to help trace things back to the client. (maybe, I am guessing a little)
* I have proposed a follow up [question][1] to determine were the magic switch actually comes from.
[1]: http://stackoverflow.com/questions/33334/how-do-you-find-what-debug-switches-are-available-or-given-a-switch-find-out-wh |
I wrote up a PHP class that lets you choose to use a certain class of Captcha Question (math, naming, opposites, completion), or to randomize which type is used. These are questions that most english-speaking children could answer.
**For example:**
1. Math: 2+5 = _
2. Naming: The animal in this picture is a ____
3. Opposites: The opposite of happy is ___
4. Completion: A cow goes _____ |
Boundary Tests For a Networked App |
|testing|networking|wireless| |
Besides "no connection", what other failure modes should I test for? How do I simulate a high-latency link, an unreliable link, or all the other sorts of crazy stuff that will undoubtedly happen "in the wild"? How about wireless applications--how do I test the performance in a less-than-ideal WL environment? |
[OWASP][1] keeps a list of the [Top 10][2] web attacks to watch our for, in addition to a ton of other useful security information for web development.
[1]: http://www.owasp.org/index.php/Main_Page
[2]: http://www.owasp.org/index.php/Category:OWASP_Top_Ten_Project |
Javascript doesn't really have namespace or packages like other languages. Instead it has closures. If you have an application that consists of multiple functions, variables and objects, then you should put them inside a single global object. This will have the same effect as a namespace.
For example:
<pre><code>
var namespace = {
this.foo; function(){
...
},
this.foo.prototype.getLength; function(){
...
}
}
</code></pre>
You could also create a set of nested objects and simulate packages:
loadPackage = function(){
var path = arguments[0];
for(var i=1; i<arguments.length; i++){
if(!path[arguments[i]]){
path[arguments[i]] = {};
}
path = path[arguments[i]];
}
return path;
}
loadPackage(this, "com", "google", "mail") = {
username: "gundersen",
login: function(password){
...
}
}
this.com.google.mail.login("mySecretPassword"); |
Downside? It's fairly limited - you trigger a "GET" request and get back some script that's executed. You don't get error handling if your server throws an error, so you need to wrap all errors in JSON as well. You can't really cancel or retry the request. You're at the mercy of the various browser author opinions of "correct" behavior for dynamically-generated `<script>` tags. Debugging is somewhat more difficult.
That said, i've used it on occasion, and haven't suffered. YMMV. |
C++ linker unresolved external symbols |
|c++| |
I'm building an application against some legacy, third party libraries, and having problems with the linking stage. I'm trying to compile with Visual Studio 9. My compile command is:
> cl -DNT40 -DPOMDLL -DCRTAPI1=_cdecl
> -DCRTAPI2=cdecl -D_WIN32 -DWIN32 -DWIN32_LEAN_AND_MEAN -DWNT -DBYPASS_FLEX -D_INTEL=1 -DIPLIB=none -I. -I"D:\src\include" -I"C:\Program Files\Microsoft Visual Studio
> 9.0\VC\include" -c -nologo -EHsc -W1 -Ox -Oy- -MD mymain.c
The code compiles cleanly. The link command is:
> link -debug -nologo -machine:IX86
> -verbose:lib -subsystem:console mymain.obj wsock32.lib advapi32.lib
> msvcrt.lib oldnames.lib kernel32.lib
> winmm.lib [snip large list of
> dependencies] D:\src\lib\app_main.obj
> -out:mymain.exe
The errors that I'm getting are:
> app_main.obj : error LNK2019:
> unresolved external symbol
> "_\_declspec(dllimport) public: void
> __thiscall std::locale::facet::_Register(void)"
> (__imp_?_Register@facet@locale@std@@QAEXXZ)
> referenced in function "class
> std::ctype<char> const & __cdecl
> std::use_facet<class std::ctype<char>
> \>(class std::locale const &)" (??$use_facet@V?$ctype@D@std@@@std@@YAABV?$ctype@D@0@ABVlocale@0@@Z)
> app_main.obj : error LNK2019:
> unresolved external symbol
> "__declspec(dllimport) public: static
> unsigned int __cdecl
> std::ctype<char>::_Getcat(class
> std::locale::facet const * *)"
> (__imp_?_Getcat@?$ctype@D@std@@SAIPAPBVfacet@locale@2@@Z)
> referenced in function "class
> std::ctype<char> const & __cdecl
> std::use_facet<class std::ctype<char>
> \>(class std::locale const &)" (??$use_facet@V?$ctype@D@std@@@std@@YAABV?$ctype@D@0@ABVlocale@0@@Z)
> app_main.obj : error LNK2019:
> unresolved external symbol
> "__declspec(dllimport) public: static
> unsigned int __cdecl
> std::ctype<unsigned
> short>::_Getcat(class
> std::locale::facet const * *)"
> (__imp_?_Getcat@?$ctype@G@std@@SAIPAPBVfacet@locale@2@@Z)
> referenced in function "class
> std::ctype<unsigned short> const &
> __cdecl std::use_facet<class std::ctype<unsigned short> >(class
> std::locale const &)"
> (??$use_facet@V?$ctype@G@std@@@std@@YAABV?$ctype@G@0@ABVlocale@0@@Z)
> mymain.exe : fatal error LNK1120: 3
> unresolved externals
Notice that these errors are coming from the legacy code, not my code - app_main.obj is part of the legacy code, while mymain.c is my source. I've done some searching around, and what that I've read says that this type of error is caused by a mismatch with the -MD switch between my code and the library that I'm linking to. Since I'm dealing with legacy code, a solution has to come from my environment. It's been a long time since I've done C++ work, and even longer since I've used Visual Studio, so I'm hoping that this is just some ignorance on my part. Any ideas on how to get these resolved? |
Instead of using a DOMParser, use a SAXParser. This reads from an input stream or reader so you can keep the XML on disk instead of loading it all into memory. |
Instead of using a DOMParser, use a SAXParser. This reads from an input stream or reader so you can keep the XML on disk instead of loading it all into memory.
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setValidating(true);
factory.setNamespaceAware(true);
SAXParser parser = factory.newSAXParser();
XMLReader reader = parser.getXMLReader();
reader.setErrorHandler(new SimpleErrorHandler());
reader.parse(new InputSource(new FileReader ("document.xml")));
|
I'm not entirely sure I understand your question, especially the bit about displaying two SPField collections. Sorry if this turns out to be the answer to a completely different question!
Anyway here's a quick demo walkthrough of using the MultipleLookupField in a web part.
Create a team site. Add a few tasks to the task list. Also put a document in the Shared Documents library. Create a new column in the Shared Documents library; call it "Related", have it be a Lookup into the Title field of the Tasks list, and allow multiple values.
Now create a web part, do all the usual boilerplate and then add this:
Label l;
MultipleLookupField mlf;
protected override void CreateChildControls()
{
base.CreateChildControls();
SPList list = SPContext.Current.Web.Lists["Shared Documents"];
if (list != null && list.Items.Count > 0)
{
LiteralControl lit = new LiteralControl("Associate tasks to " +
list.Items[0].Name);
this.Controls.Add(lit);
mlf = new MultipleLookupField();
mlf.ControlMode = SPControlMode.Edit;
mlf.FieldName = "Related";
mlf.ItemId = list.Items[0].ID;
mlf.ListId = list.ID;
mlf.ID = "Related";
this.Controls.Add(mlf);
Button b = new Button();
b.Text = "Change";
b.Click += new EventHandler(bClick);
this.Controls.Add(b);
l = new Label();
this.Controls.Add(l);
}
}
void bClick(object sender, EventArgs e)
{
l.Text = "";
foreach (SPFieldLookupValue val in (SPFieldLookupValueCollection)mlf.Value)
{
l.Text += val.LookupValue.ToString() + " ";
}
SPListItem listitem = mlf.List.Items[0];
listitem["Related"] = mlf.Value;
listitem.Update();
mlf.Value = listitem["Related"];
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
EnsureChildControls();
}
Granted, this is borderline ridiculous -- everything is hard-coded, there is no error-handling at all, and it serves no useful purpose -- but it's only meant as a quick demo. Now build and deploy this web part and add an instance of it to your team site's homepage; it should allow you to get and set the tasks which are associated with the first document in the library.
The strange bit towards the end of the button Click handler, where we read a value from mlf.Value and then write it back again, appears to be required if you want the UI to stay in sync with the actual list values. Try omitting the last line of bClick to see what I mean. This has been driving me nuts for the last hour or so, and I'm hoping another commenter can come up with a better approach... |
Actually, because of leap years, your code would be off. Since the timespan object has no TotalYears property the best way to get it would be this
Pardon the VB.Net
Dim myAge AS Integer = DateTime.Now.year - BirthDate.year
If Birthdate.month < DateTime.Now.Month _
OrElse BirthDate.Month = DateTime.Now.Month AndAlso Birthdate.Day < DateTime.Now.Day Then
MyAge -= 1
END IF
|
I think you have your answer right here: [Reflector sold to Red Gate][1]
[1]: http://blog.lutzroeder.com/2008/08/future-of-net-reflector.html |
A more complete discussion of the pitfalls of using a regex to find matching tags can be found at: <http://faq.perl.org/perlfaq4.html#How_do_I_find_matchi>. In particular, be aware that nesting tags really need a full-fledged parser in order to be interpreted correctly.
Note that case sensitivity will need to be turned off in order to answer the question as stated. In perl, that's the **i** modifier:
$ echo "Data Data Data [Start] Data i want [End] Data" \
| perl -ne '/\[start\](.*?)\[end\]/i; print "$1\n"'
Data i want
The other trick is to use the ***?** quantifier which turns off the greediness of the captured match. For instance, if you have a non-matching **[end]** tag:
Data Data [Start] Data i want [End] Data [end]
you probably don't want to capture:
Data i want [End] Data
|
MVC .Net - The best way to write a form? |
|asp.net-mvc|forms| |
What is the the best way to write a form to submit some data in asp.net MVC? Is it as Scott Gu demonstrates here? Are there better approches? Perhaps with less using of strings?
![alt text][1]
[1]: http://www.scottgu.com/blogposts/mvc4/step33.png |
I layer out the application and at least unit test from the presenter/controller (whichever is your preference, mvc/mvp) to the data layer. That way I have good test coverage over most of the code that is written.
I have looked at FitNesse, Watin and Selenium as options to automate the UI testing but I haven't got around to using these on any projects yet, so we stick with human testing. FitNesse was the one I was leaning toward but I couldn't introduce this as well as introducing TDD (does that make me bad? I hope not!). |
How do you configure tomcat to bind to a single ip address (localhost) instead of all addresses? |
|tomcat| |
How do you configure tomcat to bind to a single ip address (localhost) instead of all addresses?
|
As of PHP 5.1.0 you can use [date__default__timezone_set()][1] function to set the default timezone used by all date/time functions in a script.
For MySql (quoted from [MySQL Server Time Zone Support][2] page)
> Before MySQL 4.1.3, the server operates only in the system time zone set at startup. Beginning with MySQL 4.1.3, the server maintains several time zone settings, some of which can be modified at runtime.
Of interest to you is per-connection setting of the time zones, which you would use at the beginning of your scripts
SET timezone = 'Europe/London';
As for detecting the client timezone setting, you could use a bit of JavaScript to get and save that information to a cookie, and use it on subsequent page reads, to calculate the proper timezone.
//Returns the offset (time difference) between Greenwich Mean Time (GMT)
//and local time of Date object, in minutes.
var offset = new Date().getTimezoneOffset();
document.cookie = 'timezoneOffset=' + escape(offset);
Or you could offer users the chioce to set their time zones themselves.
[1]: http://www.php.net/manual/en/function.date-default-timezone-set.php
[2]: http://dev.mysql.com/doc/refman/4.1/en/time-zone-support.html |
Ah, if only C supported closures...
Antonio is right; if you need to pass extra parameters, you'll need to redefine your function pointer to accept the additional arguments. If you don't know exactly what parameters you'll need, then you have at least three choices:
1. Have the last argument in your prototype be a void*. This gives you flexibility of passing in anything else that you need, but it definitely isn't type-safe.
2. Use variadic parameters (...). Given my lack of experience with variadic parameters in C, I'm not sure if you can use this with a function pointer, but this gives even more flexibility than the first solution, albeit still with the lack of type safety.
3. Upgrade to C++ and use [function objects](http://en.wikipedia.org/wiki/Function_object). |
If you are trying to use xslt you can add the namespace in to the stylesheet delcaration. If you do that, you must make sure that there is a prefix or it will not work. If the source XML does not have a prefix, that is still fine, you add your own prefix in the stylesheet.
_Stylesheet_
<xsl:stylesheet
xmlns:fb="uri"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="fb:foo/bar">
<!-- do stuff here -->
</xsl:template>
</xsl:stylsheet>
Or something like that.
|
If I'm reading this right, what I'd suggest is to make your function take a pointer to a struct as an argument. Then, your struct can have can have "game" and "depth" when it needs them, and just leave them set to 0 or Null when you don't need them.
What is going on in that function? Do you have a conditional that says,
if (depth > -1) //some default
{
//do something
}
Does the function always REQUIRE "game" and "depth". Then, they should always be arguments, and that can go into your prototypes.
Are you indicating the function only sometimes requires "game" and "depth"? Well, maybe make two functions and use each one when you need to.
But, having a structure as the argument is probably the easiest thing. |
Making human readable representations of an Integer |
|practice| |
Here's a coding problem for those that like this kind of thing. Let's see your implementations (in your language of choice, of course) of a function which returns a human readable String representation of a specified Integer. For example:
<ul>
<li>humanReadable(1) returns "one".
<li>humanReadable(53) returns "fifty-three".
<li>humanReadable(723603) returns "seven hundred and twenty-three thousand, six hundred and three".
<li>humanReadable(1456376562) returns "one billion, four hundred and fifty-six million, three hundred and seventy-six thousand, five hundred and sixty-two".
</ul>
Bonus points for particularly clever/elegant solutions!
It might seem like a pointless exercise, but there are number of real world applications for this kind of algorithm (although supporting numbers as high as a billion may be overkill :-)
|
Getting Java and Twain to play together nicely |
|java|twain|scanner| |
I'm working on building an app to scan directly from TWAIN scanner to a Java applet.
I'm already aware of [Morena][1] and [JTwain][2], but they cost money. I need free.
I could re-invent the wheel with JNI, but it seems like someone has probably already done this as a FOSS tool. Is anyone familiar with a **free** tool that can save me some time and effort?
[1]: http://www.gnome.sk/Twain/jtp.html
[2]: http://asprise.com/product/jtwain/ |
PyGame works much better when it can manage its own window, or even better, use the whole screen. GTK has flexible enough widgets to allow creation of a drawing area.
[This page][1] may help, though, if you want to try it.
[1]: http://faq.pygtk.org/index.py?req=show&file=faq23.042.htp |
What are the best practices for JSF? |
|jsf| |
I have done Java and JSP programming in the past, but I am new to Java Server Faces and want to know if there's a set of best practices for JSF development. |
|java|jsf| |
I recommend using <a href="http://commons.apache.org/logging/">Apache Commmons Logging</a> as your logging interface. That way you have the flexibility to switch logging implementations anytime you want. |
I recommend using <a href="http://commons.apache.org/logging/">Apache Commmons Logging</a> as your logging interface. That way you have the flexibility to switch logging implementations anytime you want without requiring any code changes on your end. |
The traditional way is to use setjmp and longjmp, though there are caveats.
Here's a [reasonably good explanation][1]
[1]: http://homepage.mac.com/sigfpe/Computing/continuations.html |
You can configure eclipse to show warnings for things that lack javadoc, or have javadoc that does not have all the information, or has wrong information. It can also insert templates for you to fill out.
Not quite the tool you asked for, but probably better because you won't end up with empty skeletons on methods that you missed. |
I've used [this](http://www.objectmentor.com/resources/articles/acv.pdf) ("acyclic visitor") to good effect; it makes adding new classes to the hierarchy possible without changing existing ones, to some extent. |
How about using the C++ language itself?
bool b = true;
std::cout << std::noboolalpha << b << " == " << std::boolalpha << b << std::endl; |
How about using the C++ language itself?
bool t = true;
bool f = false;
std::cout << std::noboolalpha << t << " == " << std::boolalpha << t << std::endl;
std::cout << std::noboolalpha << f << " == " << std::boolalpha << f << std::endl; |
Note that Zend Optimizer and MMCache (or similar applications) are totally different things. While Zend Optimizer tries to optimize the program opcode MMCache will cache the scripts in memory and reuse the precompiled code.
I did some benchmarks some time ago and you can find the [results][1] in my blog (in German though). The basic results:
Zend Optimizer alone didn't help at all. Actually my scripts were slower than without optimizer.
When it comes to caches:
* fastest: [eAccelerator][2]
* [XCache][3]
* [APC][4]
And: You DO want to install a opcode cache!
For example:
![alt text][5]
This is the duration it took to call the wordpress homepage 10.000 times.
[1]: http://blogs.interdose.com/dominik/2008/04/11/benchmarking-php-eaccelerator-und-andere-opcode-caches/
[2]: http://eaccelerator.net/
[3]: http://xcache.lighttpd.net/
[4]: http://www.php.net/manual/en/book.apc.php
[5]: http://blogs.interdose.com/dominik/wp-content/uploads/2008/04/opcode_wordpress.png |
When do Request.Params and Request.Form differ? |
|asp.net|mvc|c#| |
I recently encountered a problem where a value was null if accessed with Request.Form but fine if retrieved with Request.Form. |
|c#|asp.net|mvc| |
I recently encountered a problem where a value was null if accessed with Request.Form but fine if retrieved with Request.Params. What are the differences between these methods that could cause this? |
|c#|asp.net| |
In ASP.NET MVC I encounter an incorrect type error when rendering a user control with the correct typed object |
|asp.net-mvc| |
I encounter an error of the form: "The model item passed into the dictionary is of type FooViewData but this dictionary requires a model item of type bar" even though I am passing in an object of the correct type (bar) for the typed user control. |
|asp.net|mvc| |
|asp.net|asp.net-mvc|mvc| |
Use the routing engine for form submissions in ASP.NET MVC Preview 4 |
|asp.net|mvc|forms|routing| |
I'm using ASP.NET MVC Preview 4 and would like to know how to use the routing engine for form submissions.
For example, I have a route like this:
routes.MapRoute(
"TestController-TestAction",
"TestController.mvc/TestAction/{paramName}",
new { controller = "TestController", action = "TestAction", id = "TestTopic" }
);
And a form declaration that looks like this:
<% using (Html.Form("TestController", "TestAction", FormMethod.Get))
{ %>
<input type="text" name="paramName" />
<input type="submit" />
<% } %>
which renders to:
<form method="get" action="/TestController.mvc/TestAction">
<input type="text" name="paramName" />
<input type="submit" />
</form>
The resulting URL of a form submission is:
**localhost/TestController.mvc/TestAction?paramName=value**
Is there any way to have this form submission route to the desired URL of:
**localhost/TestController.mvc/TestAction/value**
Thanks in advance for any assistance. |
I'm using ASP.NET MVC Preview 4 and would like to know how to use the routing engine for form submissions.
For example, I have a route like this:
routes.MapRoute(
"TestController-TestAction",
"TestController.mvc/TestAction/{paramName}",
new { controller = "TestController", action = "TestAction", id = "TestTopic" }
);
And a form declaration that looks like this:
<% using (Html.Form("TestController", "TestAction", FormMethod.Get))
{ %>
<input type="text" name="paramName" />
<input type="submit" />
<% } %>
which renders to:
<form method="get" action="/TestController.mvc/TestAction">
<input type="text" name="paramName" />
<input type="submit" />
</form>
The resulting URL of a form submission is:
**localhost/TestController.mvc/TestAction?paramName=value**
Is there any way to have this form submission route to the desired URL of:
**localhost/TestController.mvc/TestAction/value**
Thanks in advance for any assistance.
The only solutions I can think of are to create a separate action that just checks the request parameters, or to use Javascript. |
The right thing to is to access the database via an abstraction layer in a way such if you change your RDBMS or how you implemented that access, you only have to modify this layer while all the rest of your application remains untouched.
To do this, to free your application from knowing how to deal with the database, your abstraction layer for DB access must be implemented by a framework such as <a href="http://adodb.sourceforge.net/">ADODB</a>.
All the files related to this layer must be located in a sub directory:
<ul>
<li>/ado</li>
</ul>
In this directories you'll put all of your .php.inc files which contains general methods to access the database. |
My favorite method is a photoshop plugin to "Save as .ICO".
[http://www.telegraphics.com.au/svn/icoformat/trunk/dist/README.html][1]
[1]: http://www.telegraphics.com.au/svn/icoformat/trunk/dist/README.html
Fast, works offline, etc. |
My favorite method is a photoshop plugin to "Save as .ICO".
[http://www.telegraphics.com.au/svn/icoformat/trunk/dist/README.html][1]
[1]: http://www.telegraphics.com.au/svn/icoformat/trunk/dist/README.html
Fast, works offline, you're already in Photoshop, etc. |
There probably isn't a definitive "right" answer - it's going to depend on how you like to develop.
However, it's interesting to note that most of the "name" Rails folk seem to use Textmate on their Macs. So a fairly powerful editor rather than an IDE. I suspect this is at least in part because of the fairly strong TDD bias within the Rails community - not so much debugging being necessary because they're working in small test-driven steps. That's the theory anyway.
The closest analog to Textmate in Windows seems to be **e**. It costs, but a fairly trivial amount (pocket-money, if we're honest). There's a 30-day free evaluation available too.
I've used Scite for much of my Ruby/Rails work, don't discard it just because it's the "default" - there's a reason why it was chosen for inclusion.
As for IDEs, I couldn't get anything to work in Eclipse, NetBeans seems quite good and I tried the beta of Sapphire in Steel, also pretty slick. I just don't seem to want to work in an IDE; the opposite of how I feel about working in C#, strangely enough. |
I'm not 100% sure about VS2008, but I know that the Unit Testing framework that microsoft shipped in VS2005 as part of their Team Suite was only for .NET, not C++
I've used CppUnit also and it was alright. Much the same as NUnit/JUnit/so on.
If you've used boost, they [also have a unit testing library](http://www.boost.org/doc/libs/1_35_0/libs/test/doc/index.html)
The guys behind boost have some **serious** coding chops, so I'd say their framework should be pretty good, but it might not be the most user friendly :-) |
I've been arounda while, so most books that I have found influential don't necessarily apply today. I do believe it is universally important to understand the platform that you are developing for (both hardware and OS). I also think it's important to learn from other peoples mistakes. So two books I would recommend are:
[Computing Calamities][1] and [In Search of Stupidity: Over Twenty Years of High Tech Marketing Disasters][2]
[1]: http://www.amazon.com/Computing-Calamities-Products-Projects-Companies/dp/0130828629/ref=sr_1_1?ie=UTF8&s=books&qid=1218498682&sr=8-1
[2]: http://www.amazon.com/Search-Stupidity-Twenty-Marketing-Disasters/dp/1590597214/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1218498576&sr=1-1 |
To do arithmetic with dates on UNIX you get the date as the number seconds since the UNIX epoch, do some calculation, then convert back to your printable date format. The date command should be able to both give you the seconds since the epoch and convert from that number back to a printable date. My local date command does this,
% date -n
1219371462
% date 1219371462
Thu Aug 21 22:17:42 EDT 2008
%
See your local date(1) man page.
To increment a day add 86400 seconds.
|
I think you should benchmark and take a look at what you are doing to determine if stat() is the slowest part of your code. Stating 1 file on each request on a server that gets about 100 hits/day is not a problem. Stating every file could be a problem when you have to eek out a few more requests a second.
You can avoid stating the same file repeatedly by caching the results via memcached, apc or some other in-memory caching system.
Premature optimization is the root of all evil. - Donald Knuth |
How about developing your own text editor?
You can own your own editor with priceless experience. |
Is it possible to share a transaction between a .Net application and a COM+ object? |
|.net|com| |
I did some tests a while ago and never figured out how to make this work.
The ingredients:
- COM+ transactional object (developed in VB6)
- .Net web application (with transaction) that...
makes a call to the COM+ component
updates a row in a SQL database
Testing:
Run the .Net application and force an exception.
Result:
The update made from the .Net application rolls back.
The update made by the COM+ object does not roll back.
If I call the COM+ object from an old ASP page the rollback works.
I know some people may be thinking "what?! COM+ and .Net you must be out of your mind!", but there are some places in this world where there still are a lot of COM+ components. I was just curious if someone ever faced this and if you figured out how to make this work. |
|.net|com|database|transaction| |
|.net|com+|database|transaction| |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.