instruction stringlengths 0 30k ⌀ |
|---|
Can you use Boost String Algo? http://www.boost.org/doc/libs/1_35_0/doc/html/string_algo/usage.html#id1290573
erase_all(str, " "); |
I believe what you're referring to is a known php bug. Php 5.3 is aiming to address this issue with a new Late Static Binding feature.
<http://www.colder.ch/news/08-24-2007/28/late-static-bindings-expl.html> |
Use the [video4linux][1] library. I've used it with a c++ program and was able to capture webcam frames within about an hour. (Very easy to use and setup)
[1]: http://en.wikipedia.org/wiki/Video4Linux |
There is the following Levenshtein Distance Algorithm which assigns a value to the similarity of two strings (well, the difference actually), that could be used to build upon: <http://www.merriampark.com/ldcsharp.htm>. |
Although it is not in one 'replace' call, you can nest the replace calls
SET mycol = replace( replace(mycol, '{1}', 'myoneval'), '{2}', mytwoval) |
You can use named scopes in rails 2.1 and above
Class Test < ActiveRecord::Base
named_scope :created_on, :conditions => {:created_on => some_date}
named_scope :othet_condition, :conditions => {whatever hash of options you want}
end
then you can do
Test.created_on.other_condition |
If your database is straightforward and simple, LINQ to SQL will do. If you need logical/abstracted entities on top of your tables, then go for Entity Framework. |
SELECT column FROM table ORDER BY column DESC LIMIT 7,10;
Would skip the first 7, and then get you the next ten highest. |
You didn't specify which database, on MySQL you can do
SELECT column FROM table ORDER BY column DESC LIMIT 7,10;
Would skip the first 7, and then get you the next ten highest. |
You can run MSTSC /admin or MSTSC /console depending on what version you have installed which will then connect to the console sessions |
In addition to the three tools listed in the question, there's another one called [Cava Packager][1] written by Mark Dootson, who has also contributed to [PAR][2] in the past. It only runs under Windows, has a nice Wx GUI and works differently from the typical three contenders in that it assembles all Perl dependencies... |
nemiver is a great front end to gdb (looks better than ddd imo even though it might not be as advanced yet). |
The secret is to start Windows Terminal server client with the /console command so:
mstsc.exe /console
This will connect you to the existing cosole session rather than connecting you to a new session.
XP does this by default as it only supports a single (console) session. Windows Server support multiple sessi... |
Also, depending on your intentions, and what libraries you are using, you may want to use the [TRACE macro][1] ([MFC][2]) or [ATLTRACE][3] ([ATL][4]).
[1]: http://msdn.microsoft.com/en-us/library/4wyz8787(VS.80).aspx
[2]: http://en.wikipedia.org/wiki/Microsoft_Foundation_Class_Library
[3]: http://msdn.micr... |
Active threads in ExecutorService |
|java|multithreading|concurrency| |
Any ideas how to determine the number of active threads running in ExecutorService? |
If you want to know the amount of data that it's expected to arrive, you could always write at the begining of every msg sent by the pipes the size of the msg.
So write for example 4 bytes at the start of every msg with the length of your data, and then only read the first 4 bytes.
|
A few miscellaneous thoughts on this topic:
1. There is nothing unsafe about any of the hash iterators themselves. What is unsafe is modifying the keys of a hash while you're iterating over it. (It's perfectly safe to modify the values.) The only potential side-effect I can think of is that `values` returns aliases ... |
A few miscellaneous thoughts on this topic:
1. There is nothing unsafe about any of the hash iterators themselves. What is unsafe is modifying the keys of a hash while you're iterating over it. (It's perfectly safe to modify the values.) The only potential side-effect I can think of is that `values` returns aliases ... |
The comparison is to ensure readline terminates when it encounters a newline character (the '\n'). On the iteration where it does, it terminates without adding the newline to the string, so the statement after that ensures that the string is always newline terminated, even if one of the other termination conditions was... |
That ensures that you stop at the end of the line even if it's not the end of the input. Then if there is a newline the \n is added to the end of the line and i incremented one more time to avoid overwriting it with the \0. |
One method for creating several objects or several methods for creating single objects? |
|database|performance| |
If I have the following:
Public Class Product
Public Id As Integer
Public Name As String
Public AvailableColours As List(Of Colour)
Public AvailableSizes As List(Of Size)
End Class
and I want to get a list of products from the database and display them on a page a... |
The person who taught my team agile development didn't believe in planning, you only wrote as much for the tiniest requirement.
His motto was refactor, refactor, refactor. I came to understand that refactor meant 'not planning ahead'.
|
I use it only occasionally, and generally for some particular reason. I will always be a happier developer with my code separated entirely from my HTML markup. It's somewhat a personal preference, but I would say this is a better practice. |
- Does it happen on all projects or a specific one?
- Does it only occurs when a specific file is open?
- Try re-installing visual studio and any/all service packs. |
You need to specify the actual type you will be handling
so it would be something like...
public static string GetDefaultPageTitle(this ViewPage<YourSpecificType> v)
{
...
}
Note intellisense will then only display the instance method when you declare your (in this case) ViewPage with the ... |
If you want the extension to only be available for the specified type
you simply just need to specify the actual type you will be handling
something like...
public static string GetDefaultPageTitle(this ViewPage<YourSpecificType> v)
{
...
}
Note intellisense will then only display the ext... |
My experience has been that the best way to migrate to AS3 is in two phases - first structurally, and second syntactically.
First, do rounds of refactoring where you stay in AS2, but get as close to AS3 architecture as you can. Naturally this includes moving all your frame scripts and #include scripts into packages ... |
I think the `Game` Class should not concern about any implementations of the Player classes, and also ignore the User Interface.
Any user input needs to be handled by the `HumanPlayer` class. |
According to [this bug][1], there is currently no way to create optional parameters.
[1]: http://bugs.mysql.com/bug.php?id=15975 |
Occam-pi
PROC subprocess(MOBILE CHAN INT parent.out!,parent.in?)
INT value:
SEQ
parent.in ? value
IF
value = 1
SEQ
parent.out ! value
OTHERWISE
INITIAL MOBILE CHAN INT child.in IS MOBILE CHAN INT:
... |
You can either use:
"texta'textb" (APOSTROPHE inside QUOTATION MARKs)
or
'texta'\''textb' (APOSTROPHE text APOSTROPHE, then REVERSE SOLIDUS, APOSTROPHE, then APOSTROPHE more text APOSTROPHE)
I used unicode character names. REVERSE SOLIDUS is more commonly known as backslash.
In the latter case, y... |
You don't need to write your own conversion code. Just use
XmlConvert.ToDateTime()
to parse a RFC-3339 string, and
DateTime.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ")
to convert a (UTC) datetime to a string. |
You don't need to write your own conversion code. Just use
XmlConvert.ToDateTime()
to parse a RFC-3339 string, and
XmlConvert.ToString()
to convert a (UTC) datetime to a string. |
Excel report framework |
|windows|excel| |
Is there any Excel report framework available? We need to export some of the reports into Excel format. Our application is java application hence anything supporting java would be great. I have tried Apache POI API, however that is not good enough. Any framework based on Windows API would be better. |
Automated tests for Java Swing GUIs |
|java|testing|swing| |
What options are there for building automated tests for GUIs written in Java Swing?
I'd like to test some GUIs which have been written using the [NetBeans Swing GUI Builder][1], so something that works without requiring special tampering of the code under test would be ideal.
[1]: http://www.netbeans.org/feat... |
You not only need to run it in transaction, it also needs high isolation level. I fact default isolation level is Read Commited and this code need Serializable.
SET transaction isolation level SERIALIZABLE
BEGIN TRANSACTION Upsert
UPDATE myTable set Col1=@col1, Col2=@col2 where ID=@ID
if @@rowcou... |
Which compiler are you using? For example, this is a trivial matter in MS Visual Studio. |
Which compiler are you using? For example, if I understand your question correctly, this is a trivial matter in MS Visual Studio. |
Others have directly answered your question, but when trying to understand the stack and the heap, I think it is helpful to consider the memory layout of a traditional UNIX process (without threads and `mmap()`-based allocators). The [Memory Management Glossary][1] web page has a diagram of this memory layout.
The s... |
Others have directly answered your question, but when trying to understand the stack and the heap, I think it is helpful to consider the memory layout of a traditional UNIX process (without threads and `mmap()`-based allocators). The [Memory Management Glossary][1] web page has a diagram of this memory layout.
The s... |
You can subscribe to the PropertyChanged event of the DataObject class and make a RoutedEvent fire from Usercontrol level.
For RoutedEvent to work we need to have the class derived from DependancyObject |
SQLite is great.
A single file, crossplatform, a tiny library, SQL access to data, transactions, the whole enchilada.
you can use transactions to guarantee consistent return points in case of crashing. check [uses for sqlite][1], they specifically advocate using it as a data model layer for desktop applications.... |
Keep in mind that usually <> always.
Since WAS 6.0 and up you usually want to setup more than one node in each physical computer, given the usual power of the server you use the node to separate logical business entities.
Like for example have 6 nodes, 3 in each of 2 machines and have 1 pair of nodes you could de... |
Dale - That's it exactly. If you want to provide access to the underlying data store to those users then do it via services. And in my experience, it is those experienced computer users coming out of Uni/College that damage things the most. As the saying goes, they know just enough to be dangerous.
If they want to a... |
As someone familiar with Visual Studio, I've looked at several open source IDE's to replace it, and KDevelop comes the closest IMO to being something that a Visual C++ person can just sit down and start using. When you run the project in debugging mode, it uses gdb but kdevelop pretty much handles the whole thing so t... |
The AIX debugger for windows, let's you debug multithread applications.
|
What exactly do you mean by **"frameworks"**. This word is overloaded so much in our industry. If you mean something like MFC or .Net then I think they are here to stay. They have nothing to do with performance at runtime. *They have everything to do with code reuse, maintainability and separation of concerns.*
By t... |
Can you copy the files? I'd be curious to know if you can copy the files to your laptop and then attach them there. I would guess it is some kind of permissions error also, but it sounds like you've done the work to fix this.
Are there any attributes on the file? |
If you were on Sql Server 2005 you could use this:
print master.sys.fn_varbintohexstr(@binvalue)
I don't think that exists on 2000, though, so you might have to roll your won. |
Tag libraries are fine if you're using JSP, but you can also achieve I18N using a template-based technology such as [FreeMarker][1].
[1]: http://freemarker.sourceforge.net/ "FreeMarker" |
Uninitialized memory blocks in VC++ |
|c++|memory|microsoft|allocation| |
As everyone* knows, the Visual C++ runtime marks uninitialized or just freed memory blocks with special non-zero markers. Is there any way to disable this behavior entirely without manually setting all uninitialized memory to zeros? It's causing havoc with my valid not null checks, since 0xFEEEFEEE != 0. |
As everyone* knows, the Visual C++ runtime marks uninitialized or just freed memory blocks with special non-zero markers. Is there any way to disable this behavior entirely without manually setting all uninitialized memory to zeros? It's causing havoc with my valid not null checks, since 0xFEEEFEEE != 0.
Hrm, perhap... |
How can I print a binary value as hex in TSQL? |
|t-sql|sql-server| |
I'm using SQL Server 2000 to print out some values from a table using <code>PRINT</code>. With most non-string data, I can cast to nvarchar to be able to print it, but binary values attempt to convert using the bit representation of characters. For example:
DECLARE @binvalue binary(4)
SET @binvalue = 0x12... |
|sql-server|t-sql| |
I'm using SQL Server 2000 to print out some values from a table using <code>PRINT</code>. With most non-string data, I can cast to nvarchar to be able to print it, but binary values attempt to convert using the bit representation of characters. For example:
DECLARE @binvalue binary(4)
SET @binvalue = 0x12... |
The
(f.x = 1)
**is not an expression, it is an assignment** and thus returns the assigned value. In this case, the size of that value depends on the variable, it has been assigned to.
unsigned x:1
has 1 Bit and its sizeof returns 1 byte (8 bit alignment)
If you would use
unsigned x:12
... |
Twisted contains a [large number of examples][1]. One in particular, the ["evolution of Finger" tutorial][2], contains a thorough explanation of how an asynchronous program grows from a very small kernel up to a complex system with lots of moving parts. Another one that might be of interest to you is the tutorial abo... |
Besides using it as intended, volatile is used in (template) metaprogramming. It can be used to prevent accidental overloading, as the volatile attribute (like const) takes part in overload resolution. |
There's an excellent project called Dancing Monkeys, which procedurally generates DDR dance steps from music. A large part of what it does is based on (necessarily very accurate) beat analysis, and their project paper goes into much detail describing the various beat detection algorithms and their suitability to the ta... |
If true persistence isn't required how about using something more temporal like memcached instead of SQL? Calling semantics are pretty clean and easy - and of course you can expire the data manually, ttl, or @ restart. |
The best (and I think official) place to find out about this is on Andrew Kennedy's blog.
Here are the (current) relevant posts.
- [Units of Measure in F#: Part One, Introducing Units][1]
- [Units of Measure in F#: Part Two, Unit Conversions][2]
- [Units of Measure in F#: Part Three, Generic Units][3]
As I s... |
Although I would suggest the Apache approach is better, SVN Serve works fine and is pretty straightforward.
Assuming your repository is called "my_repo" and it is stored in c:\svn_repos :
1. Create a file called "passwd" in "C:\svn_repos\my_repo\conf". This file should look like:
[Users]
username = passwo... |
I am not sure since I am not an Oracle user, but I assume that the difference lies when you use multi-byte character sets such as Unicode (UTF-16/32). In this case, 11 Bytes could account for less than 11 characters.
Also those field types might be treated differently in regard to accented characters or case, for ex... |
I like this one:
[Miscellaneous Utility Library][1]
[1]: http://www.yoda.arachsys.com/csharp/miscutil/ |
In regards to Javascript
The === operator works the same as the == operator but requires that its operands have not only the same value, but also the same data type.
For example the sample below will display 'x and y are equal' but not 'x and y are identical'
var x = 4;
var y = '4';
if (x == y) {... |
Create Generic method constraining T to an Enum |
|c#|generics|enums| |
I'm building a function to extend the Enum.Parse concept that
- allows a default value to be parsed in case that an Enum value is not found
- Is case insensitive
So I wrote the following
public static T GetEnumFromString<T>(string value, T defaultValue) where T : Enum
{
... |
I'm building a function to extend the Enum.Parse concept that
- allows a default value to be parsed in case that an Enum value is not found
- Is case insensitive
So I wrote the following
public static T GetEnumFromString<T>(string value, T defaultValue) where T : Enum
{
... |
I'm building a function to extend the Enum.Parse concept that
- allows a default value to be parsed in case that an Enum value is not found
- Is case insensitive
So I wrote the following
public static T GetEnumFromString<T>(string value, T defaultValue) where T : Enum, IConvertible
... |
The interface that *Player* presents to *Game* is orthogonal to the behaviour of derived *Player* classes.
The fact that the implementation of *TakeTurn* varies depending on the concrete type of the *Player* object should not be a cause for concern. |
I'm afraid that is not possible.
Maybe you can take another approach: build an alternate way for users to change the permissions of an item. When the user applies the permissions (using the UI you've built), you can trigger an event, or start a workflow.
Going further, you could replace the default "Manage permis... |
Functional testing is a mandatory part of any project. Unit testing is great and it works well for Agile projects but the functional testing is still necessary. You need at least a basic Test Plan. If you plan to have multiple projects or sub-projects a Test Strategy document or Wiki page would be good.
Test Cases, Ac... |
As JeroenWyseur puts it, J2EE is a fairly big space. In addition to what he said, you should try to get more details of what exactly you'll be doing: servelts & co, EJB (entity, session, message beans?) and try to get familiar with that.
It should be clear for you that your code runs in a managed environment, which... |
If you have access to `netstat`, that can do precisely that. |
Do you really need a save button?
you could listen for the end of the node edit - for instance by listening for the "return" key in the KeyDown event of the TreeView. if you're editing something (find out with SelectedNode.IsEditing) then you know you have a commit. You can then commit this to your dataupdate stuff.... |
[SQL Server Reporting Services][1] has options to export to Excel.
[1]: http://www.microsoft.com/sql/technologies/reporting/default.mspx |
Run it through a bunch of checkers. Check the HTML is valid. Try to use it with script disabled. Try to use it with CSS disabled. You can do all of this with the [web developer addon][1] for Firefox
[1]: https://addons.mozilla.org/en-US/firefox/addon/60 |
You might take a look at this [http://code.google.com/p/urlrewritefilter/][1]
[1]: http://code.google.com/p/urlrewritefilter/ |
Can you copy the files? I'd be curious to know if you can copy the files to your laptop and then attach them there. I would guess it is some kind of permissions error also, but it sounds like you've done the work to fix this.
Are there any attributes on the file?
Update: If you can't copy the files then somethin... |
[KDevelop][1] is nice, especially if you run KDE. It supports many languages, as an added bonus. I've found its embedded terminal really useful.
[1]: http://www.kdevelop.org |
How do you reference .js files located within the View folders from a Page using Asp.net MVC |
|c#|asp.net|javascript|mvc| |
For example, if I have a page located in Views/Home/Index.aspx and a javascript file located in Views/Home/Index.js, how do you reference this on the aspx page?
The example below doesn't work even though the compiler says the path is correct
<script src="Index.js" type="text/javascript"></script>
The exact... |
zentiy is really the exact tool that I think that you are looking for
http://live.gnome.org/Zenity
or $zenity --help |
I haven't had to do something of this scale, but I have a few ideas. First off, start by taking a small, unimportant project, and migrate that. That will give you an idea of how much trouble it is going to take to migrate the rest of the projects. Immediately after that you should choose a medium size project as the... |
Best C++ IDE for *nix |
|c++|ide| |