instruction
stringlengths
0
30k
off the top of my head, you could store the last known file size. Check against the file size, and when it changes, open a reader. Then seek the reader to your last file size, and start reading from there.
I would keep the current text in memory if it is small enough and then use a diff algorithm to check if the new text and previous text changed. This library, http://www.mathertel.de/Diff/, not only will tell you that something changed but what changed as well. So you can then insert the changed data into the db.
Seems the most foolproof way to start with a UTC date is to create a new `Date` object and use the `setUTC…` methods to set it to the date/time you want. Then the various `toLocale…String` methods will provide localized output. Example below: // This would come from the server. // Also, this whole blo...
Seems the most foolproof way to start with a UTC date is to create a new `Date` object and use the `setUTC…` methods to set it to the date/time you want. Then the various `toLocale…String` methods will provide localized output. ### Example: // This would come from the server. // Also, this whole block...
Here is how I would do it. I do recommend a function like above if you will be using this in other places. CASE WHEN DATEPART(dw, [Date]) IN (2,3,4,5) THEN DATEADD(d, 1, [Date]) WHEN DATEPART(dw, [Date]) = 6 THEN DATEADD(d, 3, [Date]) ELSE [Date] END AS [ConvertedDate]
Casting to int is implicit truncation, not implicit flooring: double d = -3.14; int i = (int)d; // i == -3 I choose Math.Floor or Math.Round to make my intentions more explicit.
http://discussion.forum.nokia.com/forum/showthread.php?t=91500 This thread on Forum Nokia seems to suggest that certain Nokia models have problems playing tones with the Manager.playTone function, more specifically a MediaException is thrown, as you are having (MediaException is just the default exception if any pro...
http://discussion.forum.nokia.com/forum/showthread.php?t=91500 This thread on Forum Nokia seems to suggest that certain Nokia models have problems playing tones with the Manager.playTone function, more specifically a MediaException is thrown, as you are having (MediaException is just the default exception if any pro...
http://discussion.forum.nokia.com/forum/showthread.php?t=91500 This thread on Forum Nokia seems to suggest that certain Nokia models have problems playing tones with the Manager.playTone() function, more specifically a MediaException is thrown, as you are having (MediaException is just the default exception if any p...
|java|formatting|netbeans|javadoc|
Is your application running on the server under a different user account? Regional settings are per-user so date and time formats will depend on the user that the application is running under. You can log in as the application user and check the Regional settings to determine if that's the issue. This is really co...
There is no way to insert characters in to a file without rewriting them. With C# it can be done with any Stream classes. If the files are huge, I would recommend you to use GNU Core Utils inside C# code. They are the fastest. I used to handle very large text files with the core utils ( of sizes 4GB, 8GB or more etc )....
I remember we had a Winforms application that performed so slowly while parsing some data interchange files, and we all thought it was the db server thrashing, but our smart boss actually found out that the bottleneck was in the call that was converting the parsed strings into decimals! The simplest is to loop for e...
One option I would recommend for its simplicty is to have your UI just call a helper class or method on the firing of the event and unit test that. Make sure it has as little logic as possible and then from there I'm sure you'll know what to do. It can be pretty difficult to reach 100% coverage in your unit tests. B...
Did you read Bjarne Stroustrup's *The C++ Programming Language*? He created C++. The C++ FAQ Lite is also good.
Why is the unique ID Random? Why not use IDENTITY? How was the ID chosen for the existing rows. The simplest thing to do is probably (Select Max(ID) from BIGTABLE) and then make sure your new "Random" ID is larger than that...
Why is the unique ID Random? Why not use IDENTITY? How was the ID chosen for the existing rows. The simplest thing to do is probably (Select Max(ID) from BIGTABLE) and then make sure your new "Random" ID is larger than that... **EDIT**: Based on the added information I'd suggest that you're screwed. If it's a...
Best Approach For Configuring Multiple .Net Applications
|.net|asp.net|configuration|
We have a suite of interlinked .Net 3.5 applications. Some areweb sites, some are web services, and some are windows applications. Each app currently has its own configuration file (app.config or web.config), and currently there are some duplicate keys across the config files (which at the moment are kept in sync manua...
We have a suite of interlinked .Net 3.5 applications. Some are web sites, some are web services, and some are windows applications. Each app currently has its own configuration file (app.config or web.config), and currently there are some duplicate keys across the config files (which at the moment are kept in sync manu...
Try this: sudo gem install --platform ruby Note that you can get help on the install command using: gem help install
Try this: sudo gem install --platform ruby ibm_db Note that you can get help on the install command using: gem help install
Try this: sudo gem install --platform ruby ibm_db Note that you can get help on the install command using: gem help install ---------- **UPDATE:** Looks like this option only works for RubyGems 0.9.5 or above.
sudo port install boost
CREATE FUNCTION dbo.GetNextWDay(@Day datetime) RETURNS DATETIME AS BEGIN DECLARE @ReturnDate DateTime set @ReturnDate = dateadd(dd, 1, @Day) if (select datename(@ReturnDate))) = 'Saturday' set @ReturnDate = dateadd(dd, 2, @ReturnDate) if (select ...
As far as I can tell, there is no way to get a Console object from Eclipse. I'd just make sure that console != null, then JAR it up and run it from the command line.
you can download bjam for OSX (or any other OS) [here][1] [1]: http://sourceforge.net/project/showfiles.php?group_id=7586&package_id=72941
Look up the CASE statement and the DATEPART statement. You will want to use the dw argument with DATEPART to get back an integer that represents the day of week.
Try select case when datepart(dw,[Date]) between 2 and 5 then DATEADD(dd, 1, [Date]) when datepart(dw,[Date]) = 6 then DATEADD(dd, 3, [Date]) else [Date] end as [Date]
In languages like C there was no boolean value so you had to define your own. Could they have worked on a non-standard BOOL overrides?
Have a look at this: http://redmelon.net/tstme/box_model/ Basically, an element consists of content, surrounded by its padding, then the border, then the margin. Background images only extend as far as the border. Margins are best described as 'the whitespace around this element'. But have a look at the URL above...
Ex-academic physicist and now industrial physicist UK here: *What languages/environments have you used for developing scientific software, esp. data analysis? What libraries? (E.g., what do you use for plotting?)* I mainly use Matlab these days (easy to access visualisation functions and maths). I used to use FOR...
One option I would recommend for its simplicty is to have your UI just call a helper class or method on the firing of the event and unit test that. Make sure it (your event handler in the UI) has as little logic as possible and then from there I'm sure you'll know what to do. It can be pretty difficult to reach 100%...
Is there a working on-the-fly compilation in NetBeans 6.5 and how well is it doing?
|java|netbeans|compilation|
I learned today that NetBeans 6.5 should have an on-the-fly compilation of (single) Java files. This feature is well known from Eclipse: Simply sotre the file and the compiled class is stored, too. Is NetBeans working the same way? If not, how is it ticking?
I learned today that NetBeans 6.5 should have an on-the-fly compilation of (single) Java files. This feature is well known from Eclipse: Simply store the file and the compiled class is stored, too. Is NetBeans working the same way? If not, how is it ticking?
On Andy's question of security for extensions that MEF loads (sorry I don't have enough points yet :) ), the place to address this is in a Catalog. MEF catalogs are completely pluggable, so you can write a custom catalog that validates assembly keys, etc before loading. You could even use CAS if you so desired. We are ...
Declaring something private in scope does not really "hide" the information. I believe hiding information refers to isolating your logic from the consumer via an interface, so you can change the logic without affecting the consumer.
Java, perhaps? http://java.sun.com/docs/books/tutorial/java/concepts/interface.html
It's just another layer of abstraction. Not really sure where it came from.. I still often hear them called contracts rather than interfaces.
Duck typing won't ship in V1 though it is in the current drop. In a future drop we will replace it with a pluggable adapter mechanism where one could hook in a duck typing mechanism. The reason we looked at duck typing is to address versioning scenarios. With Duck Typing you can remove the shared references between exp...
C++ allows for multiple inheritance. When Java was developed, single inheritance was decided upon however classes were allowed to implement multiple interfaces. C# carried forward this concept.
"$HTTP\_GET\_VARS", "$HTTP\_POST\_VARS", ect. is an obsolete notation, you should be using $\_GET, $\_POST, etc. Now, the file contents should be in the $\_FILES global array, whereas, if there are no element names, I'm not sure about whether the rest of the content will show up in $\_POST. Anyway, if _always\_popul...
The difference is that the # symbol specifies a data binding directive, that is resolved at data binding time (for example, when you call Page.DataBind ) and the = sign specifies an evaluation expression just evaluates and prints to the HTML output when that line is processed. Edit: Just adding that only inside <%# ...
There is a slight difference, delegates can access the member variables of classes in which, they are defined. In C# (unlike Java) all inner class are consider to be static. Therefore if you are using a interface to manage callback, e.g. an ActionListener for a button. The implementing inner class needs to be passed...
There is a slight difference, delegates can access the member variables of classes in which, they are defined. In C# (unlike Java) all inner class are consider to be static. Therefore if you are using an interface to manage a callback, e.g. an ActionListener for a button. The implementing inner class needs to be pas...
This is a great example of a scenario where Linq and extension methods make things really clean and easy. public static DirectoryInfo[] GetNonSystemDirectories( this DirectoryInfo directory, string searchPattern, SearchOption searchOption) { return directory.GetDirectorie...
<p>Give <a href="http://blueprintcss.org/">BluePrint CSS</a> a try. It is really simple to get started with, yet powerful enough for most applications.</p> <p>Easy to understand tutorials and examples. Has a typography library that produces decent results straight out of the box.</p>
I think you should look at **expect** program. It`s present in all modern linux distros. Here is some exmaple script: #!/usr/bin/expect -f spawn telnet $host_name expect { "T0>" {} -re "Connection refused|No route to host|Invalid argument|lookup failure" ...
How do I sort a multidimensional array in php
|php|sorting|multidimensional|
I have CSV data loaded into a multidimensional array. In this way each "row" is a record and each "column" contains the same type of data. I am using the function below to load my CSV file. <pre><code> function f_parse_csv($file, $longest, $delimiter) { $mdarray = array(); $file = fopen($file, "r"); ...
| is the binary or || is the logic or
| is the binary or operator || is the logic or operator
I believe in following the basic pattern with a project dir with trunk,tags,branches beneath it. I usually like to setup the top level like this Projects holds all of the individual project or modules Releases holds release tags that involve multiple modules Users holds private user branches Admin holds my hook ...
I've had several issues with DB2 as a linked a server. I do not know if it will address your problems, but here is what fixed mine: 1) Enabled lazy close support and pre-fetch during EXECUTE in the ODBC settings 2) Add "FOR FETCH ONLY" on all selects 3) Query using the SELECT * FROM OPENROWSET(LinkedServerName, 'S...
RPMForge is already in /etc/yum.repos.d/ as rpmforge.repo, and the contents are: <pre> # Name: RPMforge RPM Repository for Red Hat Enterprise 5 - dag # URL: http://rpmforge.net/ [rpmforge] name = Red Hat Enterprise $releasever - RPMforge.net - dag #baseurl = http://apt.sw.be/redhat/el5/en/$basearch/dag mirrorl...
Arial *is* the Windows version of Helvatica. DTP was invented on the Mac and Microsoft basically created their own versions of the Mac fonts sometime around Windows 3.0
There are two ways that I organize the extension methods which I use, 1) If the extension is specific to the project I am working on, then I keep it in the same project/assembly, but in its own namespace. 2) If the extension is of a kind so that I may or is using it in other projects too, then I separate them in ...
Why should Python PEP-8 specify a maximum line length of 79 characters?
|python|pep8|
Why in this millenium should Python [PEP-8][1] specify a maximum line length of 79 characters? Pretty much every code editor under the sun can handle longer lines. What to do with wrapping should be the choice of the content consumer, not the responsibility of the content creator. Are there any (legitimately) go...
|python|pep8|
In WPF, what is the equivelent of Suspend/ResumeLayout();
|wpf|
If I am in a function in the code behind, and I want to implement displaying a "Loading..." in the status bar the following makes sense, but as we no from WinForms is a NoNo: StatusBarMessageText.Text = "Loading Configuration Settings..."; LoadSettingsGridData(); StatusBarMessageText....
In WPF, what is the equivelent of Suspend/ResumeLayout() and BackgroundWorker() from Windows Forms.
|c#|.net|wpf|
*foo* is not allowed in fully standard compliant C++, whereas *bar* is okay. Though chances are, *foo* will compile with warning, and *bar* may or may not compile with a warning as well. *A()* create a temporary object, which unless bound to a reference (as is the case in *bar*), or used to initialize a named object...
Stationery stores will sell standard boiler plate contracts. For software specific stuff most companies just copy the ones from bigger companies and change the name!
Using jmockit expectations with matchers and primitive types
|java|jmockit|testing|mocking|
I'm using jmockit for unit testing (with TestNG), and I'm having trouble using the Expectations class to mock out a method that takes a primitive type (boolean) as a parameter, using a matcher. Here's some sample code that illustrates the problem. /******************************************************/ im...
You can add namespaces in your code and all that, but you can effectively wildcard the namespace. Try the following XPath idiom. //*[local-name()='PropertyGroup'] //*[local-name()='MSBuildCommunityTasksPath'] name() usually works as well, as in: //*[name()='PropertyGroup'] //*[name()='MSBuild...
While, on it's surface, this may seem common, cgi-style content handlers in C on apache are pretty rare. Most people just use CGI, FastCGI, or the myriad of frameworks such as mod_perl. Most of the C apache modules that I've written are targeted at modifying the particular behavior of the web server in specific, ta...
One way to do it that's easy for the user but not for you is to hard-code the expiry date and make new versions of the installer every now and then... :) If I were you though, I wouldn't make it any more advanced than what you're already doing. Like you say it's only $10, and if someone really wants to crack your sy...
I came across [this RefEdit control replacement][1] when looking for workarounds to RefEdit's bugs. A third party control wasn't an option for me at the time but it might help you out. [1]: http://www.oraxcel.com/cgi-bin/yabb2/YaBB.pl?num=1208162527
$.get(url, {}, callback); should do the trick. Your callback could be simplified like this: function callback(content){ $('#decimal').val(content); } Or even shorter: $.get(url, {}, function(content){ $('#decimal').val(content); }); And all in all I think this shou...
Try the Shareware Starter Kit. It was developed my Microsoft and may have some other features you want. http://msdn.microsoft.com/en-us/vs2005/aa718342.aspx
Flash vs. Silverlight
|silverlight|flash|
We are building a training website where we need to track viewers watching videos and store detailed info about the viewing (when they paused, if they watched the whole video etc) What should we consider when deciding between the two technologies?
You should use: Foo.bar And not: A.foo.bar That's what the warning means. The reason is that `bar` isn't a member of an *instance* of `Foo`. Rather, `bar` is global, on the class `Foo`. The compiler wants you to reference it globally rather than pretending it's a member of the instance.
I think we all know what class is, but if you think of IDs as identifiers rather than styling tools, you wont go far wrong. You need an identifier when trying to target something and if you have more than one item with the same ID, you can no longer identify it... When it comes to writing your css for IDs and CLASSe...
This is the information for IMAPI in MSDN site http://msdn.microsoft.com/en-us/library/aa939967.aspx
I would recommend putting the path in a property, then setting the property conditionally based on the current OS. <condition property="foo.path" value="C:\Foo\Dir"> <os family="windows"/> </condition> <condition property="foo.path" value="/home/foo/dir"> <os family="unix"/> </cond...
All of the suggestions here are good, but there is no magic bullet. You'll have to look at how big your app is, how many users, how is it deployed, etc. to make your architectural, process, tool set, and other decisions. TDD, for instance, is a good methodology, but not the only good methodology for "doing things rig...
link to [Oracle Database Online Documentation][1] You may want to explore the [Data Dictionary views][2]. They have the prefixes: - User - All - DBA sample: select * from dictionary where table_name like 'ALL%' ---------- Continuing Mike's example, you may want to generate scripts to ena...
You can't create windows services for one.
Considering that XML doesn't use a line based format, you should probably check the number of characters. With a regular expression, you can create a pattern to match the comment prefix and match a minimum number of characters before it matches the first comment suffix. http://www.regular-expressions.info/
They existed in C++, but they were known as virtual base classes, which consisted only of pure virtual functions. This is where the "I-" prefix for interfaces came from -- to differentiate between virtual base classes from abstract base classes.
I'd generally recommend against it. It generally keeps your domain cleaner when your entities are given the things they need to do to perform their duties. When they have to look things up they are often taking shortcuts, shortcuts that can be avoided by doing more analysis into the domain and the relationships bet...
Information hiding has to do with how much data in your class (fields, properties) is accessible to outside classes. The more you hide, the easier it is to change your implementation later without affecting dependent classes (i.e. your "public interface"). This ultimately leads to more stable designs.
i've seen the keyword interface first in java, but they are much older than that. the same concept exists in c++ but it is not exactly the same. They are called "pure virtual classes" http://en.wikipedia.org/wiki/Virtual_function They exists with different syntax but are there to allow polymorphism in OOP.
I would say IE6 and below are dead... but many are still stuck using it. This site has a nice live listing of each browser and its actual age. [http://webbugtrack.blogspot.com/2008/08/browser-life-statuses.html][1] [1]: http://webbugtrack.blogspot.com/2008/08/browser-life-statuses.html
Windows XP - Create Shortcuts on Desktop and controll their placement
|windows|winapi|shortcut|
In any language really, im looking for a simple (very simple) way to control the position of a shortcut on the users desktop. I already make the assumption that Auto Arrange and Align to Grid are unchecked. Ex: The program creates the shortcut to the desktop than places it at position (450,302) on the desktop. I...