instruction
stringlengths
0
30k
|c#|linq|
I'm trying to get the following bit of code to work in LINQPad but am unable to index into a var. Anybody know how to index into a var in LINQ? string[] sa = {"one", "two", "three"}; sa[1].Dump(); var va = sa.Select( (a,i) => new {Line = a, Index = i}); va[1].Dump(); // Cannot apply indexing with [] to an expression of type 'System.Collections.Generic.IEnumerable<AnonymousType#1>'
You could use the AutoCompleteExtender's ContextKey parameter to use a single web method that accepted a type name as its context key. Then in the web method, use reflection and that parameter to return the desired string[].
As the comment says, you cannot apply indexing with `[]` to an expression of type `System.Collections.Generic.IEnumerable<T>`. The IEnumerable interface only supports the method `GetEnumerator()`. However with LINQ you can call the extension method `ElementAt(int)`.
[Application.Init][1] is probably a more appropriate event to use, if you only want the code to execute on the first load. [1]: http://www.asp.net/AJAX/documentation/live/ClientReference/Sys/ApplicationClass/SysApplicationInitEvent.aspx
Haskell is a "pure" functional language, where as F# has aspects of both imperative/OO and functional languages. Haskell also has lazy evaluation, which is fairly rare amongst functional languages. What do these things mean? A pure functional language, means there are no side effects (or changes in shared state, when a function is called) which means that you are guaranteed that if you call f(x), nothing else happens besides returning a value from the function, such as console output, database output, changes to global or static variables.. and although Haskell can have non pure functions (through monads), it must be 'explicitly' implied through declaration. Pure functional languages and 'No side effect' programming has gained popularity recently as it lends itself well to multi core concurrency, as it is much harder to get wrong with no shared state, rather than a myriad of locks & semaphores. Lazy evaluation is where a function is NOT evaluated until it is absolutely necessary required. meaning that many operation can be avoided when not necessary. Think of this in a basic C# if clause such as this; if(IsSomethingTrue() && AnotherThingTrue()) { do something; } If IsSomethingTrue() is false then AnotherThingTrue() method is never evaluated, While Haskell is an amazing language, the major benefit of F# (for the time being), is that it sits on top of the CLR. This lends it self to polyglot programming. One day, you may write your web UI in ASP.net MVC, your business logic in C#, your core algorithms in F# and your unit tests in Ironruby.... All amongst the the .Net framework. Listen to the latest Software Engineering radio with Simon Peyton Jones for more info on Haskell. http://www.se-radio.net/ good luck
|algorithm|state|
What kind of programming problems are state machines most suited for? I have read about parsers being implemented using state machines, but would like to find out about problems that scream out to be implemented as a state machine.
MSI Installer fails without removing a previous install
|versioning|windows-installer|
I have built an MSI that I would like to deploy, and update frequently. Unfortunately, when you install the MSI, and then try to install a newer version of the same MSI, it fails with a message like "Another version of this product is already installed. Installation of this version cannot continue..." appears. The MSI was built with a Visual Studio 2008 Setup Project. I have tried setting the "Remove Previous Versions" property to both true and false, in an effort to just make newer versions overwrite the older install, but nothing has worked. At a previous company I know I did not have this problem with installers built by Wise and Advanced Installer. Is there a setting I am missing? Or is my desired functionality not supported by the VS 2008 Setup Project?
square brackets in URLs
|url|java|apache|
Are square brackets in URLs allowed? I noticed that [Apache commons HttpClient][1] (3.0.1) throws an IOException, wget and Firefox however accept square brackets. URL example: <tt>http://example.com/path/to/file[3].html</tt> [1]: http://hc.apache.org/httpclient-3.x/index.html
|java|apache|url|
Are square brackets in URLs allowed? I noticed that [Apache commons HttpClient][1] (3.0.1) throws an IOException, wget and Firefox however accept square brackets. URL example: <tt>http://example.com/path/to/file[3].html</tt> [1]: http://hc.apache.org/httpclient-3.x/index.html My HTTP client encounters such URLs but I'm not sure whether to patch the code or to throw an exception (as it actually should be).
Stateful protocols such as TCP are often represented as state machines. However it's rare that you should want to implement anything as a state machine proper. Usually you will use a corruption of one, i.e. have it carrying out a repeated action while sitting in one state, logging data while it transitions, or exchanging data while remaining in one state.
Workflow (see WF in .net 3.0)
They have many uses, parsers being a notable one. I have personally used simplified state machines to implement complex multi-step task dialogs in applications.
A parser example. I recently wrote a parser that takes a binary stream from another program. The meaning of the current element parsed indicates the size/meaning of the next elements. There are a (small) finite number of elements possible. Hence a state machine.
Hmm, I don't understand the problem. I downloaded and tried your example solution file. An exception is thrown in TimeDefLexer.cs, line 852, which is subsequently handled by the catch block in Program.cs that just says *Handled exception*. If I uncomment the catch block above it, it will enter that block instead. What seems to be the problem here? As Kibbee said, Visual Studio will stop on exceptions, but if you ask it to continue, the exception will get caught by your code.
If this is not about porting but creating, you should really consider OpenGL as this API is as powerful as DirectX and much easier to port to Mac or Linux. I don't know your requirements so better mention it.
no (and i've used both)
How do the CakePHP and codeigniter frameworks compare to the ASP.NET MVC framework?
|php|asp.net-mvc|asp-classic|cakephp|
As a classic ASP developer about once a year since ASP.NET came out I decide I really gotta buckle down and learn this fancy new ASP.NET. A few days in and messing with code behinds and webforms and all this other stuff I decide the new fancy stuff is whack and go find something else to learn (PHP and Ruby and Python were all fun to play with but I couldn't use it much with my existing ASP stuff). Anyway, one project came up and I was able to use PHP and CakePHP and after getting my head around MVC I finally found something I liked and felt is was worth using over ASP (PHP is cool too but it feels a lot like ASP so maybe that's why I like it so much). But now with Jeff and the SO team raving about ASP.NET MVC, I think it's about time I start messing with ASP.NET again but I keep thinking that PHP is free and blah blah blah . . . is ASP.NET MVC that much better than PHP with tools like CakePHP? I know about compiled vs. not compiled and speed issues but most of that seems like a non-issue when you factor in all the caching and the fact that you can compile your PHP if you want.
I don't want a holy war, but please answer a highly subjective question with a yes/no answer. Yes, you may see a productivity increase because the powerful functionality. No, you will not see a productivity increase because the patterns and metaphors used in emacs may not align with you brain.
Emacs documentation is a forest. I came from emacs to vim when I realized how organized vim's documentation is, and how chordable many of the features are. I don't know what lies down the path of an emacs expert, but I will warn you that learning to do anything useful in it takes a long time, and wont make you any better at nethack. Stick with vim. Textmate is a better emacs for macs, though that wont help you with solaris. Eclipse is kinda cool though, and has a lot of plugins.
I prefer emacs to vi, but I'm comfortable in both. There are some things that you can do in emacs that make it more powerful than vi, but not all of them are even programming-related. (Can you send email or read news from within vi? No, but who cares?) If you're comfortable with lisp (I'm not), you might be able to write add-ons and modes and stuff to make your life easier, but that's just likely to be syntax colouring and brace matching and eye candy like that. I will stop rambling now. Will your **productivity** increase using emacs? No.
What is a jump table?
|c++|c|memory|
Can someone explain the mechanics of a jump table and why is would be needed in embedded systems?
Josh Bloch's excellent talk about [good API design][1] has a few good bits of advice: - Classes should do one thing and do it well. - If a class is hard to name or explain then it's probably not following the advice in the previous bullet point. - A class name should instantly communicate what the class is. - Good names drive good designs. If your problem is what to name exposed internal classes, maybe you should consolidate them into a larger class. If your problem is naming a class that is doing a lot of different stuff, you should consider breaking it into multiple classes. If that's good advice for a public API then it can't hurt for any other class. [1]: http://video.google.com/videoplay?docid=-3733345136856180693
Thanks guys -- I voted you both up but neither would work out for my situation. What I ended up doing was webCtrl.Document.Window.ScrollTo(0, int.MaxValue);
The sequence of characters between < and > uniquely refer to a header, which isn't necessarily a file. Implementations are pretty much free to use the character sequence as they wish. (Most, however, just treat it as a filename and do a search in the *include path*, as the other posts state.) If the #include "file" form is used, the implementation first looks for a file of the given name, if supported. If not (supported), or if the search fails, the implementation behaves as though the other (#include &lt;file&gt;) form was used. Also, a third form exists and is used when the #include directive doesn't match either of the forms above. In this form, some basic preprocessing (such as macro expansion) is done on the "operands" of the #include directive, and the result is expected to match one of the two other forms.
[Java Closure Examples][1] [1]: http://www.blog.dannynet.net/archives/87
.MSI Not Always Uninstalling Previous Versions
|.net|windows-installer|
In a number of applications we create an MSI Installer with the Visual Studio Setup Project. In most cases, the install works fine, but every now and then the previous version was not uninstalled correctly. The user ends up with two icons on the desktop, and in the Add/Remove program list, the application appears twice. We have yet to find any pattern and in most cases the installer works without any problems.
You might want to have a look at Freebase.com as a site that's had some open discussion about what a "location" means and what it means when a location is included in another. These sorts of questions can generate a lot of discussion. For example, there is the obvious "geographic nesting", but there are less obvious logical nestings. For example, in a strictly geographic sense, Vatican City is nested within Italy. But it's not nested politically. Similarly, if your user is located in a research center that belongs to a university, but isn't located on the University's property, do you model that relationship or not?
My favorite has been stackoverflow just because it is reality based. Alt.Net has good content. Software Engineering Radio and Hanselminutes are informative. ThoughtWorks is marginal for me. I'll try the others!
They don't make an Object-Oriented language better. They make practical languages more practical. If you're attacking a problem with the OO hammer - represent everything as interactions between objects - then a closure makes no sense. In a class-based OO language, closures are the smoke-filled back rooms where stuff gets done but no one talks about it afterwards. Conceptually, it is abhorrent. In practice, it's extremely convenient. I don't really want to define a new type of object to hold context, establish the "do stuff" method for it, instantiate it, and populate the context... i just want to tell the compiler, "look, see what i have access to right now? That's the context i want, and here's the code i want to use it for - hold on to this for me 'till i need it". Fantastic stuff.
Why do ruby setters need "self." qualification within the class?
|c#|ruby|
Ruby setters -- whether created by (c)attr_accessor or manually -- seem to be the only methods that need "self." qualification when accessed within the class itself. This seems to put Ruby alone the world of languages: * all methods need self/this (like perl, and I think Javascript) * no methods require self/this is (C#, Java) * only setters need self/this (ruby??) The best comparison is C# vs ruby, because both languages support accessor methods which work syntactically just like class instance variables: foo.x = y, y = foo.x . C# calls them properties. Here's a simple example; the same program in ruby then C# #!/usr/bin/ruby class A def qwerty; @q; end # manual getter def qwerty=(value); @q = value; end # manual setter, but attr_accessor is same def asdf; self.qwerty = 4; end # "self." is necessary in ruby? def xxx; asdf; end # we can invoke nonsetters w/o "self." def dump; puts "qwerty = #{qwerty}"; end end a = A.new a.xxx a.dump take away the self.qwerty =() and it fails (ruby 1.8.6 on linux & osx). Now C#, using System; public class A { public A() {} int q; public int qwerty { get { return q; } set { q = value; } } public void asdf() { qwerty = 4; } // C# setters work w/o "this." public void xxx() { asdf(); } // are just like other methods public void dump() { Console.WriteLine("qwerty = {0}", qwerty); } } public class Test { public static void Main() { A a = new A(); a.xxx(); a.dump(); } } Question: Is this true? Are there other occasions besides setters where self is necessary?
Ruby setters -- whether created by (c)attr_accessor or manually -- seem to be the only methods that need "self." qualification when accessed within the class itself. This seems to put Ruby alone the world of languages: * all methods need self/this (like perl, and I think Javascript) * no methods require self/this is (C#, Java) * only setters need self/this (ruby??) The best comparison is C# vs ruby, because both languages support accessor methods which work syntactically just like class instance variables: foo.x = y, y = foo.x . C# calls them properties. Here's a simple example; the same program in ruby then C# #!/usr/bin/ruby class A def qwerty; @q; end # manual getter def qwerty=(value); @q = value; end # manual setter, but attr_accessor is same def asdf; self.qwerty = 4; end # "self." is necessary in ruby? def xxx; asdf; end # we can invoke nonsetters w/o "self." def dump; puts "qwerty = #{qwerty}"; end end a = A.new a.xxx a.dump take away the self.qwerty =() and it fails (ruby 1.8.6 on linux & osx). Now C#, using System; public class A { public A() {} int q; public int qwerty { get { return q; } set { q = value; } } public void asdf() { qwerty = 4; } // C# setters work w/o "this." public void xxx() { asdf(); } // are just like other methods public void dump() { Console.WriteLine("qwerty = {0}", qwerty); } } public class Test { public static void Main() { A a = new A(); a.xxx(); a.dump(); } } Question: Is this true? Are there other occasions besides setters where self is necessary? UPDATE: Thanks all for the feedback. First let me be more precise about the concluding question. Question at Bottom: Are there other occasions where a ruby method *cannot* be invoked *without* self? I agree, there are lots of cases where self *becomes* necessary. This is not unique to ruby, just to be clear: using System; public class A { public A() {} public int test { get { return 4; }} public int useVariable() { int test = 5; return test; } public int useMethod() { int test = 5; return this.test; } } public class Test { public static void Main() { A a = new A(); Console.WriteLine("{0}", a.useVariable()); // prints 5 Console.WriteLine("{0}", a.useMethod()); // prints 4 } } Same ambiguity is resolved in same way. But while subtle I'm asking about the case where * A method *has* been defined, and * *No* local variable has been defined, and we encounter qwerty = 4 Ambiguity: Is this a method invocation or an new local variable assignment? The title question as to why ruby always treats this as an assignment, is perhaps best answered by ben. Let me paraphrase Summary: The parser could treat "symbol =" as an lvalue and dynamically decide between assignment and invocation. The dynamic nature of ruby means *every* assignment potentially faces this ambiguity, so in the interest of performance, ruby treats this as assignment always. C# benefits from knowing what all the methods are, and treats this case the opposite way (as a method invocation).
Java has had closures since 1.1, just in a very cumbersome and limited way. They are often useful wherever you have a callback of some description. A common case is to abstract away control flow, leaving the interesting code to call an algoritm with a closure that has no external control flow. A trivial example is for-each (although Java 1.5 already has that). Whilst you can implement a forEach method in Java as it stands, it's far too verbose to be useful. An example which already makes sense with existing Java is implementing the "execute around" idiom, whereby resource acquisition and release is abstracted. For instance, file open and close can be done within try/finally, without the client code having to get the details right.
I suppose for supporting core functional programming concepts, you need closures. Makes the code more "elegant" in some cases with the support for [closures][1]. [1]: http://martinfowler.com/bliki/Closure.html
I suppose for supporting core functional programming concepts, you need closures. Makes the code more elegant and composable with the support for [closures][1]. Also, I like the idea of passing around lines of code as parameters to functions. [1]: http://martinfowler.com/bliki/Closure.html
Floats messing up in Safari browsers
|css|safari|float|
I have a site I made real fast that uses floats to display different sections of content. The floated content and the content that has an additional margin both appear fine in FF/IE but on safari one of the divs is completely hidden. I've tried switching to padding and position:relative but nothing has worked for me. If I take out the code to display it to the right it shows up again but under the floated content The main section of css that seems to be causing the problem is: #settings{ float:left; } #right_content{ margin-top:20px; margin-left:440px; width:400px; } This gives me the same result whether I specify a size to the #settings div or not. Any ideas would be appreciated -- the site is available at: http://frickinsweet.com/tools/Theme.mvc.aspx to see the source code.
As a java developer who is trying to teach themselves lisp in an attempt to become a better programmer, I would say that I would like to see the Josh Block proposal for closures implemented. I find myself using anonymous inner classes to express things like what to do with each element of a list when aggregating some data. To would be nice to represent that as a closure, instead of having to create an abstract class.
Mine is a .bzrignore, but same idea :) .DS_Store *.mode1v3 *.pbxuser *.perspectivev3 *.tm_build_errors the tm_build_errors is for when I use TextMate to build my project. Not quite as comprehensive as Hagelin but I thought it was worth posting for the tm_build_errors line.
Here is a [hack called ssh-xfer](ControlMaster) which addresses the exact problem, but requires patching OpenSSH, which is a nonstarter as far as I'm concerned.
Here is a [hack called ssh-xfer](http://matt.ucc.asn.au/ssh-xfer/) which addresses the exact problem, but requires patching OpenSSH, which is a nonstarter as far as I'm concerned.
Performance wise, they are exactly the same (at least in SQL Server) but be aware that they are deprecating this join syntax and it's not supported by sql server2005 out of the box.
Performance wise, they are exactly the same (at least in SQL Server) but be aware that they are deprecating the _implicit_ join syntax and it's not supported by sql server2005 out of the box.
Complex CSS selector for parent of active child
|css|
Is there a way to select a parent element based on the class of a child element in the class? The example that is relevant to me relating to HTML output by a nice menu plugin for <http://drupal.org>. The output renders like this: <ul class="menu"> <li> <a class="active">Active Page</a> </li> <li> <a>Some Other Page</a> </li> </ul> My question is whether or not it is possible to apply a style to the list item that contains the anchor with the active class on it. Obviously, I'd prefer that the list item be marked as active, but I don't have control of the code that gets produced. I could perform this sort of thing using javascript (JQuery springs to mind), but I was wondering if there is a way to do this using CSS selectors. Just to be clear, I want to apply a style to the list item, not the anchor.
From what I gather from reading the [javadocs](http://static.springframework.org/spring-ws/sites/1.5/apidocs/org/springframework/ws/transport/jms/WebServiceMessageDrivenBean.html) it looks like this allows a Spring [WebServiceMessageReceiver](http://static.springframework.org/spring-ws/sites/1.5/apidocs/org/springframework/ws/transport/WebServiceMessageReceiver.html) to be invoked using a JMS client instead of a web services client. Hopefully that's right, because the rest of this is based on that assumption. The basics of is should match with how you create a regular Spring message driven bean. There is a little bit of documentation on how to do that in the [Spring Reference Manual](http://static.springframework.org/spring/docs/2.5.x/reference/ejb.html#ejb-implementation). Also see the [AbstractEnterpriseBean Javadoc](http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/ejb/support/AbstractEnterpriseBean.html?is-external=true) for some additional information about how the Spring context is retrieved. The extra configuration required for a WebServiceMessageDrivenBean appear to be a [ConnectionFactory](http://java.sun.com/javaee/5/docs/api/javax/jms/ConnectionFactory.html?is-external=true), a [WebServiceMessageFactory](http://static.springframework.org/spring-ws/sites/1.5/apidocs/org/springframework/ws/WebServiceMessageFactory.html), and your [WebServiceMessageReceiver](http://static.springframework.org/spring-ws/sites/1.5/apidocs/org/springframework/ws/transport/WebServiceMessageReceiver.html). These need to use the bean names specified in the Javadoc for the WebServiceMessageDrivenBean. The bean names are "connectionFactory", "messageFactory", and "messageReceiver" respectively.
Unfortunately, there's no way to do that with CSS. It's not very difficult with JavaScript though. For example, if you're using jQuery: $('.active').parent().get(0); // This would be the <a>'s parent <li>.
Use the library. If you try to generate it manually, I predict with 99% certainty that the resulting text will be invalid in some way. Especially with more esoteric features like Unicode strings or exponential notation.
They're great for modelling things that change status, and have logic that triggers on each transition. I'd use finite state machines for tracking packages by mail, or to keep track of the different stata of a user during the registration process, for example. As the number of possible status values goes up, the number of transitions explodes. State machines help a lot in that case.
One of the important things about erlang is how the features are used to make robust systems. The send/recieve model is no-sharing, and explicitly copying. The processes themselves are lightweight threads. If you did desire the robust properties of the erlang model, you would be best to use real processes and IPC rather than threads. If you want robust message passing though you may end up wanting to serialize and deserialise the contents. Especially with type safety. Pattern matching in C++ isn't always pretty but there will be a good pattern for this - you will end up creating a dispatcher object that uses some form of polymorphism to get what you want. Although if you are not careful you end up with xml over pipes :) Really, if you want the erlang model you really want to use erlang. If there are slow bits, I'm sure you can augment your program using a foreign function internet. The problem about re-implementing parts, is you won't get a good cohesive library and solution. The solutions you have already don't look much like C++ anymore.
Things that comes to mind are: > * Robot/Machine manipulation... those robot arms in factories * Simulation Games, (SimCity, Racing Game etc..) Generalizing: When you have a string of inputs that when interacting with anyone of them, requires the knowledge of the previous inputs or in other words, when processing of any single input requires the knowledge of previous inputs. (that is, it needs to have "states") Not much that I know of that isn't reducible to a parsing problem though.
Objects in games are often represented as state machines. An AI character might be: - Guarding - Aggressive - Patroling - Asleep So you can see these might model some simple but effective states. Of course you could probably make a more complex continuous system. Another example would be a process such as making a purchase on Google Checkout. Google gives a number of states for Financial and Order, and then informs you of transistions such as the credit card clearing or getting rejected, and allows you to inform it that the order has been shipped.
Is Flex development without FlexBuilder realistic?
|apache-flex|flexbuilder|
Is it realistic to try and learn and code a Flex 3 application without purchasing FlexBuilder? Since the SDK and BlazeDS are open source, it seems technically possible to develop without Flex Builder, but how realistic is it. I would like to test out Flex but don't want to get into a situation where I am dependent on the purchase of FlexBuilder (at least not until I am confident and competent enough with the technology to recommend purchase to my employer). I am experimenting right now, so I'm taking a long time and the trial license on my Windows machine has expired. Also Linux is my primary development platform and there is only an alpha available for Linux. Most of the documentation I've found seem to use Flex Builder. Maybe I should use Laszlo...
There's also the Microsoft .net profiler - I've used it a bit, and it's not bad for a free tool. Not sure if you can walk the object hierarchy, but does break down memory use by type, and over time. You can even see the underlying data. It does slow down the app a lot, though.
[Python Programming for the absolute beginner][1] ![Python Programming for the absolute beginner cover][2] [1]: http://safari.oreilly.com/1592000738 [2]: http://safari.oreilly.com/images/1592000738/1592000738_xs.jpg
If this is for a web service, you should definitely consider thread pooling. Too many threads will bring your application to a grinding halt because they will eventually start competing for CPU time. Is this for file or network IO? If so, you should also consider using [asynchronous IO][1]. It can be a bit more of a pain to program, but you don't have to worry about spawning off too many threads at once. [1]: http://msdn.microsoft.com/en-us/magazine/cc700359.aspx?pr=blog
This might work: i.to_i if i.match(/\d+/)
This might work: i.to_i if i.match(/^\d+$/)
Have you tried floating the #right_content div to the right? #right_content{ float: right; margin-top: 20px; width: 400px; }
Persistent DB Connections - Yea or Nay?
|php|persistence|pdo|database-connection|
I'm using PHP's PDO layer for data access in a project, and I've been reading up on it and seeing that it has good innate support for persistant DB connections. I'm wondering when/if I should use them. Would I see performance benefits in a CRUD-heavy app? Are there downsides to consider, perhaps related to security? If it matters to you, I'm using MySQL 5.x.
Creating connections to the database is a fairly expensive operation. Persistent connections are a good idea. In the ASP.Net and Java world, we have "connection pooling", which is roughly the same thing, and also a good idea.
Sorry I should have mentioned that as well. I tried floating that content right and additionally tried floating it left and setting the position with the thinking that both divs would start out at left:0 where setting the margin of the right would move it over. Thanks
A few things you should fix beforehand: 1. Your `<style>` tag is in `<body>`, when it belongs in `<head>` 2. You have a typo "realtive" in one of your inline styles: <a href="http://feeds.feedburner.com/ryanlanciaux" style="position:realtive; top:-6px;"> Try to get your page to [validate][1]; this should make debugging the actual problems far easier. [1]: http://validator.w3.org/check?uri=http%3A%2F%2Ffrickinsweet.com%2Ftools%2FTheme.mvc.aspx
To build on James' answer, I thought that JSON might be preferrable over WDDX. In fact, it proves to be considerably more efficient. Comparing hashes is not that expensive, but serializing the data and then generating the hash could be (for larger and/or more complex data structures). <cfsilent> <!--- create some semi-complex test data ---> <cfset data = StructNew() /> <cfloop from="1" to="50" index="i"> <cfif variables.i mod 2 eq 0> <cfset variables.data[variables.i] = StructNew()/> <cfset tmp = variables.data[variables.i] /> <cfloop from="1" to="#variables.i#" index="j"> <cfset variables.tmp[variables.j] = 1 - variables.j /> </cfloop> <cfelseif variables.i mod 3 eq 0> <cfset variables.data[variables.i] = ArrayNew(1)/> <cfset tmp = variables.data[variables.i] /> <cfloop from="1" to="#variables.i#" index="j"> <cfset variables.tmp[variables.j] = variables.j mod 6 /> </cfloop> <cfset variables.data[variables.i] = variables.tmp /> <cfelse> <cfset variables.data[variables.i] = variables.i /> </cfif> </cfloop> </cfsilent> <cftimer label="JSON" type="inline"> <cfset jsonData = serializeJson(variables.data) /> <cfset jsonHash = hash(variables.jsonData) /> <cfoutput> JSON: done.<br /> len=#len(variables.jsonData)#<br/> hash=#variables.jsonHash#<br /> </cfoutput> </cftimer> <br/><br/> <cftimer label="WDDX" type="inline"> <cfwddx action="cfml2wddx" input="#variables.data#" output="wddx" /> <cfset wddxHash = hash(variables.wddx) /> <cfoutput> WDDX: done.<br /> len=#len(variables.wddx)#<br/> hash=#variables.wddxHash#<br /> </cfoutput> </cftimer> Here's the output that the above code generates on my machine: JSON: done. len=7460 hash=5D0DC87FDF68ACA4F74F742528545B12 JSON: 0ms WDDX: done. len=33438 hash=94D9B792546A4B1F2FAF9C04FE6A00E1 WDDX: 47ms While the data structure I'm serializing is fairly complex, it could easily be considered small. This should make the efficiency of JSON serialization over WDDX even more preferrable. At any rate, if I were to try to write a "compareAnything" method using hash comparison, I would use JSON serialization over WDDX.
Can I ask what references this query string? Is this in some server side code or client side?
Another dirty alternative could be just to use a hidden input and set that on/off instead of manipulating the url.
While it is nowhere nearly as clean, but you could implement something like C# delegates using a Java [Proxy](http://java.sun.com/javase/6/docs/api/java/lang/reflect/Proxy.html).
The SSO solution that I've implemented here works as follows: 1. There is a master domain, login.mydomain.com with the script master_login.php that manages the logins. 2. Each client domain has the script client_login.php 3. All the domains have a shared user session database. 4. When the client domain requires the user to be logged in, it redirects to the master domain (login.mydomain.com/master_login.php). If the user has not signed in to the master it requests authentication from the user (ie. display login page). After the user is authenticated it creates a session in a database. If the user is already authenticated it looks up their session id in the database. 5. The master domain returns to the client domain (client.mydomain.com/client_login.php) passing the session id. 6. The client domain creates a cookie storing the session id from the master. The client can find out the logged in user by querying the shared database using the session id. Notes: - The session id is a unique global identifier generated with algorithm from RFC 4122 - The master_login.php will only redirect to domains in its whitelist - The master and clients can be in different top level domains. Eg. client1.abc.com, client2.xyz.com, login.mydomain.com
For when you don't want a fixed size increment, sequences aren't really what you are after, all they really guarantee is that you will be getting a unique number always bigger than the last one you got. There is always the possibility that you'll end up with gaps, and you can't really adjust the increment amount on the fly safely or effectively. I can't really think of any case where I've had to do this kind of thing, but likely the easiest way is just to store the "current" number somewhere and update it as you need it. Something like this. drop table t_so_test; create table t_so_test (curr_num number(10)); insert into t_so_test values (1); create or replace procedure p_get_next_seq (inc IN NUMBER, v_next_seq OUT NUMBER) As BEGIN update t_so_test set curr_num = curr_num + inc RETURNING curr_num into v_next_seq; END; / SQL> var p number; SQL> execute p_get_next_seq(100,:p); PL/SQL procedure successfully completed. SQL> print p; P ---------- 101 SQL> execute p_get_next_seq(10,:p); PL/SQL procedure successfully completed. SQL> print p; P ---------- 111 SQL> execute p_get_next_seq(1000,:p); PL/SQL procedure successfully completed. SQL> print p; P ---------- 1111 SQL>
Safely turning a JSON string into an object
|javascript|ajax|json|
Note that Zend Optimizer and MMCache (or similar applications) are totally different things. While Zend Optimizer tries to optimize the program opcode MMCache will cache the scripts in memory and reuse the precompiled code. I did some benchmarks some time ago and you can find the [results][1] in my blog (in German though). The basic results: Zend Optimizer alone didn't help at all. Actually my scripts were slower than without optimizer. When it comes to caches: * fastest: [eAccelerator][2] * [XCache][3] * [APC][4] And: You DO want to install a opcode cache! For example: ![alt text][5] This is the duration it took to call the wordpress homepage 10.000 times. *Edit:* BTW, eAccelerator contains an optimizer itself. [1]: http://blogs.interdose.com/dominik/2008/04/11/benchmarking-php-eaccelerator-und-andere-opcode-caches/ [2]: http://eaccelerator.net/ [3]: http://xcache.lighttpd.net/ [4]: http://www.php.net/manual/en/book.apc.php [5]: http://blogs.interdose.com/dominik/wp-content/uploads/2008/04/opcode_wordpress.png
Some tips: Understand the JSF request [lifecycle][1] and where your various pieces of code fit in it. Especially find out why your model values will not be updated if there are validation errors. Choose a tag library and then stick with it. Take your time to determine your needs and prototype different libraries. Mixing different taglibs may cause severe harm to your mental health. [1]: http://www.java-samples.com/showtutorial.php?tutorialid=470
[Visual Editor][1] is a good choice. It generates *very* clean code, with no "layout" files beside of your sourcen using a simple but convenient pattern. It's very easy to patch the generated code and directly see the result. There are some stability problems (some times, the preview window does not refresh anymore...), but nothing that a "clean Project" can't fix... [1]: http://www.eclipse.org/vep/WebContent/main.php
Daniel, [Jinja][1] implements a sandboxe environment that may or may not be useful to you. From what I remember, it doesn't yet "comprehend" list comprehensions. [Sanbox info][2] [1]: http://jinja.pocoo.org/2/documentation/intro [2]: http://jinja.pocoo.org/2/documentation/sandbox
Eclipse plugin for Mono is dead. On Linux use <a href="http://www.monodevelop.com/Main_Page">MonoDevelop</a> or <a href="http://www.omnicore.com/en/xdevelop.htm">X-Develop</a> if you like good commercial support (although MonoDevelop is closing on them fast feature-wise). On Windows <a href="http://sharpdevelop.net/OpenSource/SD/">SharpDevelop</a> has custom MSBuild targets for compiling the code against Mono. As Mono and MonoDevelop are changing fast, be sure to use the latest released versions, even if they are not marked as stable yet (e.g. versions shipped with stock Ubuntu are terribly outdated). The VMWare image is a great way to start testing Windows-developed code on Linux. Don't touch cygwin unless you are already very conformable with it.
Have a look at [ScriptManager.RegisterStartupScript][1] [1]: http://msdn.microsoft.com/en-us/library/bb310408.aspx The idea is that you register a script to run on start up (I believe once the page has loaded). Your script should call a function that causes a post back through your UpdatePanel
I have built numerous MSIs with VS 2005 Pro that do this correctly. Are you sure that the 'Version' property of the **deployment project** has been incremented? This property is independent of the version of the assemblies in the application, and this is the error message you will see if the Version property of the MSI is the same as it was for the one you are trying to overwrite.
Increment the version number on your project. In VS, select the node for your setup app and hit F4 to view the properties. Find the version field, and increment it.
If you specifically want to use the SQL Server PIVOT function, then this should work, assuming your two original columns are called act and cmd. (Not that pretty to look at though.) SELECT act AS 'Action', [View] as 'View', [Edit] as 'Edit' FROM ( SELECT act, cmd FROM data ) AS src PIVOT ( MAX(cmd) FOR cmd IN ([View], [Edit]) ) AS pvt