instruction stringlengths 0 30k ⌀ |
|---|
@Alexandru & Jeremy, Thanks for your help. You both get upvotes
@Jeremy
Using your method I got the following error:
> sed: -e expression #1, char 8:
> unterminated `s' command
If you can edit your answer to make it work I'd accept it. (pasting my solution doesn't count) |
@Alexandru & Jeremy, Thanks for your help. You both get upvotes
@Jeremy
Using your method I got the following error:
> sed: -e expression #1, char 8:
> unterminated `s' command
If you can edit your answer to make it work I'd accept it. (pasting my solution doesn't count)
**Update:** Ok, I tried it ... |
@Alexandru & Jeremy, Thanks for your help. You both get upvotes
@Jeremy
Using your method I got the following error:
> sed: -e expression #1, char 8:
> unterminated `s' command
If you can edit your answer to make it work I'd accept it. (pasting my solution doesn't count)
**Update:** Ok, I tried it ... |
Yes, I thought about that, but I soon figured out that another Domain-Specific-Language (DSL) would be a bit too much.
Essentially, they need to interact with my Gamestate in possibly unpredictable ways. For example, a card could have a rule "When this cards enter play, all your Undead Minions gain +3 Attack against... |
@Ryan
That's correct but it actually makes the tags with the least number, larger. This code has been tested:
$artist = array("the roots","michael jackson","billy idol","more","and more","and_YET_MORE");
$count = array(5,3,9,1,1,3);
$highest = max($count);
for ($x = 0; $x < count($artist); $x+... |
I know that Visual Studio itself (at least in 2003 version) references the IE dll directly to render the "Design View".
It may be worth looking into that.
Otherwise, I can't think of anything beyond the Web Browser control. |
Looking around, and using some C# 3.0 features we can do this:
foreach (KeyValuePair<string, int> item in keywordCounts.OrderBy(key => key.Value))
{
// do something with item.Key and item.Value
}
This is the cleanest way I've seen and is similar to the Ruby way o... |
On a high level, you have no other choice then to walk through the whole Dictionary and look at each value.
Maybe this helps:
http://bytes.com/forum/thread563638.html
Copy/Pasting from John Timney:
Dictionary<string, string> s = new Dictionary<string, string>();
s.Add("1", "a Item");
s.Add("2", "c... |
I usually just specify this in an .htaccess file _or_ the vhost.conf on the domain I'm working on:
php_admin_value error_log "/var/www/vhosts/example.com/error_log" |
myList.Sort(
delegate(KeyValuePair<string, string> firstPair,
KeyValuePair<string, string> nextPair)
{
return firstPair.Value.CompareTo(nextPair.Value);
}
);
Since you're targeting .net 2.0 or above, you can simplify this into lambda syntax -- it's equivalent but... |
Design problems with .Net UserControl |
|c#|vs2005|.net-2.0|user-controls| |
I have created a UserControl that has a ListView in it. The ListView is publicly accessible though a property. When I put the UserControl in a form and try to design the ListView though the property, the ListView stays that way until I compile again and it reverts back to the default state.
How do I get my design c... |
|c#|.net-2.0|user-controls| |
I also disagree about starting with the database. The DB is simply an artifact of how your business objects are persisted. I don't know of an equivalent in Java, but .Net has stellar tools such as [SubSonic](http://subsonicproject.com/) that allow your DB design to stay fluid as you iterate through your business obje... |
How do you use #define? |
|c#|.net| |
I'm wondering about instances when it makes sent to use #define and #if statements. I've known about it for a while, but never incorporated it into my way of coding. How exactly does this affect the compilation? |
I'm wondering about instances when it makes sent to use #define and #if statements. I've known about it for a while, but never incorporated it into my way of coding. How exactly does this affect the compilation?
>Is #define the only thing that determines if the code is included when compiled? If I have #define DEBUG... |
|c#| |
The Debugger :-) Beats Notepad by miles. |
Minimize javascript HTTP calls from AjaxControlToolkit controls? |
|asp.net|ajax|frontend| |
I love the ease that the ASP.NET Ajax control Toolkit provides to ASP.NET developers. However, I've not found it to be a scalable solution at all. I have a page with 2 date input fields. By putting a TextBox and an CalendarExtendar control attached to it for each date field, I get several (11, in fact) external Javascr... |
I previously organised my DDL code organised by one file per entity and made a tool that combined this into a single DDL script.
My former employer used a scheme where all table DDL was in one file (stored in oracle syntax), indicies in another, constraints in a third and static data in a fourth. A change script was... |
For the first draft, I prefer to use graph paper (the stuff with a grid printed on it) and a pencil. The graph paper is great for helping to maintain proportions. Once the client and I have come to a conclusion I'll usually fill in the drawing with pen since pencil is prone to fading.
When I actually get aroun... |
How do you typeset code elements in normal text? |
|language-agnostic|format| |
Something I've run into posting on SO: when you refer to a function with arguments, what is the best way to typeset it for readibility, brevity, and accuracy? I tend to put empty parentheses after the function name like `func()`, even if there are actually arguments for the function. I have trouble including the argu... |
[GoldenGate][1] is a very good solution, but probably as expensive as the MySQL replicator.
It basically tails the journal, and applies changes based on what's committed. They support bi-directional replication (a hard task), and replication between heterogenous systems.
Since they work by processing the journal... |
The more the better. As programming languages start to become more complex and abstract, the more processing power that will be required.
Atleat Jeff believes [Quadcore is better][1].
[1]: http://blog.stackoverflow.com/2008/04/our-dedicated-server/ |
Besides the already mentioned Robocopy, [XXCOPY](http://www.xxcopy.com) has a free version. Its syntax is backwards compatible with XCOPY, but has tons of additional options (XXCOPY /HELP > x create a 42kb file with all the options available). For instance, you can delete files with it, include or exclude a list of dir... |
I would simply be a little more careful with the name of my variables and parameters, most people will then be able to guess much more accurately what type of data you want to hold in it. |
Setup Visual Studio 2005 to print line numbers |
|visual-studio| |
How can I get line numbers to print in Visual Studio 2005 when printing code listings? |
Isn't there an option in the Print Dialog?
Edit: There is. Go to File => Print, and then in the bottom left there is "Print what" and then "Include line Numbers" |
We use apache on linux, which forks a process to handle requests. We've found that more cores help our throughput, since they reduce the latency of processes waiting to be placed on the run queue. I don't have much experience with IIS, but I imagine the same scenario applies with its thread pool. |
Subversion ignoring "--password" and "--username" options |
|svn|version-control| |
When I try to do any svn command and supply the "--username" and/or "--password" options, it prompts me for my password anyways, and always will attempt to use my current user instead of the one specified in "--username".
For example, logged in as user1:
# svn update --username 'user2' --password 'password'
... |
When I try to do any svn command and supply the "--username" and/or "--password" options, it prompts me for my password anyways, and always will attempt to use my current user instead of the one specified in "--username".
For example, logged in as user1:
# svn update --username 'user2' --password 'password'
... |
When I try to do any svn command and supply the "--username" and/or "--password" options, it prompts me for my password anyways, and always will attempt to use my current user instead of the one specified in "--username". Neither "--no-auth-cache" nor "--non-interactive" have any effect on this.
For example, logged... |
I think that "The Art of Unix Programming" is an excellent book, by an excellent hacker/brilliant mind as Eric S. Raymond, who tries to make us understand a few principles of software design (simplicity mainly). This book is a must for every programming who is about to start a project under Unix platform.
|
@Damian - Good point about the tagging and cross referencing. That's true; while I haven't working with many designers on a software development project, I have worked for a company that had a design department and know that this is an issue. Designers are still (perpetually) looking for the perfect system to handle ... |
What [Edmund][1] said.
As for not calling .add all the time, no, not idiomatically. There would be various hacks (storing it in an array and then looping) that you could do if you really wanted to, but I wouldn't recommend it.
[1]: http://stackoverflow.com/questions/29324/how-do-i-create-a-hash-table-in-java#... |
Map map = new HashMap();
Hashtable ht = new Hashtable();
The difference between the 2 is explained in the following <a href="http://www.jguru.com/faq/view.jsp?EID=430247">jGuru FAQ entry</a>.
Both classes can be found from the java.util package
|
Map map = new HashMap();
Hashtable ht = new Hashtable();
Both classes can be found from the java.util package. The difference between the 2 is explained in the following <a href="http://www.jguru.com/faq/view.jsp?EID=430247">jGuru FAQ entry</a>.
|
Which PHP opcode cacher should I use to improve performance? |
|php|performance|caching| |
I'm trying to improve performance under high load and would like to implement opcode caching. Which of the following should I use?
* APC
* eAccelerator
* XCache
I'm also open to any other alternatives that have slipped under my radar.
Currently running on a stock Debian Etch with Apache 2 and PHP 5.2 |
I'm trying to improve performance under high load and would like to implement opcode caching. Which of the following should I use?
* APC - <a href="http://www.howtoforge.com/apc-php5-apache2-debian-etch">Installation Guide</a>
* eAccelerator - <a href="http://www.howtoforge.com/eaccelerator_php5_debian_etch">Instal... |
How do you sort a C# dictionary by value? |
|c#|sorting| |
I often have Dictionary of keys & values and need sort them by value. For example, I have a hash of Name and Age, and want to order them by Age.
There's SortedList which is good for a single value (Age), but I want to map it back to the name.
[SortedDictionary](http://msdn.microsoft.com/en-us/library/f7fta44c.asp... |
I often have Dictionary of keys & values and need sort them by value. For example, I have a hash of words and their frequencies, and want to order them by frequency.
There's SortedList which is good for a single value (frequency), but I want to map it back to the word.
[SortedDictionary](http://msdn.microsoft.com... |
I often have Dictionary of keys & values and need to sort them by value. For example, I have a hash of words and their frequencies, and want to order them by frequency.
There's SortedList which is good for a single value (frequency), but I want to map it back to the word.
[SortedDictionary](http://msdn.microsoft.... |
I often have a Dictionary of keys & values and need to sort it by value. For example, I have a hash of words and their frequencies, and want to order them by frequency.
There's SortedList which is good for a single value (frequency), but I want to map it back to the word.
[SortedDictionary](http://msdn.microsoft.... |
Try removing the 0x first and then Encoding.UTF8.GetString, I think that may work.
Essentially:
0x44004500
remove the 0x, and then always 2 Bytes are one Character:
44 00 = D
45 00 = E
So it's definitely a Unicode/UTF Format with 2 Bytes/Character. |
Try removing the 0x first and then Encoding.UTF8.GetString, I think that may work.
Essentially:
0x44004500
remove the 0x, and then always 2 Bytes are one Character:
44 00 = D
45 00 = E
6F 00 = o
72 00 = r
So it's definitely a Unicode/UTF Format with 2 Bytes/Character. |
Oleg Shilo's C# Script solution (at codeproject) really is a great introduction to providing script abilities in your application.
A different approach would be to consider a language that is specifically built for scripting, such as IronRuby, IronPython, or Lua.
IronPython and IronRuby are both available today.
... |
You might be able to identify whether you're in a virtual machine by looking at the MAC address of your network connection. Xen for example typically recommends using a specific range of addresses 00:16:3e:xx:xx:xx.
This isn't guaranteed as it's up to the administrator of the system to specify what MAC address they ... |
Regarding...
> ... how to go about it from a learning point of view.
Are you trying to learning to program scientific methods? or to produce production software? I hope the community sees this as a valid question and not a nitpick.
In either case, I think writing your own Pi is a solved problem. Dmitry showed th... |
It can certainly be done, has been done, and is a hot topic currently among the raytracing and Cuda gurus. I'd start by perusing http://www.nvidia.com/object/cuda_home.html
But it's basically a research problem. People who are doing it well are getting peer-reviewed research papers out of it. But *well* at this p... |
I once ran across an assembly code snippet that told you if you were in a VM....I googled but couldn't find the original article.
I did find this though: [Detect if your program is running inside a Virtual Machine][1].
Hope it helps.
[1]: http://www.codeproject.com/KB/system/VmDetect.aspx |
The same click event can handle the button presses from multiple buttons in .Net. You could then add the the text box to find in the Tag property?
Private Sub AllButton_Click(sender As Object, e As EventArgs) Handles Button1.Click, Button2.Click, Button3.Click
Dim c As Control = CType(sender, Control)
... |
These days, any "unique" or "cool" feature in a DBMS makes me incredibly nervous. I break out in a rash and have to stop work until the itching goes away.
I just hate to be locked in to a platform unnecessarily. Suppose you build a big chunk of your system in PL/Perl inside the database. Or in C# within SQL Server, ... |
When I try to do any svn command and supply the "--username" and/or "--password" options, it prompts me for my password anyways, and always will attempt to use my current user instead of the one specified in "--username". Neither "--no-auth-cache" nor "--non-interactive" have any effect on this.
For example, logged... |
When I try to do any svn command and supply the "--username" and/or "--password" options, it prompts me for my password anyways, and always will attempt to use my current user instead of the one specified by "--username". Neither "--no-auth-cache" nor "--non-interactive" have any effect on this. This is a problem bec... |
We are using one-way replications, but not from the same application. Our applications are reading-writing to the master database, the data gets synchronized to the replca database, and the reporting tools are using this replica.
We don't want our application to read from a different database, so in this scenario I ... |
I have come across this problem a couple of times.
I think it is because of some problem in the file format.
Try importing the file in some image editor and saving it again. This should get rid of the problem. |
I tried the url you gave in FireFox 3 and IE 6, IE 6 won't show it either, firefox works. My guess is that there is something wrong with the jpg file. |
There's no really good way to meassure that in code. You would need to use a a profiler.
This won't show you directly how much time is spent with exception handling but with a little bit of research you will find out which methods of the runtime methods deal with exceptions (for example vor VC++.NET it's __cxx_exc[.... |
There's no really good way to meassure that in code. You would need to use a a profiler.
This won't show you directly how much time is spent with exception handling but with a little bit of research you will find out which of the runtime methods deal with exceptions (for example vor VC++.NET it's __cxx_exc[...]).
... |
There's no really good way to meassure that in code. You would need to use a a profiler.
This won't show you directly how much time is spent with exception handling but with a little bit of research you will find out which of the runtime methods deal with exceptions (for example for VC++.NET it's __cxx_exc[...]).
... |
Imagemagick reports that this particular image is saved in CMYK colorspace instead of the more standard RGB. Try converting it, it should be more compatible with the webkit rendering engine.
Imagemagick is available for download from <a href="http://www.imagemagick.org/script/index.php">http://www.imagemagick.org/sc... |
What do you mean by “dynamic”? A new, fixed set of controls for each data row in the data set? Then use a `UserControl` that contains your controls.
Or do you mean that, depending on your data layout, you want to provide the user with a customized set of controls, say, one `TextBox` for each column? |
Eclipse + netbeans + IntelliJ all are written pretty much all in java or *something* that runs on the JVM (not C++). In at least 2 of those IDEs I have spent some time with the editor code, so I can assure you its all java (and its not easy either).
VS 2005 was my last experience of visual studio, and even then I t... |
No-one did before, so I'll point to the trivial solution:
Have you already de-installed the Service Pack and re-installed it again (or the whole framework)? |
No-one did before, so I'll point to the trivial solution:
Have you already de-installed the Service Pack and re-installed it again (or the whole framework)?
Edit: @Kev:
Easy explanation: He said the update works on one machine, but not on the other. I had similar problems in the past and re-installing helped ... |
I think you need to reorganize the responsibilities. Each component should be responsible for itself and therefore copy its generated goodness where it needs to go. That way it doesn't matter if/who/what/when/where got built. Whatever is updated will put itself into the proper place. |
I think you need to reorganize the responsibilities. Each component should be responsible for itself and therefore copy its generated goodness where it needs to go. That way it doesn't matter if/who/what/when/where got built. Whatever is updated will put itself into the proper place.
***
IMO the other suggestions ... |
Simple MOLAP solution |
|database|text-files|olap|hackery|logging| |
To analyze lots of text logs I did some hackery that looks like this
1. Locally import logs into Access
2. Reprocess Cube link to previous mdb in Analisis Service 2000 (yes it is 2k)
3. Use Excel to visualize Cube (it is not big - up to milions raw entries)
My hackery is a succes and more people are demandi... |
C-like structures in Python |
|python|struct| |
Is there a way to conveniently define a C-like structure in Python? I'm tired of writing stuff like:
class MyStruct():
def __init__(self, field1, field2, field3)
self.field1 = field1
self.field2 = field2
self.field3 = field3
(Interesting, it appears I can't type... |
How about a dictionary?
Something like this:
myStruct = {'field1': 'some val', 'field2': 'some val'}
Then you can use this to manipulate values:
print myStruct['field1']
myStruct['field2'] = 'some other values'
And the values don't have to be strings. They can be pretty much any other objec... |
Altering database tables in Django |
|database|django| |
I'm considering using Django for a project I'm starting (fyi, a browser-based game) and one of the features I'm liking the most is using `syncdb` to automatically create the database tables based on the Django models I define (a feature that I can't seem to find in any other framework).
I was already thinking this was... |
That's kind of an open ended question, but one suggestion would be to use a map with the enum as the key type and the extra information in the value. (If your indices are continuous, unlike the example, you can use a sequence container instead of a map). |
There is at least one definite reason to go for storing in the database. You can use INSERT DELAYED in MySQL (or similar constructs in other databases), which returns immediately. You won't get any return data from the database with these kinds of queries, and they are not guaranteed to be applied.
By using INSERT D... |
I'm trying to improve performance under high load and would like to implement opcode caching. Which of the following should I use?
* APC - <a href="http://www.howtoforge.com/apc-php5-apache2-debian-etch">Installation Guide</a>
* eAccelerator - <a href="http://www.howtoforge.com/eaccelerator_php5_debian_etch">Instal... |
You could use crystal since it is built into VS. Predefine a crystal report with the appropriate columns and then you can use any datasource you would use for a datagrid or gridview.
print("
Dim report_source As CrystalDecisions.Web.CrystalReportSource
report_source.ReportDocument.SetDataSou... |
You could use crystal since it is built into VS. Predefine a crystal report with the appropriate columns and then you can use any datasource you would use for a datagrid or gridview.
Dim report_source As CrystalDecisions.Web.CrystalReportSource
report_source.ReportDocument.SetDataSource(dt)... |
If you put .ToString() to a var query varaible you get the sql. |
If you put .ToString() to a var query variable you get the sql. You can laso use this in Debug en VS2008. [Debug Visualizer][1]
ex:
var query = from p in db.Table
select p;
MessageBox.SHow(query.ToString());
[1]: http://weblogs.asp.net/scottgu/archive/20... |
Tools -> Options -> Text Editor -> C# -> Formatting -> New Lines -> New Line Options for braces -> Uncheck all boxes. |