instruction stringlengths 0 30k ⌀ |
|---|
It's because the set of integer values does not equal the set of float values for the 'int' and 'float' types. For example, the float value 0.5 has no equal in the integer set and the integer value 4519245367 might not exist in the set of values a float can store. So, the checker flags this as an issue to be checked by... |
On *nix:
$ dig -t a <domain name> |
Selecting X words from a text field in MySQL |
|mysql| |
I'm building a basic search functionality, using LIKE (I'd be using fulltext but can't at the moment) and I'm wondering if MySQL can, on searching for a keyword (e.g. WHERE field LIKE '%word%') return 20 words either side of the keyword, as well? |
Because floats can't store an exact int value, so if you have two variables, int i and float f, even if you assign "i = f;", the comparison "if (i == f)" probably won't return true. |
C++: How to extract a string from rapidxml |
|c++|xml|rapidxml| |
In my C++ program I want to parse a small piece of XML, insert some nodes, then extract the new XML (preferably as a std::string)
RapidXML ([http://rapidxml.sourceforge.net/][1]) has been recommended to me, but I can't see how to retrieve the XML back as a text string.
(I could iterate over the nodes and attribut... |
How can I get the DateTime for the Start of the Week? |
|c#|datetime| |
How do I find the Start of the week (Both Sunday and Monday) knowing just the current time in C#.NET
Something like:
DateTime.Now.StartWeek(Monday); |
You can see whether a string has been interned by calling `String.IsInterned`. The call will return a new string that is either a reference to an interned string equal to the string that was passed as an argument, or `null` if the string was not interned. |
We use ClickOnce where I work; in terms of comparison to a web release I would base the case around the need for providing users with a rich client app, otherwise it might well actually be better to use web applications.
In terms of releasing a rich client app ClickOnce is fantastic; you can set it up to enforce upd... |
I have a custom installer action that updates the PATH environment, and creates an additional environment variable. Appending a directory to the existing path variable is working fine, but for some reason my attempts to create a new environment variable have been unsuccessful. The code I am using is:
usi... |
I have a custom installer action that updates the PATH environment, and creates an additional environment variable. Appending a directory to the existing path variable is working fine, but for some reason my attempts to create a new environment variable have been unsuccessful. The code I am using is:
usi... |
You can try a plain old batchfile.
@echo off
for /f " delims==" %%i in (counter.txt) do set /A temp_counter= %%i+1
echo %temp_counter% > counter.txt
assuming the count.bat and counter.txt are located in the same directory.
|
Many of the standard paths require a user to be logged in, especially the SH* functions as those are provided by the "shell", that is, Explorer. I suspect the only way you're going to get the right path is through the registry like you already mentioned. |
Not that I know of, typically you'll develop apps on a desktop machine (PC/MAC whatever) and download/control the application on the phone. Also I don't think Java is available on a standard (non-cracked) iPhone. |
I recently did a web application that just referenced the files (about 90 in total) from one web application (aspx, master and ascx) without too much of an issue. That said I was using a heavily modified version of the [MVP pattern][1], a lot of interfaces and conventions to keep the complexity down, the same middle ti... |
In SQL server it is as easy as
SELECT * INTO NewTablenNmeHere
FROM OPENROWSET( 'Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\testing.xls','SELECT * FROM [Sheet1$]') |
Does anybody know of existing code to read a mork file (Thunderbird Address Book)? |
|.net|mork|thunderbird|file-format| |
I have the need to read the Thunderbird address book on the fly. It is stored in a file format called Mork. Not a pleasant file format to read. I found a 1999 article explaining the file format. I would love to know if someone already has gone through this process and could make the code available. I found mork.pl... |
|.net|file-format|thunderbird|mork| |
I have the need to read the Thunderbird address book on the fly. It is stored in a file format called Mork. Not a pleasant file format to read. I found a 1999 article explaining the file format. I would love to know if someone already has gone through this process and could make the code available. I found mork.pl... |
BULK
INSERT CSVTest
FROM 'c:\csvtest.txt'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
|
Parametized SQL or SPROC...doesn't matter from a performance stand point...you can query optimize either one.
For me the last remaining benefit of a SPROC is that I can eliminate a lot SQL rights management by only granting my login rights to execute sprocs...if you use Parametized SQL the login withing your connect... |
You can always use tab completion to type "s[TAB]" and press ENTER and that will execute it. |
All these code samples that these good people have posted look fine.
There is one thing to be aware of. Starting with Office 2007, Excel actually has up to 16,384 columns. That translates to XFD (the old max of 256 colums was IV). You will have to modify these methods somewhat to make them work for three charac... |
You can use double-braces to set up the data. You still call add, or put, but it's less ugly:
private static final Hashtable<String,Integer> MYHASH = new Hashtable<String,Integer>() {{
put("foo", 1);
put("bar", 256);
put("data", 3);
put("moredata", 27);
... |
You can have a service implement all the service contracts you want. I mean, I don't know if there is a limit, but I don't think there is.
That's a neat way to separate operations that will be implemented by the same service in several conceptually different service contract interfaces. |
You are missing the reference to System.Configuration. |
Newer phones come with WAP2 which uses HTML Mobile Profile (XHTML MP), which is quite similar to normal HTML. Older phones use Wireless Markup Language (WML).
Depending on your audience I would consider making a mobile phone friendly version of the site using XHTML MP and drop WML completely. By mobile phone frien... |
How many ServiceContracts can a WCF Service have? |
|web-services|wcf| |
Specifically, since a ServiceContract is an Attribute to an Interface, how many interfaces can I code into one WCF web service? Is it a one-to-one? |
Specifically, since a ServiceContract is an Attribute to an Interface, how many interfaces can I code into one WCF web service? Is it a one-to-one?
Does it make sense to separate the contracts across multiple web services? |
@jdiaz
Of course you should strive to have very different business matters in different services, but consider the case in which you want that, for example, all your services implement a GetVersion() operation. You could have a service contract just for that operation and have every service implement it, instead of ... |
A service can theoretically have any number of Endpoints, and each Endpoint is bound to a particular contract, or interface, so it is possible for a single conceptual (and configured) service to host multiple interfaces via multiple endpoints or alternatively for several endpoints to host the same interface.
If you ... |
WCF services can have multiple endpoints, each of which can implement a different service contract.
For example, you could have a service declared as follows:
[ServiceBehavior(Namespace = "DemoService")]
public class DemoService : IDemoService, IDoNothingService
Which would have configuration along... |
I hacked this together with the ActiveSupport gem:
require 'active_support'
def string_to_date(date_string)
parts = date_string.split
return parts[0].to_i.send(parts[1])
end
sinces = ['1 hour', '1 day', '3 days']
sinces.each do |since|
puts "#{since} ago: #{string_to_... |
I hacked this together with the ActiveSupport gem:
require 'active_support'
def string_to_date(date_string)
parts = date_string.split
return parts[0].to_i.send(parts[1])
end
sinces = ['1 hour', '1 day', '3 days']
sinces.each do |since|
puts "#{since} ago: #{string_to_... |
I did some research and came across this article that seems to have a solution to your question.
**Ajax Control Toolkit with ASP.NET MVC#**
source: jimzimmerman
**ARTICLE LINK**
[http://www.ajaxprojects.com/ajax/tutorialdetails.php?itemid=330][1]
**QUOTE**
> So basically if you put the class name
> Tex... |
There are several differences between HashMap and Hashtable in Java:
1. [Hashtable](http://java.sun.com/javase/6/docs/api/java/util/Hashtable.html) is synchronized, whereas [HashMap](http://java.sun.com/javase/6/docs/api/java/util/HashMap.html) is not. This makes HashMap better for non-threaded applications, as un... |
An out-of-the-box idea, but could you use a "replace" function to strip out any instances of "(", "-" and " ", and then use an "isnumeric" function to test whether the resulting string is a number?
Then you could do the same to the phone number string you're searching for and compare them as integers.
Of course, ... |
Sometimes I use this, if I don't want it to be actually set and persisted in my db:
class Person
{
private string _name;
public string Name
{
get
{
return string.IsNullOrEmpty(_name) ? "Default Name" : _name;
}
... |
Console.WriteLine and generic List |
|c#|list|generics|console| |
I frequently find myself writing code like this:
List<int> list = new List<int> { 1, 3, 5 };
foreach (int i in list) {
Console.Write("{0}\t", i.ToString()); }
Console.WriteLine();
Better would be something like this:
List<int> list = new List<int> { 1, 3, 5 };
Console.WriteLine(... |
|c#|generics|console|list| |
Gathering OS and tool version numbers for build archive purposes |
|version|archive|build-automation| |
Our automated build machine needs to archive the version numbers of the OS plus various tools used during each build. (In case we ever need to replicate exactly the same build later on, perhaps when the machine is long dead.)
I see the command "msinfo32.exe" can be used to dump a whole load of system version inform... |
|build-automation|version|archive| |
Our automated build machine needs to archive the version numbers of the OS plus various tools used during each build. (In case we ever need to replicate exactly the same build later on, perhaps when the machine is long dead.)
I see the command "msinfo32.exe" can be used to dump a whole load of system version inform... |
|build-automation|versions|archive| |
|build-automation|versions|archive| |
How do you tackle web application performance improvement? |
|performance|oracle-database|web-application| |
If a good name doesn't spring to mind, I would probably question whether there is a deeper problem - is the class serving a good purpose? If it is, naming it should be pretty straightforward. |
If you need to get around this (you have a legitimate reason and are happy none of the issues mentioned in the other answers are an issue for you) then just cast from one type to another.
|
You'll want the SOA (Start of Authority) record for a given name, and this is how you accomplish it using the nslookup tool available on Windows and Unix-derived systems:
$ nslookup
> set querytype=soa
> stackoverflow.com
Server: 217.30.180.230
Address: 217.30.180.230#53
... |
You'll want the SOA (Start of Authority) record for a given domain name, and this is how you accomplish it using the universally available **nslookup** command line tool:
command line> nslookup
> set querytype=soa
> stackoverflow.com
Server: 217.30.180.230
Address: 217.30.180.2... |
Using the "Callback" model of SampleGrabber may give you better results. See the example in Samples\C++\DirectShow\Editing\GrabBitmaps.
There's also a lot of info in Samples\C++\DirectShow\Filters\Grabber2\grabber_text.txt and readme.txt. |
Always go for MyClassA, MyClassB - It allows for a nice alpha sort..
**I'm kidding!**
This is a good question, and something I experienced not too long ago. I was reorganising my codebase at work and was having problems of where to put what, and what to call it..
The **real** problem?
I had classes doing t... |
UPDATE table1, table2 SET table1.col1='value', table2.col1='value' WHERE table1.col3='567' AND table2.col6='567'
This should work for ya.
Here is a reference in he MySQL manual -> http://dev.mysql.com/doc/refman/5.0/en/update.html
There is an example for multiple tables. |
[e-texteditor](http://e-texteditor.com) seems to be growing as the editor of choice for rails development on ruby. Too bad it isn't free.
Aside from that, the [RailsOnWindows](http://wiki.rubyonrails.org/rails/pages/RailsOnWindows) guide works fine. And Sqlite is by far your best choice for development: [RailsWithSq... |
Are you just looking for an IDE, or a full stack (IDE, source control, database, web server)?
If just an IDE, I would recommend [RadRails][1]. It has syntax highlighting, code help, support for Rails projects, code completion, and basically everything else you would expect to find in a full-featured IDE. It is als... |
Are you just looking for an IDE, or a full stack (IDE, source control, database, web server)?
If just an IDE, I would recommend [NetBeans][1] or [RadRails][2]. Both have syntax highlighting, code help, support for Rails projects, code completion, and basically everything else you would expect to find in a full-feat... |
The following will update all rows in one table
Update Table Set
Column1 = 'New Value'
The next one will update all rows where the value of Column2 is more than 5
Update Table Set
Column1 = 'New Value'
Where
Column2 > 5
There is all [Unkwntech][1]'s example of updating more than ... |
Multiple Updates in MySQL |
|untagged| |
I know that you can insert multiple rows at once, is there a way to update multiple rows at once (as in, in one query) in MySQL? |
I know that you can insert multiple rows at once, is there a way to update multiple rows at once (as in, in one query) in MySQL?
Edit:
For example I have the following
Name id Col1 Col2
Row1 1 6 1
Row2 2 2 3
Row3 3 9 5
Row4 4 16 8
I want to combin... |
You could use the [BinaryFormatter][1] class to serialize your object to a binary format, then save the resulting string in your database.
[1]: http://msdn.microsoft.com/en-us/library/system.runtime.serialization.formatters.binary.binaryformatter.aspx |
By the way, using a PowerShell [here-string](http://blogs.msdn.com/powershell/archive/2006/07/15/Variable-expansion-in-strings-and-herestrings.aspx) might make your function a little easier to read as well, since you won't need to double up all the `"`-marks:
function CreateAppPoolScript([string]$AppPoolName, [s... |
You can use [serialization][1] - it allows you to store your object at least in 3 forms: binary (suitable for BLOBs), XML (take advantage of MSSQL's XML data type) or just plain text (store in varchar or text column)
[1]: http://msdn.microsoft.com/en-us/library/ms973893.aspx |
HashMap: An implementation of the Map interface that uses a lookup table of hashcodes to locate keys.
HashTable: Hi, 1998 called. They want their collections API back.
Seriously though, you're better off staying away from Hashtable altogether. For single-threaded apps, you don't need the extra overhead of syncrhoni... |
This is a problem with Mysql - the regex function only match but cant replace. [See this post][1] for a possible solution.
[1]: http://forums.mysql.com/read.php?10,137433,137465 |
I'd suggest just appending the current datetime of the build to a log file.
date >> builddates.txt
That way you get a build count via the # of lines, and you may also get some interesting statistics if you can be bothered analysing the dates and times later on.
The extra size & time to count the number o... |
Is it possible to run a query to reformat the data to match a desired format and then just run a simple query? That way even if the initial reformatting is slow you it doesn't really matter. |
@Unsliced I think the problem he is getting at is when you take a crystal report someone developed against another database, and you bring it up in Crystal Reports XI, you have to do a Change Datasource for each field, including those in subreports. If you just change source on the top level of the report, it often ... |
> MySQL can search based on regular expressions.
Sure, but given the arbitrary formatting, if my haystack contained `"(027) 123 456"` (bear in mind position of spaces can change, it could just as easily be `027 12 3456` and I wanted to match it with `027123456`, would my regex therefore need to be this?
"^[\D... |
This would give you the preceding Sunday (I think):
DateTime t = DateTime.Now;
t -= new TimeSpan ((int) t.DayOfWeek, 0, 0, 0);
Skizz |
First up, you should use placeholders in your query instead of interpolating the variables directly. PDO/MySQLi allow you to write your queries like:
SELECT * FROM sometable WHERE iUser = ?
The API will safely substitute the values into the query.
I also prefer to have my queries in the code instead of the... |
If you're stuck with a name, sometimes just giving it <a href="http://lbrandy.com/blog/2008/08/developer-timesink-name-paralysis/"><i>any</i></a> half-sensible name with commitment to revising it later is a good strategy.
Don't get naming paralysis. Yes, names are very important but they're not important enough to w... |
In some cases (financial market data and process control for example) you might need to use a real-time database rather than a RDBMS. See [wiki link][1]
[1]: http://en.wikipedia.org/wiki/Real_time_database
|
It must be noted that the text editor/IDE that you use determines how good a font will look. I love UltraEdit, but the only font it renders properly is Courier New. It blurs out about all other useful monospace fonts. However, Visual Studio does a great job rendering any font accurately.
Currently, I will vote Co... |
This may be a bit of a hack, but you can cast the .DayOfWeek property to an int (it's an enum and since its not had its underlying data type changed it defaults to int) and use that to determine the previous start of the week.
It appears the week specified in the DayOfWeek enum starts on Sunday, so if we subtract 1 ... |
You could determine the start of the week for Sunday with:
DateTime.Now.AddDays((double)DateTime.Now.DayOfWeek * -1); |
The following method should return the DateTime that you want. Pass in true for Sunday being the first day of the week, false for Monday:
private DateTime getStartOfWeek(bool useSunday)
{
DateTime now = DateTime.Now;
int dayOfWeek = (int)now.DayOfWeek;
if(!useSunday)
... |
Unfortunately I'm using an SQLEngine for embedded systems so it does not support BULK INSERT or OLEDB datasources, which is why I was thinking of taking the sql statement generation approach.
|
Does the Fox app use .CDX indexes? If so, you might be able to improve performance by adding indexes without needing to change any program code. If it uses .IDX indexes, though, the change would have to be done in the actual app. |
In my experience writing mostly WinForms Client/Server apps these are the simple conclusions I've come to:
**Use Stored Procedures:**
1. For any complex data work. If you're going to be doing something truly requiring a cursor or temp tables it's usually fastest to it within SQL Server.
2. When you need to lo... |
Some things to think about here: [Who Needs Stored Procedures, Anyways?][1]
Clearly it's a matter of your own needs and preferences, but one very important thing to think about when using ad hoc queries in a public-facing environment is security. Always parameterize them and watch out for the typical vulnerabilities... |
I second Kristopher's recommendation of K&R for C.
I've found the "Essential Actionscript 2.0" book quite useful for AS coding (there's an AS3 version out now I believe).
I've found that having real books to thumb through is more helpful than an online reference in some cases. Not really sure why though. |
Detecting if SQL server is running |
|c#|sql-server| |
I'm looking for a way to poll different servers and check that SQL server is up and running. I'm writing my code in C#. I don't particularly care about individual databases, just that SQL server is running and responsive.
Any ideas? |