instruction stringlengths 0 30k ⌀ |
|---|
This is probably too much to ask, but is there any language that does a really terrific job of representing time and date operations? I'll grant straight away that it's <b>really hard</b> to write a truly great time library. That said, are there any widespread languages that have one? Basically, I want something tha... |
|date|time|datetime|language-features| |
My personal favourite would be Ruby with Rails' ActiveSupport.
start_time = 5.months_ago.at_end_of_week
end_time = start_time = 6.months.since(start_time)
It supports all of the features you've mentioned above with a similar DSL (domain specific language) |
There is one important difference to keep in mind:
Convert.ToDecimal will return 0 for a null string argument.
decimal.Parse will throw an ArgumentNullException if the string you want to parse is null. |
There is one important difference to keep in mind:
Convert.ToDecimal will return 0 if it is given a null string.
decimal.Parse will throw an ArgumentNullException if the string you want to parse is null. |
Are you looking for something like PHPs [strtotime][1]? That will give you the unix timestamp of almost anything you can throw at it.
From the php site:
<?php
echo strtotime("now"), "\n";
echo strtotime("10 September 2000"), "\n";
echo strtotime("+1 day"), "\n";
echo strtotime("+1 week"),... |
Build setup project with NAnt |
|nant|build|continuous-integration|deployment|.net| |
I've already got a NAnt build script that builds/runs tests/zips web project together, etc. but I'm working on a basic desktop application. How would I go about build the setup project using NAnt so I can include it with the build report on TeamCity. |
|.net|deployment|continuous-integration|nant|build| |
I've already got a NAnt build script that builds/runs tests/zips web project together, etc. but I'm working on a basic desktop application. How would I go about build the setup project using NAnt so I can include it with the build report on TeamCity.
Edit: The setup is the basic Setup Project supplied with Visual S... |
Since your question involves using DevEnv from the command line, I would also suggest using MSBuild (which can build .sln files w/o modification).
msbuild /fl /flp:Verbosity=diagnostic Your.sln
msbuild /? will show you other useful options for the filelogger. |
A very easy way to do this that I recently found is **the [IPC::Filter](http://p3rl.org/IPC::Filter) module**. It lets you do the job extremely intuitively:
$output = filter $input, 'somecmd', '--with', 'various=args', '--etc';
Note how it invokes your command without going through the shell if you pass it a ... |
How do I use calculated value date in Sharepoint lists field to find a date+30 days? |
|sharepoint| |
I have a list I've built in Sharepoint, where one of the fields is a date that the user enters.
I want to add another field, which is a calculated value field that needs to be the date provided by the user + 30 days.
What formula do I need to pass to the calculated value field to achieve that? |
I know this is a bit exorbitant, but the number of combinations are not overly excessive. If you pre-blend the wav files into a series of files and just name them as follows
1_2_3, 1_2_3, 1_2_5, 1_2_6
1_3_4, 1_3_5, 1_3_6
1_4_5, 1_4_6
2_3_4, 2_3_5, 2_3_6,
2_4_5, 2_4_6,
2_5_6
3_4_5,... |
Memory rotation may be an issue here, since every boxing of an int larger than or equal to 128 cause an object allocation (see Integer.valueOf(int)). Although the garbage collector very efficiently deals with short-lived objects, performance will suffer to some degree.
If you know that the number of increments made ... |
As advised above, use an IDENTITY field.
CREATE TABLE foo
(
user_id int IDENTITY(1,1) NOT NULL,
name varchar(50)
)
|
[Macports][1] has it (think apt-get and the likes on linux, but on OS X)
(you can see it listed [here][2])
Haven't installed myself though....
[1]: http://www.macports.org/
[2]: http://trac.macports.org/browser/trunk/dports/www/mod_perl2/Portfile |
The answer is that it's not possible. You mean you want text that's in a larger block of text to flow just like the rest of it, as if the tag were < strong > instead of of < h2 >
Since h2 is a block level element no matter how you style it, some browsers (*cough*) will choke on your attempt to flow it inline with ot... |
Well as a partial solution you could use a RegEx match to get the timezone since you will always have the same text before it. AM or PM.
I don't know enough about Java timezones to get you the last part of it. |
The way I've done it before is basically like what you wrote, but doesn't have any hardcoded values:
<pre>if($_SERVER["HTTPS"] != "on")
{
header("Location: https://" . $_SERVER["HTTP_HOST"] . #_SERVER["REQUEST_URI"]);
}</pre> |
Alright, so I've been running tests and it seems like Container.Release() WILL implicitly cause an IDisposable's Dispose() method to execute only if the lifestyle is Transient (this is probably not exactly correct but point is that it wont' do a darn if the lifestyle is singleton).
Now if you call Container.Dispose(... |
More specifically
AppDomain domain = AppDomain.CreateDomain("New domain name");
//Do other things to the domain like set the security policy
string pathToDll = @"C:\myDll.dll"; //Full path to dll you want to load
Type t = typeof(TypeIWantToLoad);
TypeIWantToLoad myObject = (TypeIWantToL... |
Have a look at Amazon Simple Storage Service (Amazon S3)
http://www.amazon.com/S3-AWS-home-page-Money/b/ref=sc_fe_l_2?ie=UTF8&node=16427261&no=3435361&me=A36L942TSJ2AJA |
Have a look at Amazon Simple Storage Service (Amazon S3)
http://www.amazon.com/S3-AWS-home-page-Money/b/ref=sc_fe_l_2?ie=UTF8&node=16427261&no=3435361&me=A36L942TSJ2AJA
--
This may be of interest re. High Availability
Dear AWS Customer:
Many of you have asked us to let you know ahead of time about features... |
http://msdn.microsoft.com/en-us/vsx2008/products/bb933751.aspx
Visual Studio Shell - Free, and F# supports it out of the box.
(edited)
http://blogs.msdn.com/dsyme/archive/2008/04/04/tackling-the-f-productization.aspx
Theres a link talking about using the Shell and such too |
I'm not sure if this works with DELETE statements, but this is a way to find duplicate rows:
SELECT *
FROM myTable t1, myTable t2
WHERE t1.field = t2.field AND t1.id > t2.id
I'm not sure if you can just change the "SELECT" to a "DELETE" _(someone wanna let me know?)_, but even if you can't, you c... |
In UTF-16, all the languages that matter (i.e. anything but klingons, elven and other strange things) will be encoded into 2 byte chars.
So the question is to find the languages that will have glyphs that will be 2-bytes or 1-byte sized characters long.
In the Wikipedia page on UTF-8:
<http://en.wikipedia.org/wi... |
More information:
I've got an app that takes the userid/password from the login page and stores it in a session variable. I plop it into my connection string for making calls to SQL Server.
When a table gets updated, we're using 'system_user' in the database to identify the 'last updated by' user. We're seeing s... |
Can CSS truly override the order of HTML elements on a page? |
|html|css| |
If you have several DIVs on a page, you can use CSS to size and float them, and move them round a little...but I can't see a way to get past the fact that the first DIV will show near the top of the page, and the last DIV will be near the bottom! I cannot completely override the order of the elements as they come from ... |
In addition to equality I often come across code like
if (0 > number)
or
if (NULL != pointer)
where there isn't even any danger of making a mistake in C/C++! It's one of those situations where a well-intentioned teaching technique has turned into a plain bad habit. |
I try to push the concept of bug days / evenings. Set a target of bugs/issues to address and when you hit that number everyone gets to go out for (paid for!) pizza/beers. Keeps the morale of the team up and acts as a focus in an otherwise boring period.
Also you can add into this concept prizes/cudos for the best pi... |
Whatever you do, see if you can manage to follow a plan where you do not have to port the application all in one big bang. It is tempting to throw it all away and start from scratch, but if you can manage to do it gradually the mistakes you do will not cost so much and cause so much panic. |
1. Can the browser support JS
2. Can the browser support flas
3. Operating system platform
4. Screen resolution
5. Supports CSS
6. Supports tables |
1. Can the browser support JS
2. Can the browser support flash
3. Operating system platform
4. Screen resolution
5. Supports CSS
6. Supports tables |
Moves in subversion are done by removing the old files and adding the new ones, so there's nothing special to do. The series of 'svn mv' commands in a loop recommended in the other question should probably work just fine. |
The choice really doesn't depend on C# itself. It comes down to a balance between:
1. How often do you use the data in your code?
2. Does the data ever change (and do you care if it does)?
3. What's the relative (time) cost of getting the data again, compared to everything else your code does?
4. How much val... |
The choice really doesn't depend on C# itself. It comes down to a balance between:
1. How often do you use the data in your code?
2. Does the data ever change (and do you care if it does)?
3. What's the relative (time) cost of getting the data again, compared to everything else your code does?
4. How much val... |
A useful Linux function and alternative to sync or fsync is sync\_file\_range. This lets you schedule data for writing without waiting for the in-kernel buffer system to get around to it.
To avoid long pauses, make sure your IO queue (for example: /sys/block/hda/queue/nr_requests) is large enough. That queue is wh... |
It looks like the latest beta version of [SharpDevelop][1] (3.0) has F# support. SharpDevelop is an open source IDE, something of a Visual Studio clone. I used it years ago when I was somewhere too cheap to buy Visual Studio.
[1]: http://www.icsharpcode.net/OpenSource/SD/Download/#SharpDevelop30 |
I've used the Data View Web Part in this case. Create a web service data source to get the data from the other site's list.
Much like this:
http://www.sharepointblogs.com/ssa/archive/2007/02/23/showing-web-service-data-in-a-data-view-web-part.aspx |
Oracle Client Upgrade from 9 to 10 |
|database|oracle-database|connections|10|9| |
Last Friday where i work, an oracle client was upgarded and our IIS server from version 9 to version 10. Now that its on version 10, we are seeing a lot of connections being open up to the database. It is opening up so many connections that we cannot log onto the database using tools like PlSQL developer or Toad. We ne... |
|database|oracle-database|upgrade-issue| |
It sounds like you are not passing in the correct initial directory (in the lpstrInitialDir or lpstrFile parameter of your OPENFILENAME struct).
Enter your cache directory in lpstrInitialDir and leave lpstrFile blank and it should work.
|
You should take a look at [Dmitry Baranovskiy's][1] Javascript library called [Raphaël][2].
[1]: http://dmitry.baranovskiy.com
[2]: http://raphaeljs.com |
I'm not aware of any ways to control this aspect of processes spawned for debugging by VS.NET. But there's a workaround, which is applicable to any situation in which VS.NET can't or doesn't start your process in the exact way you want:
Start your process (possibly using a wrapper EXE that runs as part of the post-b... |
yes, agree with Burly.
The thread will block, but the process is still alive.
In a single threaded application, this means everything is blocked while you sleep. In a multithreaded application, only the thread you explicitly 'sleep' will block and the other threads still run within the process. |
I don't think it's possible to do automatically.
I'd suggest that you keep track manually with a table like you suggested, and then keep all your documents in a version control system under a separate documentation branch in order to have an automatic revision history. If you feel up to it, you could also create a t... |
[Metaphone][1] and [Double Metaphone][2] are similar to SOUNDEX, except they may be tuned more toward your goal than [SOUNDEX][3]. They're designed to "hash" words based on their phonetic "sound", and are good at doing this for the English language (but not so much other languages and proper names).
One thing to kee... |
Hooking standard WinAPI functions is relatively safe since they're not going to change much in the near future, it at all, since Microsoft does it's
best to keep the WinAPI backwards compatible between versions.
Standard WinAPI hooking, I'd say, is generally stable and safe.
Hooking anything else, as in the target... |
Hooking standard WinAPI functions is relatively safe since they're not going to change much in the near future, if at all, since Microsoft does it's
best to keep the WinAPI backwards compatible between versions.
Standard WinAPI hooking, I'd say, is generally stable and safe.
Hooking anything else, as in the target... |
It's been a few years, but the last time I had to do this, I used a tool called Wix, which had utilities named Candle and Light. I used these tools in my NAnt script to create an MSI Installer. |
For issue number 1, you can setup custom builders for eclipse. To do so, right click on the Project and select Properties. On the left there is a item called Builders, select that.
Based off of what you are saying, you will want to remove the Java builder and replace it with a new Ant Builder. This can be done by... |
Why would'nt DB2 let me have a column in WHERE clause? |
|db2|database|sql| |
I have a remote DB2 database that I'm accessing through ODBC. When I have a query like
SELECT t.foo, t.bar, t.problemcolumn
FROM problemtable t
WHERE t.bar < 60;
it works like a charm.
But if I specify the problem column in the WHERE clause
SELECT t.foo, t.bar, t.problemcolumn
FROM pr... |
Why wouldn't DB2 let me have a column in WHERE clause? |
|sql|database|db2| |
I have a remote DB2 database that I'm accessing through ODBC. When I have a query like
SELECT t.foo, t.bar, t.problemcolumn
FROM problemtable t
WHERE t.bar < 60;
it works like a charm, so the table and columns obviously exist.
But if I specify the problem column in the WHERE clause
SELECT ... |
This might work:
(\*|\d+(\.\d+)*(\.\*)?)
At the top level, "\*" is a special case of a valid version number. Otherwise, it starts with a number. Then there are zero or more ".nn" sequences, followed by an optional ".*".
The code for retrieving the matched sequences, especially the `(\.\d+)*` part, will dep... |
This might work:
^(\*|\d+(\.\d+){0,2}(\.\*)?)$
At the top level, "\*" is a special case of a valid version number. Otherwise, it starts with a number. Then there are zero, one, or two ".nn" sequences, followed by an optional ".\*". This regex would accept 1.2.3.* which may or may not be permitted in your appl... |
I'm a huge fan of Selenium. Saying 'unit-testing your web ui' isn't exactly accurate as some of the comments have mentioned. However, I do find Selenium to be incredibly useful for performing those sort of acceptance and sanity tests on the UI.
A good way to get started is using Selenium IDE as part of your developm... |
I'd suggest writing a non-trivial webapp using either Django or Pylons, something that does some number crunching.
No better way to learn a new language than commiting yourself to a problem and learning as you go! |
The IO#closed? returns true when both reader and writer are closed.
In your case, the @sock.gets returns nil, and then you call the getcmd again, and this runs in a never ending loop. You can either use select, or close the socket when gets returns nil. |
When I saw the generated code from gSOAP, I about had a heart attack.
The fact that the user is required to do all of the memory management for each object just boggled my mind. So, I sat down and did something probably stupid in the long term, but fairly satisfying in the short term...
I wrote a program that wr... |
Somtimes [YAML][1] can be good for this.
import yaml
a = [0, 1, ['a', 'b', 'c'], 2, 3, 4]
print yaml.dump(a)
Produces:
- 0
- 1
- [a, b, c]
- 2
- 3
- 4
[1]: http://pyyaml.org/ |
Alright, so I've been running tests and it seems like Container.Release() WILL implicitly cause an IDisposable's Dispose() method to execute only if the lifestyle is Transient (this is probably not exactly correct but point is that it wont' do a darn thing if the lifestyle is singleton).
Now if you call Container.Di... |
The articles from K Scott Allen say it all:
http://odetocode.com/Blogs/scott/archive/2008/01/31/11710.aspx
|
Additionally, using a cftry block in each loop is likely slowing this down quite a bit. Unless you are expecting individual rows to fail (and you need to continue from that point), I would suggest a single try/catch block for the entire process. Try/catch is an expensive operation. |
Don't mix http and https on the same page. If you have a form page that is served up via http, I'm going to be nervous about submitting data -- I can't see if the submit goes over https or http without doing a View Source and hunting for it.
Serving up the form over https along with the submit link isn't that heavy ... |
We had this problem and we ended up with a "compatability layer" where we implemented a single set of interfaces and utility code for .NET v1.1 and v2.0.
Then our installer laid down the right code for the right version. We used [NSIS][1] (free!), and they have functions you can call to determine the .NET version.
... |
This one is kind of tough. Unless you've got a very simple DB structure with vanilla types (varchar, integer, etc), you're probably going to get the best results writing a migration tool. In a language like Perl (via the DBI), this is pretty straight-forward. The program is basically an echo loop that reads from one... |
I'm using Wincrypt for Diffie-Hellman-- can I export the shared secret in plain text? |
|cryptography|diffie-hellman|wincrypt| |
OK-- thanks to [Mike](http://stackoverflow.com/users/6970/mike-dimmick), I was able to get Wincrypt to generate a Diffie-Hellman keypair. I figured out out to export the public key, and how to import the other party's public key. According to the docs, upon import of the other party's public key, the shared secret ha... |
Programmatically stream audio in Cocoa on the Mac |
|macos|cocoa|audio|stream| |
How do I go about programmatically creating audio streams using Cocoa on the Mac. To make, say a white-noise generator using core frameworks on Mac OSX in Cocoa apps? |
You should also be aware that stored procedures were not supported in Mysql before version 5.0. http://dev.mysql.com/doc/refman/5.0/en/stored-routines.html Also stored procedures tended to be be a bit weird in that implementation. Now that Mysql 5.1 is starting to crop up in the wild I see more use of stored procedures... |
Although this looks to be for Itanium, presumably the implementation is similar for x86: [exception handling ABI][1]
[1]: http://www.codesourcery.com/public/cxx-abi/abi-eh.html |
<a href="http://weblogs.mozillazine.org/roc/archives/2005/05/rendering_web_p.html">You can use Gecko to do this.</a> |
That sounds like a security risk. It seems it's possible for the wiki admin to install scripts, see [wikipedia's user scripts][1].
[1]: http://en.wikipedia.org/wiki/Wikipedia:WikiProject_User_scripts |
The best environment for such testing, I believe, is VMWare or an equivalent. Set up your database, transaction log and so on, then record the whole lot - database as well as configuration. Then to re-test, reload the image and database and kick off the tests. This still requires maintenance of the tests as the system ... |
As @[Kris K.][1] says dumping and restoring the database between each test will probably be the way to go.
Since you are looking at doing testing external to the App I would look to build the testing framework in a language where you can take advantage of better testing tools.
If you built the testing framework... |
There is no simple answer, and in many ways even the complex answers are currently inadequate or incomplete. You'll get a better answer if you are more specific about the replies you want: pointers to dev libraries and tools, instructional materials, pointers to current research projects and issues in this area, or so... |
You could use something simple in the client app like
Sub PingServer(Server As String, Port As Integer)
Dim Temp As New System.Net.Sockets();
Temp.Connect(Server, Port)
Temp.Close()
End Sub
Get your webserver to listen on a particular port and count connections.
Also, you really s... |
Note that using the techniques above it will never be possible to completely ban the specific company from accessing your website. It will still be possible for them to use proxy servers or look at your site from home.
If you absolutely want to control who has access, you should only allow authenticated and authoriz... |
At my last job we ran statistics once a week. If I remember correctly, we scheduled them on a Thursday night, and on Friday the DBAs were very careful to monitor the longest running queries for anything unexpected. (Friday was picked because it was often just after a code release, and tended to be a fairly low traffi... |
This prose by Alberto Savoia answers precisely that question (in a nicely entertaining manner at that!):
[http://www.artima.com/forums/flat.jsp?forum=106&thread=204677][1]
> **Testivus On Test Coverage**
>
> Early one morning, a programmer asked
> the great master:
>
> “I am ready to write some unit te... |
Try to consider up front what kind of headache you're creating for yourself (if you are, which isn't always the case) by implementing sIFR. It's probably advisable to only use it when your site design is relatively straightforward. As soon as you start having to deal with specific browser rendering exceptions (CSS, for... |
How do I enable/disable Cut/Copy/Paste menu and toolbar items in a generic way? |
|winforms| |
I have a windows forms application with controls like textbox, combobox, datagridview etc.
These controls allow a user to use the clipboad, i.e. cut/copy and paste text. It is also possible to delete text (which is not related to the clipboard).
My application has a menubar with an Edit item containing Cut/Copy/Pas... |
You don't need position:absolute on every element to do what you want.
You just use it on a few key items and then you can position them where-ever you want, moving all the items contained within them along with the root element of the section. |