instruction
stringlengths
0
30k
I vaguely remember having a similar sounding problem with the DB2 for as/400 oledb driver when trying to set up a linked server from sql 2005 to the as/400. It was a permissions issue and I eventually found that only sql server accounts (not windows) could use the linked server because (i think) then the driver was loading using the credentials of the sql instead of impersonated ones. If it works when "run as" admin then it gotta be permissions.
Best GUI designer for eclipse?
|java|eclipse|swing|gui-designer|
I'm looking for a good GUI designer for swing in eclipse. My preference is for a free/open-source plugin.
I assume you have seen the writeup of [SQL1159][1] in the [DB2 Reference Guide][2]? Unfortunately for you, the reason codes stop at 6 and don't continue to 7. It does say: > User response: There was a problem with your DB2 installation. If this is the first time DB2 was installed on this computer, review the install logs for any possible errors and run a repair of DB2 from the Add/Remove Programs control panel applet. The default location of the installation logs is the My Documents/DB2LOG folder of the user that performed the installation. If this does not resolve the issue please contact IBM Support and provide the reason code associated with this message along with any installation logs. So I guess try to reinstall it and if the problem continues you'll have to contact IBM. Sorry, I know that's not much help. [1]: http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.msg.doc/doc/sql1159.htm [2]: http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp
If this is for a website, which by its very nature puts viewing of its code one menu click away, is there *really* any reason to hide anything? If someone wants to steal your code they will most likely go through the effort of making even the most mangled code human readable. Look at commercial websites, they don't obfuscate their code, and no one goes out and steals code from the google apps. If you are really worried about code theft, I would argue for writing it in some other compiled language. (which does of course destroy the whole webapp thing...) Even then, you aren't totally safe, there are many de-compilers out there. So really, there is no way to do what you want in the face of anyone with sufficient motivation.
Given everyone already has domain accounts. Try IIS integrated authentication. You will get an ugly logon box off network but your creds should pass down to the file share.
Given everyone already has domain accounts. Try IIS integrated authentication. You will get an ugly logon box off network but your creds should pass down to the file share. @lomaxx Are you saying that only you have perms to the share or that you manually mapped it to a drive letter. If the later you can use ucn \\host\share the same way you would use a c:\shared_folder. Random Would it be a burden to mirror the share to a local folder on the host? I hear ROBOCOPY is pretty handy. Another Idea. Run IIS on your target share you can read via http and if you need to write investigate webdav.
How to assign a method's output to a textbox value without code behind
|vb.net|
How do I assign a method's output to a textbox value without code behind? <%@ Page Language="VB" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> Public TextFromString As String = "test text test text" Public TextFromMethod As String = RepeatChar("S", 50) 'SubSonic.Sugar.Web.GenerateLoremIpsum(400, "w") Public Function RepeatChar(ByVal Input As String, ByVal Count As Integer) Return New String(Input, Count) End Function </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>Test Page</title> </head> <body> <form id="form1" runat="server"> <div> <%=TextFromString%> <br /> <asp:TextBox ID="TextBox1" runat="server" Text="<%# TextFromString %>"></asp:TextBox> <br /> <%=TextFromMethod%> <br /> <asp:TextBox ID="TextBox2" runat="server" Text="<%# TextFromMethod %>"></asp:TextBox> </div> </form> </body> </html>
|vb.net|asp.net|
|asp.net|vb.net|
How do I assign a method's output to a textbox value without code behind? <%@ Page Language="VB" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> Public TextFromString As String = "test text test text" Public TextFromMethod As String = RepeatChar("S", 50) 'SubSonic.Sugar.Web.GenerateLoremIpsum(400, "w") Public Function RepeatChar(ByVal Input As String, ByVal Count As Integer) Return New String(Input, Count) End Function </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>Test Page</title> </head> <body> <form id="form1" runat="server"> <div> <%=TextFromString%> <br /> <asp:TextBox ID="TextBox1" runat="server" Text="<%# TextFromString %>"></asp:TextBox> <br /> <%=TextFromMethod%> <br /> <asp:TextBox ID="TextBox2" runat="server" Text="<%# TextFromMethod %>"></asp:TextBox> </div> </form> </body> </html> it was mostly so the designer guys could use it in the aspx page. Seems like a simple thing to push a variable value into a textbox to me. It's also confusing to me why <asp:Label runat="server" ID="label1"><%=TextFromString%></asp:Label> and <asp:TextBox ID="TextBox3" runat="server">Hello</asp:TextBox> works but <asp:TextBox ID="TextBox4" runat="server"><%=TextFromString%></asp:TextBox> causes a compilation error.
There is no way to find out the source of an exception *after* it's caught, unless you include that information when it is thrown. By the time you catch the exception, the stack is already unwound, and there's no way to reconstruct the stack's previous state. Your suggestion to include the stack trace in the constructor is your best bet. Yes, it costs time during construction, but you probably shouldn't be throwing exceptions often enough that this is a concern. Making all of your exceptions inherit from a new base may also be more than you need. You could simply have the relevant exceptions inherit (thank you, multiple inheritance), and have a separate catch for those. You can use the [StackTrace64][1] function to build the trace (I believe there are other ways as well). Check out [this article][2] for example code. [1]: http://msdn.microsoft.com/en-us/library/ms680650(VS.85).aspx [2]: http://www.gamedev.net/reference/articles/article2488.asp
I haven't been able to find anything that does this directly. I think you'll have to iterate through the various font folders on the system: /System/Library/Fonts, /Library/Fonts, and there can probably be a user-level directory as well ~/Library/Fonts.
Using fcgi with Ruby is known to be very buggy. Practically everybody has moved to [Mongrel](http://mongrel.rubyforge.org/) for this reason, and I recommend you do the same.
Since you mentioned that you'll be building "fairly simple" XML, the [minidom module](http://www.python.org/doc/current/lib/module-xml.dom.minidom.html) (part of the Python Standard Library) will likely suit your needs. If you have any experience with the DOM representation of XML, you should find the API quite straight forward.
Isn't it also a factor which order you set up the colors? Like if you use Dillie-Os idea you need to mix the colors as much as possible. 0 64 128 256 is from one to the next. but 0 256 64 128 in a wheel would be more "apart" Does this make sense?
Doesn't this depend on the hardware as well as number of threads and stuff? I would make a simple test and run it with increasing amounts of threads hammering and see what seems best.
Maven helps quite a lot with this problem when I'm coding java. We commit the pom.xml to the scs and the maven repository contains all our dependencies. For me that seems like a nice way to do it.
One possibility is Hudson. It's written in Java, but there's integration with Python projects: > [http://redsolo.blogspot.com/2007/11/hudson-embraces-python.html][1] I've never tried it myself, however. [1]: http://redsolo.blogspot.com/2007/11/hudson-embraces-python.html
AFAIK, there's no ready-made library to do this for you, but producing a tool capable of translating from CSV to XML should only require you to write a crude CSV parser and hook up JDOM (or your XML Java library of choice) with some glue code.
We run [Buildbot - Trac][1] at work, I haven't used it too much since my code base isn't part of the release cycle yet. But we run the tests on different environments (OSX/Linux/Win) and it sends emails --and it's written in python. [1]: http://buildbot.net/trac
You didn't mention any specifics about your target environment or constraints, so this may not be entirely applicable... but if you're looking for a way to effectively track an evolving DB schema and aren't adverse to the idea of using Ruby, ActiveRecord's migrations are right up your alley. Migrations programatically define database transformations using a Ruby DSL; each transformation can be applied or (usually) rolled back, allowing you to jump to a different version of your DB schema at any given point in time. The file defining these transformations can be checked into version control like any other piece of source code. Because migrations are a part of [ActiveRecord](http://ar.rubyonrails.com/), they typically find use in full-stack Rails apps; however, you can use ActiveRecord independent of Rails with minimal effort. See: <http://rails.aizatto.com/2007/05/27/activerecord-migrations-without-rails/> for a more detailed treatment of using AR's migrations outside of Rails.
> Edit: Saw the responses posted while I was writing, Hash[a.flatten] seems the way to go. > Must have missed that bit in the documentation when I was thinking through the response. The second form is simpler: a = [[:apple, 1], [:banana, 2]] h = a.inject({}) { |r, i| r[i.first] = i.last; r } a = array, h = hash, r = return-value hash (the one we accumulate in), i = item in the array The neatest way that I can think of doing the first form is something like this: a = [:apple, 1, :banana, 2] h = {} a.each_slice(2) { |i| h[i.first] = i.last }
> Edit: Saw the responses posted while I was writing, Hash[a.flatten] seems the way to go. Must have missed that bit in the documentation when I was thinking through the response. Thought the solutions that I've written can be used as alternatives if required. The second form is simpler: a = [[:apple, 1], [:banana, 2]] h = a.inject({}) { |r, i| r[i.first] = i.last; r } a = array, h = hash, r = return-value hash (the one we accumulate in), i = item in the array The neatest way that I can think of doing the first form is something like this: a = [:apple, 1, :banana, 2] h = {} a.each_slice(2) { |i| h[i.first] = i.last }
There is a tool usually used in MS Servers (as far as I can remember) called [forfiles][1]: The link above contains help as well as a link to the microsoft download page. [1]: http://www.ss64.com/nt/forfiles.html
As mentioned in one of the answers to the other post, if you are going to keep your layers separated, there is no good way to avoid duplicating the validation logic in each layer. If you use something to automatically tie them together, you have introduced a sort of coupling between the layers that might hinder you down the road. This might be one of those cases where you just have to keep track of things manually. However you go about it, you have to make sure each layer is doing its own validation, because you never know how that layer is going to be accessed. There's no guarantee that all the layers you implemented will always stay together.
You can use this line to print the contents of your desktop: FOR %%c in (C:\windows\desktop\*.*) DO echo %%c Once you have the %%c variable it's easy to perform a command on it (just replace the word echo with your program) I'm not sure how this works with local variables, but if you just want the filename with no extension you can do this: %~n1 or name + extension: %~nx1 etc Here are some links that may help: http://home.att.net/~gobruen/progs/dos_batch/dos_batch.html
Try using pkg_resources, which is part of setuptools (and available on all of the pythons I have access to right now): >>> import pkg_ resources >>> pkg_ resources.resource_ filename(_ _name_ _, "foo.config") 'foo.config' >>> pkg_ resources.resource_ filename('tempfile', "foo.config") '/usr/lib/python2.4/foo.config' There's more discussion about using pkg_resources to get resources on the [eggs](http://peak.telecommunity.com/DevCenter/PythonEggs#accessing-package-resources) page and the [pkg_resources](http://peak.telecommunity.com/DevCenter/PkgResources) page. Also note, where possible it's probably advisable to use pkg_resources.resource_stream or pkg_resources.resource_string because if the package is part of an egg, resource_filename will copy the file to a temporary directory.
'Jigloo' is a very cool GUI designer. It is not free for commercial use however. It auto-generates code and allows for custom editing of the code it creates. <http://www.cloudgarden.com/jigloo/>
Must be a Vista problem. I have XP SP 2 and it looks normal.
Tools->Options->Addin/Macro Security Change Paths there.
How costly is Reflection? Really.
|c#|.net|performance|reflection|
I constantly hear how bad reflection is to use. While I generally avoid reflection and rarely find situations where it is impossible to solve my problem without it, I was wondering... For those who have used reflection in applications, have you measured performance hits and, is it really so bad?
- For blogs: Your best bet would be the [Visual C++ Team Blog][1]. - For books: [Programming Windows with MFC][2] is one of the best book on the subject. - For tutorials: Simply [search google for various tutorials on MFC][3]. ![alt text][4] [1]: http://blogs.msdn.com/vcblog/default.aspx [2]: http://www.amazon.com/Programming-Windows-Second-Jeff-Prosise/dp/1572316950 [3]: http://www.google.ca/search?q=mfc+tutorial&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a [4]: http://ecx.images-amazon.com/images/I/711B8M7PXHL._SL500_BO2,204,203,200_PIsitb-dp-500-arrow,TopRight,45,-64_OU01_AA240_SH20_.gif
In my opinion anything the computer is capable of doing automatically it should do, because it can do it faster, easier and without thought from you. Within reason of course, but stuff like that can be very trivial to automate, so I've always been a proponent of automating that whole process. and plus it can be fun too!
The only way to be too automated is if you are spending more time fighting with building or fixing automation scripts than you would just doing the job manually. As long as your automation scripts take less time and produce fewer errors than doing the job manually, then automation is great. Scripts to build and branch for production are a great idea!
System.IO.StreamWriter httpResponseStreamWriter = new StreamWriter(HttpContext.Current.Response.OutputStream); dataContext.Log = httpResponseStreamWriter; Stick that in your page and you'll get the SQL dumped out on the page. Obviously, I'd wrap that in a little method that you can enable/disable.
I'm not primarily worried about physical security, we are simply building an application not a whole system. I want to ensure votes are recorded correctly and not able to be changed or read by someone else.
Security For Voting Application
|java|desktop|security|
I have a project to build a voting desktop application for a class in Java. While security isn't the focus of the project, I would like to be as realistic as I can. What are some of the primary tools to integrate security into a Java application.
Your classic VB units are in what are called "twips". You will most likely be able to divide those numbers by 12 or 15 (depending on if you are using large or small fonts) and you will get a certain number of pixels.
Linux GUI development
|linux|kde-plasma|gnome|c++|user-interface|
I have a large GUI project that I'd like to port to Linux. What is the best framework to use for GUI programming in Linux? Should KDE / Gnome frameworks be used? Or can I use something more generic other than X? I feel like if I chose one of Gnome or KDE, I'm closing the market out for a chunk of the Linux market who have chosen one over the other. (Yes I know there is overlap) Is there a better way? Or would I have to create 2 complete GUI apps to have near 100% coverage?
|c++|linux|user-interface|gnome|kde-plasma|
I have a large GUI project that I'd like to port to Linux. What is the best framework to use for GUI programming in Linux? Should KDE / Gnome frameworks be used? Or can I use something more generic other than X? I feel like if I chose one of Gnome or KDE, I'm closing the market out for a chunk of the Linux market who have chosen one over the other. (Yes I know there is overlap) Is there a better way? Or would I have to create 2 complete GUI apps to have near 100% coverage? I do not need a cross platform solution that will work on Win32.
I done some Googling on this, and came across [this](http://www.devnewsgroups.net/group/microsoft.public.dotnet.framework.windowsforms/topic17193.aspx).. > Yes, this size of the form is limited > to the size of the desktop (more > specifcally > SystemInformation.MaxWindowTrackSize). > This is done in the Form.SetBoundsCore > protected virtual method. This > behaviour cannot be changes or at > least without a great deal of work and > using PInvoke. Also supported [here](http://www.themssforum.com/VB/Maximum-Form/) > The size of the form in the designer > is limited by your screen size. > > It sounds like you have your display > at 1600x1200, hence the designer won't > let you go larger then 1212. > > If you had your display at 1280x1024, > then the designer wouldn't let you go > larger then 1036. > > I'm not really sure why the size of > the form in the designer is limited to > the screen size, as I may deploy on a > machine that has a larger screen size > them my development machine... So looks like it cannot be done.. Thats some strange behaviour since it looks like you are limited to whatever your dev machine is.. I think the only way to do it is to size to the maximum resolution possible, set the form size, then revert back, but never touch the size again.
Variable Holding data in a while statement
|c++|
I know I must be missing something small but in a while statement how does the variable hold the data when it finishes the first pass and goes into the second pass.
I wrote this a few days ago: <a href="http://www.appidx.com/ubiq/stackoverflow.html">http://www.appidx.com/ubiq/stackoverflow.html</a> The execute portion refuses to run with POST data. The code is the right code, and I've tried with the native code of the function with the XUL component javascript and it likewise refuses to run. Any help would be appreciated. The preview on the other hand works fine. CmdUtils.CreateCommand({ name: "stackoverflow", author: {name: "Aryeh Goldsmith"}, homepage: "http://www.appidx.com/ubiq/", icon: "http://stackoverflow.com/favicon.ico", takes: {search: noun_arb_text}, license: "MPL", description: "Searches the highlighted text on stackoverflow.", _version: "52", preview: function ( pblock, inputObject) { var query = inputObject.text; pblock.innerHTML = "Search stackoverflow.com for " + query + "<br/>"; var url = "http://stackoverflow.com/search"; params = {"search-text": query, "hiddenstuff": ''}; jQuery.post( url, params, function( html ) { var $ = jQuery; pblock.innerHTML += "<div style='display:none;'>" + html + "</div>"; var ques = $(pblock).find('.summary h3'); var details = $(pblock).find('.summary .excerpt'); var out = "<div style='margin-bottom: 6px;'><b>Previewing the first 5 results:</b></div>"; for (var j = 0; j< ques.size() && j < 5; j++) { out += "<div style='padding: 5px;'><b>" + ques[j].innerHTML + "</b><br />"; out += details[j].innerHTML + "</div>"; } pblock.innerHTML = out; }); }, execute: function( inputObject ) { var query = inputObject.text; var url = "http://stackoverflow.com/search"; var params = { "search-text": query, hiddenstuff: "" }; // The following refuses to work... why? I just don't know! AFAIK it's correct. openUrl(url, params); }, })
How much writing vs. reading of this table(s) do you expect? I've used a single audit table, with columns for Table, Column, OldValue, NewValue, User, and ChangeDateTime - generic enough to work with any other changes in the DB, and while a LOT of data got written to that table, reports on that data were sparse enough that they could be run at low-use periods of the day. **Added:** If the amount of data vs. reporting is a concern, the audit table could be replicated to a read-only database server, allowing you to run reports whenever necessary without bogging down the master server from doing their work.
Multiply by 100 and then convert to an int.
This seems like a buisness requirements/usability issue - do you have a good reason for putting the map on the credit card page? If so, maybe it's worth working through some technical problems. You might try using [Mapstraction][1], so you can switch to a provider that supports SSL, and switch back to Google if they support it in the future. [1]: http://www.mapstraction.com/
Could you be a little more specific about the use case? Removing the decimal point from the representation is a little unusual given that you'll lose all information about the scale. Are you assuming that there will always be two digits? If so, you could simplify multiply by 100 and then round before converting to a string.
SELECT distinct a,b,c FROM ( SELECT A,B,C,1 as o FROM table WHERE field LIKE 'query%' UNION SELECT A,B,C,2 as o FROM table WHERE field LIKE '%query' UNION SELECT A,B,C,3 as o FROM table WHERE field LIKE '%query%' ) ORDER BY o ASC LIMIT 5 Would be my way of doing it. I dont know how that scales. I don't understand the GROUP BY B ORDER BY B ASC LIMIT 5 Does it apply only to the last SELECT in the union? Does mysql actually allow you to group by a column and still not do aggregates on the other columns?
SELECT distinct a,b,c FROM ( SELECT A,B,C,1 as o FROM table WHERE field LIKE 'query%' UNION SELECT A,B,C,2 as o FROM table WHERE field LIKE '%query' UNION SELECT A,B,C,3 as o FROM table WHERE field LIKE '%query%' ) ORDER BY o ASC LIMIT 5 Would be my way of doing it. I dont know how that scales. I don't understand the GROUP BY B ORDER BY B ASC LIMIT 5 Does it apply only to the last SELECT in the union? Does mysql actually allow you to group by a column and still not do aggregates on the other columns? EDIT: aaahh. I see that mysql actually does. Its a special version of DISTINCT(b) or something. I wouldnt want to try to be an expert on that area :)
I may get down-modded for this: To everyone just starting using version control: **Please do not use git (or hg or bzr) because of the hype** Use git (or hg or bzr) because they are **better tools** for managing source code than SVN. I used SVN for a few years at work, and switched over to git 6 months ago. Without learning SVN first I would be totaly lost when it comes to a DVCS. For people just starting out with version control: - Start by downloading SVN - Learn _why_ you need version control - Learn how to commit, checkout, branch - Learn why merging in SVN is such a pain Then switch over to a DVCS and learn: - How to clone/branch/commit - How easy it is to merge your branches back (go branch crazy!) - How easy it is to rewrite commit history and keep your branches<br/>up to date with the main line ([git rebase -i][1]) - How to publish your changes so others can benefit [1]:http://www.kernel.org/pub/software/scm/git/docs/git-rebase.html
Depending on how often you need to copy down live data and how quickly you need to do it, installing [phpMyAdmin](http://www.phpmyadmin.net/) on both machines might be an option. You can export and import DBs, but you'd have to do it manually. If it's a small DB (and it sounds like it is), and you don't need live data copied over too often, it might work well for what you need.
Use of .net Assemblies in SQL Server 2005
|.net|sql-server|
I've recently discovered that it's possible to place .net assemblies on SQL Server >=2005 servers so that .net functions can be called in T/SQL statements. I wondered what uses people found for these and how they perform?
Assuming you have two programs that process the two files, process_in.exe and process_out.exe: for %%f in (*.in) do ( echo %%~nf process_in %%~nf.in process_out %%~nf.out )
If you want to use the FCL collections, then locking is the only way to support iteration / modification from multiple threads that may overlap. Be careful what you use as your lock object, though. Using SyncRoot is only a good idea if the collection itself is a private member of the class that uses it. If the collection is protected or public, then a client of your class can take its own lock on your SyncRoot, potentially deadlocking with code in your class. If you are interested in taking a look at a 3rd-party collection library, I recommend the excellent [C5 Generic Collection Library][1]. They have a family of tree-based collections that can easily and safely be modified and iterated at the same time without locking - see sections 8.10 and 9.11 of their (excellent) documentation for details. [1]: http://www.itu.dk/research/c5/
Native C++ intellisense does not work reliably in any version of Visual Studio. I find there are two common problems: 1) Header file paths are not set-up correctly. When you find a type where intellisense is not working, use the IDE to click through each header file to find the one containing the type. (Right click on #include and select Open Document...). If this fails before you get to the file which declares the type then this is your problem. Make sure header file search paths are set-up correctly. And, 2) The intellisense database is corrupt. This happens ALL The time. You need to close the solution, delete the .ncb file, and then reopen the solution. I posted the macro I use for this in answer to another question [here][1]. [1]: http://stackoverflow.com/questions/15056/do-you-have-any-recommended-macros-for-microsoft-visual-studio#32884
Native C++ intellisense does not work reliably in any version of Visual Studio. I find there are two common problems: 1) Header file paths are not set-up correctly. When you find a type where intellisense is not working, use the IDE to click through each header file to find the one containing the type. (Right click on #include and select Open Document...). If this fails before you get to the file which declares the type then this is your problem. Make sure header file search paths are set-up correctly. And, 2) The intellisense database is corrupt. This happens ALL The time. You need to close the solution, delete the .ncb file, and then reopen the solution. I posted the macro I use for this in answer to another question [here][1]. ---------- The preprocessor can also confuse intellisense - so make sure any #defines during build are also available to intellisense. Other than that, I don't know what else can break it. I've not seen any particular issues with forward declarations. [1]: http://stackoverflow.com/questions/15056/do-you-have-any-recommended-macros-for-microsoft-visual-studio#32884
You didn't mention any specifics about your target environment or constraints, so this may not be entirely applicable... but if you're looking for a way to effectively track an evolving DB schema and aren't adverse to the idea of using Ruby, ActiveRecord's migrations are right up your alley. Migrations programatically define database transformations using a Ruby DSL; each transformation can be applied or (usually) rolled back, allowing you to jump to a different version of your DB schema at any given point in time. The file defining these transformations can be checked into version control like any other piece of source code. Because migrations are a part of [ActiveRecord](http://ar.rubyonrails.com/), they typically find use in full-stack Rails apps; however, you can use ActiveRecord independent of Rails with minimal effort. See [here](http://rails.aizatto.com/2007/05/27/activerecord-migrations-without-rails/) for a more detailed treatment of using AR's migrations outside of Rails.
A few things: You are creating (and not using) an unnecessary toplevel window, named `window`. You can just delete these lines: window = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(delete_event), NULL); g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(destroy), NULL); Also, the flow doesn't seem quite right. `gtk_main()` starts the GTK main loop, which blocks until something exits it. `gtk_dialog_run()` also starts a main loop, but it exits as soon as one of the buttons is clicked. I think it might be enough for you to remove the `gtk_init_add()` and `gtk_main()` calls, and simply deal with the return value. Also the `gtk_widget_destroy()` call is also unnecessary.
A few things: You are creating (and not using) an unnecessary toplevel window, named `window`. You can just delete these lines: window = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(delete_event), NULL); g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(destroy), NULL); Also, the flow doesn't seem quite right. `gtk_main()` starts the GTK main loop, which blocks until something exits it. `gtk_dialog_run()` also starts a main loop, but it exits as soon as one of the buttons is clicked. I think it might be enough for you to remove the `gtk_init_add()` and `gtk_main()` calls, and simply deal with the return value. Also the `gtk_widget_destroy()` call is unnecessary, as the dialog window is automatically destroyed when gtk_dialog_run() returns.
> So it says microseconds explicitly, but says the resolution of the system clock is unspecified. I suppose resolution in this context means how the smallest amount it will ever be incremented? The data structure is defined as having microseconds as a unit of measurement, but that doesn't mean that the clock is actually capable of measuring that finely. Like other people have suggested, gettimeofday() is bad because setting the time can cause clock skew and throw off your calculation. clock_gettime(CLOCK_MONOTONIC) is what you want, and clock_getres() will tell you the precision of your clock.
> So it says microseconds explicitly, but says the resolution of the system clock is unspecified. I suppose resolution in this context means how the smallest amount it will ever be incremented? The data structure is defined as having microseconds as a unit of measurement, but that doesn't mean that the clock or operating system is actually capable of measuring that finely. Like other people have suggested, gettimeofday() is bad because setting the time can cause clock skew and throw off your calculation. clock_gettime(CLOCK_MONOTONIC) is what you want, and clock_getres() will tell you the precision of your clock.
Looking at the solutions presented so far: - They all look less readable than the original, in that they involve spending more code on the mechanism of the code rather than on the algorithm itself - Some of them are broken, or were before they were edited. Most damning is the fact that people are having to think quite hard about how to write the code without labels and not break anything. - Some come with a performance penalty of running the same test twice, which may not always be trivial. The alternative to that is storing and passing round booleans, which gets ugly. - Refactoring the relevant part of the code into a method is effectively a no-op: it rearranges how the code is laid out in the file, but has no effect on how it's executed. All of which makes me believe that, at least in the case of this question as phrased, the label is the correct solution and doesn't need to be refactored away. Certainly there are cases where labels are used incorrectly and should be refactored away. I just don't think it should be treated as some unbreakable rule.
@Derek 5.3.4, section 12 talks about the array allocation overhead and, unless I'm misreading it, it seems to suggest to me that it is valid for the compiler to add it on placement new as well: > This overhead may be applied in all array new-expressions, including those referencing the library function operator new\[](std::size_t, void*) and other placement allocation functions. The amount of overhead may vary from one invocation of new to another. That said, I think VC was the only compiler that gave me trouble with this, out of it, GCC, Codewarrior and ProDG. I'd have to check again to be sure, though.
Java+Tomcat, Dying databse connection?
|java|mysql|tomcat|
I have a tomcat instance setup but the database connection I have configured in context.xml keeps dying after periods of inactivity. When I check the logs I get the following error: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was68051 seconds ago. The last packet sent successfully to the server was 68051 seconds ago, which is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem. Here is the configuration in context.xml: <Resource name="dataSourceName" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="username" password="********" removeAbandoned = "true" logAbandoned = "true" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://127.0.0.1:3306/databasename?autoReconnect=true&amp;useEncoding=true&amp;characterEncoding=UTF-8" /> I am using autoReconnect=ture like the error says to do, but the connection keeps dying. I have never seen this happen before. I have also verified that all database connections are being closed properly.
I'm with Ian on this one. Reading books is all well and good, but nothing beats getting stuck in. I actually started with a Dummies Guide to ASP (that'd be "classic" ASP), back in 1999. If I was going to start from scratch today I'd be looking at something that covered a full stack solution, whether Apache/PHP/MySQL, RoR or whatever. ATM I have no experience of Rails, but it might be a pretty good place to start as it includes a lot of stuff that you'd have to figure out early on otherwise (integration with a Scriptaculous, a JS framework) - you can always learn what going on under the hood at a later date. Oh - and don't forget databases! Sooner or later you'll need to get to grips with some pretty serious SQL...
How to find the mime type of a file in python?
|python|mime|
Let's say you want to save a bunch of files somewhere, for instance in BLOBs. Let's say you want to dish these files out via a web page and have the client automatically open the correct application/viewer. Assumption: The browser figures out which application/viewer to use by the mime-type (content-type?) header in the HTTP response. Based on that assumption, in addition to the bytes of the file, you also want to save the MIME type. How would you find the MIME type of a file? I'm currently on a Mac, but this should also work on Windows. Does the browser add this information when posting the file to the web page? Is there a neat python library for finding this information? A WebService or (even better) a downloadable database?
Let's say you want to save a bunch of files somewhere, for instance in BLOBs. Let's say you want to dish these files out via a web page and have the client automatically open the correct application/viewer. Assumption: The browser figures out which application/viewer to use by the mime-type (content-type?) header in the HTTP response. Based on that assumption, in addition to the bytes of the file, you also want to save the MIME type. How would you find the MIME type of a file? I'm currently on a Mac, but this should also work on Windows. Does the browser add this information when posting the file to the web page? Is there a neat python library for finding this information? A WebService or (even better) a downloadable database? **Edit:** Thank you, Dave Webb.
I would suggest that as part of the upgrade you opt to move to a Web Application Project rather than a Web Site Project, as the former is conceptually similar to the VS2003 web project model. Here's a nice short post summarising the differences: [http://maordavid.blogspot.com/2007/06/aspnet-20-web-site-vs-web-application.html][1] As others have said, don't worry too much about the DataGrids, the upgraded site should be backwards-compatible in this respect. [1]: http://maordavid.blogspot.com/2007/06/aspnet-20-web-site-vs-web-application.html
mod_auth_kerb is a good start: [http://modauthkerb.sourceforge.net/][1]. If you need Active Directory support, look here: [http://support.microsoft.com/?id=555092][2]. [1]: http://modauthkerb.sourceforge.net/ [2]: http://support.microsoft.com/?id=555092
The [minetypes module][1] in the standard library will determine/guess the MIME type from a file extension. I'm not sure if this will help as it seems you want to get the MIME type by looking at the contents of the file. [1]: http://docs.python.org/lib/module-mimetypes.html
The [minetypes module][1] in the standard library will determine/guess the MIME type from a file extension. If users are uploading files the HTTP post will contain the MIME type of the file alongside the data. For example, Django makes this data available as an attribute of the [UploadedFile][2] object. [1]: http://docs.python.org/lib/module-mimetypes.html [2]: http://www.djangoproject.com/documentation/upload_handling/#uploadedfile-objects
I found it to be very useful. I used this possibility to extend MSSQL2005 XML related functions. If I remember correctly you can even introduce your own data types.
@spoulson, If you can replicate it, can you post it somewhere? One avenue you could try is usign WinDBG with the SOS extensions to run the app and catch the unhandled exception. It will break on the first chance exception (before the runtime tries to find a handler) and you can see at that point where it is coming from, and what thread. If you haven't used WinDBG before, it can be a little overwhelming, but here's a good tutorial: <a href="http://blogs.msdn.com/johan/archive/2007/11/13/getting-started-with-windbg-part-i.aspx">http://blogs.msdn.com/johan/archive/2007/11/13/getting-started-with-windbg-part-i.aspx</a> Once you start up WinDBG, you can toggle the breaking of unhandled exceptions by going to Debug->Event Filters.
Each one is different and they can sometimes be obscure. As a first step, I would do the following: - Use source control and save often. When a designer error occurs, get a list of all changes to the affected controls that have occurred recently and test each one until you find the culprit - Be sure to check out the initialization routines of the controls involved. Very often these errors will occur because of some error or bad dependency that is called through the default constructor for a control (an error that may only manifest itself in VS)
Since you can access your database remotely, you can use mysqldump from your windows machine to fetch the remote database. From commandline: cd "into mysql directory" mysqldump -u USERNAME -p -h YOUR_HOST_IP DATABASE_TO_MIRROR >c:\backup\database.sql The program will ask you for the database password and then generate a file c:\backup\database.sql that you can run on your windows machine to insert the data. With a small database that should be fairly fast.
Some hosts (Godaddy is the worst) block your use of sendmail and mail(). I generally use smtp to send emails from my php applications and with [PHPMailer][1] it's super easy. Many applications are using older versions of PHPMailer and sometimes updating it can help. It's also easy enough to add quickly to short scripts as well. [1]: http://phpmailer.codeworxtech.com/
I have had this happen many times and it is a real pain. Firstly I'd suggest attempting to follow the stack trace provided by the designer, though I found that often simply lists a bunch of internals stuff that isn't much use. If that doesn't work then try compiling and determining the exception from there. You really are flying blind which is the problem. You could then try simply running the code and seeing what exception is raised when you run it, that should give you some more information. A last-gasp approach could be to remove all the non-generated code from the form and gradually re-introduce it to determine the error. If you're using custom controls you could manually remove the generated code related to the custom controls as well if the previous method still results in an error. You could then re-introduce this step-by-step in the same way to determine which custom control is causing the problem, then go and debug that separately. Basically as far as I can tell there's no real way around the problem other than to slog it out a bit!
I'm with Ian on this one. Reading books is all well and good, but nothing beats getting stuck in. I actually started with a Dummies Guide to ASP (that'd be "classic" ASP), back in 1999. If I was going to start from scratch today I'd be looking at something that covered a full stack solution, whether Apache/PHP/MySQL, RoR or whatever. ATM I have no experience of Rails, but it might be a pretty good place to start as it includes a lot of stuff that you'd have to figure out early on otherwise (integration with a Scriptaculous, a JS framework) - you can always learn what going on under the hood at a later date. .NET is always an option, and if you're comfortable with Visual Studio it may be the way to go, but it's not the easiest thing to pick up otherwise. If you know a bit of HTML but are basically new to server-side programming you might look at ColdFusion. It's actually extremely powerful and like Rails includes lots of "out of the box" benefits. There's a Swiss company called [Railo][1] who are currently in the process of releasing an Open Source ColdFusion engine that is affiliated with JBoss. Last and not least - don't forget databases! Sooner or later you'll need to get to grips with some pretty serious SQL... [1]: http://www.railo.ch
Sara Ford has this market cornered. <http://blogs.msdn.com/saraford/default.aspx> More Visual Studio tips and tricks than you can shake a stick at. Some others: - The Visual Studio 2005 and 2008 3-month trial editions are fully-functional, and can be [used indefinitely](http://www.codingthewheel.com/archives/microsoft-vs-the-system-clock) (forever) by setting the system clock back prior to opening VS. Then, when VS is opened, set the system clock forward again so your datetimes aren't screwed up. - But that's really piracy and I can't recommend it, especially when anybody with a .edu address can get a fully-functional Pro version of VS2008 through [Microsoft Dreamspark](https://downloads.channel8.msdn.com/). - You can use Visual Studio to open 3rd-party executables, and browse embedded resources (dialogs, string tables, images, etc) stored within. - Debugging visualizers are not exactly a "hidden" feature but they are somewhat neglected, and super-useful, since in addition to using the provided visualizers you can [roll your own](http://nayyeri.net/blog/how-to-write-a-visual-studio-visualizer/) for specific data sets. - Debugger's "Set Instruction Pointer" or "Set Next Statement" command. - Conditional breakpoints (as KiwiBastard noted). - You can use Quickwatch etc. to evaluate not only the value of a variable, but runtime expressions around that variable.
I'm not sure about linux, but under windows, tightvnc will detect and adapt to resolution changes on the server. So you should be able to VNC into the workstation, do the equivalent of right-click on desktop, properties, set resolution to whatever, and have your client vnc window resize itself accordingly.
How would a sdbm hash function be implemented in C#?