instruction stringlengths 0 30k ⌀ |
|---|
I think you might want to be a bit more specific, when you say data structures my mind goes in a few directions...
Arrays - They are certainly well documented and available in. (http://us.php.net/manual/en/book.array.php)
SQL Data - Depends on the database you are using, but most are available. (http://us.php.net/manual/en/book.mysql.php)
OOP - Depending on the version objects can be designed and implemented. (http://us.php.net/manual/en/language.oop.php) I had to search for OOP to find this on the php site.
Hope that helps, sorry if it does not.
|
I was able to do this about a year ago, but I no longer remember all of the details. Basically, you can use IntPtr.Size to determine which DLL to load, then perform the actual LoadLibrary through p/Invoke. At that point, you've got the module in memory and you ought to be able to just p/Invoke functions from inside of it -- the same module name shouldn't get reloaded again.
I think, though, that in my application I actually had the C++ DLL register itself as a COM server and then accessed its functionality through a generated .NET wrapper -- so I don't know if I ever tested p/Invoking directly. |
You can try to develop some sort of a generic component that accepts a [SynchronizationContext][1] as input and uses it to invoke the events.
[1]: http://msdn.microsoft.com/en-us/library/system.threading.synchronizationcontext.aspx |
Of course PHP has data structures. The array in php is incredibly flexible. Some examples:
$foo = array(
'bar' => array(1,'two',3),
'baz' => explode(" ", "Some nice words")
);
Then you have an absolute plethora of array functions available to map/filter/walk/etc the structures, or convert, flip, reverse, etc.
|
Are you wanting to change the location of the files on the workstation? If so, here's how I do it:
Open Visual Studio
Open the Source Control Explorer window.
From the Workspace dropdown select "Workspaces..."
The Manage Workspaces dialog should show up.
Select the workspace you want to modify, and click Edit...
You should be able to adjust the folders from here. |
You don't need to *compile* python for Mac/Windows/Linux. It is an interpreted language, so you simply need to have the Python interpreter installed on the system of your choice (it is available for all three platforms).
As for a GUI library that works cross platform, Python's [Tk/Tcl][1] widget library works very well, and I believe is sufficiently cross platform.
[Tkinter][2] is the python interface to Tk/Tcl
From the python project webpage:
> Tkinter is not the only GuiProgramming
> toolkit for Python. It is however the
> most commonly used one, and almost the
> only one that is portable between
> Unix, Mac and Windows
[1]: http://www.tcl.tk/
[2]: http://docs.python.org/lib/module-Tkinter.html |
Possible to "spin off" several GUI threads? (Not halting the system at Application.Run) |
|winforms|c#|.net| |
|c#|.net|winforms| |
**My Goal**
I would like to have a main processing thread (non GUI), and be able to spin off GUIs in their own background threads as needed, and having my main non GUI thread keep working. Put another way, I want my main non GUI-thread to be the owner of the GUI-thread and not vice versa. I'm not sure this is even possible with Windows Forms(?)
**Background**
I have a component based system in which a controller dynamically load assemblies and instantiates and run classes implementing a common _IComponent_ interface with a single method _DoStuff()_ .
It would be great if these components were allowed to start up their own Windows Forms GUIs.
**Problem**
When a component tries to fire up a GUI in _DoStuff()_ (the exact line of code is when the component runs Application.Run(theForm)) , the component and hence our system "hangs" at the Application.Run() line until the GUI is closed. Well, the just fired up GUI works fine, as expected.
Example of components. One hasn't nothing to do with GUI, whilst the second fires up a cute windows with pink fluffy bunnies in them.
public class MyComponent1: IComponent
{
public string DoStuff(...) { // write something to the database }
}
public class MyComponent2: IComponent
public void DoStuff()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form());
// I want the thread to immediately return after the GUI
// is fired up, so that my main thread can continue to work.
}
}
I have tried this with no luck.
public void DoStuff()
{
new Thread(ThreadedInitialize).Start()
}
private void ThreadedInitialize()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form());
}
Is it possible to spin off a GUI and return after Application.Run()? |
**My Goal**
I would like to have a main processing thread (non GUI), and be able to spin off GUIs in their own background threads as needed, and having my main non GUI thread keep working. Put another way, I want my main non GUI-thread to be the owner of the GUI-thread and not vice versa. I'm not sure this is even possible with Windows Forms(?)
(Sorry for the big post here. I've had complaints about previous shorter versions of this question just isn't comprehensible. I'm a lousy writer)
**Background**
I have a component based system in which a controller dynamically load assemblies and instantiates and run classes implementing a common _IComponent_ interface with a single method _DoStuff()_ .
Which components that gets loaded is configured via a xml configuration file and by adding new assemblies containing different implementations of _IComponent_ . The components provides utility functions to the main application. While the main program is doing it's thing, e.g. controlling a nuclear plant, the components might be performing utility tasks (in their own threads), e.g. cleaning the database, sending emails, printing funny jokes on the printer, what have you. What I would like, is to have one of these components be able to display a GUI, e.g. with status information for the said email sending component.
The lifetime of the complete system looks like this
1. Application starts.
2. Check configuration file for components to load. Load them.
3. **For each component, run DoStuff() to initialize it and make it live its own life in their own threads.**
4. Continue to do main application-thingy king of work, forever.
I have not yet been able to successfully perform point 3 if the component fires up a GUI in _DoStuff()_ . It simply just halts until the GUI is closed. And not until the GUI is closed does the program progress to point 4.
It would be great if these components were allowed to start up their own Windows Forms GUIs.
**Problem**
When a component tries to fire up a GUI in _DoStuff()_ (the exact line of code is when the component runs Application.Run(theForm)) , the component and hence our system "hangs" at the Application.Run() line until the GUI is closed. Well, the just fired up GUI works fine, as expected.
Example of components. One hasn't nothing to do with GUI, whilst the second fires up a cute windows with pink fluffy bunnies in them.
public class MyComponent1: IComponent
{
public string DoStuff(...) { // write something to the database }
}
public class MyComponent2: IComponent
public void DoStuff()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form());
// I want the thread to immediately return after the GUI
// is fired up, so that my main thread can continue to work.
}
}
I have tried this with no luck. Even when I try to fire up the GUI in it's own thread, the execution halts until the GUI as closed.
public void DoStuff()
{
new Thread(ThreadedInitialize).Start()
}
private void ThreadedInitialize()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form());
}
Is it possible to spin off a GUI and return after Application.Run()? |
LSP in OO programming? |
|oop| |
Am I right in thinking the full name of the LSP is the Liskoff Substitution Principle? I'm having trouble finding an [online] source to cite for any information on this... it seems to be a cornerstone of OOP, and yet I'm having trouble finding definitions. |
If you assume each user has one or more addresses, a telephone number, etc., you could have a 'Users' table, an 'Addresses Table' (containing a primary key and then non-unique reference to Users), the same for phone numbers - allowing multiple rows with the same UserID foreign key, which would make querying 'all addresses for user X' quite simple. |
Yes, you are right. It's spelled Liskov which is probably why you can't find a citation.
Here's the [link.][1] One of the better resources regarding this is Robert C. Martin's Agile Software Development Principles Patterns and practices book.
[1]: http://en.wikipedia.org/wiki/Liskov_substitution_principle |
Your SelectedValue should be a unique id of some sort, that doesn't change. The Text value that gets displayed to the user is something seperate, and can change if necessary without affecting your application, because you associate the id with your Order, not the displayed string value. |
It depends on what you're testing. If you're testing a business logic component -- then its immaterial where the data is coming from and you'd probably use a mock or a hand rolled stub class that simulates the data access routine the component would have called in the wild. The only time I mess with the data access is when I'm actually testing the data access components themselves.
Even then I tend to open a DB transaction in the TestFixtureSetUp method (obviously this depends on what unit testing framework you might be using) and rollback the transaction at the end of the test suite TestFixtureTeardown.
|
@Matt Hamilton
It does. "c" works for whatever the CurrentCultureInfo is, the question becomes if all the users of the web application have the same currency as the server, otherwise, they will need to get the cultureinfo clientside and use the currency gleaned from there. |
It sounds like you might be testing message based systems, or systems with highly parameterised interfaces, where there are large numbers of permutations of input data.
In general all the rules of standard unti testing still hold:
* Try to make the units being tested as small and discrete as possible.
* Try to make tests independant.
* Factor code to decouple dependencies.
* Use mocks and stubs to replace dependencies (like dataaccess)
Once this is done you will have removed a lot of the complexity from the tests, hopefully revealing good sets of unit tests, and simplifying the sample data.
A good methodology for then compiling sample data for test that still require complex input data is [Orthogonal testing](http://en.wikipedia.org/wiki/Orthogonal_array), or see [here](http://www.isixsigma.com/library/content/c030106a.asp).
I've used that sort of method for generating test plans for WCF and BizTalk solutions where the permutations of input messages can create multiple possible execution paths. |
take a look [here][1]
[1]: http://asp.dotnetheaven.com/aspnet/doc/caching/fragment.aspx
you use VaryByParam and VaryByControl in the output cache. |
This is NOT a good idea
[This article talks about ruby's timeout library.](http://blog.headius.com/2008/02/rubys-threadraise-threadkill-timeoutrb.html) which throws exceptions across threads.
It explains how doing such a thing is fundamentally broken. It's not just broken in ruby, it's broken anywhere that throws exceptions across threads.
In a nutshell, what can (and does) happen is this:
ThreadA:
At some random time, throw an exception on thread B:
ThreadB:
try {
//do stuff
} finally {
CloseResourceOne();
// ThreadA's exception gets thrown NOW, in the middle
// of our finally block and resource two NEVER gets closed.
// Obviously this is BAD, and the only way to stop is to NOT throw
// exceptions across threads
CloseResourceTwo();
}
EDIT: Upon closer reading of your example, you're not actually throwing exceptions across threads, you're just setting a flag which says "throw an exception the next time you look at this flag", which is fine as it doesn't suffer from the "can be thrown in the middle of your catch or finally block" problem.
However, if you're going to do that, you may as well just be setting an "exitnow" flag, and using that and save yourself the hassle of creating the exception object :-P |
This is NOT a good idea
[This article talks about ruby's timeout library.](http://blog.headius.com/2008/02/rubys-threadraise-threadkill-timeoutrb.html) which throws exceptions across threads.
It explains how doing such a thing is fundamentally broken. It's not just broken in ruby, it's broken anywhere that throws exceptions across threads.
In a nutshell, what can (and does) happen is this:
ThreadA:
At some random time, throw an exception on thread B:
ThreadB:
try {
//do stuff
} finally {
CloseResourceOne();
// ThreadA's exception gets thrown NOW, in the middle
// of our finally block and resource two NEVER gets closed.
// Obviously this is BAD, and the only way to stop is to NOT throw
// exceptions across threads
CloseResourceTwo();
}
Your 'periodic checking' example is fine, as you're not actually throwing exceptions across threads.
You're just setting a flag which says "throw an exception the next time you look at this flag", which is fine as it doesn't suffer from the "can be thrown in the middle of your catch or finally block" problem.
However, if you're going to do that, you may as well just be setting an "exitnow" flag, and using that and save yourself the hassle of creating the exception object. A volatile bool will work just fine for that. |
We use a commit hook script to trigger our release robot. Writing new release information to a file named changes.txt in our different products will trigger the creation of a tag and the relevant artifacts. |
I think you can specify OutputCache in the control's markup file like you'd do on an ASPX page. And it'd get properly cached automatically.
Just read up on OutputCache page directive on MSDN and get the parameters right and it should do what you want it to.
It's been a long time since I write classic ASP.NET but I believe that's how it's done. |
Boolean Field in Oracle |
|oracle-database| |
Yesterday I wanted to add a boolean field to an Oracle table. However, there isn't actually a boolean data type in Oracle. Does anyone here know the best way to simulate a boolean? Googling the subject discovered several approaches
1. Use an integer and just don't bother assigning anything other than 0 or 1 to it.
2. Use a char field with 'Y' or 'N' as the only two values.
3. Use an enum with the CHECK constraint.
Do experienced Oracle developers know which approach is preferred/canonical? |
There's no standard engine. However, the POSIX Extended Regular Expression format is a valid subset of most engines and is probably as close as you'll get to a standardised subset. |
Server Core won't be very useful (to me at least, and I think many others as well) until they get a version of .Net framework on it. Maybe a specialized subset like they have in the Compact Framework on smart phones. |
Towers of Hannoi is great for practice on recursion. |
Towers of Hannoi is great for practice on recursion.
I'd also do a search on sample programming interview questions. |
When the HTML is parsed, what JQuery sees in the DOM is a UPWARDS DOUBLE ARROW ("⇑"), not the entity reference. Thus, in your Javascript code you should test for "⇑" or "\u21d1". |
When the HTML is parsed, what JQuery sees in the DOM is a `UPWARDS DOUBLE ARROW` ("⇑"), not the entity reference. Thus, in your Javascript code you should test for `"⇑"` or `"\u21d1"`. Also, you need to switch what you're switching to:
if(arrow == "\u21d1") {
$("#"+id+" span").html("\u21d3");
} else {
$("#"+id+" span").html("\u21d1");
} |
When the HTML is parsed, what JQuery sees in the DOM is a `UPWARDS DOUBLE ARROW` ("⇑"), not the entity reference. Thus, in your Javascript code you should test for `"⇑"` or `"\u21d1"`. Also, you need to change what you're switching to:
function expandCollapse(id) {
var arrow = $("#"+id+" span").html();
if(arrow == "\u21d1") {
$("#"+id+" span").html("\u21d3");
} else {
$("#"+id+" span").html("\u21d1");
}
} |
Most regular expression tools/languages support these [basic capabilities](http://www.regular-expressions.info/reference.html):
1. Character Classes/Sets - []
2. Anchors - ^$
3. Alternation - |
4. Quantifiers - ?+*{n,m}
5. Metacharacters - \w, \s, \d, ...
6. Backreferences - \1, \2, ...
7. Dot - .
8. Simple modifiers like /g and /i for global and ignore case
6. Escaping Characters
More advanced tools/languages support:
1. Lookaheads and behinds
2. POSIX character classes
3. Word boundaries
4. Inline Switches
5. Modifiers like /x to allow extra formatting with comments
|
Most regular expression tools/languages support these [basic capabilities](http://www.regular-expressions.info/reference.html):
1. Character Classes/Sets and their Negation - []
2. Anchors - ^$
3. Alternation - |
4. Quantifiers - ?+*{n,m}
5. Metacharacters - \w, \s, \d, ...
6. Backreferences - \1, \2, ...
7. Dot - .
8. Simple modifiers like /g and /i for global and ignore case
6. Escaping Characters
More advanced tools/languages support:
1. Lookaheads and behinds
2. POSIX character classes
3. Word boundaries
4. Inline Switches like allowing case insensitivity for only a small section of the regex
5. Modifiers like /x to allow extra formatting and comments, /m for multiline
6. Named Captures
7. Unicode
|
Are you wanting to change the location of the files on the workstation? If so, here's how I do it:
<ol>
<li>Open Visual Studio</li>
<li>Open the Source Control Explorer window.</li>
<li>From the Workspace dropdown select "Workspaces..."</li>
<li>The Manage Workspaces dialog should show up.</li>
<li>Select the workspace you want to modify, and click Edit...</li>
<li>You should be able to adjust the folders from here.</li>
</ol> |
You can use fseek() to clear the eof condition on the stream. Essentially, read to the end of the file, sleep foir a file, fseek() (without changing your position) to clear eof, the read to end of file again. wash, rinse, repeat. man fseek(3) for details. |
You can use fseek() to clear the eof condition on the stream. Essentially, read to the end of the file, sleep for a while, fseek() (without changing your position) to clear eof, the read to end of file again. wash, rinse, repeat. man fseek(3) for details. |
You can use fseek() to clear the eof condition on the stream. Essentially, read to the end of the file, sleep for a while, fseek() (without changing your position) to clear eof, the read to end of file again. wash, rinse, repeat. man fseek(3) for details.
Here's what it looks like in perl. perl's seek() is essentially a wrapper for fseek(3), so the logic is the same:
wembley 0 /home/jj33/swap >#> cat p
my $f = shift;
open(I, "<$f") || die "Couldn't open $f: $!\n";
while (1) {
seek(I, 0, 1);
while (defined(my $l = <I>)) {
print "Got: $l";
}
print "Hit EOF, sleeping\n";
sleep(10);
}
wembley 0 /home/jj33/swap >#> cat tfile
This is
some
text
in
a file
wembley 0 /home/jj33/swap >#> perl p tfile
Got: This is
Got: some
Got: text
Got: in
Got: a file
Hit EOF, sleeping
Then, in another session:
wembley 0 /home/jj33/swap > echo "another line of text" >> tfile
And back to the original program output:
Hit EOF, sleeping
Got: another line of text
Hit EOF, sleeping |
The associative array can be used for most basic data structures hashtable, queue, stack. But if you want something like a tree or heap I don't think they exist by default but I'm sure there are free libraries anywhere.
To have an array emulate a stack use `array_push()` to add and `array_pop()` to take off
To have an array emulate a queue use `array_push()` to enqueue and `array_shift()` to dequeue
An associative array is a hash by default. In PHP they are allowed to have strings as indexes so this works as expected:
$array['key'] = 'value';
Finally, you can kind of emulate a binary tree with an array with the potential to have wasted space. Its useful if you know you're going to have a small tree. Using a linear array, you say for any index (i) you put its left child at index (2i+1) and right child at index (2i+2).
All of these methods are covered nicely in [this article](http://javascript-reference.info/9-javascript-tips-you-may-not-know.htm) on how to make JavaScript arrays emulate higher level data structures. |
I would probably leave it up to your application to perform the scoring. Check out [Maybe Normalizing Isn't Normal][1] by Jeff Atwood.
[1]: http://www.codinghorror.com/blog/archives/001152.html |
Sending a mail as both HTML and Plain Text in .net |
|c#|.net| |
I'm sending mail from my C# Application, using the SmtpClient. Works great, but I have to decide if I want to send the mail as Plain Text or HTML. I wonder, is there a way to send both? I think that's called multipart.
I googled a bit, but most examples essentially did not use SmtpClient but composed the whole SMTP-Body themselves, which is a bit "scary", so I wonder if something is built in the .net Framework 3.0?
If not, is there any really well used/robust Third Party Library for sending e-Mails? |
What's the best way to implement a SQL script that will grant select, references, insert, update, and delete permissions to a database role on all the user tables in a database? |
|sql|sql-server|t-sql|permissions| |
Ideally, this script could be run multiple times, as new tables were added to the database. SQL Server Management Studio generates scripts for individual database objects, but I'm looking for more of a "fire-and-forget" script. |
myList = ['a','b','c','d']
myString = ",".join(myList )
I'm pretty sure that doesn't work if the list contains numbers. |
**Foreach uses Duck Typing**
Paraphrasing, or shamelessly stealing from [Krzysztof Cwalinas blog][1] on this. More interesting trivia than anything.
For your object to support foreach, you *don't* have to implement *IEnumerable*. I.e. this is not a constraint and it isn't checked by the compiler. What's checked is that
- Your object provide a public method *GetEnumerator* that
- takes no parameters
- return a type that has two members
1. a parameterless *method MoveNext* that *returns a boolean*
2. a *property Current* with a getter that *returns an Object*
For example,
class Foo
{
public Bar GetEnumerator() { return new Bar(); }
public struct Bar
{
public bool MoveNext()
{
return false;
}
public object Current
{
get { return null; }
}
}
}
// the following complies just fine:
Foo f = new Foo();
foreach (object o in f)
{
Console.WriteLine(“Krzysztof Cwalina's da man!”);
}
[1]: http://blogs.msdn.com/kcwalina/archive/2007/07/18/DuckNotation.aspx |
What you want to do is use the AlternateViews property on the MailMessage
[http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.alternateviews.aspx][1]
[1]: http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.alternateviews.aspx |
@Andrew - I'm exactly in your situation. I use a MBP while my company work is purely Microsoft based: i.e., .NET, COM etc. While nothing can beat running Vista natively in Boot Camp (I've never seen Vista run so fast), the niceties of having your Mac OS be the "main" OS, for internet, mail etc. has gotten to the following configuration. Works like a charm:
## Hardware ##
- Load up your MBP with the max possible - 4GB. It's really worth every $.
- Upgrade your hard drive (if not already) to 7200RPM. Major performance boost here.
## Software ##
- [Parallels Desktop for Mac][1] for virtualization. You can either have multiple VM, or use a boot camp partition. The latter is supposed to be faster, but I haven't really measured it (I use it for having the option to boot natively if I really need speed). The former allows you to have multiple OS.
- Micorsoft Visual Studio 2005/8 for .NET and C++. I have yet to see any IDE for .NET which beats this one. The [intellisense][2] is really amazing.
- Code Gear (yes we have some Delphi)
For non development occasional need I also keep Microsoft Office 2007 installed. They do have MAC ports, but those don't always cut it.
[1]: http://www.parallels.com/en/products/desktop/
[2]: http://en.wikipedia.org/wiki/IntelliSense |
Mocking Frameworks enable you to test your business objects.
Data Driven tests often end up becoming more of a intergration test than a unit test, they also carry with them the burden of managing the state of a data store pre and post execution of the test and the time taken in connecting and executing queries.
In general i would avoid doing unit tests that touch the database from your business objects. As for Testing your database you need a different stratergy.
That being said you can never totally get away from data driven testing only limiting the amout of tests that actually need to invoke your back end systems. |
Another online book that I pick up whenever I need to get back into C++ is "C++ In Action" by Bartosz Milewski. Its [online][1] at his site.
[1]: http://www.relisoft.com/book/index.htm |
Combining Structures |
|matlab| |
I want to know the best way to combine two structures with differing fields names.
For example, starting with
A.field1 = 1;
A.field2 = 'a';
B.field3 = 2;
B.field4 = 'b';
I would like to have
C.field1 = 1;
C.field2 = 'a';
C.field3 = 2;
C.field4 = 'b';
Is there a more efficient way than using "fieldnames" and a for loop? |
Looking at the amount of sense people are demonstrating in other answers here, I'd say that using a regex probably isn't the best idea for your situation. Go for something tried and tested, and treat my previous answer as a demonstration that regexes need not be *that* scary. |
Linq to Entities vs ESQL |
|entity-framework|linq-to-entities|esql| |
**When using the Entity Framework, does ESQL perform better than Linq to Entities?**
I'd prefer to use Linq to Entities (mainly because of the strong-type checking), but some of my other team members are citing performance as a reason to use ESQL. I would like to get a full idea of the pro's/con's of using either method. |
I have to second the comment by @Phil Bennett as I try to approach these integration tests with a rollback solution.
I have a very detailed post about integration testing your data access layer [here][1]
I show not only the sample data access class, base class, and sample DB transaction fixture class, but a full CRUD integration test w/ sample data shown. With this approach you don't need multiple test databases as you can control the data going in with each test and after the test is complete the transactions are all rolledback so your DB is clean.
About unit testing business logic inside your app, I would also second the comments by @Phil and @Mark because if you mock out any dependancy that your business object has, it becomes very simple to test your application logic one entity at a time ;)
[1]: http://stackoverflow.com/questions/12374/has-anyone-had-any-success-in-unit-testing-sql-stored-procedures#25204 |
I have to second the comment by @Phil Bennett as I try to approach these integration tests with a rollback solution.
I have a very detailed post about integration testing your data access layer [here][1]
I show not only the sample data access class, base class, and sample DB transaction fixture class, but a full CRUD integration test w/ sample data shown. With this approach you don't need multiple test databases as you can control the data going in with each test and after the test is complete the transactions are all rolledback so your DB is clean.
About unit testing business logic inside your app, I would also second the comments by @Phil and @Mark because if you mock out all the dependencies your business object has, it becomes very simple to test your application logic one entity at a time ;)
[1]: http://stackoverflow.com/questions/12374/has-anyone-had-any-success-in-unit-testing-sql-stored-procedures#25204 |
Indexing Service + MODI = Full-text over OCR? You wish! |
|ocr|dep|cisvc|indexingservice|modi| |
Scenario: You have configured Indexing Service to index your files, which also include scanned images saved as hi-res TIFF files. You also have installed MS Office 2003+ and configured MS Office Document Imaging (MODI) correctly so you can perform OCR on your images and even embed the OCR'd text into TIFFs.
Awesomeness: Indexing Service is able to index and find those TIFFs that you manually OCR'd and re-saved with text data (using MS Document Imaging tool).
Suck(TM): Whatever you do, you cannot make the Indexing Service to OCR and index the TIFF files without text data. You scour the web, find out how to turn on MODI debugging, and see that CISVC *is* calling MODI but somehow nothing seems to happen.
Hack: Turns out, Data Execution Prevention (DEP) which is deployed with Windows XP SP2 thinks MODI is malicious and refuses to let it do its magic. I have been able to remove the Suck(TM) by turning DEP off completely, but (even though DEP hasn't yet saved my posterior that I can remember) I found this solution to be inelegant (read: the customer's IT manager's gonna fry you, if xe hears about it).
I'll share a better solution here, if I can come across it. |
It's not that difficult to switch between version control systems. As others have mentioned the important thing is to start using anything as soon as possible. The benefits of using source control over not using source control vastly outweigh the differential benefits between different types of source control.
Remember that no matter what version of source control you are using you will always be able to do a brute force conversion to another system by laying down the files from your old system onto disk and then importing those raw files into the new system.
Moreover, being familiar with source control fundamentals is a very, very important skill to have as a software developer. |
I'm sure this is possible if you hack at it hard enough, but I'd suggest it is not a good idea.
'Windows' (that you see on the screen) are highly coupled to processes. That is, each process which displays any GUI is expected to have a Message Loop, which processes all of the messages which are involved with creating and managing windows (things like 'clicked the button', 'closed the app', 'redraw the screen' and so on.
Because of this, it is more or less assumed that if you have any message loop, it must be available for the lifetime of your process. For example windows might send you a 'quit' message, and you need to have a message loop available to handle that, even if you've got nothing on the screen.
Your best bet is do it like this:
Make a fake form which is never shown which is your 'main app'
Start up
Call Application.Run and pass in this fake form.
Do your work in another thread, and fire events at the main thread when you need to do Gui stuff. |
I really like regular expressions. As long as the command strings are fairly simple, you can write a few regexes that could take a few pages of code to manually parse.
I would suggest you check out http://www.regular-expressions.info/ for a good intro to regexes, as well as specific examples for Java. |
A simple string tokenizer on spaces should work, but there are really many ways you could do this.
Here is an example using a tokenizer:
String command = "kick person";
StringTokenizer tokens = new StringTokenizer(command);
String action = null;
if (tokens.hasMoreTokens()) {
action = tokens.nextToken();
}
if (action != null) {
doCommand(action, tokens);
}
Then tokens can be further used for the arguments. This all assumes no spaces are used in the arguments... so you might want to roll your own simple parsing mechanism (like getting the first whitespace and using text before as the action, or using a regular expression if you don't mind the speed hit), just abstract it out so it can be used anywhere. |
The architecture you are talking about could become very cumbersome in the long run, and if you need to change the questions it means more changes to the UDF you are using.
I would think you could probably do your analysis in code without necessarily de-normalizing your database. De-normalization could also lend to inflexibility, or at least added expense to update, down the road. |
What this probably means is that your Apache is only using 1 child process.
Therefore:
The 1 child process is handling a request (in this case sleeping but it could be doing real work, Apache can't tell the difference), so when a new request comes it, it will have to wait until the first process is done.
The solution would be to increase the number of child processes Apache is allowed to spawn ([MaxClients][1] directive if you're using the prefork MPM), simply remove the sleep() from the PHP script.
Without exactly knowing what's going on in your script it's hard to say, but you can probably get rid of the sleep().
[1]: http://httpd.apache.org/docs/2.0/mod/mpm_common.html#maxclients |
No way, you definitely want to keep it normalized. It's not even that hard of a query.
Basically, you want to left join the students correct answers with the total answers for that question, and do a count. This will give you the percent correct. Do that for each student, and put the minimum percent correct in a where clause. |
Denormalization is generally considered a last resort. The problem seems very similar to survey applications, which are very common. Without seeing your data model, it's difficult to propose a solution, but I will say that it is definitely possible. I'm wondering why you need 20 parameters to that function?
A relational set-based solution will be simpler and faster in most cases. |
Adding Inline Search function to web page |
|javascript|html| |
Is it possible to embed an inline search box into a web page which provides similar functionality to the [IE7Pro Inline Search][1] or similar plugins for Firefox/Safari?
[1]: http://www.ie7pro.com/inline-search.html |
The tail program is open source, so you could reference that. I wondered the same thing and looked at the code a while back, thinking it would be pretty simple, but I was surprised at how complex it was. There are lots of gotchas that have to be taken into account. |
Search strategies in ORMs |
|search|orm|engine|doctrine|propel| |
I am looking for information on handling search in different ORMs.
Currently I am redeveloping some old application in PHP and one of requirements is: make everything or almost everything searchable, so user just types "punkrock live" and the app finds videos clips, music tracks, reviews, upcoming events or even user comments labeled that way.
In environment where everything is searchable ORM need to support this feature in two ways:
- providing some indexing API on "O" side of ORM
- providing means for bulk database retrieval on "R" side
Ideal solution would return ready made objects based on searched string.
Do you know any good end-to-end solutions that does the job, not necessarily in PHP?
If you dealt with similar problem it would be nice to listen what your experience is. Something more than *Use Lucene* or *semantic web is the way* oneliners, tho ;-)* |
@Andrew - I'm exactly in your situation. I use a MBP while my company work is purely Microsoft based: i.e., .NET, COM etc. While nothing can beat running Vista natively in Boot Camp (I've never seen Vista run so fast), the niceties of having your Mac OS be the "main" OS, for internet, mail etc. has gotten me to the following configuration. Works like a charm:
## Hardware ##
- Load up your MBP with the max possible - 4GB. It's really worth every $.
- Upgrade your hard drive (if not already) to 7200RPM. Major performance boost here.
## Software ##
- [Parallels Desktop for Mac][1] for virtualization. You can either have multiple VM, or use a boot camp partition. The latter is supposed to be faster, but I haven't really measured it (I use it for having the option to boot natively if I really need speed). The former allows you to have multiple OS. I gave my VM 1GB memory. I can do more if you want it more snappy.
- Micorsoft Visual Studio 2005/8 for .NET and C++. I have yet to see any IDE for .NET which beats this one. The [intellisense][2] is really amazing.
- Code Gear (yes we have some Delphi)
For non development occasional need I also keep Microsoft Office 2007 installed. They do have MAC ports, but those don't always cut it.
[1]: http://www.parallels.com/en/products/desktop/
[2]: http://en.wikipedia.org/wiki/IntelliSense |
There should be a vmware.log file or something similar in the directory that contains your vm. After you start the vm, are there any new errors in it?
Also, is the network adapter enabled? |
If you have a `std::list` of plain old data (what .NET would call 'value types'), then returning a const reference to that list will be fine (ignoring evil things like `const_cast`)
If you have a `std::list` of pointers (or `boost::shared_ptr`'s) then that will only stop you modifying the collection, not the items *in* the collection. My C++ is too rusty to be able to tell you the answer to that at this point :-( |
How do you get the current image name from an ASP.Net website? |
|c#|asp.net| |
Scenario: You have an ASP.Net webpage that should display the next image in a series of images. If 1.jpg is currently loaded, the refresh should load 2.jpg.
Assuming I would use this code, where do you get the current images name.
<code>
string currImage = MainPic.ImageUrl.Replace(".jpg", "");
currImage = currImage.Replace("~/Images/", "");
int num = (Convert.ToInt32(currImage) + 1) % 3;
MainPic.ImageUrl = "~/Images/" + num.ToString() + ".jpg";
</code>
The problem with the above code is that the webpage used is the default site with the image set to 1.jpg, so the loaded image is always 2.jpg.
So in the process of loading the page, is it possible to pull the last image used from the pages properties? |
Use of const reference or shared pointer will only help if the contents of underlying collection do not change over time.
Consider your design. Does the caller really need to see the internal array? Can you restructure the code so that the caller tells object what to do with the array? E.g., if the caller intends to search the array, could the owner object do it?
You could pass a reference to result vector to the function. On some compilers that may result in marginally faster code.
I would recommend trying to redesign first, going with a clean solution second, optimizing for performance third (if necessary).
|
Remember that the MAX aggregate function will work on text as well as numbers. This query will only require the table to be scanned once.
SELECT Action,
MAX( CASE data WHEN 'View' THEN data ELSE '' END ) ViewCol,
MAX( CASE data WHEN 'Edit' THEN data ELSE '' END ) EditCol
FROM t
GROUP BY Action |
Alas, this won't solve the re-importing problem, but check out [http://wejn.org/stuff/moz-export.html][1]
They have a single html page with a small javascript section that exports your passwords. Save the html to your desktop, read through to make sure it's not evil, open the page in FF, save the results.
Maybe I'm paranoid, but I'm not sure I'd trust a password-exporting extension...
[1]: http://wejn.org/stuff/moz-export.html |
You can use the [Foxmarks][1] plugin. This exports to XML or CSV format. I used it a week ago and it works really fine.
[1]: https://addons.mozilla.org/en-US/firefox/addon/2410 |
df -i should tell you the number of inodes used and free on the filesystem |
Good overview of different algorithms:
- [Computing pi][1];
- [Gauss-Legendre-Salamin][2].
I'm not sure about the complexity claimed for the Gauss-Legendre-Salamin algorithm in the first link (I'd say O(N log^2(N) log(log(N)))).
I do encourage you to try it, though, the convergence is *really* fast.
Also, I'm not really sure about why trying to convert a quite simple procedural algorithm into a recursive one?
[1]: http://en.wikipedia.org/wiki/Computing_%CF%80
[2]: http://en.wikipedia.org/wiki/Gauss%E2%80%93Legendre_algorithm |
Good overview of different algorithms:
- [Computing pi][1];
- [Gauss-Legendre-Salamin][2].
I'm not sure about the complexity claimed for the Gauss-Legendre-Salamin algorithm in the first link (I'd say O(N log^2(N) log(log(N)))).
I do encourage you to try it, though, the convergence is *really* fast.
Also, I'm not really sure about why trying to convert a quite simple procedural algorithm into a recursive one?
Note that if you are interested in performance, then working at a bounded precision (typically, requiring a 'double', 'float',... output) does not really make sense, as the obvious answer in such a case is just to hardcode the value.
[1]: http://en.wikipedia.org/wiki/Computing_%CF%80
[2]: http://en.wikipedia.org/wiki/Gauss%E2%80%93Legendre_algorithm |
[MultiSelectTreeView][1]:
> Why doesn't .NET have a multiselect treeview? There are so many uses for one and turning on checkboxes in the treeview is a pretty lousy alternative.
[1]: http://www.codeproject.com/KB/tree/Multiselect_Treeview.aspx |
i would start to look at SQL Server Compact Edition for this! It helps with all of your issues.
[Data Storage Architecture with SQL Server 2005 Compact Edition][1]
It specifically designed for
> Field force applications (FFAs). FFAs
> usually share one or more of the
> following attributes
>
> They allow the user to perform their
> job functions while disconnected from
> the back-end network—on-site at a
> client location, on the road, in an
> airport, or from home.
>
> FFAs are usually designed for
> occasional connectivity, meaning that
> when users are running the client
> application, they do not need to have
> a network connection of any kind. FFAs
> often involve multiple clients that
> can concurrently access and use data
> from the back-end database, both in a
> connected and disconnected mode.
>
> FFAs must be able to replicate data
> from the back-end database to the
> client databases for offline support.
> They also need to be able to replicate
> modified, added, or deleted data
> records from the client to the server
> when the application is able to
> connect to the network
[1]: http://msdn.microsoft.com/en-us/library/bb380177.aspx |
XHTML is easy, use [lxml](http://codespeak.net/lxml/validation.html).
HTML is harder, since there's traditionally not been as much interest in validation among the HTML crowd (run StackOverflow itself through a validator, yikes). The easiest solution would be to execute external applications such as [nsgmls](http://www.jclark.com/sp/) or [OpenJade](http://openjade.sourceforge.net/), and then parse their output. |
I had good luck in the past with InstantRails, but I'm not sure how up-to-date it is now, as the project has changed hands several times.
You might also try [ruby stack][1] or [flash rails][2], though I've not used either personally.
[1]: http://bitnami.org/stack/rubystack
[2]: http://rubyforge.org/projects/flashrails |
I didn't know JRun was even still in existence since 1999 or something like that. Anyway, [Tomcat][1] or [Jetty][2] would be my easy replacements. Tomcat for its scriptability from ANT etc and Jetty for its pure simplicity (start an instance in 5 lines of code!).
[Glassfish][3] is a huge system with many components, if you just want to host vanilla servlets and JSPs etc. then I would go for one of the above.
[1]: http://tomcat.apache.org/
[2]: http://jetty.mortbay.org/jetty/
[3]: https://glassfish.dev.java.net/ |