instruction
stringlengths
0
30k
You know, you should look at static linking. These days, we all have HUGE hard drives, and a few extra megabytes (for carrying around libc and what not) is really not that big a deal anymore. You could also try running your applications in chroot() jails and distributing those.
As long as there are the other web browsers (and I don't believe that they will die - which is good, because I don't want to see the internet in the hands of Google) it's just another web browser that you need to check compatibility with.
How to run gpg from a script run by cron?
|bash|cron|gnupg|
I have a script that has a part that looks like that: for file in `ls *.tar.gz`; do echo encrypting $file gpg --passphrase-file /home/$USER/.gnupg/backup-passphrase \ --simple-sk-checksum -c $file done For some reason if I run this script manually, works perfectly fine and all files are encrypted. If I run this as cron job, `echo $file` works fine (I see "encrypting <file>" in the log), but the file doesn't get encrypted and gpg silent fails with no stdout/stderr output. Any clues?
Are you trying to show the JDialog indepentently of the annimation? In order to get the order set properly, you may need to bundle those actions in a runnable that is passed to the EDT at once. eg: SwingUtilities.invokeLater(new Runnable(){ public void run(){ doAnnimation(); showDialog(); } } It may be best to subclass JDialog so that you can just add the doAnnimation() logic to the setVisible(..) or show() method before calling the superclass implementation. Finally, I imagine you'll need to set the dimensions of the dalog manually -- I don't remember if Java will know the actual size of the dialog before it is shown, so you may get some useless information for your annimation if you query the size before showing it.
You're right. dummynet works only in FreeBSD, it's actually built into the kernel. What I did when I used it was grab an older PC nobody used anymore and install the [FreeBSD distribution][1]. [1]: http://www.freebsd.org/releases/7.0R/announce.html
I liked **JavaScript:The Good Parts** by Douglas Crockford although it's focused entirely on the language and ignores the DOM altogether.
I liked [JavaScript:The Good Parts][1] by Douglas Crockford although it's focused entirely on the language and ignores the DOM altogether. [1]: http://oreilly.com/catalog/9780596517748/
Could you do it with an `onchange` event? <select onfocus="this.oldIndex=this.selectedIndex" onchange="this.selectedIndex=this.oldIndex">
Joel, (your co-host here) did a thing about using access reports for shipping labels a few years back... maybe this could be a inspriation for you? <http://www.joelonsoftware.com/articles/HowToShipAnything.html>
Please see: [http://www.sap-img.com/oracle-database/finding-oracle-sid-of-a-database.htm][1] > What is the difference between Oracle > SIDs and Oracle SERVICE NAMES. One > config tool looks for SERVICE NAME and > then the next looks for SIDs! What's > going on?! > > Oracle SID is the unique name that > uniquely identifies your > instance/database where as Service > name is the TNS alias that you give > when you remotely connect to your > database and this Service name is > recorded in Tnsnames.ora file on your > clients and it can be the same as SID > and you can also give it any other > name you want. > > SERVICE_NAME is the new feature from > oracle 8i onwards in which database > can register itself with listener. If > database is registered with listener > in this way then you can use > SERVICE_NAME parameter in tnsnames.ora > otherwise - use SID in tnsnames.ora. > > Also if you have OPS (RAC) you will > have different SERVICE_NAME for each > instance. > > SERVICE_NAMES specifies one or more > names for the database service to > which this instance connects. You can > specify multiple services names in > order to distinguish among different > uses of the same database. For > example: > > SERVICE_NAMES = sales.acme.com, > widgetsales.acme.com > > You can also use service names to > identify a single service that is > available from two different databases > through the use of replication. > > In an Oracle Parallel Server > environment, you must set this > parameter for every instance. In short: SID = the unique name of your DB, ServiceName = the alias used when connecting [1]: http://www.sap-img.com/oracle-database/finding-oracle-sid-of-a-database.htm
If you want to do anything other than parse or format a date there is not much out there for handling the patterns themselves. Sometime ago I was writing a Swing component for entering dates into a formatted text field. You supplied a pattern and it moved the text entry cursor through the elements of that pattern, only allowing valid values. As part of that I wrote a DateFormatParser [available here as part of the OpenHarmonise open source project](http://openharmonise.cvs.sourceforge.net/openharmonise/harmonise3/harmonise-gui/src/java/org/openharmonise/swing/datefield/). Parsing a date into a pattern would be an extremely interesting problem to tackle. You would have to make certain assumptions (e.g. use of : in time not date) but you would face the eternal problems of 2 digit years and day/month or month/day arrangements.
Why @OneToMany does not work with inheritance in Hibernate
|java|orm|inheritance|hibernate|
<pre> @Entity @Inheritance(strategy = InheritanceType.SINGLE_TABLE) public class Problem { @ManyToOne private Person person; } @Entity @DiscriminatorValue("UP") public class UglyProblem extends Problem {} @Entity public class Person { @OneToMany(mappedBy="person") private List< UglyProblem > problems; } </pre> I think it is pretty clear what I am trying to do. I expect @ManyToOne person to be inherited by UglyProblem class. But there will be an exception saying something like: "There is no such property found in UglyProblem class (mappedBy="person")". All I found is [this][1]. I was not able to find the post by Emmanuel Bernard explaining reasons behind this. [1]: http://opensource.atlassian.com/projects/hibernate/browse/ANN-558
If we're talking Microsoft platform, then I'd always develop a separate Windows Service to handle such batch tasks. You can always reference the same assemblies that are being used by your web application to avoid any nasty code duplication.
I see you have your solution, but mine would have avoided this and added a field to the documents you're indexing called email_domain, into which I would have added the parsed out domain of the email address. It might sound silly, but the amount of storage associated with this is pretty minimal. If you feel like getting fancier, say some domain had many subdomains, you could instead make a field into which the reversed domain went, so you'd store com.gmail, com.company.department, or ae.eim so you could find all the United Arab Emirates related addresses with a prefix query of 'ae.'
Our network/server closet is a spaghetti-mess of wires; I'm not going to walk in there and start unplugging stuff lest I hit something mission-critical. (At least I have access to it; I'm sure many readers don't even know where their routers are.) Similarly, both ends of the ethernet cable require a hands-and-knees adventure to reach. I tested enabling/disabling the network adapter, and I'm going to test from my cable internet connection from home as well. Also, I had the idea of installing Tor to create a high latency connection. For wireless connections, I have a metal box to test what happens when the signal dies, but I notice that network connection behavior is very different depending on how I test: - put the transmitter/reciever in a metal box - go stand next to the microwave in the kitchen and turn it on - go stand in a little closet which has concrete walls
is it better to structure an SQL table to have a match, or return no result
|sql|query|optimization|
I've got an interesting design question. I'm designing the security side of our project, to allow us to have different versions of the program for different costs and also to allow Manager-type users to grant or deny access to parts of the program. I'm using a simple Allow or Deny option for each 'Resource' or screen. We're going to have a large number of resources, and the user will be able to set up many different groups to put users in to control access. I've got two approaches to this in mind, and was curious which would be better for the SQL server **Option A** The presence of an entry in the table means access is allowed. This will not need a column in the database to store information. If no results are returned, then access is denied. I think this will mean a smaller table, but would queries search the whole table to determine there is no match? **Option B** A bit column is included in the database that controls the Allow/Deny. This will mean there is always a result to be found, and makes for a larger table. Thoughts?
I've got an interesting design question. I'm designing the security side of our project, to allow us to have different versions of the program for different costs and also to allow Manager-type users to grant or deny access to parts of the program to other users. Its going to web-based and hosted on our servers. I'm using a simple Allow or Deny option for each 'Resource' or screen. We're going to have a large number of resources, and the user will be able to set up many different groups to put users in to control access. I've got two approaches to this in mind, and was curious which would be better for the SQL server in terms of performance. **Option A** The presence of an entry in the access table means access is allowed. This will not need a column in the database to store information. If no results are returned, then access is denied. I think this will mean a smaller table, but would queries search the whole table to determine there is no match? **Option B** A bit column is included in the database that controls the Allow/Deny. This will mean there is always a result to be found, and makes for a larger table. Thoughts?
To make this less tedious, you will need to encapsulate/refactor the mapping between the DataReader and the Object you hold in the list. There is quite of few steps to encapsulate that logic out. If that is the road you want to take, I can post code for you. I am just not sure how practical it would be to post the code here on StackOverflow, but I can give it a shot to keep it concise and to the point. Otherwise, you are stuck with the tedious task of repeating each expectation on the index accessor for the reader. The encapsulation process will also get rid of the strings and make those strings more reusable through your tests. Also, I am not sure at this point how much you want to make the existing code more testable. Since this is legacy code that wasn't built with testing in mind.
As I understand it, the problem is that you don't know what format the document is prior to parsing. You could use a delegate pattern. I'm assuming you're not validating against a DTD/XSD/etcetera and that it is OK for the DefaultHandler to have state. public class DelegatingHandler extends DefaultHandler { private Map<String, DefaultHandler> saxHandlers; private DefaultHandler delegate = null; public DelegatingHandler(Map<String, DefaultHandler> delegates) { saxHandlers = delegates; } @Override public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException { if(delegate == null) { delegate = saxHandlers.get(name); } delegate.startElement(uri, localName, name, attributes); } @Override public void endElement(String uri, String localName, String name) throws SAXException { delegate.endElement(uri, localName, name); } //etcetera...
[Nerdtree](http://www.vim.org/scripts/script.php?script_id=1658)
MSTest is certainly not as efficient or extensible as some of the open source frameworks, but it is workable. Since the question asks about making life easier with MSTest and not about alternatives, here are my MSTest tips. * **Shortcuts**. Like Haacked said, take a few seconds to learn the shortcuts. * **Current Context**. Since MSTest is so slow, run tests only in the current context when you can. (CTRL+R, CTRL+T). If your cursor is in a test method, this will only run the method. If your cursor is outside a method, but in a test class, this will only run the test. And with namespace, etc etc * **Efficient tests and organization**. It's dog slow. Make things as best as you can by writing efficient tests. Move slow tests to other test classes or projects so you can run the fast tests more frequently. * **Testing with WCF**. If you're testing services, be sure to DEBUG tests rather than RUN tests so Visual Studio can fire up the ASP.NET development web servers. After these are up, then you can go back to RUN, but it can be easier to just always DEBUG so you don't have to think about it. * **Config Files**. Edit your test-run configuration to move .config files into the test execution folder. * **Integration with Source Safe**. You need to be aware that MSTest hates SourceSafe and the feeling is mutual. Because MSTest wants to put test files under source control, and add them to the solution, it must check out the solution every time you run tests. So SourceSafe must be running in multi-check-out mode to avoid killing your fellow developers. * **Ignore the fluff** With MSTest, you get a dozen different windows and views. Test Runs, Test View, Test Lists ... they're all less-than-helpful. Stick with Test Results and you'll be much happier. * **Stick with "Unit Tests"**. When you add a new test, you can add an ordered test, a unit test, or run through a wizard. Stick with just plain simple unit tests.
Your two `xint` examples don't work for two different reasons. The first doesn't work because `self += value` is equivalent to `self = self + value` which just reassigns the local variable `self` to a different object (an integer) but doesn't change the original object. You can't really get this to work with a subclass of `int` since integers are immutable. To get the second one to work you can define an `__add__` method, like so: class xint(int): def __add__(self, value): return xint(int.__add__(self, value)) >>> x = xint(10) >>> type(x) <class '__main__.xint'> >>> x += 3 >>> x 13 >>> type(x) <class '__main__.xint'>
Your two `xint` examples don't work for two different reasons. The first doesn't work because `self += value` is equivalent to `self = self + value` which just reassigns the local variable `self` to a different object (an integer) but doesn't change the original object. You can't really get this to work with a subclass of `int` since integers are [immutable][1]. To get the second one to work you can define an [`__add__` method][2], like so: class xint(int): def __add__(self, value): return xint(int.__add__(self, value)) >>> x = xint(10) >>> type(x) <class '__main__.xint'> >>> x += 3 >>> x 13 >>> type(x) <class '__main__.xint'> [1]: http://docs.python.org/ref/objects.html [2]: http://docs.python.org/ref/numeric-types.html
Your two `xint` examples don't work for two different reasons. The first doesn't work because `self += value` is equivalent to `self = self + value` which just reassigns the local variable `self` to a different object (an integer) but doesn't change the original object. You can't really get this >>> x = xint(10) >>> x.add(2) to work with a subclass of `int` since integers are [immutable][1]. To get the second one to work you can define an [`__add__` method][2], like so: class xint(int): def __add__(self, value): return xint(int.__add__(self, value)) >>> x = xint(10) >>> type(x) <class '__main__.xint'> >>> x += 3 >>> x 13 >>> type(x) <class '__main__.xint'> [1]: http://docs.python.org/ref/objects.html [2]: http://docs.python.org/ref/numeric-types.html
In .NET you can use the RNGCryptoServiceProvider method GetBytes() which will "fill an array of bytes with a cryptographically strong sequence of random values" (from ms documentation). byte[] randomBytes = new byte[4]; RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(); rng.GetBytes(randomBytes); You can increase the lengh of the byte array and pluck out the character values you want to allow.
Try using a combination of [GetCurrentThemeName](http://www.pinvoke.net/default.aspx/uxtheme/GetCurrentThemeName.html) ([MSDN Page](http://tinyurl.com/67hbzj)) and [DwmIsCompositionEnabled](http://tinyurl.com/66l5mz) I linked the first to PInvoke so you can just drop it in your code, and for the second one you can use the code provided in the MSDN comment: [DllImport("dwmapi.dll", PreserveSig = false)] public static extern bool DwmIsCompositionEnabled(); See what results you get out of those two functions; they should be enough to determine when you want to use a different theme!
`/dev/cu.xxxxx` is the "callout" device, it's what you use when you establish a connection to the serial device and start talking to it. `/dev/tty.xxxxx` is the "dialin" device, used for monitoring a port for incoming calls for e.g. a fax listener.
We use FindBugs and JDepend integrated with Ant. We use JUnit but we're not using any coverage tool. I'm not using it integrated to Rational Application Developer (the IDE I'm using to develop J2EE applications) because I like how neat it looks when you run javac in the Windows console. :P
How to learn ADO.NET
|ado.net|
>I need to learn ADO.NET to build applications based on MS Office. I have read a good deal about ADO.NET in the MSDN Library, but everything seems rather messy to me. >What's the basics one must figure out when using ADO.NET? I think a few key words will suffice to let me organize my learning.
http://www.danga.com/memcached/ worked awesome for me and have heard nothing but goodness about it
1) I use print_r(). In TextMate, I have a snippet for 'pre' which expands to this: echo "<pre>"; print_r(); echo "<pre>"; 2) I use Xdebug, but haven't been able to get the GUI to work right on my Mac. It at least prints out a readable version of the stack trace.
Someone correct me if I'm wrong, but I don't think that AppSettings is typically meant to be used for these type of configuration settings. Normally you would only put in settings that remain fairly static (database connection strings, file paths, etc.). If you want to store customizable user settings, it would be better to create a separate preferences file, or ideally store those settings in a database.
I would expect tools that need this simply walk the tree in a depth-first manner and when they hit a leaf, just process it (e.g. compile) and remove it from the graph (or mark it as processed, and treat nodes with all leaves processed as leaves). As long as it's a DAG, this simple stack-based walk should be trivial.
Could I ask why you're not saving the user's settings in a database? Generally, I save application settings that are changed very infrequently in the appSettings section (the default email address error logs are sent to, the number of minutes after which you are automatically logged out, etc.) The scope of this really is at the application, not at the user, and is generally used for deployment settings.
one thing I would look at doing is caching the appsettings on a read, then flushing the settings from the cache on the write which should minimize the amount of actual load the server has to deal with for processing the appSettings. Also, if possible, look at breaking the appSettings up into [configSections][1] so you can read write and cache related settings. Having said all that, I would seriously consider looking at storing these values in a database as you seem to actually be storing <b>user preferences</b>, and not application settings. [1]: http://www.copernic.com/en/products/desktop-search/whats-new-15.html
First, do you really want to ignore errors? If you get an error, it is likely that the data is not in sync any more. Perhaps what you want is to drop the slave database and restart the sync process when you get an error. Second, I think the error you are getting is not when you replicate an item that does not exist (what would that mean anyway?) - it looks like you are replicating an item that already exists in the slave database. I suspect the problem mainly arises from not starting at a clean data copy. It seems that the master has been copied to the slave; then replication has been turned off (or failed); and then it has started up again, but without giving the slave the chance to catch up with what it missed. If you ever have a time when the master can be closed for write access long enough to clone the database and import it into the slave, this might get the problems to go away.
[System.Diagnostics.FileVersionInfo]::GetVersionInfo("Path\To\File.dll")
Just to clarify, you want to be able to test your call into SQL Server returned some data, or that if you had some data you could map it back into the model? If you want to test your call into SQL returned some data checkout my answer found [here][1] [1]: http://stackoverflow.com/questions/12374/has-anyone-had-any-success-in-unit-testing-sql-stored-procedures#25204
Try this: SELECT B.[Group], COUNT(*) AS GroupCount FROM Table1 A LEFT JOIN Table2 B ON B.ItemType=A.ItemType GROUP BY B.[Group]
How do I create a draggable and resizable JavaScript popup window?
|javascript|dialog|
I want to create a draggable and resizable window in JavaScript for cross browser use, but I want to try and avoid using a framework if I can. Has anyone got a link or some code that I can use?
@thomas -- Amazingly Microsoft's own [Windows Vista User Experience Guidelines][1] agree with you ... >While having a background window flash its taskbar button is better than having it automatically come to the top and steal input focus, flashing taskbar buttons are still very intrusive. It is hard for users to concentrate when a taskbar button is flashing, so you should assume that users will immediately stop what they are doing to make the flashing stop. Consequently, reserve taskbar flashing only for situations where immediate attention is required. Of course who knows who actually follows those guidelines ... or who even reads them. :) [1]: http://msdn.microsoft.com/en-us/library/aa511446.aspx
Since PowerShell can call .Net classes you could do the following: [System.Diagnostics.FileVersionInfo]::GetVersionInfo("somefilepath").FileVersion Or as [noted here][1] on a list of files: get-childitem * -include *.dll,*.exe | foreach-object { "{0}`t{1}" -f $_.Name, [System.Diagnostics.FileVersionInfo]::GetVersionInfo($_).LegalCopyright } Or even nicer as a script: http://jtruher.spaces.live.com/blog/cns!7143DA6E51A2628D!125.entry [1]: http://kamhungsoh.com/blog/2008/01/powershell-file-version-information.html
As EBGreen said, [System.Diagnostics.FileVersionInfo]::GetVersionInfo(path) will work, but remember that you can also get all the members of FileVersionInfo, for example: [System.Diagnostics.FileVersionInfo]::GetVersionInfo(path).CompanyName You should be able to use every member of FileVersionInfo documented here, which will get you basically anything you could ever want about the file.
|java|orm|hibernate|inheritance|
@Entity @Inheritance(strategy = InheritanceType.SINGLE_TABLE) public class Problem { @ManyToOne private Person person; } @Entity @DiscriminatorValue("UP") public class UglyProblem extends Problem {} @Entity public class Person { @OneToMany(mappedBy="person") private List< UglyProblem > problems; } I think it is pretty clear what I am trying to do. I expect @ManyToOne person to be inherited by UglyProblem class. But there will be an exception saying something like: "There is no such property found in UglyProblem class (mappedBy="person")". All I found is [this][1]. I was not able to find the post by Emmanuel Bernard explaining reasons behind this. [1]: http://opensource.atlassian.com/projects/hibernate/browse/ANN-558
Two others not mentioned yet are The Register's [Open Season][1] (about the Open Source industry) and [Semi Coherent Computing][2] (which loosely is about enterprise hardware). I'm not sure if Open Season has any more legs left in it though, since Ashley Vance (the apparent 'driver' of the podcast) has recently left El Reg for The New York Times. That said, the past year's worth of episodes are great and include some notable guests. [1]: http://www.theregister.co.uk/software/open_season/podcast.rss [2]: http://www.theregister.co.uk/hardware/semi_coherent/podcast.rss
I claim no credit for the answer because I found it after some searching: What I didn't know is that PostgreSQL allows you to define your own aggregate functions with [CREATE AGGREGATE][1] [This post][2] on the PostgreSQL list shows how trivial it is to create a function to do what's required: CREATE AGGREGATE textcat_all( basetype = text, sfunc = textcat, stype = text, initcond = '' ); SELECT company_id, textcat_all(employee || ', ') FROM mytable GROUP BY company_id; [1]: http://www.postgresql.org/docs/8.3/interactive/sql-createaggregate.html [2]: http://archives.postgresql.org/pgsql-novice/2003-09/msg00177.php
Your best bet would be to swap out the options within the select box. If you only have one answer in that box, it doesn't matter if it is clickable. I would, however, try to find another way of doing this as it seems like it would cause frustration for a user. Imagine this user scenario: 1. "Look, a select box of options." 2. *click* 3. "Hrm, why didn't that work?" 4. *click* 5. ***click**!* 6. "This stupid thing is broken, I'm never coming back here." If you swap out the select for HTML text, it accomplishes the same goal. This is a fairly simple task for most of the major Javascript frameworks.
@[Geoff](#43818) That sort of Eval statement was actually added in 2.0, but if performance is important Eval should be avoided since it uses Reflection. The repeater is a pretty good way of doing it, although it might be faster to generate the table in code: ASPX Page: <table class="report" id="bookTable" runat="server"> <tr> <th>Published</th> <th>Title</th> <th>Author</th> <th>Price</th> </tr> </table> Code Behind: Protected Sub Page_Load( ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostback Then BuildTable() End If End Sub Private Sub BuildTable() Dim db As New BookstoreDataContext Dim bookCollection = from b in db.Books _ Order By b.Published _ Select b Dim row As HtmlTableRow Dim cell As HtmlTableCell For Each book As Books In bookCollection row = New HtmlTableRow() cell = New HtmlTableCell With { .InnerText = b.Published.ToShortDateString } row.Controls.Add(cell) cell = New HtmlTableCell With { .InnerText = TryNbsp(HttpContext.Current.Server.HtmlEncode(b.Title)) } row.Controls.Add(cell) cell = New HtmlTableCell With { .InnerText = TryNbsp(HttpContext.Current.Server.HtmlEncode(b.Author)) row.Controls.Add(cell) cell = New HtmlTableCell With { .InnerText = Format(b.Price, "c") } row.Controls.Add(cell) bookTable.Controls.Add(row) Next I guess it depends on how important speed is to you. For simplicity's sake I think I would go with the Repeater.
symbols in a .so file
|c++|c|gcc|symbols|
How do list the symbols being exported from a .so file. If possible, I'd also like to know there source (e.g. if they are pulled in from a static library). I'm using gcc 4.0.2, if that makes a difference
You don't have to live with that extension if you can install an ISAPI filter on the server. Basically you route matched urls to the {controller}.mvc variety, then in ASP.NET you rewrite this url to remove .mvc -- doing this you don't have to define any extra routes or expose .mvc to your users. I've written about this here: [http://www.flux88.com/UsingASPNETMVCOnIIS6WithoutTheMVCExtension.aspx][1] and Steve Sanderson has a good post here as well: [http://blog.codeville.net/2008/07/04/options-for-deploying-aspnet-mvc-to-iis-6/][2] [1]: http://www.flux88.com/UsingASPNETMVCOnIIS6WithoutTheMVCExtension.aspx [2]: http://blog.codeville.net/2008/07/04/options-for-deploying-aspnet-mvc-to-iis-6/
To be honest I would recode the function to make it a linear algorithm that uses a loop. This way you have no chance of running out of heap space if you are stepping through an extremely large string. Also, you would not need to have a the extra parameter just to keep track of the count. This also would probably have the result of making the algorithm faster because it does not need to make a function call for every character. Unless of course there is a specific reason it needs to be recursive.
DesignMode is a private property (from what I can tell). The answer is to provide a public property that exposes the DesignMode prop. Then you can cascasde back up the chain of user controls until you run into a non-user control or a control that is in design mode. Something like this.... public bool RealDesignMode() { if (Parent is MyBaseUserControl) { return (DesignMode ? true : (MyBaseUserControl) Parent.RealDesignMode; } return DesignMode; } Where all your UserControls inherit from MyBaseUserControl. Alternatively you could implement an interface that exposes the "RealDeisgnMode". Please note this code is not live code, just off the cuff musings. :)
Best practices with jQuery form binding code in an application
|jquery|
We have an application with a good amount of jQuery JSON calls to server side code. Because of this, we have a large amount of binding code to parse responses and bind the appropriate values to the form. This is a two part question. 1. What is the reccomended approach for dealing with a large number of forms that all have different data. Right now were are trying to take a structured approach in setting up a js "class" for each page, with an init, wireClickEvents etc.. to try to have everything conformed. 2. Is there any "best practices" with creating repetitive jQuery code or any type of reccomended structure other than just throwing a bunch of functions in a js file?
|javascript|jquery|ooad|
This is probably going to be difficult to resolve unless you post either the error message from the log file or the list of steps that you took so far. I have JRun 3.1 configured on my machine so maybe I can duplicate your issue if you give us more information.
|sql|optimization|query|
I've got an interesting design question. I'm designing the security side of our project, to allow us to have different versions of the program for different costs and also to allow Manager-type users to grant or deny access to parts of the program to other users. Its going to web-based and hosted on our servers. I'm using a simple Allow or Deny option for each 'Resource' or screen. We're going to have a large number of resources, and the user will be able to set up many different groups to put users in to control access. Each user can only belong to a single group. I've got two approaches to this in mind, and was curious which would be better for the SQL server in terms of performance. **Option A** The presence of an entry in the access table means access is allowed. This will not need a column in the database to store information. If no results are returned, then access is denied. I think this will mean a smaller table, but would queries search the whole table to determine there is no match? **Option B** A bit column is included in the database that controls the Allow/Deny. This will mean there is always a result to be found, and makes for a larger table. Thoughts?
Procedural languages tend to keep track of state (using variables) and tend to execute as a sequence of steps. Purely functional languages don't keep track of state, use immutable values, and tend to execute as a series of dependencies. In many cases the status of the call stack will hold the information that would be equivalent to that which would be stored in state variables in procedural code. Recursion is a classic example of functional style programming.
There are several usages of [this][1] keyword in C#. 1. To qualify members hidden by similar name 2. To pass an object as a parameter to other methods 3. To declare indexers 4. To declare extension methods 5. To pass parameters between constructors You can avoid the first usage by declaring getter and setter for all fields and accessing fields only through properties. In C# 3.0 this can be done easily via automatic properties however you lose the debugging advantage of this approach. [1]: http://msdn.microsoft.com/en-us/library/dk1507sz.aspx
CruiseControl.NET and NAnt
|cruisecontrol.net|nant|
I have a CC.NET project configured to call a common NAnt build file, which does some stuff, and then calls a child NAnt build file. The child build file name is specified by CC.NET to the command build file using a property. The hurdle that I am trying to get over is that the common build file log gets overwritten by the child build file log, so I don't get the common build log in the CC.NET build log. Anyone have any ideas on how to fix this? I thought about changing the child build's log, but reading up on the NAnt &lt;nant&gt; task doesn't allow me to change the child's output log.
If you want to be one of the best you need to specialise. If you become very good in many skills then you may never become truly excellent in one. I know because I have taken this route myself and have found it difficult to get employment at times. After all, who wants someone who is capable at many languages when there is someone who excels at the specific thing they need. If a company develops in C# then who would want someone who is OK at C# but also is good at C, Visual Basic, Perl and Cobol, when all they really want is the best possible C# developer for the money they can afford. After all, you will only ever be employed for one, maybe two of your skills. There are very few jobs for people who are good in 10 or 15 skills. If you are looking to a new skill then maybe check out the job boards and find which skills are particularly in need, but be aware that what is the flavour of the month this year may not even be on the scene next year, which will make all of that effort to learn the skill futile and wasted. What I would say is: 1. do one thing, and do it well. This may include supporting skills (C#, ASP.Net, SQL, LINQ etc). 2. If you want to choose something else, then choose something complementary. 3. Possibly most importantly, choose something you will enjoy. Maybe Ruby on Rails is the current flavour of the month, but if you don't enjoy doing it, then don't do it. Really, it's not worth it. You will never wish, on your death bed, that you had worked more in something you didn't enjoy. Another direction you could look at is maybe not for a particular development skill, but look for something else, maybe softskills like people management, beter business understanding or even look to something like literary skills to help improve your communications skills. All of these will help to allow you to do what you want to do more, and cut down on the stuff you really don't enjoy, thus helping to make your job more enjoyable. Apologies for the waffling here. Hope you are still awake :)
Depending on your mix os OSes, you might be better off creating packages for each class of system. Alternatively, if they all share the same ABI and hardware architecture, you could also compile static binaries.
Use e.g. [mysql_pconnect][1] [1]: http://de.php.net/manual/en/function.mysql-pconnect.php
You cannot instantiate connection pools manually. But you can use the "built in" connection pooling with the [mysql_pconnect][1] function. [1]: http://de.php.net/manual/en/function.mysql-pconnect.php
One critical thing you has to keep in mind about TFS, is that it likes to have the machine all to it self. So if you have to create a separate instance on Hyper-V do it using the proven Windows Server 2003 platform with SQL Server 2005. I am sure Microsoft has done a great job getting it to work under Windows Server 2008 and SQL Server 2008, however you don't get any additional features with this newer install and it is currently unproven in the wild. So my recommendation is to stick with what is known until the next release of TFS comes out. Also splitting the layers is definitely not recommended, especially in the workgroup edition where you will only be allowed to have 5 licensed users. Those 5 users will never exceed the server's needs. Also my recommendation is to not update Sharepoint if you don't need to. In my environment, we don't really use Sharepoint all that much, so I left it alone. Sharepoint is usually, in my experience, where most of the problems come from with TFS.
Connection Pooling in .NET/MSSQL?
|c#|.net|database|connectionpooling|
Is it necessary or advantageous to write custom connection pooling code when developing applications in .NET with an MSSQL database? I know that ADO.NET gives you the option to enable/disable connection pooling -- does that mean that it's built into the framework and I don't need to worry about it? Why do people talk about writing their own connection pooling software and how is this different than what's built into ADO.NET?
|c#|.net|database|connection-pooling|
Connection pooling in PHP
|php|
Is it possible to cache database connections when using PHP like you would in a J2EE container? If so, how?
|php|connection-pooling|
How do I model a chessboard when programming a computer to play chess?
|chess|
What data structures would you use to represent a chessboard for a computer chess program?
I've used [Traffic Shaper XP][1] on my XP dev box at work. It seems to handle any connection (not just HTTP). It wasn't perfect, but worked well enough for the tests I was doing. If you're on Windows maybe it'll do enough for you. [1]: http://bandwidthcontroller.com/trafficShaperXp.html
How Do You Communicate Service Layer Messages/Errors to Higher Layers Using MVP?
|c#|asp.net|exception|mvp|n-tier-architecture|
I'm currently writing an ASP.Net app from the UI down. I'm implementing an MVP architecture because I'm sick of Winforms and wanted something that had a better separation of concerns. So with MVP, the Presenter handles events raised by the View. Here's some code that I have in place to deal with the creation of users: public class CreateMemberPresenter { private ICreateMemberView view; private IMemberTasks tasks; public CreateMemberPresenter(ICreateMemberView view) : this(view, new StubMemberTasks()) { } public CreateMemberPresenter(ICreateMemberView view, IMemberTasks tasks) { this.view = view; this.tasks = tasks; HookupEventHandlersTo(view); } private void HookupEventHandlersTo(ICreateMemberView view) { view.CreateMember += delegate { CreateMember(); }; } private void CreateMember() { if (!view.IsValid) return; try { int newUserId; tasks.CreateMember(view.NewMember, out newUserId); view.NewUserCode = newUserId; view.Notify(new NotificationDTO() { Type = NotificationType.Success }); } catch(Exception e) { this.LogA().Message(string.Format("Error Creating User: {0}", e.Message)); view.Notify(new NotificationDTO() { Type = NotificationType.Failure, Message = "There was an error creating a new member" }); } } } I have my main form validation done using the built in .Net Validation Controls, but now I need to verify that the data sufficiently satisfies the criteria for the Service Layer. Let's say the following Service Layer messages can show up: - E-mail account already exists (failure) - Refering user entered does not exist (failure) - Password length exceeds datastore allowed length (failure) - Member created successfully (success) Let's also say that more rules will be in the service layer that the UI cannot anticipate. Currently I'm having the service layer throw an exception if things didn't go as planned. Is that a sufficent strategy? Does this code smell to you guys? If I wrote a service layer like this would you be annoyed at having to write Presenters that use it in this way? Return codes seem too old school and a bool is just not informative enough.
From a purely theoretical stance: The implementation I am familiar with would be to build a Deterministic Finite Automaton to recognize the regex. This is done in O(2^m), m being the size of the regex, using a standard algorithm. Once this is built, running a string through it is linear in the length of the string - O(n), n being string length. A replacement on a match found in the string should be constant time. So overall, I suppose O(2^m + n).
C++: Reading from text file until EOF repeats last line
|c++|fstream|iostream|