instruction stringlengths 0 30k ⌀ |
|---|
MySQL 3 and 4:
desc tablename
MSSQL (from 2000) and MySQL 5:
select COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS
where TABLE_NAME = 'tablename' |
MySQL 3 and 4 (and 5):
desc tablename
which is an alias for
show fields from tablename
MSSQL (from 2000) and MySQL 5:
select COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS
where TABLE_NAME = 'tablename'
Completing the answer: Like people below have said, in MSSQL you can also use the st... |
I use [Total Commander's][1] built-in Lister (file viewer). It can show data as text, hex, it can show images. Then there are many plugins that range from code editors / viewers, image viewers etc.
Plugins I use are
- imagine for viewing images
- fileinfo for displaying info of executables
- HTML viewer... |
Python on Windows - how to wait for multiple child processes? |
|python|windows|asynchronous| |
How to wait for multiple child processes in Python on Windows, without active wait (polling)? Something like this _almost_ works for me:
proc1 = subprocess.Popen(['python','mytest.py'])
proc2 = subprocess.Popen(['python','mytest.py'])
proc1.wait()
print "1 finished"
proc2.wait()
prin... |
Test an object for NOT being a type (C#) |
|c#|object|testing|syntax| |
I know how to test an object to see if it is of a type, using the IS keyword e.g.
if (foo is bar)
{
//do something here
}
but how do you test for it not being "bar"?, I can't seem to find a keyword that works with IS to test for a negative result.
BTW - I have a horrible feeling this is ... |
|c#|syntax|object|testing| |
Test an object for NOT being a type |
Git over Email |
|git| |
Assuming network access is sporadic with no central server, what would be the best way to use git to keep three or more branches in sync? Is there a way to extract just my deltas, email those, and merge them on the other end? |
|version-control|git| |
Definately start by reformatting the code, especially indentations.
Then modularise the SQL. Pull out chunks into smaller, descriptively named procedures and functions in their own stand alone files. This alone I find works very well with improving my understanding of large SQL files. |
@Philippe
I assume that you are using the word **admit** as being roughly equivalent to **understand** or perhaps **agree**; as opposed to the opposite of **deny**.
I understand the implications of having all the users login to the database using one ID and password (and having them stored in the application). T... |
System.Diagnostics.Process.Start("http://www.stackoverflow.com"); |
I've always had good results with [lxml](http://codespeak.net/lxml/). It's a pain to install, as it's mostly a wrapper around [libxml2](http://xmlsoft.org/), but `lxml.etree` tree objects have a `.write()` method that takes a file-like object to stream to.
from lxml.etree import XML
tree = XML('<ro... |
C++ syntax, assuming bit 0 is LSB, assuming flags is unsigned long:
Check if Set:
flags & (1UL << (bit to test# - 1))
Check if not set:
invert test !(flag & (...))
Set:
flag |= (1UL << (bit to set# - 1))
Clear:
flag &= ~(1UL << (bit to clear# - 1))
Toggle:
flag ^= (1UL ... |
Well, you may not actually need to adapt.
There is a good chance that a J2ME stack will become available for Android before long since Android is not supposed to become as restrictive of third-party runtimes as the iPhone.
I know one guy who has been working on just that:
http://justanapplication.wordpress.com/
... |
It may depend on the work environment. As a self employed consultant, I'm always in chat - it's my primary communication to the world, along with emails for more official type communications.
Being able to converse with others creates synergy, but it also can cause distractions. A good manager can tell the differe... |
The following code surely works:
Process.Start("http://www.yoururl.com/Blah.aspx");
It opens the default browser (technically, the default program that handles HTTP URIs). |
HRESULT: 0x80131040 |
|.net| |
The located assembly's manifest definition does not match the assembly reference
getting this when running nunit through ncover. Any idea? |
File I/O operations that write to the file will automatically lock the file. Check if the file is locked (by trying the write) and if it is do not write. Before doing any writes, check the timestamp on the file and see if its more than 15 minutes.
afaik you can not write to a file without it being locked by Windows/... |
DataMapper uses the ActiveRecord pattern, right? |
|activerecord|ruby-on-rails|datamapper| |
[DataMapper][1] uses the ActiveRecord ORM pattern, right? I'm trying to understand the differences between it and the ActiveRecord software for Rails.
If so, the pros/cons for the ActiveRecord pattern would then mostly apply to DataMapper, right?
[1]: http://datamapper.org/ |
How does the ActiveRecord pattern differ from the Domain Object or Data Mapper pattern? |
A free tool to check C/C++ source code against a set of coding standards? |
|coding-style|c++|c| |
It looks quite easy to find such a tool for Java ([Checkstyle][1], [JCSC][2]), but I can't seem to find one for C/C++. I am not looking for a lint-like static code analyzer, I only would like to check against coding standards like variable naming, capitalization, spacing, identation, bracket placement, and so on.
... |
|c++|c|coding-style| |
In a language like PHP where a method call that doesn't exist results in a fatal error and takes the whole application down, then yes interfaces make sense.
In a language like Python where you can catch and handle invalid method calls, it doesn't. |
Java: Reading an ASCII file with FileChannel and ByteArrays. |
|java|io|arrays|filechannel|input-file| |
I have the following code:
String inputFile = "somefile.txt";
FileInputStream in = new FileInputStream(inputFile);
FileChannel ch = in.getChannel();
ByteBuffer buf = ByteBuffer.allocateDirect(BUFSIZE); // BUFSIZE = 256
/* read the file into a buffer, 256 bytes at ... |
"Principles of Concurrent and Distributed Programming", M. Ben-Ari<br>
ISBN-13: 978-0-321-31283-9<br>
They have in on safari books online for reading:<br>
[http://my.safaribooksonline.com/9780321312839][1]
[1]: http://my.safaribooksonline.com/9780321312839 |
If you've done your programming in an object-oriented way, you can make use of the [autoload][1] function, which will load classes from their source files on-demand as you call them.
[1]: http://us2.php.net/autoload |
If you've done your programming in an object-oriented way, you can make use of the [autoload][1] function, which will load classes from their source files on-demand as you call them.
**Edit**: I noticed that someone downvoted both answers that referred to autoloading. Are we wrong? Is the overhead of the __autoloa... |
Windsor Container: Registering things in Code vs Xml |
|castle-windsor|.net| |
From what I've read about Windsor/Microkernel it is in theory possible to do everything that you can do using xml files with code. As a matter of fact - and please correct me if I'm wrong - it seems like the major contribution of the Windsor layer is to add xml configuration for things Microkernel can already do.
... |
You have a problem there. I don't know if thats a simplified scenario of your code, but if the Helper class is used that way, then your code is not testable. First, the Helper class is used directly, so you **can't replace it with a mock**. Second, you're calling a static method. I don't know about C#, but in Java you ... |
You have a problem there. I don't know if thats a simplified scenario of your code, but if the Helper class is used that way, then your code is not testable. First, the Helper class is used directly, so you **can't replace it with a mock**. Second, you're calling a static method. I don't know about C#, but in Java you ... |
You have a problem there. I don't know if thats a simplified scenario of your code, but if the Helper class is used that way, then your code is not testable. First, the Helper class is used directly, so you **can't replace it with a mock**. Second, you're calling a static method. I don't know about C#, but in Java you ... |
I don't think this is possible -- if you use the browser's HTTP client implementation, it will always pop up that dialog. Two hacks come to mind:
1. Maybe Flash handles this differently (I haven't tried yet), so having a flash movie make the request might help.
2. You can set up a 'proxie' for the service that ... |
I would use AccuRev. I've used svn, cvs, clearcase (base, usm), ccc/harvest, but none of them can beat AccuRev's strengths. "3000+ developer organization with several site"? you can use Accurev distributed solution (AccuReplica) for that - which mean you have one single master server and as many as you want replicas on... |
Do you have a problem with standard SSH connections to the server as well? If it's generally slow to connect to your server via SSH, this could be a problem with reverse DNS lookups.
Andrew |
It's not actually a C# hidden feature, but I recently discovered the [WeakReference class][1] and was blown away by it (although this may be biased by the fact that it helped me found a solution to a [particular problem of mine][2]...)
[1]: http://msdn.microsoft.com/en-us/library/system.weakreference.aspx
[2]... |
Here's the quick answer
gci -r -i *.log | select-string ERROR
I found it [here](http://www.interact-sw.co.uk/iangblog/2006/06/03/pshfindstr) which has a great indepth answer!
|
Yes I know that in the old days Memory Leaks are an entirily different subject. But with managed code, new meaning to the term Memory Leak might be more appropiate...
Microsoft even acknowledges it to be a memory leak:
> Why Implement the WeakEvent Pattern?
>
> Listening for events can lead to
> memory leaks.... |
Just use TortoiseSVN, and you can live even without knowing actual Subversion commands... But that's bad. Luckily there will always be a “great opportunity” to learn them by heart — when your priceless repository first gets corrupted.
Yes, it happens.
|
Profiler may seem like a "needle in a haystack" approach, but it may turn up something useful. Try running it for a couple of minutes while the databases are under typical load, and see if any queries stand out as taking way too much time or hogging resources in some way. While a situation like this could point to some... |
If you can't use cookies because it's cross domain then encrypt it, with a nonce.
Setup a shared secret/key between the two servers; send the encrypted GUID and nonce combination to the second server. Unencrypt, check the nonce hasn't already been used (to stop reply attacks), then use the unencrypted GUID.
Even ... |
If you can't use cookies because it's cross domain then encrypt it, with a nonce.
Setup a shared secret/key between the two servers; send the encrypted GUID and nonce combination to the second server. Unencrypt, check the nonce hasn't already been used (to stop reply attacks), then use the unencrypted GUID.
If yo... |
Licensing Websites - How does it work? |
|website|licensing| |
I've been looking at several sites that offer a form of "linkware" license where you get the website for free but need to keep all links to the developers site in place. Purchasing a license key and adding it to the site (either in a database or some form of config file) removes these links.
I was wondering if anyon... |
Theres a proper mechanism for communicating with plugins, RPlugin.
Do not use RFile. I'm not even sure that it would work as the path is checked in Initialise of RFile functions which is called before the plugin stack. |
Here are instructions for building Cairo/Cairomm with Visual C++.
Required:
Visual C++ 2008 Express SP1 (now includes SDK)
MSYS 1.0
To use VC++ command line tools, a batch file 'vcvars32.bat' needs to be run.
C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\vcvars32.bat
ZLib
... |
Here are instructions for building Cairo/Cairomm with Visual C++.
Required:
- Visual C++ 2008 Express SP1 (now includes SDK)
- MSYS 1.0
To use VC++ command line tools, a batch file 'vcvars32.bat' needs to be run.
<pre>
C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\vcvars32.bat
</p... |
"Mysql server has gone away" with Rails |
|mysql|ruby-on-rails| |
After our rails app has run for a while, it starts throwing 500s with "Mysql server has gone away". Often this happens overnight. It's started doing this recently, with no obvious change in our server configuration.
Mysql::Error: MySQL server has gone away: SELECT * FROM `widgets`
Restarting the mongrels (no... |
Code to provide:
<script language="javascript" type="text/javascript">
document.write("<script language='javascript' type='text/javascript'>function callGeneratedContent() { alert('during'); }<\x2Fscript>");
document.write("<script language='javascript' type='text/javascript' src='before.js'><\x2Fscrip... |
I would use AccuRev. I've used svn, cvs, clearcase (base, ucm), ccc/harvest, but none of them can beat AccuRev's strengths. "3000+ developer organization with several site"? you can use Accurev distributed solution (AccuReplica) for that - which mean you have one single master server and as many as you want replicas on... |
> LINQ to Active Directory implements a
> custom LINQ query provider that allows
> querying objects in Active Directory.
> Internally, queries are translated
> into LDAP filters which are sent to
> the server using the
> System.DirectoryServices .NET
> Framework library.
<http://www.codeplex.com/LINQtoAD>
... |
In response to Frank Krueger's request above (in comments) for a demonstration of a difference:
Compile this code in gcc with no optimizations and -mfpmath=387 (I have no reason to think it wouldn't work on other compilers, but I haven't tried it.)
Then compile it with no optimizations and -msse -mfpmath=sse.
Th... |
It is not exactly a blog engine but you may find [Typolight][1] interesting. It is very easy to use and fairly extensible.
[1]: http://www.typolight.org/ |
(Stolen from Joel :o) )
Don't disable/remove options - rather give a helpful message when the user click/select it. |
Have you tried
identify -ping filename.png
? |
Scrum is a bottom up process, so in principle every team member should support the process.
How is the team put together? By organizational tradition or because of a common goal?
Not everybody buy into the Scrum idea, and we should respect that. Perhaps the best for all is that these members are not part of the... |
I kinda like [b2evo][1] we used it on [our site][2] and modded it to great effect.
[1]: http://b2evolution.net/
[2]: http://blogs.lessthandot.com/ |
@Philippe
I assume that you are using the word **admit** as being roughly equivalent to **understand** or perhaps **agree**; as opposed to the opposite of **deny**.
I understand the implications of having all the users login to the database using one ID and password (and having them stored in the application). T... |
What I was hoping to do (which I just experimented with) was to refresh the links to the database something like this for each table (Note: I've switched the ODCB connection to SQL Server authentication for this experiment, and added the accounts to the SQL server as well: **readonly** - which can't to any updates, and... |
There are several options available to you:
- You can open a new window with slightly different data to be printed.
- There are also CSS styles which you can use to alter the page layout.
- Finally you can specify completly different style sheets for screen, printed media, Braille readers etc.
e.g. `<lin... |
I'm assuming that php has an associative array (commonly called dictionary or hashtable). The most efficient routine would be to run over the array once and put the fields into a dictionary keyed on the field name.
Then instead of having to search through the original array when you want to find a specific field (an... |
Use File::Spec;
File::Spec->rel2abs( \_\_FILE\_\_ );
http://perldoc.perl.org/File/Spec/Unix.html
|
|.net|inversion-of-control|castle-windsor| |
Modeling is creating an abstraction of a problem, where as programming is the implementation of such an abstraction.
Modeling can be done in many ways: textual, formulas, diagrams... UML is one standard of modeling object oriented concepts.
Programming can be done in different ways too, depending on the tool, lan... |
Does customising `mf-max-width' work? Its documentation:
"*The maximum display width to support. This helps better support the true
nature of display-pixel-width. Since multiple monitors will result in a
very large display pixel width, this value is used to set the stop point for
maximizing the... |
Maybe this is just one case where you could use tables to enforce layout. It's not optimal, and I know you aren't supposed to use tables for things that aren't tabular, but you could do something like this.
<table>
<tr>
<td><img src="Pin.jpg"></td>
<td> </td>
<td><img src="Pin.jpg"></... |
Case or the kind of conditional construct your RDBMS supports is a way to do it
select *, case when col like '%foo%' and col like '%bar%' then 2 end when col like
'%foo%' or col like '%bar%' then 1 end else 0 end as ordcol from items where col like
'%foo%' and col like '%bar%' order by ordcol |
Case or the kind of conditional construct your RDBMS supports is a way to do it
select *, case when col like '%foo%' and col like '%bar%' then 2 end
else 1 end as ordcol
from items
where col like '%foo%' and col like '%bar%' order by ordcol |
Case or the kind of conditional construct your RDBMS supports is a way to do it
select *, case when col like '%foo%' and col like '%bar%' then 2 end
else 1 end as ordcol
from items
where col like '%foo%' or col like '%bar%' order by ordcol |
This is caused by how each browser implements HTML design mode, and unfortunately, they all seem to mangle perfectly good HTML. There's no option to prevent this behavior, but some post processing could be done with JavaScript using regular expressions to tidy things up (or using a [JS HTML parser][1].)
[1]: htt... |
- function, no template function, yes
- template, I think so (but C++
- templates are not my thing)
**Edit:** From Doug's code
template <typename T>
uint32_t StructSize()
{
return sizeof(T)/sizeof(*T);
}
// or
class StructSize<typename T>
{
enum { resu... |
- function, no template function, yes
- template, I think so (but C++
- templates are not my thing)
**Edit:** From Doug's code
template <typename T>
uint32_t StructSize()
{
return sizeof(T)/sizeof(*T);
}
// or to get it at compile time
class StructSize<typename T>
... |
- function, no template function, yes
- template, I think so (but C++
- templates are not my thing)
**Edit:** From Doug's code
template <typename T>
uint32_t StructSize() // This might get inlined to a constant at compile time
{
return sizeof(T)/sizeof(*T);
}
// or to ge... |
Javascript drawing library? |
|javascript|ajax|graphics| |
Any suggestion for a JS interactive drawing library? Just need to draw lines, polygons, texts of different colors. IE/Firefox/Opera/Safari compatible. |
Do you need to do this programmatically, or is it a one-time shot?
Using the Enterprise Manager, right-click Import Data lets you select your delimiter. |
Yup, K Richard is right: `FIELDTERMINATOR = '","'`
See http://www.sqlteam.com/article/using-bulk-insert-to-load-a-text-file for more info. |
From Eric Lippert, a Senior Software Design Engineer on the C# team:
Why was the `var` keyword introduced?
> There are two reasons, one which
> exists today, one which will crop up
> in 3.0.
>
> The first reason is that this code is
> incredibly ugly because of all the
> redundancy:
>
>
> `Dictionary<... |
How to check PDF-A 1b compliance with open source tools? |
|java|open-source|pdf| |