instruction stringlengths 0 30k ⌀ |
|---|
Just to check, if you use **just** this part you get an error?
<?php
include("../includes/connect.php");
$query = "SELECT * from story";
$result = mysql_query($query) or die(mysql_error());
If so, do you still get an error if you copy and paste one of those Inserts into this page, I am trying to see if it's local to the page or that actual line.
Also, can you post a copy of the connection calls (minus passwords), unless the inserts use exactly the same syntax as this example. |
[Sonic File Finder](http://jens-schaller.de/sonictools/sonicfilefinder/) for when you have loads of files in your solutions and searching for them in the solution explorer becomes a pain in the wrist.
You might also find [DPack](http://www.usysware.com/dpack/) interesting. Several tools and enhancements rolled into one neat package. |
Does the apache user require a password to connect to the database? If so, then the fact that it says "using password: NO" would lead me to believe that the code is trying to connect without a password.
If, however, the apache user doesn't require a password, a double-check of the permissions may be a good idea (which you mentioned you already checked). It may still be beneficial to try executing something like this at a mysql prompt:
> `GRANT ALL PRIVILEGES ON` *databasename*`.* to 'apache'@'localhost';`
That syntax should be correct.
Other than that, I'm just as stumped as you are. |
Try this, Chris:
SELECT
AccountNumber as [clientId]
FROM
Location.Location
WHERE
LocationId = 'long-guid-here'
FOR
XML AUTO, ELEMENTS, ROOT('root') |
Try this, Chris:
SELECT
AccountNumber as [clientId]
FROM
Location.Location root
WHERE
LocationId = 'long-guid-here'
FOR
XML AUTO, ELEMENTS
TERRIBLY SORRY! I mixed up what you were asking for. I prefer the XML AUTO just for ease of maintainance, but I believe either one is effective. My apologies for the oversight ;-) |
If indeed you are able to insert using the same connection calls, your problem most likely lies in the user "apache" not having SELECT permissions on the database. If you have phpMyAdmin installed you can look at the permissions for the user in the Privileges pane. phpMyAdmin also makes it very easy to modify the permissions.
If you only have access to the command line, you can check the permissions from the mysql database.
You'll probably need to do something like:
GRANT SELECT ON myDatabase.myTable TO 'apache'@'localhost'; |
What is the argument for printf that formats a long? |
|c| |
The <code>printf</code> function takes an argument type, such as %d or %i for a signed int. However, I don't see anything for a long value. |
@DrPizza:
> OK, I'm still a bit unclear about how
> you wish the priorities to work. If
> the pool is currently running a task
> of type A with maximal concurrency of
> 1 and low priority, and it gets given
> a new task also of type A (and maximal
> concurrency 1), but this time with a
> high priority, what should it do?
This one is a bit of a tricky one, although in this case I think I would be happy with simply allowing the low-priority task to run to completion. Usually, we wouldn't see a lot of the same types of tasks with different thread priorities. In our model it is actually possible to safely halt and later restart tasks at certain well defined points (for different reasons than this) although the complications this would introduce probably aren't worth the risk.
Normally, only different types of tasks would have different priorities. For example:
- A task - 1000 instances - low priority
- B task - 1000 instances - high priority
Assuming the A tasks had come along and were running, then the B tasks had arrived, we would want the B tasks to be able to run more or less straight away. |
Distributed caching with .NET 2.0+ ? |
|caching|asp.net| |
What is the best approach to implement distributed caching with .NET? |
|asp.net|caching| |
What is the best approach to implement distributed caching with .NET?
Edit: I was looking for a general caching schema for internal and external applications |
Inner Joins require that a record with a related ID exist in the joined table.
Outer Joins will return records for the left side even if nothing exists for the right side.
For instance you have a Orders and a OrderDetails table. They are related by an "OrderID"
Orders
- OrderID
- CustomerName
OrderDetails
- OrderDetailID
- OrderID
- ProductName
- Qty
- Price
*SELECT Orders.OrderID, Orders.CustomerName FROM Orders INNER JOIN OrderDetails ON Orders.OrderID = OrderDetails.OrderID*
will only return Orders that also have something in the OrderDetails table
if you change it to OUTER LEFT JOIN
SELECT Orders.OrderID, Orders.CustomerName FROM Orders LEFT JOIN OrderDetails ON Orders.OrderID = OrderDetails.OrderID
then it will return records from the Orders table even if they have no OrderDetails records.
You can use this to find Orders that do not have any OrderDetails indicating a possible orphaned order by adding a where clause like WHERE OrderDetails.OrderID IS NULL
|
%ld see [http://www.cplusplus.com/reference/clibrary/cstdio/printf.html][1]
[1]: http://www.cplusplus.com/reference/clibrary/cstdio/printf.html |
Here are a few sites on blogspot that may help. They have RSS feeds that will hopefully be easier to consume than paging through PDFs.
- [http://descriptor-tips.blogspot.com/][1]
- [http://descriptors.blogspot.com/][2]
[1]: http://descriptor-tips.blogspot.com/
[2]: http://descriptors.blogspot.com/ |
Names -- you can try yourselves or ask friends/customers about what they are thinking about when listen/use your product (I don't know correct English word for that -- if two things have something in common they are associated?).
Or, depends on what kind of product is it, ask someone with unlimited imagination -- kids are very good at it.
Logos and branding -- you need professionals.
And of course you need layer :). |
What's a good way to encapsulate data access with PHP/MySQL? |
|php|mysql|database|lamp| |
Most of my experience is on the MSFT stack, but I am now working on a side project, helping someone with a personal site with cheap hosting that is built on the LAMP stack. My options for installing extras are limited, so I'm wondering about how to write my data access code without embedding raw queries in the .php files.
I like to keep things simple, even with .NET. I generally write stored procedures for everything, and I have a helper class that wraps all calls to execute procedures and return data sets. I'm not looking for a full-blown ORM or any kind of entity model.
Remember that I'm on a $7/month GoDaddy account, so I'm limited to what's already installed in their basic package. |
|php|database|mysql|lamp| |
Most of my experience is on the MSFT stack, but I am now working on a side project, helping someone with a personal site with cheap hosting that is built on the LAMP stack. My options for installing extras are limited, so I'm wondering about how to write my data access code without embedding raw queries in the .php files.
I like to keep things simple, even with .NET. I generally write stored procedures for everything, and I have a helper class that wraps all calls to execute procedures and return data sets. I'm not looking for a full-blown ORM, but it might be the way to go and others who view this question might be looking for that.
Remember that I'm on a $7/month GoDaddy account, so I'm limited to what's already installed in their basic package.
[Edit]
Thanks @rix0rr, @Alan, @Anders, @dragon, I will check all of those out. I edited the question to be more open to ORM solutions, since they are so popular. |
Unless it's a business requirement, I suggest you move the connection string from the command line to the package and use a package configuration to define the path to the Excel file (in order not to hard-code it).
1. Define a variable *@ExcelPath*.
2. Use connection's *Expression* property to construct a connection string - an example:
"Data Source=" + @[User::FilePath] + ";Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=dBASE IV;"
3. Assign a value to *@ExcelPath* in the package configuration (I use *SQL Server* configuration type). |
Unless it's a business requirement, I suggest you move the connection string from the command line to the package and use a package configuration to define the path to the Excel file (in order not to hard-code it). This will make it easier to maintain.
1. Define a variable *@ExcelPath*.
2. Use connection's *Expression* property to construct a connection string - an example:
"Data Source=" + @[User::FilePath] + ";Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=dBASE IV;"
3. Assign a value to *@ExcelPath* in the package configuration.
---------
Take at look at my connection string example. It's taken from a working package. As you can see, the quotes are only there because I am concatenating two strings with a variable. |
The approach I favour is the following setup (Actually assuming you are in a .NET project):
- CruiseControl.NET.
- NANT tasks for each individual step. Nant.Contrib for alternative CC templates.
- NUnit to run unit tests.
- NCover to perform code coverage.
- FXCop for static analysis reports.
- Subversion for source control.
- CCTray or similar on all dev boxes to get notification of builds and failures etc.
On many projects you find that there are different levels of tests and activities which take place when someone does a checkin. Sometimes these can increase in time to the point where it can be a long time after a build before a dev can see if they have broken the build with a checkin.
What I do in these cases is create three builds (or maybe two):
- A CI build is triggered by checkin and does a clean SVN Get, Build and runs lightweight tests. Ideally you can keep this down to minutes or less.
- A more comprehensive build which could be hourly (if changes) which does the same as the CI but runs more comprehensive and time consuming tests.
- An overnight build which does everything and also runs code coverage and static analysis of the assemblies and runs any deployment steps to build daily MSI packages etc.
The key thing about any CI system is that it needs to be organic and constantly being tweaked. There are some great extensions to CruiseControl.NET which log and chart build timings etc for the steps and let you do historical analysis and so allow you to continously tweak the builds to keep them snappy. It's something that managers find hard to accept that a build box will probably keep you busy for a fifth of your working time just to stop it grinding to a halt. |
Consolas all the way. |
You're doing it wrong if you are generating pixmaps inside any of the delegate methods (paint, draw...).
Try to generate the thumbnails only once (on worker thread or maybe not even at runtime, if possible) and have the delegate just display them for the appropriate role.
If you do it at runtime display a default picture until you have the thumbnail generated (like web browsers do with pictures that are not yet downloaded). |
regex formats |
|regex| |
I've seen a lot of commonality in regex capabilities of different regex-enabled tools/languages (e.g. perl, sed, java, vim, etc), but I've also many differences.
Is there a *standard* subset of regex capabilities that all regex-enabled tools/languages will support? How do regex capabilities vary between tools/languages? |
|language-agnostic|regex| |
Include an example of how making Java code more groovy takes away soooo much code. Wait for them to pick their jaws up off of the floor before continuing. Scott Davis has a simple example at the beginning of Groovy Recipes that takes 35 lines of Java or 3 lines of Groovy.
|
<http://en.wikipedia.org/wiki/Comparison_of_regular_expression_engines>
Even more detailed: <http://www.regular-expressions.info/refflavors.html> |
If you do an alert of `arrow` what does it return? Does it return the exact string that you're matching against? If you are getting the actual characters `'⇓'` and `'⇑'` you may have to match it against `"\u21D1"` and `"\u21D3"`.
Also, you may want to try `⇑` and `⇓` since not all browsers support those entities. |
If you use javascript to open the popup you can use something like this.
var newWin = window.open(url);
if(!newWin || newWin.closed || typeof newWin.closed=='undefined')
{
//POPUP BLOCKED
} |
You should look into DBUnit, or try to find a PHP equivalent (there must be one out there). You can use it to prepare the database with a specific set of data which represents your test data, and thus each test will no longer depend on the database and some existing state. This way, each test is self contained and will not break during further database usage.
Update: A quick google search showed a [DB unit extension][1] for PHPUnit.
[1]: http://www.ds-o.com/archives/63-PHPUnit-Database-Extension-DBUnit-Port.html |
I have the exact same problem with my work and I find that the best idea is to have a PHP script to re-create the database and then a separate script where I throw crazy data at it to see if it breaks it.
I have not ever used any Unit testing or suchlike so cannot say if it works or not sorry. |
From [Mark Harrison][1]
>And here's what works...
>curl -s --cookie soba=. http://stackoverflow.com/users
And for wget:
wget --no-cookies --header "Cookie: soba=(LookItUpYourself)" http://stackoverflow.com/users/30/myProfile.html
[1]: http://stackoverflow.com/questions/2815/#2878 |
If you can setup the database with a known quantity prior to running the tests and tear down at the end, then you'll know what data you are working with.
Then you can use something like Selenium to easily test from your UI (assuming web-based here, but there are a lot of UI testing tools out there for other UI-flavours) and detect the presence of certain records pulled back from the database.
It's definitely worth setting up either a test version of the database - or make your test scripts populate the database with known data as part of the tests. |
Don't overlook the compiler itself.
Read the compiler's documentation and find all the warnings and errors it can provide, and then enable as many as make sense for you.
Also make sure to tell your compiler to treat warnings like errors so you're forced to fix them right away. ("-Werror" on gcc)
Also: "-Wall" on gcc does *not* enable all warnings, don't be fooled.
Also also: check out valgrind (free!) - it "automatically detect[s] many memory management and threading bugs, and profile[s] your programs in detail."
Valgrind isn't a static checker, but it's a great tool! http://valgrind.org |
A quick hack you can consider is doing a chmod on the file you're editing, save with vim, and then chmod back to what the file was originally.
ls -l test.file (to see the permissions of the file)
chmod 777 test.file
[This is where you save in vim]
chmod xxx test.file (restore the permissions you found in the first step)
Of course I don't recommend this approach in a system where you're worried about security, as for a few seconds anyone can read/change the file without you realizing. |
Emacs is a wonderful text editor. It has huge power once you become a power user. You can access a shell, have as many files open as you want in as many sub-windows and an extremely powerful scripting support that lets you add all kinds of neat features.
I have been using a ruby-mode which adds syntax highlighting and whatnot to ruby, and the same exists for every major language.
If you keep at it, you can use exclusively the keyboard and never touch the mouse, which increases your editing speed by a significant margin.
If you want to start with something a lot more basic though, gedit is nice... it has built in syntax highlighting as well for most languages based on the filename extension. It comes with the OS as well (though emacs you can easily install with apt-get or some similar package finder utility). |
Another option is running the appropriate `vars` batch file from a regular command prompt. The name and location varies from version to version. For VS2003, I believe it's
`C:\Program Files\Microsoft Visual Studio.NET 2003\Vc7\bin\vcvars32.bat`
|
looping and average in c++ |
|c++| |
Programming Student here...trying to work on a project but I'm stuck.
The project is trying to find the miles per gallon per trip then at the end outputting total miles and total gallons used and averaging miles per gallon
How do I loop back up to the first question after the first set of questions has been asked.
Also how will I average the trips...will I have to have a variable for each of the trips?
I'm stuck, any help would be great! |
You will have to tell us the type of data you are given.
As per your last question: remember that an average can be calculated in real time by either storing the sum and the number of data points (two numbers), or the current average and the number of data points (again, two numbers).
For instance:
class Averager {
double avg;
int n;
public:
Averager() : avg(0), n(0) {}
void addPoint(double v) {
avg = (n * avg + v) / (n + 1);
n++;
}
double average() const { return avg; }
}; |
I'd drop the '-l'
If all you plan to run the the system is this build I *think* the -j 4 does what you want.
Based on my memory, if you have anything else running (crond?), that can push the load average over 4.
[GNU make ref][1]
[1]: http://sunsite.ualberta.ca/Documentation/Gnu/make-3.79/html_chapter/make_5.html#SEC47 |
Here's my really naive solution. Your mileage may vary.
Keep a sign bit, which is `sign(dividend) ^ sign(divisor)`. (Or `*`, or `/`, as you please. Basically, negative if either one is negative, positive if none or both are negative.)
Then, call the unsigned division function on the absolute values of both. Then tack the sign back onto the result. |
Here's my really naive solution. Your mileage may vary.
Keep a sign bit, which is `sign(dividend) ^ sign(divisor)`. (Or `*`, or `/`, if you're storing your sign as 1 and -1, as opposed to false and true. Basically, negative if either one is negative, positive if none or both are negative.)
Then, call the unsigned division function on the absolute values of both. Then tack the sign back onto the result. |
Here's my really naive solution. Your mileage may vary.
Keep a sign bit, which is `sign(dividend) ^ sign(divisor)`. (Or `*`, or `/`, if you're storing your sign as 1 and -1, as opposed to false and true. Basically, negative if either one is negative, positive if none or both are negative.)
Then, call the unsigned division function on the absolute values of both. Then tack the sign back onto the result.
P.S. That is actually how `__divdi3` is implemented in `libgcc2.c` (from GCC 4.2.3, the version that's installed on my Ubuntu system). I just checked. :-) |
The "<a href="http://wiki.class-dbi.com/wiki/Common_problems">common problems</a>" page on the <a href="http://wiki.class-dbi.com/wiki">Class::DBI wiki</a> has a <a href="http://wiki.class-dbi.com/wiki/Common_problems#Old_data_due_to_object_index">section</a> on this subject. The simplest solution is to disable the live object index entirely using:
$Class::DBI::Weaken_Is_Available = 0;
|
Put an 'l' directly before the specifier.
unsigned long n;
printf("%ld", n); |
Common lisp idiom - is there a better way? |
|lisp| |
I find myself doing this sort of thing all the time. I've been considering writing a macro/function to make this sort of thing easier, but it occurs to me that I'm probably reinventing the wheel.
Is there an existing function that will let me accomplish this same sort of thing more succinctly?
(defun remove-low-words (word-list)
"Return a list with words of insufficient score removed."
(let ((result nil))
(dolist (word word-list)
(when (good-enough-score-p word) (push word result)))
result)) |
Yes, SP1 is required.
There are several bits of SP1 that Dynamic Data uses, notably the ASP.NET routing extensions and the new data annotation classes in System.ComponentModel. |
Here's a small script I wrote for finding the total numbers of occurrence for different source code elements in ActionScript 3 code (this is written in Python simply because I'm familiar with it, while Perl would probably be better suited for a regex-heavy script like this):
#!/usr/bin/python
import sys, os, re
# might want to improve on the regexes used here
codeElements = {
'package':{
'regex':re.compile('^\s*[(private|public|static)\s]*package\s+([A-Za-z0-9_.]+)\s*', re.MULTILINE),
'numFound':0
},
'class':{
'regex':re.compile('^\s*[(private|public|static|dynamic|final|internal|(\[Bindable\]))\s]*class\s', re.MULTILINE),
'numFound':0
},
'interface':{
'regex':re.compile('^\s*[(private|public|static|dynamic|final|internal)\s]*interface\s', re.MULTILINE),
'numFound':0
},
'function':{
'regex':re.compile('^\s*[(private|public|static|protected|internal|final|override)\s]*function\s', re.MULTILINE),
'numFound':0
},
'member variable':{
'regex':re.compile('^\s*[(private|public|static|protected|internal|(\[Bindable\]))\s]*var\s+([A-Za-z0-9_]+)(\s*\\:\s*([A-Za-z0-9_]+))*\s*', re.MULTILINE),
'numFound':0
},
'todo note':{
'regex':re.compile('[*\s/][Tt][Oo]\s?[Dd][Oo][\s\-:_/]', re.MULTILINE),
'numFound':0
}
}
totalLinesOfCode = 0
filePaths = []
for i in range(1,len(sys.argv)):
if os.path.exists(sys.argv[i]):
filePaths.append(sys.argv[i])
for filePath in filePaths:
thisFile = open(filePath,'r')
thisFileContents = thisFile.read()
thisFile.close()
totalLinesOfCode = totalLinesOfCode + len(thisFileContents.splitlines())
for codeElementName in codeElements:
matchSubStrList = codeElements[codeElementName]['regex'].findall(thisFileContents)
codeElements[codeElementName]['numFound'] = codeElements[codeElementName]['numFound'] + len(matchSubStrList)
for codeElementName in codeElements:
print str(codeElements[codeElementName]['numFound']) + ' instances of element "'+codeElementName+'" found'
print '---'
print str(totalLinesOfCode) + ' total lines of code'
print ''
Pass paths to all of the source code files in your project as arguments for this script to get it to process all of them and report the totals.
A command like this:
find /path/to/project/root/ -name "*.as" -or -name "*.mxml" | xargs /path/to/script
Will output something like this:
1589 instances of element "function" found
147 instances of element "package" found
58 instances of element "todo note" found
13 instances of element "interface" found
2033 instances of element "member variable" found
156 instances of element "class" found
---
40822 total lines of code
|
I really enjoy [IEEE Software][1] because it covers broader issues regarding software engineering.
[1]: http://www.computer.org/portal/site/software/ |
Here's something I cooked up for something similar.
It handles the following types of ranges:
1 single number
1-5 range
-5 range from (firstpage) up to 5
5- range from 5 up to (lastpage)
.. can use .. instead of -
;, can use both semicolon, comma, and space, as separators
It does not check for duplicate values, so the set *1,5,-10* will produce the sequence *1, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10*.
public class RangeParser
{
public static IEnumerable<Int32> Parse(String s, Int32 firstPage, Int32 lastPage)
{
String[] parts = s.Split(' ', ';', ',');
Regex reRange = new Regex(@"^\s*((?<from>\d+)|(?<from>\d+)(?<sep>(-|\.\.))(?<to>\d+)|(?<sep>(-|\.\.))(?<to>\d+)|(?<from>\d+)(?<sep>(-|\.\.)))\s*$");
foreach (String part in parts)
{
Match maRange = reRange.Match(part);
if (maRange.Success)
{
Group gFrom = maRange.Groups["from"];
Group gTo = maRange.Groups["to"];
Group gSep = maRange.Groups["sep"];
if (gSep.Success)
{
Int32 from = firstPage;
Int32 to = lastPage;
if (gFrom.Success)
from = Int32.Parse(gFrom.Value);
if (gTo.Success)
to = Int32.Parse(gTo.Value);
for (Int32 page = from; page <= to; page++)
yield return page;
}
else
yield return Int32.Parse(gFrom.Value);
}
}
}
}
|
I'd encapsulate similar fields into an object of its own with its own construction/validation logic.
Say for example, if you've got
* BusinessPhone
* BusinessAddress
* HomePhone
* HomeAddress
I'd make a class that stores phone and address together with a tag specifying wether its a "home" or a "business" phone/address. And then reduce the 4 fields to merely an array.
ContactInfo cinfos = new ContactInfo[] {
new ContactInfo("home", "+123456789", "123 ABC Avenue"),
new ContactInfo("biz", "+987654321", "789 ZYX Avenue")
};
Customer c = new Customer("john", "doe", cinfos);
that should make it looks more like a code than spaghetti
Anyway another solution would be to take a broader look at your class diagrams and see if refactoring some parts of it might reduce the number of your constructor arguments and dependency on the Customer object.
And I'd try the following too:
* Spread out the validation logic instead of storing it in a single class. Validate when user input them and then validate again at the database layer etc...
* Make a `CustomerFactory` class that would help me construct `Customer`s
* @marcio's solution is also interesting... |
I'd encapsulate similar fields into an object of its own with its own construction/validation logic.
Say for example, if you've got
* BusinessPhone
* BusinessAddress
* HomePhone
* HomeAddress
I'd make a class that stores phone and address together with a tag specifying wether its a "home" or a "business" phone/address. And then reduce the 4 fields to merely an array.
ContactInfo cinfos = new ContactInfo[] {
new ContactInfo("home", "+123456789", "123 ABC Avenue"),
new ContactInfo("biz", "+987654321", "789 ZYX Avenue")
};
Customer c = new Customer("john", "doe", cinfos);
That should make it look less like spaghetti.
Surely if you have a lot of fields, there must be some pattern you can extract out that would make a nice unit of function of its own. And make for more readable code too.
And the following is also possible solutions:
* Spread out the validation logic instead of storing it in a single class. Validate when user input them and then validate again at the database layer etc...
* Make a `CustomerFactory` class that would help me construct `Customer`s
* @marcio's solution is also interesting... |
Compare Regular Expression Flavors
http://www.regular-expressions.info/refflavors.html |
//author[contains(., 'Ritchie')] |
/books/book/authors/author[contains(., 'Ritchie')]
or
//author[contains(., 'Ritchie')] |
Use a class to signal the current state of the span.
The html could look like this
<h3 id="headerId"><span class="upArrow">⇑</span>Header title</h3>
Then in the javascript you do
$( '.upArrow, .downArrow' ).click( function( span ) {
if ( span.hasClass( 'upArrow' ) )
span.text( "⇓" );
else
span.text( "⇑" );
span.toggleClass( 'upArrow' );
span.toggleClass( 'downArrow' );
} );
This may not be the best way, but it should work. Didnt test it tough |
In raw Javascript, the best that you can do is using the few asynchronous calls (xmlhttprequest), but that's not really threading and very limited. [Google Gears][1] adds a number of APIs to the browser, some of which can be used for threading support.
[1]: http://gears.google.com/ |
**Problem:**
Insert + or - sign anywhere between the digits 123456789 in such a way that the expression evaluates to 100. The condition is that the order of the digits must not be changed.
e.g.: 1 + 2 + 3 - 4 + 5 + 6 + 78 + 9 = 100
**Programming Problem:**
Write a program in your favorite language which outputs all possible solutions of the above problem. |
You also might want to allow for whitespace before the "p" in the p tag. Not sure how often you'll run into this, but < p> is perfectly valid HTML. |
my boss has. it was a real pain. permissions issues. he used the built in sharepoint backup tool. I can more details tomorrow if need. I'll check back. |
my boss has. it was a real pain. permissions issues. he used the built in sharepoint backup tool. I can more details tomorrow if need. I'll check back.
I'm back. Here's the steps he used.
- install an instance of sql server
2005 on the sql 2000 box
(side-by-side)
- back up the sharepoint site using the sharepoint admin tools. This will create a one mother of a large xml file w/ the whole kit and kaboodle (the site & all it's content)
- delete the old-n-busted sharepoint site
- create a new hotness sharepoint site using the sql server 2005 as the database.
- do a restore from the xml backup using the admin tools - this will take hours to run (thank you xml ...)
- Bingo! |
my boss has. it was a real pain. permissions issues. he used the built in sharepoint backup tool. I can more details tomorrow if need. I'll check back.
I'm back. Here's the steps he used.
- install an instance of sql server
2005 on the sql 2000 box
(side-by-side)
- back up the sharepoint site using the sharepoint admin tools. This will create a one mother of a large xml file w/ the whole kit and kaboodle (the site & all it's content)
- delete the old-n-busted sharepoint site
- create a new hotness sharepoint site using the sql server 2005 as the database.
- do a restore from the xml backup using the admin tools - this will take hours to run (thank you xml ...)
- Bingo!
- P.S. I forgot, the account you use to do the restore must be an 'sa' account. |
Unless it's a business requirement, I suggest you move the connection string from the command line to the package and use a package configuration to define the path to the Excel file (in order not to hard-code it). This will make it easier to maintain.
1. Define a variable *@ExcelPath*.
2. Use connection's *Expression* property to construct a connection string - an example:
"Data Source=" + @[User::FilePath] + ";Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=dBASE IV;"
3. Assign a value to *@ExcelPath* in the package configuration.
---------
Take a closer look at the connection string above. It's taken from a working package. I'm not sure about this, but maybe you don't need any quotes at all (the ones above are only there because the expression editor requires them). |
Unless it's a business requirement, I suggest you move the connection string from the command line to the package and use a package configuration to define the path to the Excel file (in order not to hard-code it). This will make it easier to maintain.
1. Define a variable *@ExcelPath*.
2. Use connection's *Expression* property to construct a connection string - an example:
"Data Source=" + @[User::FilePath] + ";Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=dBASE IV;"
3. Assign a value to *@ExcelPath* in the package configuration.
---------
Take a closer look at the connection string above. It's taken from a working package. I'm not sure about this, but maybe you don't need any quotes at all (the ones above are only there because the expression editor requires them).
---------
[I have also had some problems with SSIS on 64-bit SQL Server 2005.][1] That post from my blog does not answer your question, but it is somewhat related so I am posting the link.
[1]: http://chopeen.blogspot.com/2007/04/importing-data-from-dbf-files-using.html |
RE @Wilka:
Actually, bitsets are supported by C/C++ in a way that doesn't require you to do your own masking. I don't remember the exact syntax, but it's something like this:
struct MyBitset {
bool firstOption:1;
bool secondOption:2;
bool thirdOption:3;
int fourBitNumber:4;
};
You can reference any value in that struct by just using dot notation, and the right things will happen:
MyBitset bits;
bits.firstOption = true;
bits.fourBitNumber = 2;
if(bits.thirdOption) {
// Whatever!
}
You can use arbitrary bit sizes for things. The resulting struct can be up to 7 bits larger than the data you define (its size is always the minimum number of bytes needed to store the data you defined). |
RE @Wilka:
Actually, bitsets are supported by C/C++ in a way that doesn't require you to do your own masking. I don't remember the exact syntax, but it's something like this:
struct MyBitset {
bool firstOption:1;
bool secondOption:1;
bool thirdOption:1;
int fourBitNumber:4;
};
You can reference any value in that struct by just using dot notation, and the right things will happen:
MyBitset bits;
bits.firstOption = true;
bits.fourBitNumber = 2;
if(bits.thirdOption) {
// Whatever!
}
You can use arbitrary bit sizes for things. The resulting struct can be up to 7 bits larger than the data you define (its size is always the minimum number of bytes needed to store the data you defined). |
> I have a Powerbook g4 running Leopard and would very much like to do dev on it
Not sure what sort of application you are developing, but if you jailbreak your iPhone, you can:
- develop applications using Ruby/Python/Java which won't require compiling at all
- compile on the phone(!), as there is an GCC/Toolchain install in Cydia - although I've no idea how long that'll take, or if you can simply take a regular iPhone SDK project and SSH it to the phone, and run `xcodebuild`)
You *should* be able to compile iPhone applications from a PPC machine, as you can compile PPC applications from an Intel Mac, and vice-versa, there shouldn't be any reason you can't compile an ARM binary from PPC.. Wether or not Apple include the necessary stuff with Xcode to allow this is a different matter.. The steps that [Ingmar posted](http://3by9.com/85/) seem to imply you can..? |
I recommend mixing in a few packages from Debian Unstable feeds. They tend to be pretty stable, despite the name. They're also very up to date. |
> What is your static memory manager actually doing? Unless it is doing something unsafe (P/Invoke, unsafe code), the behaviour you are seeing is a bug in your program, and not due to the behaviour of the CLR.
I was in fact speaking about unsafe pointers. What I wanted was something like Marshal.AllocHGlobal, though with a lifetime exceeding a single method call. On reflection it seems that just using an index is the right solution as I might have gotten too caught up in mimicking the c++ code.
> One thing I would say from your post is that using structs may not help performance as you hope. C# fails to inline any method calls involving structs, and even though they've fixed this in their latest runtime beta, structs frequently don't perform that well.
I looked into this a bit and I see it has been fixed in .NET 3.5SP1, I assume that's what you were refering to as the runtime beta. In fact, I now understand that this change accounted for a doubling of my rendering speed. Now, structs are agressively inlined, improving their performance greatly on X86 systems (X64 had better struct performance in advance). |
onnodb,
The PostgreSQL ODBC driver is [actively developed][1] and an Access front-end combined with PostgreSQL server, in my opinion makes a great option on a LAN for rapid development. I have been involved in a reasonably big system (100+ PostgreSQL tables, 200+ Access forms, 1000+ Access queries & reports) and it has run excellently for a few years, with ~20 users. Any queries running slow because Access is doing something stupid can generally just be solved by using [views][2], and any really data-intensive code can easily be moved into PostgreSQL functions and then called from Access.
The only main ODBC-related issue we have is that there is no way to kill a slow running query from Access, so we do often get users just killing Access and then massive queries are just left executing on the server.
[1]: http://www.postgresql.org/ftp/odbc/versions/msi/
[2]: http://www.postgresql.org/docs/8.3/interactive/sql-createview.html |
You cannot marshal a Lambda or Proc. This is because both of them are considered closures which means they close around the memory on which they were defined and can reference it. (In order to marshal them you'd have to Marshal all of the memory they could access at the time they were created.)
As Gaius pointed out though, you can use ruby2ruby to get a hold of the string of the program. That is, you can marshal the string that represents the ruby code and then reevaluate it later. |
Can you get a real count of the number of files? Does it fall very near a 2^n boundry? Could you simply be running out of RAM to hold all the file names?
I know that in windows at least file system performance would drop dramatically as the number of files in the folder went up, but I thought that linux didn't suffer from this issue, at least if you were using a command prompt. God help you if you try to get something like nautilus to open a folder with that many files.
I'm also wondering where these files come from. Are you able to calculate file names programmatically? If that's the case, you might be able to write a small program to sort them into a number of sub-folders. Often listing the name of a specific file will grant you access where trying to look up the name will fail. For example, I have a folder in windows with about 85,000 files where this works.
If this technique is successful, you might try finding a way to make this sort permanent, even if it's just running this small program as a cron job. It'll work especially well if you can sort the files by date somewhere. |
Personally, I'm hoping it has less of an impact on web developers and more of an impact on browser developers. Some of the features are really nice, and while the process-oriented approach to separation of tabs will probably make it hefty compared to other browsers, I like the ideas behind it.
My guess is it's going to have to spend a year or longer post-beta to make the kind of impact that Firefox has on web development. |
No. Inode limits are per-filesystem, and decided at filesystem creation time. You could be hitting another limit, or maybe 'ls' just doesn't perform that well.
Try this:
tune2fs -l /dev/DEVICE | grep -i inode
It should tell you all sorts of inode related info. |
Perhaps [Runtime#addShutdownHook](http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Runtime.html#addShutdownHook%28java.lang.Thread%29) ?
|
Regarding the [excerpt from the csharp faq][1]:
Most of the problems listed there were solved for VB.Net (specifically the intellisense and xml comments issues), meaning they're really red herrings-- _there is code available to the C# team that will solve the problem._
Another reason has to do with forcing a user of a class to re-compile, but that's a bit of a red herring, too. If you _change_ a default value in your framework class and the user does _not_ have to recompile, you risk the user _not knowing that the default value changed._ Now you have a potential but in the code that doesn't show up until runtime. In other words, the alternative of overloading the function is at least as bad.
Therefore you have to weigh the remaining reason ("try to limit the magic") vs the fact (which they acknowledge) that writing the overloads is "a bit less convenient". Personally, I say put the feature in, and let the programmer decide whether or not to use it.
[1]: http://blogs.msdn.com/csharpfaq/archive/2004/03/07/85556.aspx |
Regarding the [excerpt from the csharp faq][1]:
Most of the problems listed there were solved for VB.Net (specifically the intellisense and xml comments issues), meaning they're really red herrings-- _there is code available to the C# team that will solve the problem._
Another reason has to do with forcing a user of a class to re-compile, but that's a bit of a red herring, too. If you _change_ a default value in your framework class and the user does _not_ have to recompile, you risk the user _not knowing that the default value changed._ Now you have a potential but in the code that doesn't show up until runtime. In other words, the alternative of overloading the function is at least as bad. Of course, this also presumes a specific implementation of the feature, but it's the implementation suggested in the faq.
Therefore you have to weigh the remaining reason ("try to limit the magic") vs the fact (which they acknowledge) that writing the overloads is "a bit less convenient". Personally, I say put the feature in, and let the programmer decide whether or not to use it.
[1]: http://blogs.msdn.com/csharpfaq/archive/2004/03/07/85556.aspx |
Emacs is a wonderful text editor. It has huge power once you become a power user. You can access a shell, have as many files open as you want in as many sub-windows and an extremely powerful scripting support that lets you add all kinds of neat features.
I have been using a ruby-mode which adds syntax highlighting and whatnot to ruby, and the same exists for every major language.
If you keep at it, you can use exclusively the keyboard and never touch the mouse, which increases your editing speed by a significant margin.
If you want to start with something a lot more basic though, gedit is nice... it has built in syntax highlighting as well for most languages based on the filename extension. It comes with the OS as well (though emacs you can easily install with apt-get or some similar package finder utility).
UPDATE: I think gedit is exclusively GUI based though, so it would be useful to learn emacs in case you are stuck with just a shell (it is fully featured in both shell and graphical mode). |
Emacs is a wonderful text editor. It has huge power once you become a power user. You can access a shell, have as many files open as you want in as many sub-windows and an extremely powerful scripting support that lets you add all kinds of neat features.
I have been using a ruby-mode which adds syntax highlighting and whatnot to ruby, and the same exists for every major language.
If you keep at it, you can use exclusively the keyboard and never touch the mouse, which increases your editing speed by a significant margin.
If you want to start with something a lot more basic though, gedit is nice... it has built in syntax highlighting as well for most languages based on the filename extension. It comes with the OS as well (though emacs you can easily install with apt-get or some similar package finder utility).
UPDATE: I think gedit is exclusively GUI based though, so it would be useful to learn emacs in case you are stuck with just a shell (it is fully featured in both shell and graphical mode).
FURTHER UPDATE: Just FYI, I am not trying to push Emacs over Vim, it's just what I use, and it's a great editor (as I'm sure Vim is too). It is daunting at first (as I'm sure Vim is too), but the question was about text editors on Linux besides vi... Emacs seems the logical choice to me, but gedit is a great simple text editor with some nice features if that's all you are looking for. |
**Using attributes, child config sections and constraints**
There is also the possibility to use attributes which automatically takes care of the plumbing, as well as providing the ability to easily add constraints.
I here present an example from code I use myself in one of my sites. With a constraint I dictate the maximum amount of disk space any one user is allowed to use.
MailCenterConfiguration.cs:
namespace Ani {
public sealed class MailCenterConfiguration : ConfigurationSection
{
[ConfigurationProperty("userDiskSpace", IsRequired = true)]
[IntegerValidator(MinValue = 0, MaxValue = 1000000)]
public int UserDiskSpace
{
get { return (int)base["userDiskSpace"]; }
set { base["userDiskSpace"] = value; }
}
}
}
This is set up in web.config like so
<configSections>
<!-- Mailcenter configuration file -->
<section name="mailCenter" type="Ani.MailCenterConfiguration" requirePermission="false"/>
</configSections>
...
<mailCenter userDiskSpace="25000">
<mail
host="my.hostname.com"
port="366" />
</mailCenter>
**Child elements**
The child xml element _mail_ is created created in the same .cs file as the one above. Here I've added constraints on the port. If the port is assigned a value not in this range the runtime will complain when the config is loaded.
MailCenterConfiguration.cs:
public sealed class MailCenterConfiguration : ConfigurationSection
{
[ConfigurationProperty("mail", IsRequired=true)]
public MailElement Mail
{
get { return (MailElement)base["mail"]; }
set { base["mail"] = value; }
}
public class MailElement : ConfigurationElement
{
[ConfigurationProperty("host", IsRequired = true)]
public string Host
{
get { return (string)base["host"]; }
set { base["host"] = value; }
}
[ConfigurationProperty("port", IsRequired = true)]
[IntegerValidator(MinValue = 0, MaxValue = 65535)]
public int Port
{
get { return (int)base["port"]; }
set { base["port"] = value; }
}
**Use**
To then use it practically in code, all you have to do is instantiate the MailCenterConfigurationObject, this will **automatically** read the relevant sections from web.config.
MailCenterConfiguration.cs
private static MailCenterConfiguration instance = null;
public static MailCenterConfiguration Instance
{
get
{
if (instance == null)
{
instance = (MailCenterConfiguration)WebConfigurationManager
.GetSection("mailCenter");
}
return instance;
}
}
AnotherFile.cs
public void SendMail()
{
MailCenterConfiguration conf = MailCenterConfiguration.Instance;
SmtpClient smtpClient = new SmtpClient(conf.Mail.Host, conf.Mail.Port);
}
**Check for validity**
I previously mentioned that the runtime will complain when the configuration is loaded and some data does not comply to the rules you have set up (e.g. in MailCenterConfiguration.cs). I tend to want to know these things as soon as possible when my site fires up. One way to solve this is load the configuration in _Global.asax.cx.Application_Start_ , if the configuration is invalid you will be notified of this with the means of an exception, and you site won't start.
Global.asax.cs
protected void Application_ Start(object sender, EventArgs e)
{
MailCenterConfiguration.Instance;
} |
Your code is testing for the down arrow and then setting it to the down arrow. It's never an up arrow.
(And .text() would be more appropriate.)
Edit: Also, maybe you're not getting an exact match because the browser is lower-casing the entity or something. Try using a carat (^) and lower-case "v" just for testing. |
Maybe you're not getting an exact match because the browser is lower-casing the entity or something. Try using a carat (^) and lower-case "v" just for testing.
Edited - My first theory was plain wrong. |
Quite a few online sites for competitive programming are full of sample questions/challenges, sorted by 'difficulty'. Quite often, the simpler categories in the 'algorithms' questions would suit you I think.
For example, check out [TopCoder][1] (algorithms section)!
Apart from that, 2 samples:
1. You are given a list of N points in the plane by their coordinates (x_i, y_i), and a number R>0. Output the maximum number out of the N given points that can be simultaneously covered by a disk of radius R (for bonus points: complexity?).
2. You are given an array of N numbers a1 to aN, and you want to compute <code>a1 * a2 * ... * aN / ai</code> for all values of i (so the output is again an array of N elements) *without using division*. Provide a (non-naive) method (complexity should be in O(N) multiplications).
[1]: http://www.topcoder.com/ |
There's no true threading in JavaScript. JavaScript being the malleable language that it is, does allow you to emulate some of it. Here's an example I came across the other day.
http://www.neilmix.com/2007/02/07/threading-in-javascript-17/
|
I've been working on [http://projecteuler.net/][1]
[1]: http://projecteuler.net/ |
G'day,
I think if you took the grep regexp grammar, not the egrep one, or the sed regexp grammar and used that you would be using a safe subset across many platforms and tools.
About the only thing that may bite you then is when you go shift between regexp implementations using finite decision automata and non-finite decision automata, e.g. greedy implementations will vary from grep to Perl.
cheers,
Rob |
You can put the Foo instances in a list and compare the objects with what you read:
var arrFoos = new Foos[]{...}; // what you expect
var expectedFoos = new List<Foo>(arrFoos); // make a list from the hardcoded array of expected Foos
var readerResult = ReadEntireList(reader); // read everything from reader and put in List<Foo>
Expect.ContainSameFoos(expectedFoos, readerResult); // compare the two lists
|
If you are using asp.net you can use the [defaultButton][1] attribute on the form.
[1]: http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlform.defaultbutton(VS.80).aspx |