instruction stringlengths 0 30k ⌀ |
|---|
An alternative way to code Brettski's answer, with which I otherwise agree entirely, might be
With New FileSystemObject
If .FileExists(yourFilePath) Then
.DeleteFile yourFilepath
End If
End With
Same effect but fewer (well, none at all) variable declarations.
The FileSy... |
I think caching is a reasonable approach and you can take it a step further and add a SQL Dependency to it.
[ASP.NET Caching: SQL Cache Dependency With SQL Server 2000][1]
[1]: http://www.c-sharpcorner.com/UploadFile/mosessaur/sqlcachedependency01292006135138PM/sqlcachedependency.aspx?ArticleID=3caa7d32-dce0... |
Is there a way to use Lua on BREW 3.0 platform? |
|mobile|lua|brew-framework| |
It looks like [BREW](http://brew.qualcomm.com/brew/) 4.0 will have Lua included. But is it possible to use Lua on older BREW 3.0 (or even BREW 2.0)? |
You could probably modify the installer that Tomcat itself uses.
Simply zipping up the directory is a valid solution, but as you note, it will not install the service.
I would probably (a) zip up the directory (b) use one of the open-source service registry programs to install the server and maybe (c) uses NSIS... |
I guess I'm not in the majority here, but I still see a lot of use for tables in HTML. Of course, yes, for things like forms, you simply can't beat a table. Trying to line up the labels and accompanying form fields would certainly be possible using DIV's, but what a PITA that would be, and resizing the page would be ug... |
I my search, also came across [*Customize RSS for the Content Query Web Part*][1]
"After you customize the Content Query Web Part to display the fields and content you want, you can set up the Web Part to emit a Really Simple Syndication (RSS) feed of that content."
[1]: http://msdn.microsoft.com/en-us/librar... |
svn:// doesn't talk http, therefor there's nothing a http proxy could do.
Any reason why http doesn't work? Have you considered https? If you really need it, you probably have to have port 3690 opened in your firewall. |
Are you sure the content server only returns a short error page ?
Doesn't it also set the HTTPResponse to something appropriate like 404. In which case you can trap the HTTPClientError derived exception (most likely HTTPNotFound) which is raised when accessing Net::HTTP.value().
If you get an error then your fil... |
I think you should rather not even catch all Exception but better let them be shown to the user. The reason for this is that you should only catch Exceptions which you can actually handle. If you run into some Exception which causes the program to stop but still catch it, this might cause much more severe problems.
Al... |
You might also want to look at [Psake][1] - a PowerShell based build environment.
[1]: http://code.google.com/p/psake/ |
How to track changes to business objects? |
|business-objects| |
I get the concept of creating a business object or entity to represent something like a Person. I can then serialize the Person using a DTO and send it down to the client. If the client changes the object, it can have an IsDirty flag on there so when it gets sent back to the server I know to update it.
But what if I... |
|c#|business-objects| |
Firstly, you can use an existing framework that addresses these issues, like CSLA.NET. The author of this framework has tackled these very issues. Go to [http://www.rockfordlhotka.net/cslanet/][1] for this. Even if you don't use the full framework, the concepts are still applicable.
If you wanted to roll your own,... |
Be careful to consider how scalable the framework is. There are several frameworks out there that like to hammer your database because they think it's nothing but a glorified file system... those frameworks don't scale well at all. |
When I first encountered fixed point numbers I found this article very helpful, and it does suggest one way of representing fixed point values.
[http://www.embedded.com/columns/15201575?_requestid=65598][1]
I didn't wind up using his union representation for fixed point numbers though. I mostly have experience w... |
Agreed with Abe, this is an anonymous method. An anonymous method is just that -- a method without a name, which can be supplied as a parameter argument.
Obviously the OnLogin object is an Event; using an += operator ensures that the method specified by the anonymous delegate above is executed whenever the OnLogin e... |
I group them based on what there doing, and then in the order I wrote them (alphabetically would probs be better though)
eg in texture.cpp I have:
//====(DE)CONSTRUCTOR====
...
//====LOAD FUNCTIONS====
...
//====SAVE FUNCTIONS====
...
//====RESOURCE MANGEMENT FUNCTIONS====
/... |
Basically, the code inside the {} will run when the "OnLogin" event of the xmpp event is fired. Based on the name, I'd guess that event fires at some point during the login process.
The syntax:
delegate(object o) { statements; }
is a called an anonymous method. The code in your question would be equivile... |
How to implement a simple auto-complete functionality? |
|java|autocomplete| |
I'd like to implement a simple class (in Java) that would allow me to register and deregister strings, and on the basis of the current set of strings auto-complete a given string. So, the interface would be:
* void add(String)
* void remove(String)
* String complete(String)
What's the best way to do this in ter... |
[System.Runtime.Remoting.Proxies.RealProxy][1]
It enables Aspect Oriented Programming in C#, and you can also do a lot of other fancy stuff with it.
[1]: http://msdn.microsoft.com/en-us/library/system.runtime.remoting.proxies.realproxy.aspx |
import operator
a_list_of_dicts.sort(key=operator.itemgetter('name'))
'key' is used to sort by an arbitrary value and 'itemgetter' sets that value to each item's 'name' attribute. |
.Net WinForms Transparent Control |
|user-interface|winforms| |
I want to simulate a 'Web 2.0' Lightbox style UI technique in a WinForms application. That is, to draw attention to some foreground control by 'dimming' all other content in the client area of a window. The obvious solution is to create a control that is simply a partially transparent rectangle that can be docked to th... |
__declspec(dllexport) tells the linker that you want this object to be made available for other dll's to import. It is used when creating a dll that others can link to.
__declspec(dllimport) imports the implementation from a dll so your application can make use it
I'm only a novice c/c++ developer so perhaps some... |
This works for me
<pre>/(?:(?<!\\)|(?<=\\\\))\\q/x</pre>
Output of my test program:
<pre>q does not match
\q does match
\\q does not match
\\\q does match</pre> |
This works for me
<pre>/(?:(?<!\\)|(?<=\\\\))\\q/x</pre>
Output of my test program:
<pre>q does not match
\q does match
\\q does not match
\\\q does match</pre>
Edit: explanation follows. Not all regex implementation support extended syntax, so this may not work in yours. If it works I recommend using this... |
Updated:
My new an improved regex, supporting more than 3 backslashed:
<pre>/(?<!\\) # Not preceded by a single backslash
(\\\\)* # an even number of backslashes
\\q # Followed by a \q
/x;</pre>
or if your regex library doesn't support extended syntax.
<pre>/(?<!\\)(\\\\)*\\q/;</pre>
Outpu... |
Updated:
My new an improved regex, supporting more than 3 backslashes:
<pre>/(?<!\\) # Not preceded by a single backslash
(\\\\)* # an even number of backslashes
\\q # Followed by a \q
/x;</pre>
or if your regex library doesn't support extended syntax.
<pre>/(?<!\\)(\\\\)*\\q/;</pre>
Outpu... |
Updated:
My new and improved regex, supporting more than 3 backslashes:
<pre>/(?<!\\) # Not preceded by a single backslash
(?>\\\\)* # an even number of backslashes
\\q # Followed by a \q
/x;</pre>
or if your regex library doesn't support extended syntax.
<pre>/(?<!\\)(?>\\\\)*\\q/</pre>
... |
Two different use cases:
1) You are defining a class implementation within a dll. You want another program to use the class. Here you use dllexport as you are creating a class that you wish the dll to expose.
2) You are using a function provided by a dll. You include a header supplied with the dll. Here the he... |
You could conceivably split your application up into multiple GWT modules but you need to remember that this will limit your ability to share code between modules. So if one module has classes that reference the same class that another module references, the code for the common class will get included twice.
Effecti... |
I'm not a make expert, but I would try have $(BOMS) depend on $(SIGS), and making the $(SIGS) target execute the if/else rules that you currently have under the $(BOMS) target.
$(DEP) : $(SIGS)
... recreate dependency
$(BOMS) : $(SIGS)
...checkout TAG=$(VER) $@
$(SIGS) :
...i... |
I'm not a make expert, but I would try have $(BOMS) depend on $(SIGS), and making the $(SIGS) target execute the if/else rules that you currently have under the $(BOMS) target.
$(DEP) : $(SIGS)
... recreate dependency
$(BOMS) : $(SIGS)
...checkout TAG=$(VER) $@
$(SIGS) :
...i... |
I think with MSMQ (avaiable only on Vista) you might be able to to do like this:
<bindings>
<netMsmqBinding>
<binding name="PosionMessageHandling"
receiveRetryCount="3"
retryDelay="00:05:00"
maxRetryCycles="3"
receiveErrorHandling="Move" />
</netMsmqBinding>
</binding>
WCF will im... |
There are [anti-aliasing differences][1] between Safari 3.1 and Gogole Chrome, for whatever that's worth. This will doubtless be because Safari on Windows uses its own text-rendering and anti-aliasing layer instead of Windows's GDI.
[1]: http://www.flickr.com/photos/kurafire/2822606444/ |
- unless you are in the business of providing .net components, you should be looking to buy it off the shelf. Its a lot of work getting such a control right - There are already vendors providing this kind of UI. e.g. [ComponentOne][1]
- if you are trying to build this component as a product, you should look at the... |
In this case obfuscating is the wrong approach.
When you release the code to the client you should keep a copy of the code you send them (either on disk or preferably in your version control as a tag/branch).
Then if your client makes changes then you can compare the code they have to the code you sent them and e... |
In this case obfuscating is the wrong approach.
When you release the code to the client you should keep a copy of the code you send them (either on disk or preferably in your version control as a tag/branch).
Then if your client makes changes you can compare the code they have to the code you sent them and easily... |
It's quite simple to reverse engineer a .net app using [.net reflector][1] - since the app will generate VB, VC and C# code straight from the MSIL, and it's possible to pull out all kinds of useful gems.
Code obfuscators hide code quite well from most reverse engineering hacks, and would be a good idea to use on pro... |
debug an embedded system containing gdb remotely using some kind of gui. |
|gdb| |
I would like to debug an embedded system containing gdb remotely using some kind of gui (ie like ddd). The embedded system does not have the sources or build symbols. However my local x windows box has. However the execution must happen on the embedded system. How can I from my development box drive gdb remotely with s... |
One common scenario is where you need to pass a **null** pointer to a function, and have it initialized within that function, and used outside the function. Without multplie indirection, the calling function would never have access to the initialized object.
Consider the following function:
initialize(foo* my... |
Eclipse can be quite a change, especially coming from something like just a text editor, or Visual Studio
1. try to let Eclipse build the project itself, without the help of ant. Leave ant to a handwritten build.xml file to build the project from the command line outside of eclipse, e.g., on yer build/release machin... |
",liger, unicorn, snipe".TrimStart(','); |
You're going to want to use the `join into` construct to create a group query.
TestContext db = new TestContext(CreateSparqlTripleStore());
var q = from a in db.Album
join t in db.Track on a.Name equals t.AlbumName into tracks
select new Album{Name = a.Name, Tracks = tracks};
... |
Maybe the layout area doesn't have the right **style**. I think you may have to give the map_canvas a
position: absolute
or
position: relative
That's just a hunch. |
Algorithm to find a common multiplier to convert decimal numbers to whole numbers |
|algorithm|math| |
I have an array of numbers that potentially have up to 8 decimal places and I need to find the smallest common number I can multiply them by so that they are all whole numbers. I need this so they can all be multiplied out to the same scale and be processed by a sealed system that will only deal with whole numbers, the... |
I have an array of numbers that potentially have up to 8 decimal places and I need to find the smallest common number I can multiply them by so that they are all whole numbers. I need this so all the original numbers can all be multiplied out to the same scale and be processed by a sealed system that will only deal wit... |
If you can get SSH to it you can an SSH Port-forwarded SVN server.
Use SSHs -L ( or -R , i forget, it always confuses me ) to make an ssh tunnel so that
127.0.0.1:3690 is really connecting to remote:3690 over the ssh tunnel, and then you can use it via
svn co svn://127.0.0.1/....
|
I personnaly use [the resources files][1].
Very efficient, very simple.
[1]: http://msdn.microsoft.com/en-us/library/c6zyy3s9.aspx |
I believe and hope the era of using tables for layout is gone. Simply put: **a table is a table, nothing else**.
What I think will be the new, similar, flamewar topic for next few years is : should I use new CSS properties table, table-cell, table-row etc. for layout?? ? :-)
|
I believe and hope the era of using tables for layout is gone. Simply put: **a table is a table, nothing else**.
What I think will be the new, similar, flamewar topic for next few years is : should I use new CSS feature **display**: **table**, **table-cell**, **table-row** etc. for layout?? ? :-)
|
Found a [DevX][1] article regarding a touch utility that look useful.
I'm going to try combining that with either a table in the database (add a record and the touch utility finds it and updates the appropriate web.config file) or a web service (make a call and the touch utility gets called to update the appropria... |
^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$
Perhaps a more concise one could be :
^(?:(\d+)\.){0,2}(\*|\d+)$
This can then be enhanced to 1.2.3.4.5.* or restricted exactly to X.Y.Z using * or {2} instead of {0,2} |
Best server-side framework for heavy RIA based application? |
|ria| |
What do the collective beleive to be the best platform to use as a backend to AJAX / Flex / Silverlight applications and why?
We are undergoing a technology review and I would like to know some other opinions.
Is It Java, Grails, Python, Rails, ColdFusion, something else? |
If you're using the standard SVN installation the svn:// connection will work on tcpip port 3690 and so it's basically impossible to connect unless you change your network configuration (you said only Http traffic is allowed) or you install the http module and Apache on the server hosting your SVN server. |
I would say it is possible to drop _to_ Flash if you detect that the item is dragged on to the <div> that contains the flash stuff, and you set your dragged objects to have a z-index higher than the flash. Then when it is dropped you can talk to Flash using javascript to tell it where and what was dropped.
However ... |
Dllexport is used to mark a function as exported. You implement the function in your DLL and export it so it becomes available to anyone using your DLL.
Dllimport is the opposite: it marks a function as being imported from a DLL. In this case you only declare the function's signature and link your code with the libr... |
using System.Diagnostics;
Process.Start("http://www.google.com/");
This approach has worked for me, but I could be missing something important.
|
This [article][1] will walk you through it.
Short answer:
ProcessStartInfo sInfo = new ProcessStartInfo("http://mysite.com/");
Process.Start(sInfo);
[1]: http://support.microsoft.com/kb/320478 |
Loading different versions of the same assembly |
|c#|.net|reflection|assembly|dll| |
Using reflection, I need to load 2 different versions of the same assembly. Can I load the 2 versions in 2 different AppDomains in the same process?
I need to do some data migration from the old version of the app to the new version.
Please let me know if this is possible or should I use 2 separate processes. |
How did my process exit? |
|c#|.net|system.diagnostics| |
From C# on a Windows box, is there a way to find out how a process was stopped?
I've had a look at the [Process][1] class, managed to get a nice friendly callback from the Exited event once I set EnableRaisingEvents = true; but I have not managed to find out whether the process was killed or whether it exited natural... |
There is a very steep learning curve to WPF and I recommend you get the obvious books first (Adam Nathan, Sells/Griffiths, Chris Anderson) and Blogs (Josh Smith, etc.). Just be prepared for it and make sure your project allows you the time to learn WPF.
In addition to learning the technology spend some time learning... |
Your scheme is sound and achievable in VSS (although I would suggest you consider an alternative, VSS is really an outdated product).
For your "CI" Build - you would do the Versioning take a look at [MSBuild Community Tasks Project][1] which has a "Version" tasks. Typically you will have a "Version.txt" in your sou... |
|.net|winforms|user-interface| |
[^]+ should do it |
[^]+ should do it
In answer to aku's comment attached to this, I tested it with an online regex tester (http://www.regextester.com/), and so assume it works with JavaScript. I have to confess to not testing it in "real" code ;) |
Pretty much use this approach for anything I am coding in. Good structure and well commented code makes good reading
- Global Variables
- Functions
- Main Body/Method |
When exceptions aren't available, I'd use the PEAR model and provide isError() functionality in all your classes. |
I've got a PSP, it has a browser that's based on WebKit (also Google Chrome and Safari use WebKit engine), so pretty any site that works fine on Safari/Chrome will work fine on PSP. However, PSP has a 480×272 resolution so if you want to target PSP platform, you have to keep this small resolution in mind.
You will ... |
You are subscribing to the OnLogin event in xmpp.
This means that when xmpp fires this event, the code inside the anonymous delegate will fire. Its an elegant way to have callbacks.
In Xmpp, something like this is going on:
// Check to see if we should fire the login event
// ALso check to see i... |
It depends on whether you want to do client-side or server-side paging. If server side, your web services will have to include a couple of additional parameters (e.g. "startFrom" and "pageSize") which will let you specify which 'page' of the data to retrieve. Your service will probably also need to return the total res... |
You can also just set the UA on the LWP::Simple module - just import the $ua variable, and it'll allow you to modify the underlying UserAgent:
use LWP::Simple qw/get $ua/;
$ua->agent("WikiBot/0.1");
print get("http://en.wikipedia.org/wiki/Stack_overflow"); |
If you are trying to call a stored procedure from c# you would want to use ADO.Net instead of the calling sqlcmd via the command line. Look at SqlConnection and SqlCommand in the System.Data.SqlClient namespace.
Once you are calling the stored procedure via SqlCommand you will be able to catch an exception raised b... |
If your language supports properties, just use properties. |
> but then the model will create and store instances of other models which is where my problem is.
What is wrong with this?
If your 'business logic' states that an Operation must have a valid set of Entries, then surely there is nothing wrong for the Operation class to know about, and deal with your Entry object... |
What language do you want to use?
curl with awk might be all you need. |
Daniel Feenberg (an economist at the private National Bureau of Economic Research) claims that the chances of overwritten data being recovered from a modern hard drive amount to "urban legend":
[Can Intelligence Agencies Read Overwritten Data?][1]
So theoretically overwriting the file once with zeroes would be ... |
Eric Sink has a great [series of posts][1] on source control basics. His company (Sourcegear) makes a source control tool called Vault, but the how-to is generally pretty system agnostic.
[1]: http://www.ericsink.com/scm/source_control.html |
What is the best epoll/kqueue/select equvalient on Windows? |
|windows|api|io|sdk|epoll| |
What is Windows' best I/O event notification facility?
By best I mean something that ...
1. doesn't have a limit on number of input file descriptors
2. works on all file descriptors (disk files, sockets, ...)
3. provides various notification modes (edge triggered, limit triggered)
|
I find that using the var keyword actually makes the code more readable because you just get used to skipping the 'var' keyword. You don't need to keep scrolling right to figure out what the code is doing when you really don't care about what the specific type is. If I really need to know what type 'item' is below, I... |
You still have all the files on your hard drive, ready for F5!
The difference is that you can "checkpoint" your files into the repository. Your daily life doesn't have to change at all. |