instruction stringlengths 0 30k ⌀ |
|---|
How can I return a variable from a $.getJSON function |
|jquery|javascript| |
I want to return StudentId to use elsewhere outside of the scope of the $.getJSON()
j.getJSON(url, data, function(result)
{
var studentId = result.Something;
});
//use studentId here
I would imagine this has to do with scoping, but it doesn't seem to work the same way c# does
|
|javascript|jquery|ajax| |
Can't you just use the same control I'm Stack Overflow uses (that we're all typing into)---WMD, and just store the Markdown in the VARCHAR. Then use the .NET Markdown to HTML converter, as you mentioned, to display the HTML as needed. Jeff talks about this in more detail in a StackOverflow podcast (don't know the episode number). |
Both of you were on the right track. What I realized is that SimpleModal appends the dialog to the body, which is outside ASP.Net's `<form>`, which breaks the functionality, since it can't find the elements.
To fix it, I just modified the SimpleModal source to append eveything to `'form'` instead of `'body'`. When I create the dialog, I also use the `persist: true` option, to make sure the buttons stay through opening and closing.
Thanks everyone for the suggestions! |
How do threads work in python, and what are common python-threading specific pitfalls? |
|python|multithreading| |
I've been trying to wrap my head around how threads work in python, and it's hard to find good information on how they operate. I may just be missing a link or something, but it seems like the official docs aren't very thorough on the subject, and I haven't been able to find a good write-up.
From what I can tell, only one thread can be running at once, and the active thread switches every 10 instructions or so?
Could someone who has a lot of experience with using threads with python either point me towards a good explanation, or write one up? It would also be very nice to be aware of common problems that you run into while using threads with python. |
Well, I've been browsing around Bugzilla for a bit now and seemingly the best way you can go for clearing the authentication would be to send non-existant credentials.
Read more here: [https://bugzilla.mozilla.org/show_bug.cgi?id=287957][1]
[1]: https://bugzilla.mozilla.org/show_bug.cgi?id=287957 |
Do you need the .NET 1.0 framework to target the .NET 1.0 framework? |
|.net| |
I have a bunch of .NET frameworks installed on my machine. I know that with the Java JDK, I can use the 6.0 version to target 5.0 and earlier. Can I do something similar with the .NET framework - target 1.0 and 2.0 with the 3.0 framework? |
(**Updated**)
You need to compile with the 1.0 compilers. These are only available with the 1.0 release of the runtime/SDK.
The 2.0/3.5 compilers won't emit 1.0-compatible assemblies.
Visual Studio 2008 can generate 2.0 assemblies, but 1.0 was left off.
|
Alternative "architectural" approaches to javaScript client code? |
|javascript|client|ria|architecture|model-view-controller| |
I've been working on a side project for some time now, and the further I get, the more my webpage has turned into a full-featured application. Right now, I'm sticking with <a href="http://jquery.com">jQuery</a>, however, the logic on the page is growing to a point where some organization, or dare I say it, "architecture" is needed. My first approach is "MVC-ish":
- The 'model' is very application specific, and is often updated "purely" with JSON from AJAX requests, etc
- The view is basically the DOM
- The controller is the object where I stick a lot of my event handling and kick off DOM adjustments
I'm very interested, however, in how other people have built more substantial javaScript apps. I'm not interested in GWT, or other server-oriented approaches... just in the approach of "javaScript + <generic web service-y thingy here>"
Because javaScript is not really OO, not really functional, I feel like I'm trying to force another paradigm on it with the MVC thing. |
|javascript|model-view-controller|architecture|client|ria| |
How is your javaScript code organized? Does it follow patterns like MVC, or something else?
I've been working on a side project for some time now, and the further I get, the more my webpage has turned into a full-featured application. Right now, I'm sticking with <a href="http://jquery.com">jQuery</a>, however, the logic on the page is growing to a point where some organization, or dare I say it, "architecture" is needed. My first approach is "MVC-ish":
- The 'model' is a JSON tree that gets extended with helpers
- The view is the DOM plus classes that tweak it
- The controller is the object where I connect events handling and kick off view or model manipulation
I'm very interested, however, in how other people have built more substantial javaScript apps. I'm not interested in GWT, or other server-oriented approaches... just in the approach of "javaScript + <generic web service-y thingy here>"
Note: earlier I said javaScript "is not really OO, not really functional". This, I think, distracted everyone. Let's put it this way, because javaScript is unique in many ways, and I'm coming from a strongly-typed background, I don't want to force paradigms I know but were developed in very different languages. |
MVC Route Help, 2 routes, 1 with a category url structure and the other for content page |
|mvc|routes| |
2 routes, the URLS look like:
- categories, always ends in a '/'
www.example.com/category/
www.example.com/category/subcategory/
www.example.com/category/subcategory/subsubcategory/
- content page, doesn't end in a '/', can only be at the root level or after 1 subcategory page.
www.example.com/root-level-page
www.example.com/category/some-page-name
|
ASP.NET MVC Route Help, 2 routes, 1 with a category url structure and the other for content page |
Really you're only doing four calculations, so ***readability seems way more important*** here than efficiency. My approach to make something like this more readable is to
1. Extract common code to a function
2. Put similar calculations together to make the patterns more obvious
3. Get rid of the intermediate variable print_zeroes and be explicit about the cases in which you output bytes even if they're zero (i.e. the preceding byte was non-zero)
I've changed the random code block into a function and changed a few variables (underscores are giving me trouble in the markdown preview screen). I've also assumed that *bytes* is being passed in, and that whoever is passing it in will pass us a pointer so we can modify it.
Here's the code:
/* append byte b to stream, increment index */
/* really needs to check length of stream before appending */
void output( int i, unsigned char b, char stream[], int *index )
{
printf("byte %d: 0x%02x\n", i, b);
stream[(*index)++] = b;
}
void answer( char bytestream[], unsigned int *bytes, unsigned int n)
{
/* mask out four bytes from word n */
first = (n & 0xFF000000) >> 24;
second = (n & 0x00FF0000) >> 16;
third = (n & 0x0000FF00) >> 8;
fourth = (n & 0x000000FF) >> 0;
/* conditionally output each byte starting with the */
/* first non-zero byte */
if (first)
output( 1, first, bytestream, bytes);
if (first || second)
output( 2, second, bytestream, bytes);
if (first || second || third)
output( 3, third, bytestream, bytes);
if (first || second || third || fourth)
output( 4, fourth, bytestream, bytes);
}
Ever so slightly more efficient, and ***maybe*** easier to understand would be this modification to the last four if statements:
if (n>0x00FFFFFF)
output( 1, first, bytestream, bytes);
if (n>0x0000FFFF)
output( 2, second, bytestream, bytes);
if (n>0x000000FF)
output( 3, third, bytestream, bytes);
if (1)
output( 4, fourth, bytestream, bytes);
I agree, however, that compressing this field makes the receiving state machine overly complicated. But if you can't change the protocol, this code is much easier to read. |
@chakrit
does this really work if refreshing the page?
i thought the viewstate was stored on the page, and had to be sent to the server on a postback, with a refresh that is not happening. |
If you still wish to get the project to compile using VS2008 (or in the future) I can suggest using a binary editor to view the object file in question *mainapp.obj*.
Here is an example from a small project of mine.
The zdbException.obj contains the following excerpt
DEFAULTLIB:"libc
pmtd" /DEFAULTLI
B:"uuid.lib" /DE
FAULTLIB:"uuid.l
ib" /include:?id
@?$num_put@DV?$o
streambuf_iterat
or@DU?$char_trai
ts@D@std@@@std@@
@std@@2V0locale@
2@A /include:?id
@?$numpunct@D@st
d@@2V0locale@2@A
/DEFAULTLIB:"LI
BCMTD" /DEFAULTL
IB:"OLDNAMES" /E
DITANDCONTINUE
Note the entry **/DEFAULTLIB:"LIBCMTD"**. This indicates the object file was compiled with the static c run-time multi-threaded debug.
There is also the possibility that the functions referenced in the obj are deprecated in the standard run-time lib shipped with VS2008. |
http://www.iconarchive.com has a nice selection |
Possible? Absolutely. Undetected? [Unlikely][1], since UDP employs a checksum that would require multiple-bit errors to appear valid.
[1]: http://gaia.cs.umass.edu/kurose/transport/UDP.html |
Possible? Absolutely. Undetected? [Unlikely][1], since UDP employs a checksum that would require multiple-bit errors to appear valid. If an error is detected, the system will likely drop the packet - such are the risks of using UDP.
[1]: http://gaia.cs.umass.edu/kurose/transport/UDP.html |
I've had the best luck with [Icon Buffet][1] and [StockIcons][2]
[1]: http://www.iconbuffet.com
[2]: http://stockicons.com |
I've used Silk Icons (http://www.famfamfam.com/lab/icons/silk/) on a few projects. It's covered under the creative commons license so you will have to include a link back to the site somewhere in your app. |
Try to make each .c focus on a particular area of functionality. Use the corresponding .h file to declare those functions.
Each .h file should have a 'header' guard around it's content. For example:
#ifndef ACCOUNTS_H
#define ACCOUNTS_H
....
#endif
That way you can include "accounts.h" as many times as you want, and the first time it's seen in a particular compilation unit will be the only one that actually pulls in its content. |
UPD is really faster than TCP, and the simple reason is because it's non-existent acknowledge packet (ACK) that permits a continuous packet stream, instead of TCP that acknowledges each packet.
For more information I recommend the simple, but very comprehensible [Skullbox explanation][1]
[1]: http://skullbox.net/tcpudp.php |
I can perhaps give you a taste of our experience when we began looking at unit testing our middle-tier process that included a ton of "business logic" sql operations.
We first created an abstraction layer that allowed us to "slot in" any reasonable database connection (in our case, we simply supported a single ODBC-type connection).
Once this was in place, we were then able to do something like this in our code (we work in C++, but I'm sure you get the idea):
GetDatabase().ExecuteSQL( "INSERT INTO foo ( blah, blah )" )
At normal run time, GetDatabase() would return an object that fed all our sql (including queries), via ODBC directly to the database.
We then started looking at in-memory databases - the best by a long way seems to be SQLite. ([http://www.sqlite.org/index.html][1]). It's remarkably simple to set up and use, and allowed us subclass and override GetDatabase() to forward sql to an in-memory database that was created and destroyed for every test performed.
We're still in the early stages of this, but it's looking good so far, however we do have to make sure we create any tables that are required and populate them with test data - however we've reduced the workload somewhat here by creating a generic set of helper functions that can do a lot of all this for us.
Overall, it has helped immensely with our TDD process, since making what seems like quite innocuous changes to fix certain bugs can have quite strange affects on other (difficult to detect) areas of your system - due to the very nature of sql/databases.
Obviously, our experiences have centred around a C++ development environment, however I'm sure you could perhaps get something similar working under PHP/Python.
Hope this helps.
[1]: http://www.sqlite.org/index.html |
|asp.net|mvc|routes| |
I need some help with ASP.NET MVC routes. I need to create 2 routes for a cms type application. One route will be for category level URLS, and the other route will be for the actual page content.
- categories, always ends in a '/'
www.example.com/category/
www.example.com/category/subcategory/
www.example.com/category/subcategory/subsubcategory/
- content page, doesn't end in a '/', can only be at the root level or after 1 subcategory page.
www.example.com/root-level-page
www.example.com/category/some-page-name
Ideas?
|
> The server must analyze all of this
> info to determine the health of these
> computers
That is probably the biggest clue so far explaning what your application is kinda about. Are you able to provide a more elaborate briefing on what this application is seeking to achieve in this distributed environment? We do not even know if the client-side processing is disk I/O or processor intensive. How you design the solution is dependent on the nature of what needs to be done to help the users/business accomplish their jobs and objectives. |
Base64 Encoding Image |
|php|encoding|base64|opensearch| |
Where do the linux TCP/IP hackers live? |
|linux|tcp-ip|kernel| |
Over the past year or so my production platform has been plagued by an odd TCP/IP issue. I've spent zillions of hours working with competent & knowledgeable sysadmins, scouring the net, reading source code, been jerked around by RH's pathetic support, and **crying tears of blood**! To no avail. (Google ['unkn-4'][1] and you'll see many posts with my name all over.)
Work-a-rounds are in place, so the issue is not a priority. But the geek in me really would like to understand and solve this problem.
***So, where can a moderately competent systems programmer go to ask detailed questions and receive detailed answers from The Lords of TCP/IP stacks?*** I assume that their world so close to the bare metal, their population so small, is different from my own. That, and they don't want to answer emails to "My modem doesn't work" so they hide in the shadows.
Any pointers would be greatly appreciated.
[1]: http://www.google.ch/search?source=ig&hl=en&rlz=&=&q=unkn-4&btnG=Google+Search&meta= |
Where do the Linux TCP/IP hackers 'live'? |
|linux|tcp|kernel| |
I don't see it mentioned often enough, but you **can** still implement fairly simple services with WCF, very similar to ASMX services. For example:
[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class SimpleService
{
[OperationContract]
public string HelloWorld()
{
return "Hello World";
}
}
You still have to register the end point in your web.config, but that's not so bad.
Eliminating the verbosity of the separated data, service, and operation contracts goes a long way toward making WCF more manageable for me. |
$a = array(
0 => '- select -',
1 => 'Afghanistan',
2 => 'Albania',
3 => 'Algeria',
80 => 'USA'
);
$temp = array();
foreach ($a as $k => $v) {
$v == 'USA'
? array_unshift($temp, array($k, $v))
: array_push($temp, array($k, $v));
}
foreach ($temp as $t) {
list ($k, $v) = $t;
echo "$k => $v\n";
}
The output is then:
80 => USA
0 => - select -
1 => Afghanistan
2 => Albania
3 => Algeria
|
Whilst it may be automatically dropped at the end of a session, it is good practice to drop the table yourself when you're done with it. |
How would you make a comma-separated string from a list? |
|python| |
What would be your preferred way to concatenate strings from a sequence such that between each two consecutive pair a comma is added. That is, how do you map, for instance, `[ 'a', 'b', 'c' ]` to `'a,b,c'`? (The cases `[ s ]` and `[]` should be mapped to `s` and `''`, respectively.)
I usually end up using something like `''.join(map(lambda x: x+',',l))[:-1]`, but also feeling somewhat unsatisfied. |
|python| |
What would be your preferred way to concatenate strings from a sequence such that between each two consecutive pair a comma is added. That is, how do you map, for instance, `[ 'a', 'b', 'c' ]` to `'a,b,c'`? (The cases `[ s ]` and `[]` should be mapped to `s` and `''`, respectively.)
I usually end up using something like `''.join(map(lambda x: x+',',l))[:-1]`, but also feeling somewhat unsatisfied.
Edit: I'm both ashamed and happy that the solution is so simple. Obviously I have hardly a clue as to what I'm doing. (I probably needed "simple" concatenation in the past and somehow memorised `s.join([e1,e2,...])` as a shorthand for `s+e1+e2+...`.) |
|python|list| |
Things have definitely quited down for the idea. Which is strange since you'd think its goals are even more relevant now.
[http://www.jini.org/wiki/Category:News][1]
[1]: http://www.jini.org/wiki/Category:News |
In Firebug's CSS tab, you can see what style rules apply to a selected elements in the cascading order. This may or may not help you in your problem.
My guess would be that something about the content of #inner3 is causing it to wrap below the first line, and the #outer is just getting sized to accommodate the smaller needed space. |
Is there any way to repopulate an Html Select's Options without firing the Change event (using jQuery)? |
|javascript|jquery|dom|html-select| |
I have multiple selects:
<select id="one">
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
</select>
<select id="two">
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
</select>
What I want is to select "one" from the first select, then have that option be removed from the second one.
Then if you select "two" from the second one, I want that one removed from the first one.
Here's the JS I have currently:
$(function () {
var $one = $("#one");
var $two = $("#two");
var selectOptions = [];
$("select").each(function (index) {
selectOptions[index] = [];
for (var i = 0; i < this.options.length; i++) {
selectOptions[index][i] = this.options[i];
}
});
$one.change(function () {
var selectedValue = $("option:selected", this).val();
for (var i = 0; i < selectOptions[1].length; i++) {
var exists = false;
for (var x = 0; x < $two[0].options.length; x++) {
if ($two[0].options[x].value == selectOptions[1][i].value)
exists = true;
}
if (!exists)
$two.append(selectOptions[1][i]);
}
$("option[value='" + selectedValue + "']", $two).remove();
});
$two.change(function () {
var selectedValue = $("option:selected", this).val();
for (var i = 0; i < selectOptions[0].length; i++) {
var exists = false;
for (var x = 0; x < $one[0].options.length; x++) {
if ($one[0].options[x].value == selectOptions[0][i].value)
exists = true;
}
if (!exists)
$one.append(selectOptions[0][i]);
}
$("option[value='" + selectedValue + "']", $one).remove();
});
});
But when the elements get repopulated, it fires the change event in the select whose options are changing. I tried just setting the `disabled` attribute on the option I want to remove, but that doesn't work with IE6. |
|java|twain|scanner|java-native-interface| |
I'm working on building an app to scan directly from TWAIN scanner to a Java applet. I'm already aware of [Morena][1] and [JTwain][2], but they cost money. I need free. I could re-invent the wheel with JNI, but it seems like someone has probably already done this as a FOSS tool.
Is anyone familiar with a **free** tool that can get a Java applet to read directly from a TWAIN scanner?
[1]: http://www.gnome.sk/Twain/jtp.html
[2]: http://asprise.com/product/jtwain/ |
Getting Java and TWAIN to play together nicely |
|java|java-native-interface|twain|scanner| |
PHP on IIS |
|php|iis|windows|lamp|portability| |
Having been a PHP developer on LAMP servers for quite a while, is there anything that I will need to take into consideration while preparing an application for IIS on windows. |
|php|windows|iis|lamp|portability|wimp| |
If you're willing to use some C++, you can use a "function object":
struct MoveHandler {
chess_game *game;
int depth;
MoveHandler(chess_game *g, int d): game(g), depth(d) {}
void operator () (chess_move*) {
// now you can use the game and the depth
}
};
and turn your <code>foreachMove</code> into a template:
template <typename T>
void foreachMove(T action, chess_game* game);
and you can call it like this:
chess_move getNextMove(chess_game* game, int depth){
//for each valid move, determine how good the move is
foreachMove(MoveHandler(game, depth), game);
}
but it won't disrupt your other uses of <code>MoveHandler</code>. |
I'm not familiar with WebObjects, but I see you have java listed in there.
[iText][1] is a java api for building pdfs. If you can access a java api from WebObjects you should be able to build pdfs that way.
[1]: http://www.lowagie.com/iText/ |
After a moment of inspiration, the solution to my question became apparent to me (I was riding my bike). The '$now' part of
strtottime( string $time {,int $now ])
needs to be set as the current date. Not "$time()-now", but "the current date I'm concerned with / I'm looking at my log for.
ie: if I'm looking at the timesheet summary for 8/10/2008, then that is "now" according to strtotime(); yesterday is 8/09 and tomorrow is 8/11. Once I creep up one day, "now" is 8/11, yesterday is 8/10, and tomorrow is 8/12.
Here's the code example:
<?php
//catch variable
$givendate=$_GET['given'];
//convert given date to unix timestamp
$date=strtotime($givendate);
echo "Date Set As...: ".date('m/d/Y',$date)."<br />";
//use given date to show day before
$yesterday=strtotime('-1 day',$date);
echo "Day Before: ".date('m/d/Y',$yesterday)."<br />";
//same for next day
$tomorrow=strtotime('+1 day',$date);
echo "Next Day: ".date('m/d/Y',$tomorrow)."<br />";
$lastmonday=strtotime('last monday, 1 week ago',$date);
echo "Last Moday: ".date('D m/d/Y',$lastmonday)."<br />";
//form
echo "<form method=\"get\" action=\"{$_SERVER['PHP_SELF']}\">";
//link to subtract a day
echo "<a href=\"newtimetravel.php?given=".date('m/d/Y',$yesterday)."\"><< </a>";
//show current day
echo "<input type=\"text\" name=\"given\" value=\"$givendate\">";
//link to add a day
echo "<a href=\"newtimetravel.php?given=".date('m/d/Y',$tomorrow)."\"> >></a><br />";
//submit manually entered day
echo "<input type=\"submit\" name=\"changetime\" value=\"Set Current Date\">";
//close form
echo "<form><br />";
?>
Clicking on the "<<" and ">>" advances and retreats the day in question |
Symmetric key storage |
|security|symmetric-key|key-storage| |
My company is going to be storing sensitive data for our customers, and will be encrypting data using one of the managed .NET encryption algorithm classes. Most of the work is done, but we haven't figured out how/where to store the key. I've done some light searching and reading, and it seems like a hardware solution might be the most secure. Does anyone have any recommendations on a key storage solution or method? |
That sounds pretty harsh to me, but if you think about the amount of money that changes hands during acquisitions, it's probably one of those cases where your IDE vendor just gets paid without complaint most of the time, so they keep with the policy.
I can see why it shouldn't be completely free to transfer the license -- there is some (probably 'nominal') administrative work to do on the vendor's side, and they need to discourage people from transferring licenses all over the place when they really shouldn't be. But 25% seems awfully high for the amount of work and verification they need to do -- it seems like they could put some sort of cap on the license transfer fee, or have a fixed price.
It does seem like the kind of policy that would drive customers to a competitor, particularly one that does not have the same kind of draconian license transfer policy.
|
A good algorithm similar to Levenstein but weighted for Qwerty keyboards? |
|algorithm|string|comparison|text| |
I noticed some posts here on string matching, which reminded me of an old problem I'd like to solve. Does anyone have a good Levenstein-like algorithm that is weighted toward Qwerty keyboards?
I want to compare two strings, and and allow for typos. Levenstein is okay, but I'd prefer to also accept spelling errors based on the physical distance between keys on Qwerty keyboard. In other words, the algorithm should prefer "yelephone" to "zelephone" since the "y" key is located nearer to the "t" key than to the "z" key on most keyboards.
Any help would be great... this feature isn't central to my project, so I don't want to veer off into a rat-hole when I should be doing something more productive. |
Getting out of control? I think it's already out of control!
Can you not categorise the cases into 'x' general areas and split down into helper routines? |
Why does a "file exists" method in many languages return true for a directory? |
|file-io|methods|language-design| |
I know that it does in PHP, and I'm pretty sure it does in Java. I haven't used the latest versions of .NET, so I won't speak for them. It seems very awkward, but I was wondering if there was an underlying reason for this. |
In a single sentence, I'd say that WCF is "software that lets you set up and manage communication between systems a lot more efficiently than in the past".
I can see them bringing up BizTalk as a competitor, but of course you could say that WCF works with it and is in fact used as base technology for it in the more recent versions.
I'm not sure if I can think of any inappropriate shoe-horning of WCF that I have seen, although there are plenty of legacy apps that will probably be "upgraded" to WCF that don't really need to be for any real business reason. |
What's the best way to display a video with rounded corners in Silverlight? |
|silverlight| |
The MediaElement doesn't support rounded corners (radiusx, radiusy). Should I use a VideoBrush on a Rectangle with rounded corners? |
Visual Studio 2008 was the first to support targeting older versions of .NET. Unfortunately, it supports only .NET 2 and up.
In other words, you'll need .NET framework SDK 1 or 1.1 to do this. |
Yet another way to do it:
$ ls template_*.txt | sed -e 's/^template\(.*\)$/cp template\1 foo\1/' | ksh -sx
I've always been impressed with the ImageMagick [convert](http://www.imagemagick.org/script/convert.php) program that does what you expect with image formats:
$ convert rose.jpg rose.png
It has a sister program that allows batch conversions:
$ mogrify -format png *.jpg
Obviously these are limited to image conversions, but they have interesting command line interfaces. |
We are using the tools by [RedGate][1] which I personally find very useful in any aspect of work with databases. For scripting I would recommend the [SQL Compare][2] (you need a pro version for scripting). The SQL Compare is a must have for deploying schema changes from the deployment DB to the live Server and a real timesaver.
Those tools are not free but I think they could save you money in a long run
[1]: http://www.red-gate.com/
[2]: http://www.red-gate.com/products/SQL_Compare/index.htm |
The most widely used IDE for Common Lisp, particularly in the free software subset of the community, is in fact [SLIME][1], which runs on Emacs. You can use whatever CL compiler you prefer and invoke Lisp source files the way you describe, but if you do that, you won't be taking advantage of many of Lisps dynamic features that are so incredibly useful while developing your application.
I suggest you take a look at this [SLIME demonstration video][2] to see what I mean, even though it might be a bit outdated at this point.
If the problem is that you (think you) don't like Emacs, I seriously suggest you try to learn it. Seriously. No, really, I mean that. However, there are alternatives, such as the IDEs provided by commercial Lisp implementations such as [Allegro][3] and [Lispworks][4] (free trials available), or an Eclipse plug-in called [Cusp][5].
[1]: http://common-lisp.net/project/slime/
[2]: http://common-lisp.net/project/movies/movies/slime.mov
[3]: http://www.franz.com/products/allegrocl/
[4]: http://www.lispworks.com/downloads/index.html
[5]: http://bitfauna.com/projects/cusp/ |
XSLT Find and Replace with Unique |
|xslt| |
I am performing a find and replace on the line feed character (` `) and replacing it with the paragraph close and paragraph open tags using the following code:
<xsl:template match="/STORIES/STORY">
<component>
<xsl:if test="boolean(ARTICLEBODY)">
<p>
<xsl:call-template name="replace-text">
<xsl:with-param name="text" select="ARTICLEBODY" />
<xsl:with-param name="replace" select="' '" />
<xsl:with-param name="by" select="'</p><p>'" />
</xsl:call-template>
</p>
</xsl:if>
</component>
</xsl:template>
<xsl:template name="replace-text">
<xsl:param name="text"/>
<xsl:param name="replace" />
<xsl:param name="by" />
<xsl:choose>
<xsl:when test="contains($text, $replace)">
<xsl:value-of select="substring-before($text, $replace)"/>
<xsl:value-of select="$by" disable-output-escaping="yes"/>
<xsl:call-template name="replace-text">
<xsl:with-param name="text" select="substring-after($text, $replace)"/>
<xsl:with-param name="replace" select="$replace" />
<xsl:with-param name="by" select="$by" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
This almost works perfectly, except that I really need it to de-dup the line feeds as the paragraphs tend to be separated by 2 or more resulting in `</p><p></p><p>`.
Is it possible to get it so that it will only ever replace this once per paragraph? |
Shouldn't you be able to do something like this?
var strings = (from a in fooList select a.Bar).Distinct();
string[] array = strings.ToArray(); |
How to get an array of distinct property values from in memory lists? |
|linq| |
I have a List of Foo. Foo has a string property named Bar. I'd like to use linq to get a string[] of distinct values for Foo.Bar in List of Foo.
How can I do this? |
|.net|linq| |
For primitives (int, long etc) it is pass by value *the actual value (e.g. 3)*
For Objects you pass by value *the reference to the object*.
So if you have `doSomething(foo)` and `public void doSomething(Foo foo) { .. }` the two Foos have copied *references* that point to the same objects. |
Java passes references by value.
So you can't change the reference that gets passed in.
|
Building on what SQLMenace said, you can use a CROSS JOIN to quickly populate the table or efficiently create it in memory.
[http://www.sitepoint.com/forums/showthread.php?t=562806][1]
[1]: http://www.sitepoint.com/forums/showthread.php?t=562806 |
You'll have to handle the OnSelectedIndexChanged event of your drop down list to rebind your dataset based on the users selection. If you want the filtering to happen in an asynch postback, wrap the dataset (or datagrid I'm assuming) and your drop down in an UpdatePanel. That is one way to do it anyhow. |