instruction stringlengths 0 30k ⌀ |
|---|
I would do something like this
public class Utils{
public static String join(Collection<Object> obj, String delimiter) {
if (s.isEmpty()){
return "";
}
Iterator<Object> iter = s.iterator();
StringBuilder buffer = new StringBuilder();
... |
I would do something like this
package util;
import java.util.ArrayList;
import java.util.Iterable;
import java.util.Collections;
import java.util.Iterator;
public class Utils {
// accept a collection of objects, since all objects have toString()
public stat... |
I would use Google Collections. There is a nice Join facility.
http://google-collections.googlecode.com/svn/trunk/javadoc/index.html?com/google/common/base/Join.html
But if I wanted to write it on my own,
package util;
import java.util.ArrayList;
import java.util.Iterable;
import java... |
Some experimentation and I figured this one out:
def methodA(arg, **kwargs):
methodB("argvalue", **kwargs)
Seems obvious now... |
MS SQL server 2005 and 2008 already support this.
http://technet.microsoft.com/en-us/library/ms188698.aspx
http://technet.microsoft.com/en-us/library/ms188698(SQL.90).aspx
|
MS SQL server 2005 and 2008 already support this.
http://technet.microsoft.com/en-us/library/ms188698.aspx
<http://technet.microsoft.com/en-us/library/ms188698(SQL.90).aspx>
|
Put the asterisks before the kwargs variable. This makes Python pass the variable (which is assumed to be a dictionary) as keyword arguments.
methodB("argvalue", **kwargs) |
# General way to implement IN in LINQ to SQL
var q = from t1 in table1
let t2s = from t2 in table2
where <Conditions for table2>
select t2.KeyField
where t2s.Contains(t1.KeyField)
select t1;
# General way to implement EXISTS ... |
You could try Sxipper. It provides intelligent automatic form-fill, including auto-login. It is supposed to actually work as an OpenID provider, but I have not tried this feature yet. |
You could try [Sxipper](http://www.sxipper.com). It provides intelligent automatic form-fill, including auto-login.
From the Sxipper FAQ:
> _How does Sxipper support OpenID?_
> Sxipper remembers your OpenIDs and presents an overlay. You choose the one you want to use and login with one click. Sxipper also hel... |
How to get the base 10 logarithm of a Fixnum in Ruby? |
|ruby|math|logarithm| |
I want to get the base 10 logarithm of a Fixnum using Ruby, but found that n.log or n.log10 are not defined. Math::log is defined but uses a different base than 10.
What is the easiest way to get the base 10 logarithm of a Fixnum? |
You can spend hours if not days customizing Wordpress with plugins, themes, etc...
I would go with a 0 installation solution, such as blogger (https://www.blogger.com/start)
You can even use our own domain name with it if you need do.
|
You can spend hours if not days customizing Wordpress with plugins, themes, etc...
I would go with a 0 installation solution, such as blogger (https://www.blogger.com/start)
You can even use our own domain name with it if you need do.
EDIT: Plus, if you ever get slashdotted, digged or redditted, google can han... |
Reading the documentation for module Math the answer is really obvious:
Math::log10(n)
This gives the base 10 logarithm of n. |
|sql| |
I recently had to solve this problem and find I've needed this info many times in the past so I thought I would post it. Assuming the following table def, how would you write a query to find all differences between the two?
table def:
CREATE TABLE feed_tbl
(
code varchar(15),
name varchar(40),... |
I recently had to solve this problem and find I've needed this info many times in the past so I thought I would post it. Assuming the following table def, how would you write a query to find all differences between the two?
table def:
CREATE TABLE feed_tbl
(
code varchar(15),
name varchar(40),... |
PHP - recursion just for fun. I imagine needing a PHP interpreter takes it out of the running, but hey - it'll make the crash.
function a() { a(); } a(); |
**PHP** - recursion just for fun. I imagine needing a PHP interpreter takes it out of the running, but hey - it'll make the crash.
function a() { a(); } a(); |
Use CASE. Something like this.
SELECT Salable =
CASE Obsolete
WHEN 'N' THEN 1
ELSE 0
END
|
SELECT
CASE
WHEN OBSOLETE = 'N' or InStock = 'Y' THEN 'TRUE'
ELSE 'FALSE'
END AS Salable,
*
FROM PRODUCT
|
The CASE statement is the closest to IF in SQL.
<pre><code>SELECT CAST(CASE WHEN Obsolete = 'N' or InStock = 'Y' THEN 1 ELSE 0 END AS bit) as Salable, * FROM Product</code></pre>
You only need to do the CAST if you want the result as a boolean value. |
System.Windows.Forms.ToolTip ToolTip1 = new System.Windows.Forms.ToolTip();
ToolTip1.SetToolTip(this.textBox1, "Hello");
The tooltip will be set over the control "textBox1".
Have a read here:
http://msdn.microsoft.com/en-us/library/aa288412.aspx
|
I found what I was looking for in the Apple docs. In short Kendall is correct:
[http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/chapter_3_section_4.html#//apple_ref/doc/uid/10000051i-CH4-SW18][1]
[1]: http://developer.apple.com/iphone/library/documentation/C... |
I found what I was looking for in the Apple docs. In short you can set up your objects as properties that you release and retain (or just @property, @synthesize), but you don't have to for things like UILabels:
[http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/chapt... |
If you are going to use multiple buffers, I think the most important thing is to
set hidden
so that it will let you switch buffers even if you have unsaved changes in the one you are leaving. |
TFS vs open source alternatives? |
|.net|open-source|tfs|cruisecontrol.net|subversion| |
We're currently in the process of setting up a source control/build/and more-server for .NET development and we're thinking about either utilizing the Team Foundation Server (which costs a lot of dough) or combining several open source options, such as SourceForge Enterprise/GForge and Subversion and CruiseControl.net ... |
|.net|visual-studio|project|installation|msi| |
|.net|visual-studio|installation|projects|msi| |
Are you running Win2008 x86 as your desktop? Because Win2008 includes version [2.0.50727.1434][1], which is an updated version of 2.0 included in Vista RTM.
[1]: http://www.ditii.com/2008/02/16/windows-server-2008-windows-vista-sp1-net-framework-source-symbols/ |
I know it says language-agnostic, but why not take advantage of the conventions provided by the server-side language you are using? If it were Java, the data could persist by setting a Request attribute. You would use a controller to process the form, detect the login, and then forward through. If the attributes are se... |
How do I automatically destroy child processes in Windows? |
|windows|processes| |
In C++ Windows app, I launch several long running child processes (currently I use CreateProcess(...) to do this.
I want the child processes to be automatically closed if my main processes crashes or is closed.
How do I do this? |
In C++ Windows app, I launch several long running child processes (currently I use CreateProcess(...) to do this.
I want the child processes to be automatically closed **if my main processes crashes** or is closed.
How do I do this? |
In C++ Windows app, I launch several long running child processes (currently I use CreateProcess(...) to do this.
I want the child processes to be automatically closed **if my main processes crashes** or is closed.
Because of the requirement that this needs to work for a crash of the "parent", I believe this wou... |
Windows services cannot have GUIs, so you will need to either get rid of the GUI or separate your application into two pieces - a service with no UI, and a "controller" application. If you have the source code, converting the non-GUI code into a service is easy - Visual Studio has a 'Windows Service' project type that ... |
Performance is improved with typed datasets over untyped datasets (though I've never found performance issues with trivial things like that worth worrying about).
I'd say the biggest pain is just keeping them in sync with your database--I can't speak for VS 2008 but prior versions do not provide good support for th... |
Have a look at http://www.xamlog.com/2006/07/17/creating-a-custom-cursor/ |
Have a look at http://www.xamlog.com/2006/07/17/creating-a-custom-cursor/
Also, you could try this
<Window Cursor=""C:\WINDOWS\Cursors\dinosaur.ani"" />
|
Perhaps it's not solved by you logging in, but by the user logging out. It could be a memory leak and logging out closes the process, causing windows to reclaim the memory. I assume programs indicated multiple applications, so it could be a shared dll that's causing the problem. Is there any kind of similarities in ... |
Unless your string is limited in length, you can't avoid collisions. There are 4294967296 possible values for an integer (2^32). If you have a string of more than 4 ASCII characters, or more than two unicode characters, then there are more possible string values than possible integer values. You can't have a unique int... |
Unless your string is limited in length, you can't avoid collisions. There are 4294967296 possible values for an integer (2^32).
If you have a string of more than 4 ASCII characters, or more than two unicode characters, then there are more possible string values than possible integer values. You can't have a unique ... |
Unless your string is limited in length, you can't avoid collisions.
There are 4294967296 possible values for an integer (2^32). If you have a string of more than 4 ASCII characters, or more than two unicode characters, then there are more possible string values than possible integer values. You can't have a unique... |
SQL Server Duplicate Checking |
|sql|sql-server| |
Here is a generic Binary Search Tree. The only thing I didn't do was implement IEnumerable<T> so you could traverse the tree using a enumerator. However that should be fairly straight forward.
The Node Class:
class BSTNode<T> where T : IComparable<T>
{
private BSTNode<T> _left = null... |
Here is a generic Binary Search Tree. The only thing I didn't do was implement IEnumerable<T> so you could traverse the tree using a enumerator. However that should be fairly straight forward.
Special thanks to Scott Mitchel for his BSTTree article, I used it as a reference on the delete method.
The Node Cl... |
How Do Sockets Work in C? |
|c|sockets|network-programming| |
I am a bit confused about socket programming in C.
You create a socket, bind it to an interface and an IP address and get it to listen. I found a couple of web resources on that, and understood it fine. In particular, I found an article [Network programming under Unix systems][1] to be very informative.
What conf... |
When you do a read on the socket, you tell it how many maximum bytes to read, but if it doesn't have that many, it gives you however many it's got. It's up to you to design the protocol so you know whether you've got a partial packet or not. For instance, in the past when sending variable length binary data, I would ... |
Sockets operate at a higher level than raw packets - it's like a file you can read/write from. Also, when you try to read from a socket, the operating system will block (put on hold) your process until it has data to fulfill the request. |
Multi-Threaded splash screen in c#? |
|c#|winforms|multithreading| |
I know this question is all over the net, but I can't quite find what I am looking for and quite frankly this community seems more sophisticated than most I have seen. I want a splash screen to show while the application is loading. I have a form with a system tray control tied to it. I want the splash screen to dis... |
It depends on your database flavor. MS SQL Server, for example, tends to prefer more narrower tables. That's also the more 'normalized' approach. Other engines might prefer it the other way around. Mainframes tend to fall in that category. |
.NET Framework dependency |
|.net|dependency| |
When developing a desktop application in .NET, is it possible to not require the .NET Framework? Is developing software in .NET a preferred way to develop desktop applications? What is the most used programming language that software companies use to develop desktop applications? |
|.net|dependencies| |
When developing a desktop application in .NET, is it possible to not require the .NET Framework? Is developing software in .NET a preferred way to develop desktop applications? What is the most used programming language that software companies use to develop desktop applications?
Is the requirement of the .NET Fra... |
|.net|frameworks|dependencies| |
i would consider normalizing as the first step, so cities, counties, states, countries would be better as separate columns... the power of SQL language, together with today DBMS-es allows you to group your data later if you need to view it in some other, non-normalized view.
When the system is being developed, you m... |
I think balance is in order in this case. If it makes sense to put a column in a table, then put it in the table, if it doesn't, then don't. Your coworkers approach would definately help to normalize the database, but that might not be very useful if you have to join 50 tables together to get the information you need... |
There are advantages to having tables with fewer columns, but you also need to look at your scenario above and answer these questions:
Will the customer be allowed to have more than 1 address? If not, then a separate table for address is not necessary. If so, then a separate table becomes helpful because you can eas... |
Just in case you have a getTracker() function in your own code, or similar.
In other words, to avoid naming conflicts with the page's javascript code, probably. |
Just in case you have a getTracker() function in your own code, or similar.
In other words, to avoid naming conflicts with the page's javascript code, probably.
@Theo: Didn't realize (ie, not read carefully enough) they were methods. Then maybe to encourage caution or discourage use? Dunno, really. |
In addition to John Sheehan's anwser:<br />
With JQuery I'd rather use
<br/><code>$('#z').parents('li').addClass('myClass');</code><br/>
than relying on the actual structure. |
|.net|svn|open-source|tfs|cruisecontrol.net| |
|svn|open-source|tfs|cruisecontrol.net| |
Does anyone use template metaprogramming in real life? |
|c++|templates| |
I discovered [template metaprogramming](http://en.wikipedia.org/wiki/Template_metaprogramming) more than 5 years ago and got a huge kick out of reading [Modern C++ Design](http://www.amazon.com/Modern-Design-Programming-Patterns-Depth/dp/0201704315) but I never found an opertunity to use it in real life.
Have *you* ... |
Also just to save you some time, there is no way to change this image during the runtime of your application. If you look at Apple's Clock application you can see how depending on the last state of the application, the Default.png changes. You cannot do this in your own app because of permission limits. Also, make s... |
you can find some nice examples [here][1], and I think the statement that you can use will be something like this:
(from 4guysfromrolla:)
SELECT
FirstName, LastName,
Salary, DOB,
CASE Gender
WHEN 'M' THEN 'Male'
WHEN 'F' THEN 'Female'
END
FROM Employees
... |
Microsoft SQL Server (T-SQL)
In a select use:
select case when Obsolete = 'N' or InStock = 'Y' then 'YES' else 'NO' end
In a where clause, use:
where 1 = case when Obsolete = 'N' or InStock = 'Y' then 1 else 0 end |
I have also used this simple C# made tool.
[http://richnewman.wordpress.com/2007/07/09/c-visual-basic-and-c-net-line-count-utility-version-2/][1]
[1]: http://richnewman.wordpress.com/2007/07/09/c-visual-basic-and-c-net-line-count-utility-version-2/ |
The Reuse/Release Equivalence Principle |
|oop| |
What is the Reuse/Release Equivalence Principle and why is it important? |
The Reuse/Release Equivalence Principle (REP) |
|oop| |
Use a CASE statement:
SELECT CASE
WHEN (Obsolete = 'N' OR InStock = 'Y')
THEN 'Y'
ELSE 'N'
END as Salable
etc... |
All I can think of is to loop over the list of strings (which you have got from performing a split) and doing something like <code>int.TryParse()</code> on them one after the other and putting them into a new <code>List<int></code>. Encapsulate it in a nice little helper method somewhere and it won't be too horri... |
[Math.log10][1](numeric) => float
returns base 10 log
[1]: http://www.ruby-doc.org/core-1.8.7/classes/Math.html#M001197 |
How do you start Knowledge Transfer? |
|knowledge|knowledge-management| |
Do you use a formal event to get people talking in your IT department? Like a **monthly meetup** in a social place, a **internal wiki/chat** space or just a regular "information market" with some **presentations about technology or projects** made by your staff for your staff? Do you invite Sales people to participate ... |
|knowledge-management|knowledge| |
Do you use a formal event to get people talking in your IT department? Like a **monthly meetup** in a social place, a **internal wiki/chat** space or just a regular "information market" with some **presentations about technology or projects** made by your staff for your staff? Do you invite Sales people to participate ... |
There is
Math::log10 (n)
And there is also a property of logarithms that logx(y) = log(y)/log(x) |
The first thing I would do is construct a model of the system to map the data flow and try to understand precisely where the bottleneck lies. If you can model your system as a [pipeline][1], then you should be able to use the theory of constraints (most of the literature is about optimising business processes but it a... |
What is the best way to determine duplicate records in a SQL Server table?
For instance, I want to find the last duplicate email received in a table (table has primary key, receiveddate and email fields).
Sample data:
1 01/01/2008 stuff@stuff.com
2 02/01/2008 stuff@stuff.com
3 01/12/2008 noone@stuff.c... |
Couldn't you join the list on the e-mail field and then see what nulls you get in your result?
Or better yet, count the instances of each e-mail address? And only return the ones with count > 1
Or even take the email and id fields. And return the entries where the e-mail is the same, and the IDs are different. (T... |
something like this
select email ,max(receiveddate) as MaxDate
from YourTable
group by email
having count(email) > 1 |