instruction
stringlengths
0
30k
We're using [IdeaBlade][1] on our projects. I've found it to be pretty easy to use. [1]: http://www.ideablade.com/
Load Balancing of Process in 1 Server
|linux|load-balancing|
I have 1 process that receives incoming connection from port 1000 in 1 **linux** server. However, 1 process is not fast enough to handle all the incoming request. I want to run multiple processes in the server but with 1 end-point. In this way, the client will only see 1 end-point/process not multiple. I have checked LVS and other Load Balancing Solution. Those solutions seem geared towards multiple servers load-balancing. Any other solution to help on my case?
Adding Functionality to Rails
|ruby|ruby-on-rails|
I'm working on a Rails app and am looking to include some functionality from an [earlier question][1] I asked here. However, I'm having problems getting it to work. I was under the impression that I should just make a file in the lib directory, so I named it 'get_ip.rb', with the contents: require 'socket' module GetIP def local_ip orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true # turn off reverse DNS resolution temporarily UDPSocket.open do |s| s.connect '64.233.187.99', 1 s.addr.last end ensure Socket.do_not_reverse_lookup = orig end end I had also tried defining GetIP as a class but when I do the usual `ruby script/console`, I'm not able to use the `local_ip` method at all. Any ideas? [1]: http://stackoverflow.com/questions/42566/getting-the-hostname-or-ip-in-ruby-on-rails
updating an auto_now DateTimeField in a parent model w/ Django
|database|orm|django|
I've got two models: Message and Attachment. Each attachment is attached to a specific message, using a ForeignKey on the Attachment model. Both models have an auto_now DateTimeField called updated. I'm trying to make it so that when any attachment is saved, it also sets the updated field on the associated message to now. Here's my code: def save(self): super(Attachment, self).save() self.message.updated = self.updated Will this work, and if you can explain it to me, why? If not, how would I accomplish this?
|python|database|django|orm|
[@Mark Biek][1] I was going to say that, but you beat me to it! Anyways, I just wanted to add that there is also the -R option: ssh -R 8022:myinsideserver:22 paul@myoutsideserver The difference is what machine you are connecting to/from. My boss showed me this trick not too long ago, and it is definitely really nice to know... we were behind a firewall and needed to give external access to a machine... he got around it by ssh -R to another machine that was accessible... then connections to that machine were forwarded into the machine behind the firewall, so you need to use -R or -L based on which machine you are on and which you are ssh-ing to. Also, I'm pretty sure you are fine to use a regular user as long as the port you are forwarding (in this case the 8022 port) is not below the restricted range (which I think is 1024, but I could be mistaken), because those are the "reserved" ports. It doesn't matter that you are forwarding it to a "restricted" port because that port is not being opened (the machine is just having traffic sent to it through the tunnel, it has no knowledge of the tunnel), the 8022 port IS being open and so is restricted as such. EDIT: Just remember, the tunnel is only open so long as the initial ssh remains open, so if it times out or you exit it, the tunnel will be closed. [1]: http://stackoverflow.com/questions/45230/is-it-possible-to-forward-ssh-requests-that-come-in-over-a-certain-port-to-anot#45237
When merging two code branches in TFS, I get an error stating: "the given key was not present in the dictionary". Some files are checked out and show up in "Pending Changes", but no changes are actually made. I have a workaround: 1. Attempt to merge (Fails with error) 2. Get latest from trunk 3. Undo all pending changes with "merge, edit" or "merge" 4. Merge Again (Works this time) Any ideas what's causing this error?
|tfs|merge|
Error using Team Foundation Server merge function
When merging two code branches in Team Foundation Server I get the following error: "the given key was not present in the dictionary" Some files are checked out and show up in "Pending Changes", but no changes are actually made. I have a workaround: 1. Attempt to merge (fails with error) 2. Get latest from trunk 3. Undo all pending changes with "merge, edit" or "merge" 4. Merge Again (works this time) Any ideas on what's causing this error?
When merging two code branches in Team Foundation Server I get the following error: "the given key was not present in the dictionary" Some files are checked out and show up in "Pending Changes", but no changes are actually made. I have a workaround: 1. Attempt to merge (fails with error) 2. Get latest from trunk 3. Undo all pending changes with "merge, edit" or "merge" 4. Merge Again (works this time) Any ideas on what's causing this error? *Edit after answer: Seems like a bug. And it's extremely repeatable. Every single merge does it. I'll send a bug report to MS and see what happens.*
Using Regular Expressions is probably the best way. Here's an example: function validateEmail(email) { var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\ ".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA -Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ return email.match(re) } But keep in mind that one should not rely only upon JavaScript validation. JavaScript can easily be disabled. This should be validated on the server side as well.
Can't you just start with a hash code, and if the hash codes match, do a character by character comparison?
What is the best approach for disabling a submit button?
|webforms|asp.net|javascript|
Details: * Only disable after user clicks the submit button * ASP.NET Webforms (.NET 1.1) * Prefer jQuery (if any library at all) * Must be enabled if form reloads (i.e. credit card failed) This isn't a necessity that I do this, but if there is a simple way to do it without having to change too much, I'll do it. (i.e. if there isn't a simple solution, I probably won't do it, so don't worry about digging too deep)
What is the best approach for (client-side) disabling of a submit button?
Details: * Only disable after user clicks the submit button, but before the posting back to the server * ASP.NET Webforms (.NET 1.1) * Prefer jQuery (if any library at all) * Must be enabled if form reloads (i.e. credit card failed) This isn't a necessity that I do this, but if there is a simple way to do it without having to change too much, I'll do it. (i.e. if there isn't a simple solution, I probably won't do it, so don't worry about digging too deep)
You might want to experiment with a not-strictly-database solution like a [Java Content Repository][1] implementation (e.g. [Apache Jackrabbit][2]) and use a search engine built on top of that like [Apache Lucene][3]. This solution with the appropriate caching mechanisms would possibly yield better performance than a home-grown solution. However, I don't really think that in a small or medium-sized application you would require a more sophisticated implementation than the normalized database mentioned in earlier posts. EDIT: minor typo corrected. EDIT: with your clarification it seems more compelling to use a JCR-like solution with a search engine. That would greatly simplify your programs in the long run. [1]: http://en.wikipedia.org/wiki/Content_repository_API_for_Java [2]: http://en.wikipedia.org/wiki/Apache_Jackrabbit [3]: http://en.wikipedia.org/wiki/Apache_Lucene
You won't be able to avoid joins and still be somewhat normalized. My approach is to have a Tag Table. TagId (PK)| TagName (Indexed) Then, you have a TagXREFID column in your items table. This TagXREFID column is a FK to a 3rd table, I'll call it TagXREF: TagXrefID | ItemID | TagId So, to get all tags for an item would be something like: SELECT Tags.TagId,Tags.TagName FROM Tags,TagXrefId WHERE TagXrefID.TagId = Tags.TagId AND TagXrefID.ItemID = @ItemID
You won't be able to avoid joins and still be somewhat normalized. My approach is to have a Tag Table. TagId (PK)| TagName (Indexed) Then, you have a TagXREFID column in your items table. This TagXREFID column is a FK to a 3rd table, I'll call it TagXREF: TagXrefID | ItemID | TagId So, to get all tags for an item would be something like: SELECT Tags.TagId,Tags.TagName FROM Tags,TagXref WHERE TagXref.TagId = Tags.TagId AND TagXref.ItemID = @ItemID And to get all items for a tag, I'd use something like this: SELECT * FROM Items, TagXref WHERE TagXref.TagId = ( SELECT Tags.TagId FROM Tags WHERE Tags.TagName = @TagName; ) AND Items.ItemId = TagXref.ItemId;
You won't be able to avoid joins and still be somewhat normalized. My approach is to have a Tag Table. TagId (PK)| TagName (Indexed) Then, you have a TagXREFID column in your items table. This TagXREFID column is a FK to a 3rd table, I'll call it TagXREF: TagXrefID | ItemID | TagId So, to get all tags for an item would be something like: SELECT Tags.TagId,Tags.TagName FROM Tags,TagXref WHERE TagXref.TagId = Tags.TagId AND TagXref.ItemID = @ItemID And to get all items for a tag, I'd use something like this: SELECT * FROM Items, TagXref WHERE TagXref.TagId IN ( SELECT Tags.TagId FROM Tags WHERE Tags.TagName = @TagName; ) AND Items.ItemId = TagXref.ItemId; To AND a bunch of tags together, You would to modify the above statement slightly to add AND Tags.TagName = @TagName1 AND Tags.TagName = @TagName2 etc...and dynamically build the query.
You might want to look at Oracle XE. I cannot remember all of the differences, but O-Lite didn't fit my project needs. Oracle XE is a very good database for local development. Brad
I have recently integrated the [Compass][1] search engine into a Java EE 5 application. It is based on [Lucene Java][2] and supports different ORM frameworks as well as other types of models like XML or no real model at all ;) In the case of an object model managed by an ORM framework you can annotate your classes with special annotations (e.g. @Searchable), register your classes and let Compass index them on application startup and listen to changes to the model automatically. When it comes to searching, you have the power of Lucene at hand. Compass then gives you instances of your model objects as search result. It's not PHP, but you said it didn't have to be PHP necessarily ;) Don't know if this helps, though... [1]: http://www.compass-project.org/ [2]: http://lucene.apache.org/java/docs/index.html
+1 for PuTTy... been using it for the last decade and never needed anything else!
If you are using Delphi, I highly recommend [Indy][1] sockets, a set of classes for easy manipulation of sockets and many other internet protocols (HTTP, FTP, NTP, POP3 etc.) [1]: http://www.indyproject.org/index.en.aspx
I use: - Infragistics (.NET WinForms controls) - LeadTools (video capture) - Xtreme ToolkitPro (MFC controls) - National Instruments Measurement Studio (computational libraries, plotting, and DAQ) I've found significant bugs in every one of these, so I try to limit their use as much as possible. Infragisitcs is pretty good for what it is, and National Instruments is by far the best, although quite limited. I would avoid LeadTools at all cost.
I just use simple questions that anyone can answer: What color is the sky? What color is an orange? What color is grass? It makes it so that someone has to custom program a bot to your site, which probably isn't worth the effort. If they do, you just change the questions.
Pulling loads of binary data out of your DB over the wire is going to cause huge latency issues and won't scale well. Store paths in the DB and let your webserver take the load - it's what it was designed for!
By far the most painful part of moving an application from XP to Vista (from my point of view) is dealing with the numerous services and IPv6 stuff that uses ports which were previously free, and dealing with the Wireless Provisioning -> Native WiFi transition. The UAC stuff is basically a moot point; there is very little the application developer needs to do.
[IO::Dir][1] is nice and provides a tied hash interface as well. From the perldoc: use IO::Dir; $d = IO::Dir->new("."); if (defined $d) { while (defined($_ = $d->read)) { something($_); } $d->rewind; while (defined($_ = $d->read)) { something_else($_); } undef $d; } tie %dir, 'IO::Dir', "."; foreach (keys %dir) { print $_, " " , $dir{$_}->size,"\n"; } So you could do something like: tie %dir, 'IO::Dir', $directory_name; my @dirs = keys %dir; [1]: http://search.cpan.org/~gbarr/IO-1.2301/IO/Dir.pm
Interestingly, if you click on the screen (remove the focus from the textbox) on second example with only one textbox, the event onClick fires... So it's not an expected behaviour since it only occurs when you have just one textbox _and_ you have the focus on the textbox. I'm afraid you've found a bug on the browser and you'll have to find a workaround, or avoid using the onClick event in that case. I use the onSubmit event for validations because it's a "safer" event that is more likely to work on different browsers and situations.
First you need to setup where Ant can find the Emma libraries: <path id="emma.lib" > <pathelement location="${emma.dir}/emma.jar" /> <pathelement location="${emma.dir}/emma_ant.jar" /> </path> Then import the task: <taskdef resource="emma_ant.properties" classpathref="emma.lib" /> Then instrument the code: <target name="coverage.instrumentation"> <mkdir dir="${instr.target}"/> <mkdir dir="${coverage}"/> <emma> <instr instrpath="${target}" destdir="${instr.target}" metadatafile="${coverage}/metadata.emma" mode="copy"> <filter excludes="*Test*"/> </instr> </emma> <!-- Update the that will run the instrumented code --> <path id="test.classpath"> <pathelement location="${instr.target}"/> <path refid="junit.classpath"/> <pathelement location="${emma.dir}/emma.jar"/> </path> </target> Then run a target with the proper VM arguments like: <jvmarg value="-Demma.coverage.out.file=${coverage}/coverage.emma" /> <jvmarg value="-Demma.coverage.out.merge=true" /> Finally generate your report: <target name="coverage.report" depends="coverage.instrumentation"> <emma> <report sourcepath="${source}" depth="method"> <fileset dir="${coverage}" > <include name="*.emma" /> </fileset> <html outfile="${coverage}/coverage.html" /> </report> </emma> </target>
According to the [XML-RPC Spec][1] it returns the "fault" in the xml. Is this the "Exception" you are referring to or are you refering to a Java Exception generated while making the XML-RPC call? **Fault example** HTTP/1.1 200 OK Connection: close Content-Length: 426 Content-Type: text/xml Date: Fri, 17 Jul 1998 19:55:02 GMT Server: UserLand Frontier/5.1.2-WinNT <?xml version="1.0"?> <methodResponse> <fault> <value> <struct> <member> <name>faultCode</name> <value><int>4</int></value> </member> <member> <name>faultString</name> <value> <string>Too many parameters.</string> </value> </member> </struct> </value> </fault> </methodResponse> [1]: http://www.xmlrpc.com/spec
I've been using Assembly.CodeBase instead of Location: Assembly a; a = Assembly.GetAssembly(typeof(DaoTests)); string s = a.CodeBase.ToUpper(); // file:///c:/path/name.dll Assert.AreEqual(true, s.StartsWith("FILE://"), "CodeBase is " + s); s = s.Substring(7, s.LastIndexOf('/') - 7); // 7 = "file://" while (s.StartsWith("/")) { s = s.Substring(1, s.Length - 1); } s = s.Replace("/", "\\"); It's been working, but I'm no longer sure it is 100% correct. The page at [http://blogs.msdn.com/suzcook/archive/2003/06/26/assembly-codebase-vs-assembly-location.aspx][1] says: *"The CodeBase is a URL to the place where the file was found, while the Location is the path where it was actually loaded. For example, if the assembly was downloaded from the internet, its CodeBase may start with "http://", but its Location may start with "C:\". If the file was shadow-copied, the Location would be the path to the copy of the file in the shadow copy dir. It’s also good to know that the CodeBase is not guaranteed to be set for assemblies in the GAC. Location will always be set for assemblies loaded from disk, however.*" You _may_ want to use CodeBase instead of Location. [1]: http://blogs.msdn.com/suzcook/archive/2003/06/26/assembly-codebase-vs-assembly-location.aspx
I want to show a chromeless modal window with a close button in the upper right corner. Is this possible?
[This other question][1] also has some useful links in it... [1]: http://stackoverflow.com/questions/22278/whats-a-good-way-to-encapsulate-data-access-with-phpmysql
How about: select top 3 with ties points from scores order by scores desc Not sure if "with ties" works on anything other the SQL Server.
How about: select top 3 with ties points from scores order by scores desc Not sure if "with ties" works on anything other the SQL Server. On SQL Server 2005 and up, you can pass the "top" number as an int parameter: select top (@n) with ties points from scores order by scores desc
How about: select top 3 with ties points from scores order by points desc Not sure if "with ties" works on anything other the SQL Server. On SQL Server 2005 and up, you can pass the "top" number as an int parameter: select top (@n) with ties points from scores order by points desc
<http://beta.stackoverflow.com/questions/25259/how-do-you-change-a-title-to-be-part-of-the-url-like-stackoverflow>
Here's how we do it. Note that there are probably more edge conditions than you realize at first glance.. if (String.IsNullOrEmpty(title)) return ""; // remove entities title = Regex.Replace(title, @"&\w+;", ""); // remove anything that is not letters, numbers, dash, or space title = Regex.Replace(title, @"[^A-Za-z0-9\-\s]", ""); // remove any leading or trailing spaces left over title = title.Trim(); // replace spaces with single dash title = Regex.Replace(title, @"\s+", "-"); // if we end up with multiple dashes, collapse to single dash title = Regex.Replace(title, @"\-{2,}", "-"); // make it all lower case title = title.ToLower(); // if it's too long, clip it if (title.Length > 80) title = title.Substring(0, 79); // remove trailing dash, if there is one if (title.EndsWith("-")) title = title.Substring(0, title.Length - 1); return title;
Have a look at the [Calais Viewer](http://sws.clearforest.com/calaisviewer/) for a real world application.
The filesystem's prety handy for storing binary data, which never works amazingly well in relational databases.
You should separate logic and presentation. Using MVP(Model-View-Presenter)/MVC (Model-View-Controller) patterns you can unit test you logic without relying on UI events. Also you can use [White framework][1] to simulate user input. I would highly recommend you to visit Microsoft's [Patterns&Practices developer center][2], especially take a look at composite application block and Prism - you can get a lot of information on test driven design. [1]: http://www.codeplex.com/white [2]: http://msdn.microsoft.com/en-us/practices/default.aspx
how to teach a crash course on C++
|c++|teaching|
In a few weeks we'll be teaching a crash course on C++ for Java programmers straight out of college. They have little or no experience yet with C or C++. Previous editions of this course were just 1 or 2 half-day sessions and covered topics including: * new language features, e.g. * header vs. implementation * pointers and references * memory management * operator overloading * templates * the standard libraries, e.g. * the C library headers * basic iostreams * basic STL * using libraries (headers, linking) * they'll be using Linux, so * basic Linux console commands * gcc and how to interpret its error messages * Makefiles and autotools * basic debugger commands * any topic they ask about During the course each person individually writes, compiles, runs, and debugs simple programs using the newly introduced features. Is this the best way to learn? Which topics do you consider most crucial? Which topics should be added or removed? Which topics just can't be covered adequately in a short time?
problem with dojo dijit.form.ValidationTextBox
|javascript|dojo|
The following xhtml code is not working: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" type="text/css" href="/dojotoolkit/dijit/themes/tundra/tundra.css" /> <link rel="stylesheet" type="text/css" href="/dojotoolkit/dojo/resources/dojo.css" /> <script type="text/javascript" src="/dojotoolkit/dojo/dojo.js" djConfig="parseOnLoad: true"/> <script type="text/javascript"> dojo.require("dijit.form.ValidationTextBox"); dojo.require("dojo.parser"); </script> </head> <body class="nihilo"> <input type="text" dojoType="dijit.form.ValidationTextBox" size="30" /> </body> </html> In FireBug I get the following error message: [Exception... "Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMNSHTMLElement.innerHTML]" nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)" location: "JS frame :: http://localhost:21000/dojotoolkit/dojo/dojo.js :: anonymous :: line 319" data: no] http://localhost:21000/dojotoolkit/dojo/dojo.js Line 319 Any idea what is wrong?
Don't know much about this field, but maybe an [Astaro security gateway][1]? [1]: http://www.astaro.com/
I'm still foggy as to why you can't store whatever object(s) you are binding against in session. If you could store that object in session the following should work: 1. On first Page_Load bind top user control to the object. Store the object in session. Viewstate will automatically be stored for those controls. 2. On post back, rebind your top user user control in the On_Init method instead of Page_Load. All of your controls should be recreated. Then when viewstate is restored, the values will be set to whatever is in viewstate. The only caveat here is that when you bind again on the post back, you have to make 100% sure that the same number of controls are created again. This should work. However, again if you can't use session for some reason, then you'll have to take a slightly different approach such as storing whatever you are binding against in the database after you bind your control, then pulling it out of the database and rebinding again on every post back. Note that in both scenarios, you have to rebind on every postback. I think I'm missing some obvious detail about your situation.
I think one of the most under-appreciated and lesser-known features of C# (3.5) are Expression Trees, **especially** when combined with Generics and Lambdas. This is an approach to API creation that newer libraries like NInject and Moq are using. For example, let's say that I want to register a method with an API and that API needs to get the method name Given this class: public class MyClass { public void SomeMethod() { /* Do Something */ } } Before, it was very common to see developers do this with strings and types (or something else largely string-based): RegisterMethod(typeof(MyClass), "SomeMethod"); Well, that sucks because of the lack of strong-typing. What if I rename "SomeMethod"? Now, in 3.5 however, I can do this in a strongly-typed fashion: RegisterMethod<MyClass>(cl => cl.SomeMethod()); In which the RegisterMethod class uses Expression<Action<T>> like this: void RegisterMethod<T>(Expression<Action<T>> action) where T : class { var expression = (action.Body as MethodCallExpression); if (expression != null) { // TODO: Register method Console.WriteLine(expression.Method.Name); } } This is one big reason that I'm in love with Lambdas and Expression Trees right now.
You might have an open transaction on the dev db...that gets me sometimes on SQL Server
Using generic classes with ObjectDataSource
|asp.net|generics|objectdatasource|
I have a generic Repository&lt;T&gt; class I want to use with an ObjectDataSource. Repository&lt;T&gt; lives in a separate project called DataAccess. According to <a href="http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet/browse_thread/thread/767f1a821d9b23da/b1e045958ae427a5?lnk=st#b1e045958ae427a5">this post from the MS newsgroups</a> (relevant part copied below): >Internally, the ObjectDataSource is calling Type.GetType(string) to get the type, so we need to follow the guideline documented in Type.GetType on how to get type using generics. You can refer to MSDN Library on Type.GetType: ><http://msdn2.microsoft.com/en-us/library/w3f99sx1.aspx> >From the document, you will learn that you need to use backtick (`) to denotes the type name which is using generics. >Also, here we must specify the assembly name in the type name string. >So, for your question, the answer is to use type name like follows: >TypeName="TestObjectDataSourceAssembly.MyDataHandler`1[System.String],TestObjectDataSourceAssembly" Okay, makes sense. When I try it, however, the page throws an exception: <asp:ObjectDataSource ID="MyDataSource" TypeName="MyProject.Repository`1[MyProject.MessageCategory],DataAccess" /> >[InvalidOperationException: The type specified in the TypeName property of ObjectDataSource 'MyDataSource' could not be found.] The curious thing is that this only happens when I'm viewing the page. When I open the "Configure Data Source" dialog from the VS2008 designer, it properly show me the methods on my generic Repository class. Passing the TypeName string to Type.GetType() while debugging also returns a valid type. So what gives?
I have a generic Repository&lt;T&gt; class I want to use with an ObjectDataSource. Repository&lt;T&gt; lives in a separate project called DataAccess. According to <a href="http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet/browse_thread/thread/767f1a821d9b23da/b1e045958ae427a5?lnk=st#b1e045958ae427a5">this post from the MS newsgroups</a> (relevant part copied below): >Internally, the ObjectDataSource is calling Type.GetType(string) to get the type, so we need to follow the guideline documented in Type.GetType on how to get type using generics. You can refer to MSDN Library on Type.GetType: ><http://msdn2.microsoft.com/en-us/library/w3f99sx1.aspx> >From the document, you will learn that you need to use backtick (`) to denotes the type name which is using generics. >Also, here we must specify the assembly name in the type name string. >So, for your question, the answer is to use type name like follows: >TypeName="TestObjectDataSourceAssembly.MyDataHandler`1[System.String],TestObjectDataSourceAssembly" Okay, makes sense. When I try it, however, the page throws an exception: <asp:ObjectDataSource ID="MyDataSource" TypeName="MyProject.Repository`1[MyProject.MessageCategory],DataAccess" /> >[InvalidOperationException: The type specified in the TypeName property of ObjectDataSource 'MyDataSource' could not be found.] The curious thing is that this only happens when I'm viewing the page. When I open the "Configure Data Source" dialog from the VS2008 designer, it properly shows me the methods on my generic Repository class. Passing the TypeName string to Type.GetType() while debugging also returns a valid type. So what gives?
MS SQL Stored Procedures.
I usually create a DataTier with LiNQ. It consist of repositories that implement composite interfaces, so I have total flexibility on how to use them. IPersonRepository : IReadRepository<Person>, ICreateRepository<Person>, IUpdateRepository<Person> //and so on.. They are mostly domain object centric, so they emit domain objects and take care of all the mapping logic themselves. They might also create some list dictionaries, f.ex a dictionary consisting of the id and name of a person, so I don't have to pull up too much from the db to display a drop down list. Although sometimes, for smaller projects, I just use Attribute base mapping without a .dbml. I feel that this approach gives a very clean application model, because all the messy data centric logic is hidden in the DataTier. The Business-/ServiceTier is pure business :)
For UI, check out [Ext][1]. It's great as a standalone library, though it can also be used with jQuery, YUI, Prototype and GWT. Samples: [http://extjs.com/deploy/dev/examples/samples.html][2] [1]: http://extjs.com/ [2]: http://extjs.com/deploy/dev/examples/samples.html
* SQL Server * All stored procedures * Handrolled polymorphic entity framework that I reuse from project to project to handle the Sproc Resultset -> Object mapping. I guess that makes me oldschool.
Another way to go would be to use ssh tunneling (which happens on the client side). You'd do an ssh command like this: ssh -L 8022:myinsideserver:22 paul@myoutsideserver That connects you to the machine that's accessible from the outside (myoutsideserver) and creates a tunnel through that ssh connection to port 22 (the standard ssh port) on the server that's only accessible from the inside. Then you'd do another ssh command like this (leaving the first one still connected): ssh -p 8022 paul@localhost That connection to port 8022 on your localhost will then get tunneled through the first ssh connection taking you over myinsideserver. There may be something you have to do on myoutsideserver to allow forwarding of the ssh port. I'm double-checking that now. **Edit** Hmmm. The ssh manpage says this >>>>Only the superuser can forward privileged ports. That sort of implies to me that the first ssh connection has to be as root. Maybe somebody else can clarify that.
Another way to go would be to use ssh tunneling (which happens on the client side). You'd do an ssh command like this: ssh -L 8022:myinsideserver:22 paul@myoutsideserver That connects you to the machine that's accessible from the outside (myoutsideserver) and creates a tunnel through that ssh connection to port 22 (the standard ssh port) on the server that's only accessible from the inside. Then you'd do another ssh command like this (leaving the first one still connected): ssh -p 8022 paul@localhost That connection to port 8022 on your localhost will then get tunneled through the first ssh connection taking you over myinsideserver. </strike> There may be something you have to do on myoutsideserver to allow forwarding of the ssh port. I'm double-checking that now. **Edit** Hmmm. The ssh manpage says this: **Only the superuser can forward privileged ports. ** <strike>That sort of implies to me that the first ssh connection has to be as root. Maybe somebody else can clarify that.</strike> It looks like superuser privileges aren't required as long as the forwarded port ***(in this case, 8022)*** isn't a privileged port (like 22). Thanks for the clarification [Mike Stone](http://stackoverflow.com/questions/45230/is-it-possible-to-forward-ssh-requests-that-come-in-over-a-certain-port-to-anot#45254).
|asp.net|javascript|.net-1.1|webforms|
|asp.net|javascript|jquery|webforms|.net-1.1|
How big are your strings? Arbitrarily long strings cannot be compressed into 32/64 bit format.
Some notable problems I saw when attempting to convert a large number of AS2 classes to AS3: ### Package naming class your.package.YourClass { } becomes package your.package { class YourClass { } } ### Imports are required You must explicitly import any outside classes used -- referring to them by their fully qualified name is no longer enough. ### Interface methods can't be labelled 'public' This makes total sense, but AS2 will let you do it so if you have any they'll need to be removed. ### Explicit 'override' keyword Any functions that override a parent class function must be declared with the _override_ keyword, much like C#. Along the same lines, if you have interfaces that extend other interfaces and redeclare functions, those overrides must be removed (again, as with _public,_ this notation didn't make sense anyway but AS2 let you do it). ### All the Flash builtin stuff changed You alluded to this above, but it's now _flash.display.MovieClip_ instead of just _MovieClip,_ for example. There are a lot of specifics in this category, and I didn't get far enough to find them all, but there's going to be a lot of annoyance here. ### Conclusion I didn't get to work on this conversion to the point of success, but I was able in a matter of hours to write a quick C# tool that handled every aspect of this except the _override_ keyword. Automating the imports can be tricky -- in my case the packages we use all start with a few root-level packages so they're easy to detect.
Yes -- you can also use a newer version of Visual Studio. As long as you have the PDB file for the target application it doesn't matter what version it was built with (well, VS6 might not understand a newer PDB, but backwards should be fine). The remote debugging experience on newer VS versions is a lot smoother than old versions in my experience. It is also easier to set up if you can arrange things so that you are attaching to an existing process that you have started manually rather than kicking off the process (avoid a lot of the path setup).
If all you want to do is remove the changes made in revision 3, you might want to use git revert. Git revert simply creates a new revision with changes that undo all of the changes in the revision you are reverting. What this means, is that you retain information about both the unwanted commit, and the commit that removes those changes. This is probably a lot more friendly if it's at all possible the someone has pulled from your repository in the mean time, since the revert is basically just a standard commit.
You shouldn't need to import any win32 functions for this. If .Focus() isn't enough the form should also have a .BringToFront() method you can use. If that fails, you can set it's .TopMost property to true. You don't want to _leave_ it true forever, so then call Application.DoEvents so the form can process that message and set it back to false.
If you don't want collisions, try something insane like SHA-512. I can't guarantee there won't be collisions, but I don't think they have found any yet.
I'm still foggy as to why you can't store whatever object(s) you are binding against in session. If you could store that object in session the following should work: 1. On first load bind your top user control to the object during On_Init. Store the object in session. Viewstate will automatically be stored for those controls. 2. On postback, rebind your top user user control in the On_Init method against the object you stored in session. All of your controls should be recreated before the viewstate load. Then when viewstate is restored, the values will be set to whatever is in viewstate. The only caveat here is that when you bind again on the post back, you have to make 100% sure that the same number of controls are created again. The key to using Repeaters, Gridviews etc... with dynamic controls inside of them is that they **have** to be rebound on every postback before the viewstate is loaded. On_Init is typically the best place to do this. There is no technical constraint in the framework that dictates that you must do all your work in Page_Load on the first load. This should work. However, again if you can't use session for some reason, then you'll have to take a slightly different approach such as storing whatever you are binding against in the database after you bind your control, then pulling it out of the database and rebinding again on every post back. Note that in both scenarios, you have to rebind on every postback. I think I'm missing some obvious detail about your situation.
I'm still foggy as to why you can't store whatever object(s) you are binding against in session. If you could store that object in session the following should work: 1. On first load bind your top user control to the object during On_Init. Store the object in session. Viewstate will automatically be stored for those controls. 2. On postback, rebind your top user user control in the On_Init method against the object you stored in session. All of your controls should be recreated before the viewstate load. Then when viewstate is restored, the values will be set to whatever is in viewstate. The only caveat here is that when you bind again on the postback, you have to make 100% sure that the same number of controls are created again. The key to using Repeaters, Gridviews etc... with dynamic controls inside of them is that they **have** to be rebound on every postback before the viewstate is loaded. On_Init is typically the best place to do this. There is no technical constraint in the framework that dictates that you must do all your work in Page_Load on the first load. This should work. However, again if you can't use session for some reason, then you'll have to take a slightly different approach such as storing whatever you are binding against in the database after you bind your control, then pulling it out of the database and rebinding again on every postback. Am I missing some obvious detail about your situation? I know it can be very tricky to explain the subtleties of the situation without posting code.
> I have to explicitly null the session > value during non postbacks in order to > emulate how ViewState works. I'm still foggy as to why you can't store whatever object(s) you are binding against in session. If you could store that object in session the following should work: 1. On first load bind your top user control to the object during On_Init. Store the object in session. Viewstate will automatically be stored for those controls. If you have to bind the control the first time on Page_Load that is ok, but you'll end up having events that call bind if you follow the next step. 2. On postback, rebind your top user user control in the On_Init method against the object you stored in session. All of your controls should be recreated before the viewstate load. Then when viewstate is restored, the values will be set to whatever is in viewstate. The only caveat here is that when you bind again on the postback, you have to make 100% sure that the same number of controls are created again. The key to using Repeaters, Gridviews etc... with dynamic controls inside of them is that they **have** to be rebound on every postback before the viewstate is loaded. On_Init is typically the best place to do this. There is no technical constraint in the framework that dictates that you must do all your work in Page_Load on the first load. This should work. However, again if you can't use session for some reason, then you'll have to take a slightly different approach such as storing whatever you are binding against in the database after you bind your control, then pulling it out of the database and rebinding again on every postback. Am I missing some obvious detail about your situation? I know it can be very tricky to explain the subtleties of the situation without posting code.
There is also [DP_DateExtensions][1], though I believe DateJS is more robust. [1]: http://www.depressedpress.com/Content/Development/JavaScript/Extensions/DP_DateExtensions/Index.cfm
From what it says on the PHP website, you can use crypt() in the following method: <?php // Set the password & username $username = 'user'; $password = 'mypassword'; // Get the hash, letting the salt be automatically generated $hash = crypt($password); // write to a file file_set_contents('.htpasswd', $username ':' . $contents); ?> Part of this example can be found: [http://ca3.php.net/crypt][1] This will of course overwrite the entire existing file, so you'll want to do some kind of concatination. I'm not 100% sure this will work, but I'm pretty sure. [1]: http://ca3.php.net/crypt
It can be done in CSS! Don't let people tell you otherwise. The easiest, most pain-free way to do it is to use the [Faux Columns](http://www.alistapart.com/articles/fauxcolumns/) method. However, if that solution doesn't work for you, you'll want to read up on [this technique](http://www.positioniseverything.net/articles/onetruelayout/equalheight). But be warned, this is the kind of CSS hackery that will make you wake up in a cold sweat in the middle of the night. The gist of it is that you assign a large amount of padding to the bottom of the column, and a negative margin of the same size. Then you place your columns in a container that has `overflow: hidden` set. More or less the padding/margin values allow the box to keep expanding until it reaches the end of the wrapper (which is determined by the column with the most content), and any extra space generated by the padding is cut off as overflow. It doesn't make much sense, I know... <div id="wrapper"> <div id="col1">Content</div> <div id="col2">Longer Content</div> </div> #wrapper { overflow: hidden; } #col1, #col2 { padding-bottom: 9999px; margin-bottom: -9999px; } Be sure to read the entire article I linked to, there are a number of caveats and other implementation issues. It's not a pretty technique, but it works fairly well.
Yes, ++ to Matt and System.AddIn (a two-part MSDN magazine article about System.AddIn are available [here](http://msdn.microsoft.com/en-us/magazine/cc163476.aspx) and [here](http://msdn.microsoft.com/en-us/magazine/cc163460.aspx)). Another technology you might want to look at to get an idea where the .NET Framework might be going in the future is the [Managed Extensibility Framework](http://www.codeplex.com/mef) currently available in CTP form on Codeplex.
Algorithm to decide if digital audio data is clipping?
|algorithm|audio|heuristics|
Is there an algorithm or some heuristic to decide whether digital audio data is [clipping][1]? [1]: http://en.wikipedia.org/wiki/Clipping_(audio)#Digital_clipping
Thanks to the answers I received I was able to create something like the following, which suits my needs. My question was somewhat ambiguous..thanks for following up...my final problem was solved by including "selected" in the option that I wanted selected. HTML <label>One<input name="myRadio" type="radio" value="1" /></label> <label>Two<input name="myRadio" type="radio" value="2" /></label> <select id="mySelect" size="9"></select> Javascript $(function() { $('#mySelect').children().remove().end().append('<option selected value="One">One option</option>') ; // clear the select box, then add one option which is selected $("input[name='myRadio']").filter( "[value='1']" ).attr( "checked", "checked" ); // select radio button with value 1 // bind click event to each radio button $("input[name='myRadio']").bind("click", function() { switch(this.value) { case "1": $('#mySelect').find('option').remove().end().append('<option selected value="One">One option</option>') ; break ; case "2": $('#mySelect').find('option').remove() ; var items = ["Item1", "Item2", "Item3"] ; // set locally for demo var options = '' ; for (var i = 0; i < items.length; i++) { if (i==0) { options += '<option selected value="' + items[i] + '">' + items[i] + '</option>'; } else {options += '<option value="' + items[i] + '">' + items[i] + '</option>';} } $('#mySelect').html(options); // populate select box with array break ; } // Switch end } // bind function end ); // bind end }); // Event listener end
You haven't described how you're trying to use the method, so I apologize in advance if this is stuff you already know. The methods on a module never come into use unless the module is included into a class. Instance methods on a class require there to be an instance of the class. You probably want a class method instead. And the file itself should be loaded, generally through the require statement. If the following code is in the file getip.rb, require 'socket' class GetIP def self.local_ip orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true UDPSocket.open do |s| s.connect '64.233.187.99', 1 s.addr.last end ensure Socket.do_not_reverse_lookup = orig end end Then you should be able to run it by saying, require 'getip' GetIP.local_ip
Django Calendar Widget?
|django|calendar|
Does anyone know of any existing packages or libraries that can be used to build a calendar in a django app?
How do I make AutoCompleteExtender render above select controls in IE6
|asp.net|internet-explorer-6|autocompleteextender|
When an AutoCompleteExtender is displayed in IE6 it seems to ignore z-index and renders below any select controls (like dropdownlists) in IE6. <asp:TextBox ID="TextBox1" runat="server" /> <cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" TargetControlID="TextBox1" EnableCaching="true" CompletionSetCount="5" FirstRowSelected="true" ServicePath="~/Services/Service1.asmx" ServiceMethod="GetSuggestion" /> <asp:DropDownList ID="DropDownList1" runat="server"> <asp:ListItem Text="Item 1" Value="0" /> <asp:ListItem Text="Item 2" Value="1" /> </asp:DropDownList> How do I make it render above dropdownlists?
A quick google search reveals [django-calendar](http://code.google.com/p/django-calendar/), which looks like exactly what you need. It would also be worth looking at the snippets under the calendar tag on Django Snippets at <http://www.djangosnippets.org/tags/calendar/>.
The question is a little unclear to me, but I suspect the answer you are looking for is to have a single process accepting tasks from the network, and then forking off 'worker processes' to actually perform the work (before returning the result to the user). In that way, the work which is being done does not block the acceptance of more requests. As you point out, the term load balancing carries the implication of multiple servers - what you want to look for is information about how to write a linux network daemon. The two kes system calls you'll want to look at are called [fork and exec][1]. [1]: http://en.wikipedia.org/wiki/Fork-exec
Java, Signed JARs and JAAS. Java to prevent buffer overflow and pointer/stack whacking exploits. Don't use JNI. ( Java Native Interface) it exposes you to DLL/Shared libraries. Signed JAR's to stop class loading being a security problem. JAAS can let your application not trust anyone, even itself. J2EE has (admittedly limited) built-in support for Role based security. There is some overhead for some of this but the security holes go away.