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 with UnixUtils and it worked. (For reference, the UnixUtils I downloaded was dated March 1, 2007, and uses GNU sed version 3.02, my Cygwin install has GNU sed version 4.1.5) ## Heading ## )
@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 with UnixUtils and it worked. (For reference, the UnixUtils I downloaded was dated March 1, 2007, and uses GNU sed version 3.02, my Cygwin install has GNU sed version 4.1.5)
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 flying enemies, except when the enemy is blessed". As Trading Card Games are turn based, the GameState Manager will fire OnStageX Events and let the cards modify other cards or the GameState in whatever way the Card needs. If I try to create a DSL, I have to implement a rather large feature set and possibly constantly update it, which shifts the maintenance work to another part without actually removing it. That's why I wanted to stay with a "real" .net Language to essentially be able to just fire the Event and let the Card manipulate the Gamestate in whatever way (within the Limits of the Code Access Security).
@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++) { $normalized = ($highest - $count[$x]+1) / $highest; $heading = ceil($normalized * 6); // 6 heading types echo "<h$heading>{$artist[$x]}</h$heading>"; }
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 of handling hashes.
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 Item"); s.Add("3", "b Item"); List<KeyValuePair<string, string>myList = new List<KeyValuePair<string, string>>(s); myList.Sort( delegate(KeyValuePair<string, stringfirstPair, KeyValuePair<string, stringnextPair) { return firstPair.Value.CompareTo(nextPair.Value); } );
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 shorter. If you're targeting .net 2.0 you can only use this syntax if you're using the compiler from vs2008. myList.Sort((firstPair,nextPair) => { return firstPair.Value.CompareTo(nextPair.Value); } );
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 changes to stick for the ListView?
|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 objects design. I'd say first and foremost (even before deciding on what technologies to introduce) focus on the process and identify your nouns and verbs ... then build out from those abstractions. Hey, it really does work in the "real world", just like OOP 101 taught you!
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 DEBUGme as a custom symbol, the only way to exclude it from compile is to remove this #define statement?
|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 Javascript calls to /ScriptResource.axd?d=xxxx Is there any way to control this? Why does it suck so much? What's a better Ajax toolkit for .NET that can provide equal (or better) set of functionality that is more scalable, straight forward and completely customizable? NOT looking to reinvent the wheel here.
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 kept in paralell with this (again in Oracle). The conversion to SQL was manual. It was a mess. I actually wrote a handy tool that will convert Oracle DDL to SQL Server (it worked 99.9% of the time). I have recently switched to using [Visual Studio Team System for Database professionals][1]. So far it works fine, but there are some glitches if you use CLR functions within the database. [1]: http://msdn.microsoft.com/en-us/vsts2008/db/default.aspx
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 around to building the digital prototype, I'll scan in the hand-drawn one and use it as a background template. Seems to work pretty well for me.
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 arguments and still feeling like the paragraph is readable. Any thoughts on best practices for this?
[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 file, they can do large-scale distributed replication without affecting performance on the source machine(s). [1]: http://www.goldengate.com/
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 directories for the copy, use it as a "touch" utility, etc. I've been using it for years, it's 2 thumbs up.
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' # user1@domain.com's password: Why does it prompt me? And why is it asking for user1's password instead of user2's? I'm 99% sure all of my permissions are set correctly. Is there some config option for svn that switches off command-line passwords? Or is it something else entirely? I'm running svn 1.3.2 (r19776) on Fedora Core 5 (Bordeaux).
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' # user1@domain.com's password: Why does it prompt me? And why is it asking for user1's password instead of user2's? I'm 99% sure all of my permissions are set correctly. Is there some config option for svn that switches off command-line passwords? Or is it something else entirely? I'm running svn 1.3.2 (r19776) on Fedora Core 5 (Bordeaux). Here's a list of my environment variables (with sensitive information X'ed out). None of them seem to apply to SVN: # HOSTNAME=XXXXXX # TERM=xterm # SHELL=/bin/sh # HISTSIZE=1000 # KDE_NO_IPV6=1 # SSH_CLIENT=XXX.XXX.XXX.XXX XXXXX XX # QTDIR=/usr/lib/qt-3.3 # QTINC=/usr/lib/qt-3.3/include # SSH_TTY=/dev/pts/2 # USER=XXXXXX # LS_COLORS=no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35: # KDEDIR=/usr # MAIL=/var/spool/mail/XXXXXX # PATH=/usr/lib/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin # INPUTRC=/etc/inputrc # PWD=/home/users/XXXXXX/my_repository # KDE_IS_PRELINKED=1 # LANG=en_US.UTF-8 # SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass # SHLVL=1 # HOME=/home/users/XXXXXX # LOGNAME=XXXXXX # QTLIB=/usr/lib/qt-3.3/lib # CVS_RSH=ssh # SSH_CONNECTION=69.202.73.122 60998 216.7.19.47 22 # LESSOPEN=|/usr/bin/lesspipe.sh %s # G_BROKEN_FILENAMES=1 # _=/bin/env # OLDPWD=/home/users/XXXXXX
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 in as user1: # svn update --username 'user2' --password 'password' # user1@domain.com's password: Why does it prompt me? And why is it asking for user1's password instead of user2's? I'm 99% sure all of my permissions are set correctly. Is there some config option for svn that switches off command-line passwords? Or is it something else entirely? I'm running svn 1.3.2 (r19776) on Fedora Core 5 (Bordeaux). Here's a list of my environment variables (with sensitive information X'ed out). None of them seem to apply to SVN: # HOSTNAME=XXXXXX # TERM=xterm # SHELL=/bin/sh # HISTSIZE=1000 # KDE_NO_IPV6=1 # SSH_CLIENT=XXX.XXX.XXX.XXX XXXXX XX # QTDIR=/usr/lib/qt-3.3 # QTINC=/usr/lib/qt-3.3/include # SSH_TTY=/dev/pts/2 # USER=XXXXXX # LS_COLORS=no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35: # KDEDIR=/usr # MAIL=/var/spool/mail/XXXXXX # PATH=/usr/lib/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin # INPUTRC=/etc/inputrc # PWD=/home/users/XXXXXX/my_repository # KDE_IS_PRELINKED=1 # LANG=en_US.UTF-8 # SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass # SHLVL=1 # HOME=/home/users/XXXXXX # LOGNAME=XXXXXX # QTLIB=/usr/lib/qt-3.3/lib # CVS_RSH=ssh # SSH_CONNECTION=69.202.73.122 60998 216.7.19.47 22 # LESSOPEN=|/usr/bin/lesspipe.sh %s # G_BROKEN_FILENAMES=1 # _=/bin/env # OLDPWD=/home/users/XXXXXX
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 this sort of thing. I think this is more suited to a design department for shared access, searching and versioning, etc to all assets -- where there is a business incentive to not reinvent the wheel wherever/whenever possible. I don't think it would apply for a project-oriented manner as tagging and cross referencing wouldn't be quite as applicable.
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#29336
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">Installation Guide</a> * XCache - <a href="http://www.howtoforge.com/xcache-php5-apache2-debian-etch">Installation Guide</a> 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 **[Update 1]** HowtoForge installation links added **[Update 2]** Based on the answers and feedback given, I have tested all 3 implementations using the following Apache JMeter test plan on my application: * Login * Access Home Page With 50 concurrent connections, the results are as follows: No Opcode Caching<br> <img src="http://edmundtay.com/stackoverflow/28716/nocache.jpg"> APC<br> <img src="http://edmundtay.com/stackoverflow/28716/apc.jpg"> eAccelerator<br> <img src="http://edmundtay.com/stackoverflow/28716/eaccelerator.jpg"> XCache<br> <img src="http://edmundtay.com/stackoverflow/28716/xcache.jpg"> From the above results, eAccelerator has a slight edge in performance compared to APC and XCache. However, what matters most from the above data is that any sort of opcode caching gives a tremendous boost in performance. I have decided to use APC due to the following 2 reasons: * Package is available in official Debian repository * More functional control panel To summarize my experience: Ease of Installation: APC > eAccelerator > XCache<br> Performance: eAccelerator > APC, XCache<br> Control Panel: APC > XCache > eAccelerator
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.aspx) orders by key, not value. Some resort to a [custom class](http://www.codeproject.com/KB/recipes/lookupcollection.aspx), but what's the cleanest way?
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/en-us/library/f7fta44c.aspx) orders by key, not value. Some resort to a [custom class](http://www.codeproject.com/KB/recipes/lookupcollection.aspx), but what's the cleanest way?
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.com/en-us/library/f7fta44c.aspx) orders by key, not value. Some resort to a [custom class](http://www.codeproject.com/KB/recipes/lookupcollection.aspx), but what's the cleanest way?
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.com/en-us/library/f7fta44c.aspx) orders by key, not value. Some resort to a [custom class](http://www.codeproject.com/KB/recipes/lookupcollection.aspx), but what's the cleanest way?
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. For a guide to embedding IronPython read [How to embed IronPython script support in your existing app in 10 easy steps][1] Lua is a scripting language commonly used in games. There is a lua compiler for .net, available from codeplex -- [http://www.codeplex.com/Nua][2] That codebase is a great read if you want to learn about building a compiler in .net. A different angle altogether is to try Powershell. There are numerous examples of embedding powershell into an application -- here's a thorough project on the topic: [Powershell Tunnel][3] [1]: http://blogs.msdn.com/jmstall/archive/2005/09/01/Howto_embed_ironpython.aspx "How to embed IronPython script support in your existing app in 10 easy steps" [2]: http://www.codeplex.com/Nua "Nua is Lua for .net" [3]: http://code.msdn.microsoft.com/PowerShellTunnel/Wiki/View.aspx?title=PowerShellTunnel%20Reference "PowerShell Tunnel"
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 like.
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 the 'Math.PI' constant already. Attack another problem in the same space! Go for generic Newton approximations or something slick.
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 point still means that the best GPU/Cuda results are approximately competitive with best-of-class solutions on CPU/multi-core/SSE. So I think that it's a little early to assume that using Cuda is going to accelerate a ray tracer. The problem is that although ray tracing is "embarrassingly parallel" (as they say), it is not the kind of "fixed input and output size" problem that maps straightforwardly to GPUs -- you want trees, stacks, dynamic data structures, etc. It can be done with Cuda/GPU, but it's tricky. Your question wasn't clear about your experience level or the goals of your project. If this is your first ray tracer and you're just trying to learn, I'd avoid Cuda -- it'll take you 10x longer to develop and you probably won't get good speed. If you're a moderately experienced Cuda programmer and are looking for a challenging project and ray tracing is just a fun thing to learn, by all means, try to do it in Cuda. If you're making a commercial app and you're looking to get a competitive speed edge -- well, it's probably a crap shoot at this point... you might get a performance edge, but at the expense of more difficult development and dependence on particular hardware. Check back in a year, the answer may be different after another generation or two of GPU speed, Cuda compiler development, and research community experience.
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) Dim t As TextBox = FindControl(CType(c.Tag, String)) If t Is Not Nothing Then t.Text = "Clicked" End If End Sub
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, or PL/SQL within Oracle, there are plenty of examples*. Now you suddenly discover that your chosen platform doesn't scale. Or isn't fast enough. Or something. Worse, there's a new kid on the database block (something like MonetDB, CouchDB, Cache, say but much cooler) that would solve all your problems (even if your only problem, like mine, is having an uncool databse platform). And you can't switch to it without recoding half your application. (*Admittedly, the paid-for products are to some extent seeking to lock you in by persuading you to use their unique features, which is not an accusation that can directly be levelled at the free providers, but the effect is the same). So that's a rant on the first part of the question. Heart-felt, though. > is there any valid reason to use an > untrusted language? It seems like > making it so that any user can execute > any operation would be a bad idea My goodness, yes it does! A sort of "Perl injection attack"? Almost worth doing it just to see what happens, I'd have thought. For philosophical reasons outlined above I think I'll pass on the PL/LOLCODE challenge. Although I was somewhat amazed to discover it was a link to something extant.
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 in as user1: # $ svn update --username 'user2' --password 'password' # user1@domain.com's password: Other options work correctly: # $ svn --version --quiet # 1.3.2 Why does it prompt me? And why is it asking for user1's password instead of user2's? I'm 99% sure all of my permissions are set correctly. Is there some config option for svn that switches off command-line passwords? Or is it something else entirely? I'm running svn 1.3.2 (r19776) on Fedora Core 5 (Bordeaux). ---------- Here's a list of my environment variables (with sensitive information X'ed out). None of them seem to apply to SVN: # HOSTNAME=XXXXXX # TERM=xterm # SHELL=/bin/sh # HISTSIZE=1000 # KDE_NO_IPV6=1 # SSH_CLIENT=XXX.XXX.XXX.XXX XXXXX XX # QTDIR=/usr/lib/qt-3.3 # QTINC=/usr/lib/qt-3.3/include # SSH_TTY=/dev/pts/2 # USER=XXXXXX # LS_COLORS=no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35: # KDEDIR=/usr # MAIL=/var/spool/mail/XXXXXX # PATH=/usr/lib/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin # INPUTRC=/etc/inputrc # PWD=/home/users/XXXXXX/my_repository # KDE_IS_PRELINKED=1 # LANG=en_US.UTF-8 # SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass # SHLVL=1 # HOME=/home/users/XXXXXX # LOGNAME=XXXXXX # QTLIB=/usr/lib/qt-3.3/lib # CVS_RSH=ssh # SSH_CONNECTION=69.202.73.122 60998 216.7.19.47 22 # LESSOPEN=|/usr/bin/lesspipe.sh %s # G_BROKEN_FILENAMES=1 # _=/bin/env # OLDPWD=/home/users/XXXXXX
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 because I'm trying to call svn commands from a script, and I can't have it show the prompt. For example, logged in as user1: # $ svn update --username 'user2' --password 'password' # user1@domain.com's password: Other options work correctly: # $ svn --version --quiet # 1.3.2 Why does it prompt me? And why is it asking for user1's password instead of user2's? I'm 99% sure all of my permissions are set correctly. Is there some config option for svn that switches off command-line passwords? Or is it something else entirely? I'm running svn 1.3.2 (r19776) on Fedora Core 5 (Bordeaux). ---------- Here's a list of my environment variables (with sensitive information X'ed out). None of them seem to apply to SVN: # HOSTNAME=XXXXXX # TERM=xterm # SHELL=/bin/sh # HISTSIZE=1000 # KDE_NO_IPV6=1 # SSH_CLIENT=XXX.XXX.XXX.XXX XXXXX XX # QTDIR=/usr/lib/qt-3.3 # QTINC=/usr/lib/qt-3.3/include # SSH_TTY=/dev/pts/2 # USER=XXXXXX # LS_COLORS=no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35: # KDEDIR=/usr # MAIL=/var/spool/mail/XXXXXX # PATH=/usr/lib/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin # INPUTRC=/etc/inputrc # PWD=/home/users/XXXXXX/my_repository # KDE_IS_PRELINKED=1 # LANG=en_US.UTF-8 # SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass # SHLVL=1 # HOME=/home/users/XXXXXX # LOGNAME=XXXXXX # QTLIB=/usr/lib/qt-3.3/lib # CVS_RSH=ssh # SSH_CONNECTION=69.202.73.122 60998 216.7.19.47 22 # LESSOPEN=|/usr/bin/lesspipe.sh %s # G_BROKEN_FILENAMES=1 # _=/bin/env # OLDPWD=/home/users/XXXXXX
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 would suggest using file groups and partitioning on the master database. Using file groups (especially on different drives) and partitioning of files and indexes can help on performance a lot.
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[...]). Add their times up and you have the overhead. In our project we used vTunes from Intel which works with both Visual C++ and gcc. Edit: Well, if you just need a generic number that might work. Thought you had an actual application to profile where you can't just turn off exceptions.
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[...]). Add their times up and you have the overhead. In our project we used vTunes from Intel which works with both Visual C++ and gcc. Edit: Well, if you just need a generic number that might work. Thought you had an actual application to profile where you can't just turn off exceptions.
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[...]). Add their times up and you have the overhead. In our project we used vTunes from Intel which works with both Visual C++ and gcc. Edit: Well, if you just need a generic number that might work. Thought you had an actual application to profile where you can't just turn off exceptions.
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/script/index.php</a> - it's available for windows and *NIX systems.
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 thought eclipse was much more responsive (intelliJ doubly so given time to warm up and index). Not sure how thats relevant but thats my experience. But I am surprised visual studio is still today written in C++ - I would think that it would be in Microsoft's interest to use C# - if nothing else it would really push its performance hard, nothing like eating your own dog food !
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 to solve some of them. And it is trivial to do. That's my approach: 1. trivial 2. easy 3. headache You are right, on productive systems you must be careful, but that's his decision. And because it is a virtual server, maybe it is easy for him to copy it and try as a test environment first.
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 are no-nos since they'll circumvent the compiler's smarts to know when a rebuild is necessary for the main project. And hence killing any compile time-savings. If your "plugin" projects are assemblies (and not just project-references from the main project), then you do not need to rebuild the main project each time a plugin is rebuilt. The new assembly will get selected into the process / debugger w/o the main project needing a rebuild.
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 demanding an access to my Tool. As you see I see more automating and easier deployment. Do you now some tools/libraries that would give me the same but with easier deployment? Kind of **embedded OLAP** serwice?
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 underscores following non-whitespace in pre-formatted text blocks)
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 object.
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 too good to be true when I saw this in the [documentation][1]: > Syncdb will not alter existing tables > syncdb will only create tables for models which have not yet been installed. It will never issue ALTER TABLE statements to match changes made to a model class after installation. Changes to model classes and database schemas often involve some form of ambiguity and, in those cases, Django would have to guess at the correct changes to make. There is a risk that critical data would be lost in the process. > If you have made changes to a model and wish to alter the database tables to match, use the sql command to display the new SQL structure and compare that to your existing table schema to work out the changes. It seems that altering existing tables will have to be done "by hand". What I would like to know is the best way to do this. Two solutions come to mind: - As the documentation suggests, make the changes manually in the DB; - Do a backup of the database, wipe it, create the tables again (with syncdb, since now it's creating the tables from scratch) and import the backed-up data (this might take too long if the database is big) Any ideas? [1]: http://www.djangoproject.com/documentation/django-admin/
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 DELAYED, you won't slow down your app to much because of the logging. The database is free to write the INSERTs to disk at any time, so it can bundle a bunch of inserts together. You need to watch out for using MySQL's built in timestamp function (like CURRENT_TIMESTAMP or CUR_DATE()), because they will be called whenever the query is actually executed. So you should make sure that any time data is generated in your programming language, and not by the database. (This paragraph might be MySQL-specific)
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">Installation Guide</a> * XCache - <a href="http://www.howtoforge.com/xcache-php5-apache2-debian-etch">Installation Guide</a> 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 **[Update 1]** HowtoForge installation links added **[Update 2]** Based on the answers and feedback given, I have tested all 3 implementations using the following Apache JMeter test plan on my application: * Login * Access Home Page With 50 concurrent connections, the results are as follows: No Opcode Caching<br> <img src="http://edmundtay.com/stackoverflow/28716/nocache.jpg"> APC<br> <img src="http://edmundtay.com/stackoverflow/28716/apc.jpg"> eAccelerator<br> <img src="http://edmundtay.com/stackoverflow/28716/eaccelerator.jpg"> XCache<br> <img src="http://edmundtay.com/stackoverflow/28716/xcache.jpg"> Performance Graph (smaller is better)<br> <img src="http://chart.apis.google.com/chart?cht=bhs&chco=454545|008866|880066|ff8000&chs=620x125&chd=t:13337,2901,2687,2997&chds=0,15000&chdl=No%20Opcodes|APC|eAcellerator|XCache"> From the above results, eAccelerator has a slight edge in performance compared to APC and XCache. However, what matters most from the above data is that any sort of opcode caching gives a tremendous boost in performance. I have decided to use APC due to the following 2 reasons: * Package is available in official Debian repository * More functional control panel To summarize my experience: Ease of Installation: APC > eAccelerator > XCache<br> Performance: eAccelerator > APC, XCache<br> Control Panel: APC > XCache > eAccelerator
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.SetDataSource(dt) 'DT IS A DATATABLE report_source.Report.FileName = "test.rpt" report_source.ReportDocument.Refresh() report_source.ReportDocument.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.Excel, "c:\test.xls") ");
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) 'DT IS A DATATABLE report_source.Report.FileName = "test.rpt" report_source.ReportDocument.Refresh() report_source.ReportDocument.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.Excel, "c:\test.xls")
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/2007/07/31/linq-to-sql-debug-visualizer.aspx
Tools -> Options -> Text Editor -> C# -> Formatting -> New Lines -> New Line Options for braces -> Uncheck all boxes.