Home »
Tag: Programming languages Tag: Programming languagesParents:
Children:
- C#,
- C++,
- C#,
- COBOL,
- Erlang,
- Forth,
- Haskell,
- Java,
- Javascript,
- K,
- Lisp,
- Lua,
- Matlab,
- OCaml,
- Perl,
- PHP,
- Python,
- REBOL,
- Rexx,
- Scheme,
- Smalltalk
-
Kirk Allen Evans's Blog : Getting Path from an XmlNode
¶ (0)
Tags: [C#, XML]
-
Worlds: Controlling the Scope of Side Effects | Lambda the Ultimate. It's a short paper, to read.
¶ (0)
Tags: [Programming languages]
-
jQuery: » jQuery, Microsoft, and Nokia:
Both Microsoft and Nokia are taking the major step of adopting jQuery as part of their official application development platform. Not only will they be using it for their corporate development but they will be providing it as a core piece of their platform for developers to build with... This means that jQuery will be distributed with Visual Studio (which will include jQuery intellisense, snippets, examples, and documentation).
¶ (0)
Tags: [Javascript]
-
Moritz Lenz's blogs on Perl 6, intended for people familiar with Perl 5, have done a lot to get me re-interested in Perl 6, despite how long it's taken to develop.
My understanding is that a full release of Perl 6 is probably another year away, but it may have been worth the wait. Perl 6 looks like a really fun language.
¶ (0)
Tags: [Perl]
-
[squeak-dev] Using V8 for other languages (via):
One thing is clear: JavaScript is the assembly language of the Internet, at least for a few years now.
Edit: here was the thing I'd read on TraceMonkey a while back (via Simon).
Edit: One more post on TraceMonkey (to read).
¶ (0)
Tags: [Javascript]
Just learned about the W3C Selectors API from Simon's blog. Turns out a native implementation is forthcoming in Firefox 3.1 (as well as Opera, IE 8, and WebKit), but in the meantime many Javascript libraries already implement the spec, Mootools, jQuery, and Prototype to name a few.
WebKit provides a speed test of a native implementation of querySelectorAll vs popular Javascript libraries (obviously the native implementation won't work for you unless you're using a Firefox beta). It's based on Mootools' test.
-
Looks like Python 3.0 is implementing John Lim's suggested syntax for octal literals (with a slight difference). I'd prefer John's Oc to Python 3.0's Oo, but it doesn't matter.
They've made a lot of nice cruft-removing changes to Python for 3.0.
¶ (0)
Tags: [Python]
or shoehorning in what the C# library should have included in the first place.
public static void Each<T>(this IEnumerable<T> source, Action<T> a){
foreach (var item in source)
a(item);
}
public static void Each(this IEnumerable source, Action<object> a){
foreach (var item in source)
a(item);
}
See my previous extension method, Join.
I should be able to do something like:
var table = new HtmlTable {
Rows = { // <-- error is here
from XmlNode p in node.SelectNodes("./property")
select new HtmlTableRow{
Cells = {
new HtmlTableCell{ InnerText = Server.HtmlEncode(p.Attributes["description"].Value) },
new HtmlTableCell{ InnerText = Server.HtmlEncode(p.InnerText) }
}
}
}
};
But I can't, because the LINQ code isn't "expanded" so the compiler complains that while it expects an HtmlTableRow element between the braces assigned to Rows, you're giving it a collection. But, you can't assign the collection to Rows directly because it's a read-only property.
Bad class design (Rows being read-only... same as Cells fwiw) or bad language design in that there's no way to "expand" the results of the LINQ query to do what seems natural in that spot?
Instead, I have to do:
var rows =
from XmlNode p in node.SelectNodes("./property")
select new HtmlTableRow{
Cells = {
new HtmlTableCell{ InnerText = Server.HtmlEncode(p.Attributes["description"].Value) },
new HtmlTableCell{ InnerText = Server.HtmlEncode(p.InnerText) }
}
};
var table = new HtmlTable();
foreach (var r in rows)
table.Rows.Add(r);
which is redundant.
-
Javascript Drag and Drop. Old, but pretty concise tutorial.
¶
Tags: [Javascript]
function getViewport(){
var e = window, a = 'inner';
if(!('innerWidth' in e)){
var t = document.documentElement
e = t && t.clientWidth ? t : document.body
a = 'client';
}
return {width: e[a+'Width'], height: e[a+'Height']}
}
Modified slightly from a comment here.
Edit: the code in that comment didn't fully implement the original, and broke when I tried it in IE. So I've updated the code above.
-
Sketchy LISP, An Introduction to Functional Programming in Scheme (via).
¶ (0)
Tags: [Books, Scheme]
-
Raphaël—JavaScript Library (via).
Raphaël is small JavaScript library that should simplify your work with vector graphics on the web. In case you want to create your own specific chart or image crop-n-rotate widget, you can simply achieve it with this library.
Raphaël uses SVG and VML as a base for graphics creation. Because of that every created object is a DOM object so you can attach JavScript event handlers or modify objects later. Raphaël’s goal is to provide adapter that will make drawing cross-browser and easy. Currently library supports Firefox 3.0+, Safari 3.0+, Opera 9.5+ and Internet Explorer 6.0+.
¶ (0)
Tags: [Javascript]
-
Second p0st: PHP hackery: quick and dirty anonymous objects. Eew.
¶ (0)
Tags: [PHP]
-
SitePen Blog » window.name Transport (via Keith and Simon). To read.
¶ (0)
Tags: [Javascript, To Read]
-
LINQ to Objects - 5 Minute Overview - Hooked on LINQ. Decent tutorial. Has examples of grouping and joins.
¶ (0)
Tags: [C#, LINQ]
-
C# 3.0: The Evolution Of LINQ And Its Impact On The Design Of C# (via). Very interesting explanation of how LINQ came about.
¶ (0)
Tags: [C#, LINQ]
-
New "Orcas" Language Feature: Extension Methods - ScottGu's Blog. Very informative post.
Edit: He also covers C# 3's query syntax (i.e. LINQ).
¶ (0)
Tags: [C#, LINQ]
Say you want to search a string with a regular expression and return all the matches concatenated together, using LINQ:
var str = "some string";
var matches = Regex.Matches(str, @"REGEX");
Three ways to concatenate:
Using String.Join (simplest):
var foo = String.Join("", (from Match match in result select match.Value).ToArray());
Using an accumulator:
var foo = (from Match match in matches select match.Value)
.Aggregate(new StringBuilder(), (sb, s) => sb.Append(s)).ToString();
Using a loop:
var sb = new StringBuilder();
foreach (var s in (from Match match in result select match.Value)){
sb.Append(s);
}
var foo = sb.ToString();
First seems most concise, and it's easier to specify a join character with. Apparently there's no way to massage an IEnumerable(T) into a String.Join, so unfortunately you need to pass it an array, which makes the IEnumerable fill out all its values into an array (so it can't be lazy), and then String.Join makes another pass over that array and copies the values into a string. So it uses double the space and double the time.
The second is more obscure, but only makes one pass over the result, though it's harder to specify a join character if desired.
The third is presumably most efficient, but it's more verbose.
In conclusion, there should be a String.Join(IEnumerable<T>).
Edit: Though it's impossible to define a "static" extension method (like, another variation of String.Join), you can define a Join method on IEnumerable like so:
static class Extentions{
public static string Join(this IEnumerable source, string separator){
var sb = new StringBuilder();
bool first = true;
foreach(var foo in source){
if(!first)
sb.Append(separator);
sb.Append(foo.ToString());
first = false;
}
return sb.ToString();
}
}
The first example above now becomes:
var foo = (from Match match in result select match.Value).Join("");
or even more concisely:
var foo = Regex.Matches(str, @"REGEX").Join("");
// (apparently the ToString on a Match object returns its Value)
Very cool.
Note: Works with custom ToString()s as expected:
class Custom{
public string Value { get; set; }
public override string ToString(){
return "VALUE: "+Value;
}
}
var list = new List<Custom> {
new Custom { Value = "one" },
new Custom { Value = "two" }
};
Console.WriteLine(list.Join(", "));
prints "VALUE: one, VALUE: two" as expected.
Final note: I would have used FirstOrDefault in my Join extension method instead of a first boolean, but the example of the regular expression object was chosen because it's not a generic, so I can't use IEnumerable<T>, only IEnumerable.
-
Simple Top-Down Parsing in Python (via). To read.
¶ (0)
Tags: [Python, To Read]
-
FirePHP - Firebug Extension for AJAX Development (via).
¶ (0)
Tags: [Firefox, PHP]
-
Overview of C# 3.0
¶ (0)
Tags: [C#]
-
Blue programming language
¶ (0)
Tags: [Programming languages]
-
Running C and Python Code on The Web at Toolness, via.
¶ (0)
Tags: [C, Flash, Python]
-
John Resig - Processing.js (via):
I've ported the Processing visualization language to JavaScript, using the Canvas element.
Impressive, to say the least.
¶ (0)
Tags: [Javascript]
-
Generator Tricks for Systems Programmers (via). Presentation on Python's generators.
¶ (0)
Tags: [Python]
-
JavaScript: The Good Parts, by Douglas Crockford (via).
¶ (0)
Tags: [Books, Javascript]
-
Reading binary files using Ajax « nagoon97’s Weblog (via).
¶ (0)
Tags: [Ajax]
-
Javascript getElementsByClass function. I know there's one built into prototype, but I didn't want to include the whole library since I wasn't already using it. This seems to work.
¶
Tags: [Javascript]
-
JSLint, The JavaScript Verifier (via).
¶ (0)
Tags: [Javascript]
|
Generated in about 0.352s. (Used 12 db queries) |
new⇒Timesheet Calculator
Hadn't seen it before now, but mycompany already uses a timetracking prog...
Keith: Oct 7, 10:44am