instruction stringlengths 0 30k ⌀ |
|---|
As a "general purpose" backup, I'd say it's probably not the greatest idea, mainly for the reasons given by others (lots of excess folders and wasted disk space). If you want to just keep backups, again I'd say there's probably better options, depending on your needs, eg: do you need to keep every single version of eve... |
Use a regular expression to detect the IP address. A couple examples:
/\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/
/^([1-9][0-9]{0,2})+\.([1-9][0-9]{0,2})+\.([1-9][0-9]{0,2})+\.([1-9][0-9]{0,2})+$/ |
There is *no such thing* as an ASCII string in C#! Strings *always* contain UTF-16. Not realizing this leads to a lot of problems. That said, the methods mentioned before work because they consider the string as UTF-16 encoded and transform the characters to ASCII symbols. |
There is *no such thing* as an ASCII string in C#! Strings *always* contain UTF-16. Not realizing this leads to a lot of problems. That said, the methods mentioned before work because they consider the string as UTF-16 encoded and transform the characters to ASCII symbols.
/EDIT in response to the clarification: how... |
No, can't be done, at least not if you're talking about the Feature Pack version. Version 10 of the BCGSoft libraries do have this functionality, see for example: http://www.bcgsoft.com/bcgcontrolbarpro-versions.htm and http://www.bcgsoft.com/images/SkinnedBuiltInDlgs.jpg. The MFC feature pack is more or less the previ... |
You have the answer in your question: Backup the log, then it will be shrunk.
Make a maintenance plan to regularly backup the database and don't forget to select "Backup the transaction log". That way you'll keep it small.
|
What's the best approach to embed RegEx in Oracle or SQL Server 2005 SQL? |
|sql|sql-server|oracle-database|regex| |
This is a 3 part question regarding embedded RegEx into SQL statements.
1. How do you embed a RegEx expression into an Oracle PL/SQL
select statement that will parse out
the “DELINQUENT” string in the text
string shown below?
2. What is the performance impact if used within a
mission critic... |
Given masto's caveats about sorting:
`ls | sed -n '1~4 p' | xargs -i mv {} ../destdir/`
The thing I like about this solution is that everything's doing what it was designed to do, so it feels unixy to me. |
I'm not sure how to get the attribute to work, but there is another option that may be easier.
In addition to checking for the DefaultValueAttribute, the PropertyGrid also uses reflection to look for a method named "ShouldSerialize[Property Name]()", where [Property Name] is the name of the property in question. Th... |
Typical revision changes are stored using a delta algorithm, so the only data stored are the changes in each revision in relation to the original. I am unsure of wikipedia or stackoverflow how they have it implemented. |
You could use Microsoft SyncToy (free).
http://www.microsoft.com/Downloads/details.aspx?familyid=C26EFA36-98E0-4EE9-A7C5-98D0592D8C52&displaylang=en
|
I agree, it's sounding a bit too much like Homework! |
I agree, it's sounding a bit too much like Homework!
If it isn't homework then I guess the simplest answer is readability.
As stated before, both queries will produce the same execution plan. If this is the case then the only thing you need to worry about it maintainability. |
Depends on the web server. If you can use servlets, try this :
// UploadServlet.java : Proof of Concept - Mike Smith March 2006
// Accept a file from the client, assume it is an image, rescale it and save it to disk for later display
import javax.servlet.http.*;
import javax.imageio.*;
import java.io.*;
import... |
X-Sendfile is an HTTP header, so you want something like this:
header("X-Sendfile: $filename");
Your web server picks it up if correctly configured. Here's some more details:
[http://blog.adaniels.nl/articles/how-i-php-x-sendfile/][1]
[1]: http://blog.adaniels.nl/articles/how-i-php-x-sendfile/ |
To obtain BI2008 you must install MSSQL2008. When you have done so, you may find the project will load. If it doesn't, create a new report project and add existing RDL files to it. |
The only trouble with compatibility regarding Module::Build is when a user tries to install modules without updating their CPAN client (CPAN.pm or CPANPLUS.pm) If they are installing your module from the CPAN, they can just as easily upgrade their client from the same mirror.
If you don't want to do <em>anything</e... |
Wildcard Subdomains |
|subdomain|mamp|localhost|wildcard|wildcard-subdomain| |
I know there have been a few threads on this before, but I have tried absolutely everything suggested (that I could find) and nothing has worked for me thus far...
With that in mind, here is what I'm trying to do:
First, I want to allow users to publish pages and give them each a subdomain of their choice (ex: us... |
It depends on whether you're writing a value type or a reference type. For a sortable value type, I recommend this: http://www.peterritchie.com/Hamlet/Downloads/77.aspx
|
Answering my own question, but the answer, sadly, is no.
<http://www.netbeans.org/kb/articles/tom-ball-interview.html> |
You can capture the output of cout like this, for example:
std::streambuf* old_rdbuf = std::cout.rdbuf();
std::stringbuf new_rdbuf;
// replace default output buffer with string buffer
std::cout.rdbuf(&new_rdbuf);
// write to new buffer, make sure to flush at the end
std::cout << "hello... |
Visualize Friend of a Friend (foaf) graph |
|graph|visualization|foaf| |
I wrote a script to export twitter friends as foaf rdf description. Now I'm looking for a tool to visualize the friend networks. I tried http://foafscape.berlios.de/ but for 300+ Nodes it is really slow and does a bad job on auto formatting.
Any hints for good graph visualization tools? It's ok if they do not suppor... |
|semantic-web|visualization|rdf|graph|foaf| |
I wrote a script to export twitter friends as foaf rdf description. Now I'm looking for a tool to visualize the friend networks. I tried http://foafscape.berlios.de/ but for 300+ Nodes it is really slow and does a bad job on auto formatting.
Any hints for good graph visualization tools? It's ok if they do not suppor... |
The SDK is only available on OS X, forcing you to use a mac. If you don't want to purchase a mac you can either run OS X on a virtual machine on your windows box, or you can install OS X on your PC.
In my experience the virtual machine solution is unusably slow (on a core2 duo laptop with 2G ram). If you feel like ... |
[This guide][1] is probably more info than you really requested, but webserver information is in there. It's Gentoo-specific, but you can apply the same information with minor translations to any other distro.
[1]: http://gentoo-wiki.com/HOWTO_setup_a_home-server |
This cannot work due to the fact that generics don't have the ability to follow inheritance patterns. ie. IQueryable<SimpleObj> is not in the inheritance tree of IQueryable<IPrimaryKey> |
Because at the IL level, a read/write property translates into two (getter and setter) methods.
When overriding, you have to keep supporting the underlying interface. If you could add a setter, you would effectively be adding a new method, which would remain invisible to the outside world, as far as your classes' in... |
There is a [library for XModem][1] that you could adapt to use Y-Modem without much effort.
[1]: http://trackday.cc/b2evo/blog2.php/2007/08/02/net-xmodem |
Perforce. Getting the file status in the sandbox. |
|untagged| |
I am new to Perforce and I am only used to CVS.
Question :
How can I figure out the state of the files in my client, I want to know if the file needs an updated, or patched, or modified etc. In CVS, I used to simply run "cvs -n -q update . > file". Later look for M,U,P,C attributes to get the current status of t... |
Because that would break the concept of encapsulation and implementation hiding. Consider the case when you create a class, ship it, and then the consumer of your class makes himself able to set a property for which you originally provide a getter only. It would effectively disrupt any invariants of your class which yo... |
It doesn't look like you can override the empty constructor. Instead, I would create a method that performs the functionality that you need in the empty constructor and returns the new object.
// Add new partial class to extend functionality
public partial class User {
// Add additional constructor... |
Another try:
^(((\d+)\.)?(\d+)\.)?(\d+|\*)$
This gives the three parts in groups 4,5,6 BUT:
They are aligned to the right. So the first non-null one of 4,5 or 6 gives the version field.
- 1.2.3 gives 1,2,3
- 1.2.* gives 1,2,*
- 1.2 gives null,1,2
- *** gives null,null,*
- 1.* gives null,1,* |
That is creating an anonymous function. This feature was introduced in C# 2.0 |
Is this what you are looking for?
List<string> strings = new List<string>()
{
"Hello", "I", "am", "a", "list", "of", "strings."
};
IEnumerator<string> e = strings.GetEnumerator();
Func<string> f = () => e.MoveNext() ? e.Current : null;
for (; ; )
{
string str = f()... |
input = [{'name':'Homer', 'age':39}, {'name':'Bart', 'age':10}]
input.sort(lambda x,y : cmp(x['name'], y['name']))
input will now be what you want.
|
What's the best way to organize code? |
|language-agnostic|organizing| |
I'm not talking about how to indent here. I'm looking for suggestions about the best way of organizing the chunks of code in a source file.
Do you arrange methods alphabetically? In the order you wrote them? Thematically? In some kind of 'didactic' order?
What organizing principles do you follow? Why?
|
I had a project which used win32 Python.
Due to various reasons, some modules used odbc.py to access the DB, and other modules - pyodbc.py.
There was a problem when a function needed to be used by both kinds of modules. It had an connection object passed to it as an argument, but then it had to know whet... |
> how acceptable is a practice like this?
I'd say it's unacceptable.
1. Requires the === operator, which is very dangerous. If the user used ==, it leads to a very hard to find bug.
2. Using "0" and "" to denote false may change in future PHP versions. Plus in a lot of other languages "0" and "" does not evalu... |
I am not sure if you can do it using the command line. You can on the other hand add repositories in the **pom.xml** as in the following example. Using this approach you do not need to change the **~/.m2/settings.xml** file.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.... |
I would recommend using [Beautiful Soup](http://www.crummy.com/software/BeautifulSoup/) module instead and it has [good documentation](http://www.crummy.com/software/BeautifulSoup/documentation.html). |
I would look into using a [post-commit hook](http://svnbook.red-bean.com/en/1.4/svn.ref.reposhooks.post-commit.html) to update the site when changes are made. This could be something as simple as using "svn export" to export the current state of the repository to the live website location. Of course, this has performan... |
I haven't really used maven 2 before, our system is still working on maven 1.x because of some issues with maven 2.
However, looking at the documentation for maven 2 it seems that there aren't any specific System properties like that. However, you could probably build one into your poms/settings using the System pro... |
C# automatically converts the objects to strings for you. Consider this line of code:
aString = aString + 23;
This is valid C#; it compiles down to a call to String.Concat(), which takes two objects as arguments. Those objects are automatically converted to string objects for you.
The same thing occurs w... |
I don't know of any such tools, and I have thought about writing one in the past, but it turns out that this is a difficult problem to solve.
Say your source file includes a.h and b.h; a.h contains `#define USE_FEATURE_X` and b.h uses `#ifdef USE_FEATURE_X`. If `#include "a.h"` is commented out, your file may still ... |
The [Virtual Data Toolkit][1] (VDT) is not a virtual machine image, but it is a nice distro of tons of grid tools (including Globus) which is *very* easy to install. I use it all the time, and love it.
From their website:
> The Virtual Data Toolkit (VDT) is an
> ensemble of grid software that can be
> easily i... |
The [Virtual Data Toolkit][1] is not a virtual machine image, but it is a nice distro of tons of grid tools (including Globus) which is *very* easy to install. I use it all the time, and love it.
From [their website][2]:
> The Virtual Data Toolkit (VDT) is an
> ensemble of grid software that can be
> easily in... |
What about using <a href="http://solutoire.com/flotr/">Flotr</a>? The syntax is pretty clean and you can produce some pretty nifty graphs (Check out <a href="http://solutoire.com/flotr/docs/">some examples</a>) with minimal effort. |
It could also be that although you are have JDK 1.5 or higher, the project has some specific settings set that tell it to compile as 1.4. You can test this via Project >> Properties >> Java Compiler and ensure the "Compiler Compliance Level" is set to 1.5 or higher. |
I think it depends on how familiar you are with linux. Certainly, many people do this for hobbiest websites.
There are many aspects involved - you should begin with something simple like getting apache running and visible to the outside world. |
Whether or not something is a URI is context-dependent. In general the only thing they always have in common is that they start "scheme_name:". The scheme name can be anything (subject to legal characters). But other strings also contain colons without being URIs.
So you need to decide what schemes you're interested... |
Tables have no equivalent in CSS2, and they aren't that easy to duplicate using css. The particular part of tables that is hard to reproduce is the auto-sizing of the columns. While it's easy to let the 1 row grow to the same size across the page, it's hard for the next row to match up the column size or each cell size... |
Web application projects works more like a traditional VS project, which has a project file, is compiled in one step and so on.
Web site projects works more like classic ASP or PHP-sites. There is no project file (references are stored in the solution file), and pages are recompiled dynamically on the server. The ni... |
|localhost|mamp|subdomain|wildcard-subdomain|wildcard| |
I know there have been a few threads on this before, but I have tried absolutely everything suggested (that I could find) and nothing has worked for me thus far...
With that in mind, here is what I'm trying to do:
First, I want to allow users to publish pages and give them each a subdomain of their choice (ex: us... |
There was another 68000 Macintosh debugger called TMON. I don't remember the kipper quote being in it, but it's been a while.
|
In Javascript, why is the "this" operator inconsistent? |
|javascript| |
In javascript, the "this" operator can refer to different things under different scenarios.
Typically in a method within a javascript "object", it refers to the current object.
But when used as a callback, it becomes a reference to the calling object.
I have found that this causes problems in code, because if... |
In JavaScript, the "this" operator can refer to different things under different scenarios.
Typically in a method within a JavaScript "object", it refers to the current object.
But when used as a callback, it becomes a reference to the calling object.
I have found that this causes problems in code, because if... |
How to retrieve error when launching sqlcmd from C# ? |
|c#|sql-server| |
I need to run a stored procedure from a C# application.
I use the following code to do so:
Process sqlcmdCall = new Process();
sqlcmdCall.StartInfo.FileName = "sqlcmd.exe";
sqlcmdCall.StartInfo.Arguments = "-S localhost\\SQLEXPRESS -d some_db -Q \":EXIT(sp_test)\""
sqlcmdCall.Start();
sqlc... |
If you use a traditional HTTP model (i.e. don't use runat="server") you can post the data to another asp page and place the posted data into hidden form elements, you can do this for however many pages you need thus avoiding placing anything in a session variable. |
This one started me off into true OOA&D.
Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development - Craig Larman
These would be up there as well:
- Patterns in Enterprise Application Architecture - Fowler
- Domain-Driven Design - Eric Evans
|
Extending on Abe's solution, you can also use closures to hold a reference to the enumerator:
var iter = ((IEnumerable<char>)"hello").GetEnumerator();
//with closure
{
Func<object> f =
() =>
{
iter.MoveNext();
return... |
The forms themselves have an opacity property that would be perfect, but I don't think most of the individual controls do. You'll have owner-draw it. |
The big dimming rectangle is good.
Another way to do it would be:
Roll your own base Form class says a `MyLightboxAwareForm` class that would listen to a `LightboxEvent` from a `LightboxManager`. Then have all your forms inherit from `MyLightboxAwareForm`.
On calling the `Show` method on any `Lightbox`, the `L... |
It serves as an anonymous method, so you don't need to declare it somewhere else. It's very useful.
What it does in that case is to attach that method to the list of actions that are triggered because of the `onLogin` event. |
Here's the answer from <a href="perldoc.perl.org/perlfaq1.html">perlfaq1</a>.
What's the difference between "perl" and "Perl"?
One bit. Oh, you weren't talking ASCII? :-) Larry now
uses "Perl" to signify the language proper and "perl" the
implementation of it, i.e. the current inte... |
Unless the control you use to display the Flash content is built in WPF, you will run in to these "airspace" issues. Every display technology from Win32 to WinForms used HWNDs "under the hood", but WPF uses DirectX. The Window Manager in Windows however, still only understands HWNDs, so WPF apps have one top-level HWND... |
I think the easiest way would be to add a check to your mail sending code on the website (there's got to be some class which is in charge of sending the mails out).
You could include a check which is only active when the code is compiled in debug mode (using compiler directives). Thus, when you are developing and bu... |
Assuming that the classes have similar functionality with 1.5 vs. 6.0 differences in implementation you could merge them into one class. Then, without editing the source to comment/uncomment, you can rely on the optimization that the compiler always do. If an if expression is always false, the code in the if statement... |
A collection it was, and stunning. Edsger Dijkstra's (with some help from C.A.R. Hoare) little black book [Structured Programming](http://portal.acm.org/citation.cfm?id=1243380&jmp=cit&coll=portal&dl=GUIDE&CFID=://www.acm.org/publications/&CFTOKEN=www.acm.org/publications/#CIT) and particlarly the essay titled "On Our... |
I'd checkout the [Monkeysphere][1] project. It uses OpenPGP's web of trust concepts to manage ssh's authorized_keys and known_hosts files, without requiring changes to the ssh client or server.
[1]: http://web.monkeysphere.info/ |
How to catch ALL exceptions/crashes in a .NET app |
|c#|.net|exception| |
I have a .NET console app app that is crashing and displaying a message to the user.
All of my code is in a try{<code>} catch(Exception e){<stuff>} block, but still errors are occasionally displayed.
In a Win32 app, you can capture all possible exceptions/crashes by installing various exception handlers:
_set_s... |
I would look into installing apache
99% of linux distributions will have a package for it.
On ubuntu you can run:
sudo apt-get install apache2
Are you considering hosting a web page locally for the internet? Or is this just for development etc..
If it's for an internet server, you will need a stable... |
Other than for [tabular data][1], tables are unfortunately still necessary if you want to create *flexible* grid layouts such as complex forms in a cross-browser compatible manner.
CSS2 has support for creating flexible grid layouts without using the `table` element via the [display property][2], but this is [not su... |
It seems pretty hard to have a regex that does exactly what you want (i.e. accept only the cases that you need and reject **all** others *and* return some groups for the three components). I've give it a try and come up with this:
^(\*|(\d+(\.(\d+(\.(\d+|\*))?|\*))?))$
IMO (I've not tested extensively) this s... |
I am going to assume that your question is actually - *"Should I avoid using HTML tables for layout purposes?"*. The answer is: No. In fact, tables are specifically meant to be used to control layout. The drawback for using tables to control the layout of an entire page is that the source file rapidly becomes diffic... |
While I don't have an url to a good tutorial in english, I would just warn you that this is not something you should take lightly. Administrating a server involves getting your hands dirty in linux stuff and dealing with security can be pretty complex depending on your knowledge and requirements.
So if you know not... |
Ok, if you use dynamic scaffolding a workaround for this bug, is edit directly in your GRAILS_HOME/src/grails/templates/scaffolding |
What does an 'M' in an IMAP message filename mean? |
|imap| |
I'm cleaning up some old IMAP folders, and finding messages with names like:
1095812260.M625118P61205V0300FF04I002DC537_0.redoak.cise.ufl.edu,S=2576:2,ST
Since they don't show up in my mail client, I presume it's some semaphore indicating the message already got moved somewhere else. Is that the case, and can the... |
What do the flags in a Maildir message filename mean? |
|imap|maildir| |
I'm cleaning up some old Maildir folders, and finding messages with names like:
1095812260.M625118P61205V0300FF04I002DC537_0.redoak.cise.ufl.edu,S=2576:2,ST
They don't show up in my IMAP client, so I presume it's some semaphore indicating the message already got moved somewhere else. Is that the case, and can the... |