instruction stringlengths 0 30k ⌀ |
|---|
<?php
$a = array('a' => '1', 'b' => array('t' => '4', 'g' => array('e' => '8')));
$b = array('c' => '3', 'b' => array('0' => '4', 'g' => array('h' => '5', 'v' => '9')));
$c = array_merge_recursive($a, $b);
print_r($c);
?>
outputs:
Array
(
[a] => 1
... |
First, I would suggest you have a look at "[Rapid Development with Python, Django, and Google App Engine][2]"
GvR describes a general/standard project layout on page 10 of his [slide presentation][1].
Here I'll post a slightly modified version of the layout/structure from that page. I pretty much follow this ... |
First, I would suggest you have a look at "[Rapid Development with Python, Django, and Google App Engine][2]"
GvR describes a general/standard project layout on page 10 of his [slide presentation][1].
Here I'll post a slightly modified version of the layout/structure from that page. I pretty much follow this ... |
Do you often see in API documentation (as in 'javadoc of public functions' for example) the description of "value limits" as well as the classic documentation ?
Note: I am not talking about [comments within the code][1]
By "value limits", I mean:
- does a parameter can support a null value (or an empty Strin... |
Lambdas are simplified versions of delegates. They have some of the the properties of a [closure][1] like anonymous delegates, but also allow you to use implied typing. A lambda like this:
something.Sort((x, y) => return x.CompareTo(y));
is a lot more concise than what you can do with a delegate:
som... |
Something like this may be useful?
http://www.docjar.com/ |
ClickOnce is a good solution to this problem. If you go to Project Properties > Publish, you can setup settings for this. In particular, "Install Mode and Settings" is good to look at:
- The application is available online only -- this is effectively a "run once" application
- The application is avaiable offli... |
What you want to do is available explicitly already. See the section "NSView Drawing Redirection API" in the 10.4 AppKit release notes.
Make an NSBitmapImageRep for caching and clear it:
NSGraphicsContext *bitmapGraphicsContext = [NSGraphicsContext graphicsContextWithBitmapImageRep:cacheBitmapImageRep];
[... |
Actually, contrary to common understanding of Monads, they have nothing to do with state. Monads are simply a way to wrapping things and provide methods to do operations on the wrapped stuff without unwrapping it.
For example, you can create a type to wrap another one, in Haskell:
data Wrapped a = Wrap a
T... |
Mark Harrison: Your for loop will never terminate! (++p is indented, but is not actually within the for :-)
Also, switching between pointers and indexing will generally have no effect on performance, nor will adding register keywords (as mat already mentions) -- the compiler is smart enough to apply these transforma... |
Static means that any class part of the package(project) can acces it without using a pointer. This can be usefull or hindering depending on the situation.
The perfect example of the usefullnes of "static" methods is the Math class. All methods in Math are static. This means you don't have to go out of your way, mak... |
First, I would suggest you have a look at "[Rapid Development with Python, Django, and Google App Engine][2]"
GvR describes a general/standard project layout on page 10 of his [slide presentation][1].
Here I'll post a slightly modified version of the layout/structure from that page. I pretty much follow this ... |
Should protected attributes always be banned ? |
|oop| |
I seldom use inheritance, but when I do, I never use protected attributes because I think it breaks the encapsulation of the inherited classes.
Do you use protected attributes ? what do you use them for ?
|
It depends on what Java 6 features you want to use. For a simple thing like adding row sorters to JTables, you can actually test at runtime:
private static final double javaVersion =
Double.parseDouble(System.getProperty("java.version").substring(0, 3));
private static final boolean supp... |
For strings you should just separate your strings from your code (having an XML/DLL that will transform string IDs to real strings is one way to go). However you do need to make sure that you are supporting double byte characters for some languages (this is relevant if you use C/C++).
For input data what you want is... |
It's been a while since I used Lucene but my guess would be to add an extra field for sorting and storing the value in there with the stop words already stripped. You can probably use the same analyzers to generate this value. |
I wouldn't call the class the same (aside from casing) as the constant ... I would have at a minimum one class of "Settings", or "Values", or "Constants", where all the constants would live. If I have a large number of them, I'd group them up in logical constant classes (UserSettings, AppSettings, etc.) |
Some statistics from 2005 I found at [Scott Wiltamuth's blog][1]:
- More than 120M copies of the .NET Framework have been downloaded and installed using either Microsoft downloads or Windows Update
- More than 85% of new consumer PCs sold in 2004 had the .NET Framework installed
- More than 58% of business PCs ... |
Some statistics from 2005 I found at [Scott Wiltamuth's blog][1] (you can be sure these numbers are much higher now):
- More than 120M copies of the .NET Framework have been downloaded and installed using either Microsoft downloads or Windows Update
- More than 85% of new consumer PCs sold in 2004 had the .NET Fr... |
A document-ordered node list is the behavior in other implementations of the DOM, such as Javascript's or Python's. And a randomly-ordered node list would be utterly useless. I think it's safe to depend on nodes being returned in document order. |
I'd have to go with the try / catch concept. I feel like in terms of readability this provides the most to a code maintainer. It should be fairly straight forward to find the chain of function calls as long as the exception is properly typed and the associated message contains detailed enough data (I personally do no... |
Doing so would be pretty much equivalent to delivering a ZIP file and calling unzip by the end of installation.
With such approach AD and Windows Installer would be fooled as if dealing with proper MSI installation, but as it is not the case, they'd backfire on you on the very first occasion.
Don't go this way.
... |
As stated by Leon & Lee, 14.2/3 (C++ '03) explicitly defines this behaviour.
C++ '0x adds to the fun with a similar rule applying to '>>'. The basic concept, is that when parsing a template-argument-list a non nested '>>' will be treated as two distinct '>' '>' tokens and not the right shift operator:
templa... |
No free distributed version control system supports this. If you want this feature, you will have to implement it.
You can write off git: they are interested in raw performance for the Linux kernel development use case. It is improbable they would ever accept the performance trade-off in scaling to huge binary files... |
No free distributed version control system supports this. If you want this feature, you will have to implement it.
You can write off git: they are interested in raw performance for the Linux kernel development use case. It is improbable they would ever accept the performance trade-off in scaling to huge binary files... |
I think the [Java Service Wrapper][1] works well. Not that there are [three ways][2] to integrate your application. It sounds like option 1 will work best for you given that you don't want to change the code. The configuration file can get a little crazy, but just remember that (for option 1) the program you're startin... |
I think the [Java Service Wrapper][1] works well. Note that there are [three ways][2] to integrate your application. It sounds like option 1 will work best for you given that you don't want to change the code. The configuration file can get a little crazy, but just remember that (for option 1) the program you're starti... |
We admit here that you are using an ODBC connexion to your database with Integrated Security on, so that you do not have/do not want to write a username/pasword value in the connexion string (which is according to me the right choice).
In this case, there is fortunately no way to "simulate" another user when connect... |
string test = "one,two,three";
string[] okNow = test.Split(','); |
Building off of icco's suggestion of SVN, I'd actually suggest that if you are using subversion or similar for source control (and if you aren't, you should probably start) you can keep the production environment up to date by putting the command to update the repository into the post-commit hook.
There are a lot of... |
It depends on what Java 6 features you want to use. For a simple thing like adding row sorters to JTables, you can actually test at runtime:
private static final double javaVersion =
Double.parseDouble(System.getProperty("java.version").substring(0, 3));
private static final boolean supp... |
This could be a bug in Eclipse 3.4. I'm using 3.3 (M20080221-1800), and do not observe this behavior. |
cakephp.org
Cakephp is really good, really close to ruby on rails (1.2). It is in php, works very well on shared hosts and is easy to implement.
The only downside is that the documentation is somewhat lacking, but you quickly get it and quickly start doing cool stuff.
I totally recommend cakephp. |
Similar to what Paul said, if there's only one A, you can implement that as a singleton. You can then pass the instance of A as an argument to the constructor (aggregation), with a setter method (essentially aggregation again), or you can set this relationship directly in the constructor (composition).
However, whil... |
I only use Visual Studio as a text editor for xaml and C#. I don't use the designer in Visual Studio at all. You can put together most of your UI with Blend, open your C# files individually with Express. You don't have much intelisense in Visual Studio for the xaml anyway. |
As with most things: it depends. Each of your ideas have merit. If it were me, I'd start out this way:
class Product < ActiveRecord::Base
has_one :AWSItem
end
class AWSItem
belongs_to :product
end
The key questions you want to ask yourself are:
1. Are you only... |
Sometimes a simple "**static Foo foo = new Foo();**" is not enough. Just think of some basic data insertion you want to do.
On the other hand you would have to synchronize any method that instantiates the singleton variable as such. Synchronisation is not bad as such, but it can lead to performance issues or locking... |
My own solution is to add a "filter" control in the header part of the form for each of the columns I want to be able to filter on (usually all ...). Each time such a "filter" control is updated, a procedure will run to update the active filter of the form, using the "BuildCriteria" function available in Access VBA.
... |
My own solution is to add a "filter" control in the header part of the form for each of the columns I want to be able to filter on (usually all ...). Each time such a "filter" control is updated, a procedure will run to update the active filter of the form, using the "BuildCriteria" function available in Access VBA.
... |
As in any unix-based environment, you can use the [`sudo`][1] command:
$ sudo script-name
It will ask for your password (your own, not a separate `root` password).
[1]: http://en.wikipedia.org/wiki/Sudo |
As in any unix-based environment, you can use the [`sudo`][1] command:
$ sudo script-name
It will ask for your password (your own, not a separate `root` password).
[1]: http://xkcd.com/149/ |
That is the big problem with the way CSS treats width property and the reason Microsoft implemented box model differently at first. Microsoft lost, and now it's either width or margin/padding/border for an element.
Situation may change to better in CSS3 with [box-sizing property](http://www.css3.info/preview/box-si... |
In Java, the static interface/class allows the interface/class to be used like a top-level class, that is, it can be declared by other classes. So, you can do:
class Bob
{
void FuncA ()
{
Foo.Bar foobar;
}
}
Without the static, the above would fail to compile. The advan... |
Eclipse may be bloated for learning needs, but will probably give you the best overall Java experience. Try working through some of the built-in tutorials if you find the interface confusing. |
zvon.org has good tutorials on many xml technologies |
Visio and Forward-Engineering |
|c#|visio|forward-engineer| |
Do you know if I can use Visio to forward-engineer a sequence diagram into code (c#)?
Can it be done with Visio alone or do I need a plugin?
What about other diagrams? |
|visual-c#|logo|prolog|people|people-skills| |
|c#|visio|forward-engineer| |
As a professional PL/SQL developer I use (heh) PL/SQL Developer from Allaround Automations.
I've worked with TOAD for quite a long time but now it is quite overpriced comparing with PL/SQL dev. It has some advantages like knowledge base or ability to work with other RDBMS like SQL server but that's not a necessity for... |
Integration with Siebel On-Premise CRM? |
|integration|crm|siebel| |
Has anyone ever integrated an external web application with Siebel On-Premise CRM? Note that I'm not talking about Siebel On-Demand SaaS, but their behind-the-firewall product. Specifically, I'm trying to achieve two-way synchronization of CRM objects (contacts, accounts, sales opportunities) between my web applicat... |
If you mean when you are not the person writing the web page, then you could disable the add ons you do not wish to use with the [Manage Add-Ons][1] IE Options screen added in Win XP SP2
[1]: http://windowsxp.mvps.org/addons.htm |
On the 'how to stay focused', I think once you decide to close your email and put your phone on send, the next things to control are the sounds around you that might derail your thoughts. People talking, phones ringing, etc.
I have started putting the headphones on and surfing to http://www.simplynoise.com/. This is... |
string s = "1,2,3,4,5";
string myStrings[] = s.Split({','}};
Note that Split() takes an *array* of characters to split on.
|
Depends on what sort of processing you want to do. You can tell Tidy to generate XHTML, which is a type of XML, which means you can use all the usual XML tools like XSLT and XQuery on the results.
If you want to process them in Microsoft Excel, then you should be able to slice the table out of the HTML and put it in... |
separationChar[] = {';'}; // or '\t' ',' etc.
var strArray = strCSV.Split(separationChar); |
The C++ standard clearly states:
delete-expression:
::opt delete cast-expression
::opt delete [ ] cast-expression
> The first alternative is for non-array objects, and the second is for arrays. The operand shall have a pointer type, or a class type having a single conversio... |
As soon as you take a full backup of the database, and the database is not using the Simple recovery model, SQL Server keeps a complete record of all transactions ever performed on the database. It does this so that in the event of a catastrophic failure where you lose the data file, you can restore to the point of fai... |
If you want to control the formatting of the unique identifier you can [create your own <FieldType> in SharePoint][1]. MSDN also has a [visual How-To][2]. This basically means that you're creating a custom column.
WSS defines the Counter field type (which is what the ID column above is using). I've never had the nee... |
ASP.NET - Common Gotchas |
|c#|asp.net|vb|gotcha| |
When I am working with ASP.NET, I find that there are always unexpected things I run into that take forever to debug. I figure that having a consolidated list of these would be great for those "weird error" circumstances, plus to expand our knowledge of oddness in the platform.
So: answer with one of your "Gotcha"s!... |
I have previously blogged along these lines [here][1]. Basically, I describe how you can find an existing delegate to meet your needs using Reflector.
[1]: http://kentb.blogspot.com/2008/01/consolidating-delegates-with-reflector.html |
You cannot put more than one object/datasource on a datagrid. You will have to build a single ConceptObject that combines the exposed properties of the part Entities. Try to use DB -> L2S Entities -> ConceptObject. You must be very contrived if the DB model matches the ConceptObject field-for-field. |
You're describing a [Star Schema](http://en.wikipedia.org/wiki/Star_schema). I think its fairly standard practice in your kind of case |
You're describing a [Star Schema](http://en.wikipedia.org/wiki/Star_schema). I think its fairly standard practice in your kind of case
Edit: Actually your schema is slightly modified from the Star Schema, you use the primary key of the fact table in each of the dimension tables to join on so you can have multiple ... |
That's the right way to go.
Generally constants are *not* kept in separate "Constants" classes because they're not discoverable. If the constant is relevant to the current class, keeping them there helps the next developer. |
If the versioning will always be in #.#.# format, you could do this:
ls | grep ^[0-9]\.[0-9]\.[0-9]$ | sort -nr | head -n 1
That will list the versions in descending numerical order, then selects the first of those |
I would say that depends on the nature of your problem. Different problem domains could require almost arbitrary error messages, while other trivial tasks just can return NULL or -1 on error.
*The problem with error return codes is that you're polluting/masking the error since it can be ignored (sometimes without t... |
As with most things: it depends. Each of your ideas have merit. If it were me, I'd start out this way:
class Product < ActiveRecord::Base
has_one :aws_item
end
class AWSItem
belongs_to :product
end
The key questions you want to ask yourself are:
**Are you only... |
how to put an .net application in system tray when minimized? |
|system|system-tray| |
can anyone please suggest a **good code example** of vb.net/c# code to put the application in system tray when minized. |
|.net|system|system-tray| |
Good way to time SQL queries when using Linq to SQL |
|.net|linq|optimization|linq-to-sql|logging| |
Is there a good way to time SQL queries when using Linq to SQL? I really like logging feature, but it would be great if you could somehow also time that query. Any ideas? |
symlink every terminal editor on your system to vim and symlink every graphical editor on your system to a script that opens a new terminal window with vim running. |
Windows Mobile 6 J2SE-scale JVM implementation |
|windows-mobile|java-me|java| |
Does anybody have experience of a decent J2SE (preferably at least Java JDK 1.5-level) Java Virtual Machine for Windows Mobile 6? If you know of any CLDC VMs, I'm also interested because even that would be better than what we [currently have][1] for the platform.
[1]: http://www.nsicom.com/Default.aspx?tabid=13... |
So a couple of things you might do to get the feel that it seems like you're looking for:
1) Extend List class - and add the join method to it. The join method would simply do the work of concatenating and adding the delimiter (which could be a param to the join method)
2) It looks like Java 7 is going to be add... |
I don't like getXByY() - that might be cool in PHP, but I just don't like it in Java (ymmv).
I'd go with overloading, unless you have properties of the same datatype. In that case, I'd do something similar to your second option, but instead of using ints, I'd use an Enum for type safety and clarity. And instead of b... |
I would zip the jar file along with other dependent jars, configuration files and documentation along with a run.bat/run.sh. End user should be able unzip it to any location and edit the run.bat if required (It should run without editing in most of the cases).
An installer may be useful if you want to create entries i... |
using a good library is a great way to get around browser inconsistencies, and jquery is the one that I typically recommend - and if you're running into issues altering the elements in a form in particular, jquery boasts a few really useful plugins focused specifically on form manipulation and evaluation. |
I personally prefer to have the explicit naming "...ByRoomNumber" because if you end up with many "overloads" you will eventually introduce unwanted errors. Being explicit is imho the best way. |
You could use something like that:
interface Employee{
public String getName();
int getBatchId();
}
interface Filter{
boolean matches(Employee e);
}
public Filter byName(final String name){
return new Filter(){
public boolean matches(Employee e) {
return e.getName().equals(name);
}
... |
I wrote some code a while ago that merges two records. Is not entirely dynamic, but whith macros you could easily use it for several records.
It works like this: The merge/2 function takes two records and converts them to lists together with the empty record for reference (the record type is defined at compile time,... |
I always like talks on different subjects. The real hard thing about talking to a specialized community is keeping the detail level high and the scope narrow. What's the point of talking to a bunch of .NET programmers about the benefits of Polymorphism? It always kills me when I go to a meeting on a particular subje... |
I just recently switched from Bitstream Vera Sans Mono to Inconsolata, but reading the answers here, I'm going to give Consolas a chance for a bit. Looks really nice so far. |
I've really fallen in love with [Droid Sans Mono][1].
![alt text][2]
[1]: http://damieng.com/blog/2007/11/14/droid-sans-mono-great-coding-font
[2]: http://images.damieng.com/blog/Droid12Xcode.png |
The Sqlite API has a function called something like <code>sqlite_prepare</code> which takes <em>one</em> statement and prepares it for execution, essentially parsing the SQL and storing in memory. This means that the SQL only has to be sent once to the database engine even though the statement is executed many times.
... |
I just looked at the AIR SQL API, and there's an <code>attach</code> method on <code>SQLConnection</code> it looks exactly what you need.
I haven't tested this, but according to the documentation it should work:
var connection : SQLConnection = new SQLConnection();
connection.open(firstDbFile);
co... |
test this out on a staging box first, change it on a server level for sql server
> declare @option int
>
> set @option = @@options | 64
>
> exec sp_configure 'user options',
> @option
>
> RECONFIGURE
|
I don't think renaming or moving the log file that will work while the database is online.
Easiest thing to do, IMO, is to open the properties for the database and switch it ti Simple logging mode. then shrink the database and then go back and set the DB to Full logging (or whatever logging you need).
Changing... |