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 ind... |
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, whe... |
|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 ... |
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 su... |
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 exchangi... |
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.... |
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 ... |
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 be... |
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... |
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... |
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" ... |
[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... |
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 obviou... |
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 stuf... |
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/thi... |
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/thi... |
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 i... |
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. I... |
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 ... |
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<... |
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/springframe... |
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 ... |
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 IP... |
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 processin... |
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 m... |
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 o... |
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... |
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?
... |
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 s... |
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>
<!--- crea... |
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 requir... |
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... |
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 t... |
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. M... |
[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... |
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/Ope... |
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 ... |
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 (
... |