Free Money For Doin What You Love

Mickey Gunderloy has announced the Larkware 2005 Developer Tool Programming Contest... now I've said before that Very Very few people enter these things, so the potential return on investment is HUGE!.

I urge you -- YOU -- to enter Mike Gunderloy's Programming contest.

If you need an idea, here's one of mine:

Implement the 'Automatic Screenshot journal.'

Here's some possible names for it: Snapsalot, Pixalot, Snapaday, timeSnapper, Pixatime.. and so on

I think it would take between 1 hour and three days to implement that thing fully.

Build a NICE installer for it.

Focus on simplicity. Less features. Fun to use. Stick to the core. Don't let it mess with the clipboard.

Split me your prizes, remember me in your speech, but first: get coding. Our prizes await. as seen on the daily grind

 

Thus Spake Gaksloope: The future of browse and code

My strange friend Gaksloope, who lives in an alternative-reality cubicle, fourteen minutes into the future, sent me an IM message today that i thought i'd share.

(first, recall that alternative universes only ever seem to inter-communicate via instant messaging services. And Google talk is weapon-of-choice for most trans-temporal-cross-reality chatters. But we digress.)

Here is what Gaksloope has to say:

gaks:It 'trigues me that you whine about syntax highlighting for the web, when here, in my alternative-reality cubicle, fourteen minutes into the future, we have very nice syntax highlighting features available from all of the seven popular browsers.

leon:syntax highlighting controls? i don't get it?

gaks:oh it's easy, you start typing and it highlights for you and has intellisense too

leon://show me the code//, gakza, i can sell this to some fools i know

gaks:here goes. first you drop a textarea tag into your document like this:
<textarea> </textarea>

leon:OK, np.

gaks:next you set the syntax attribute, to tell it what syntax to use:
<textarea syntax="http://www.w3c.org/syntax/microsoft/CSharp.syntax"></textarea>

leon:So what does that do?

gaks:That tells the browser what syntax we're expecting.

leon:The browser? Don't you mean the server?

gaks:The browser, the browser, man, everything interestng happens on the browser. anyway forget the server. We don't have those here -- everyone's machines act as nodes in giant peer-to-peer clusters. Client machines are more powerful than servers these days anyway. it's the "reverse 'big-fish-eats-little-fish' rule of computing." Sheesh - sometimes i think you must be //sixteen// minutes behind in your alternative reality cubicle.

leon:so the browser loads and parses that document... Csharp.syntax, before it renders the textarea tag? must be slow.

gaks:no, it axs for it.

leon:axs?

gaks:Asynchronous Xml Slurping. Tell me, for the love of god, you've got AXS?

leon:oh //that// 'AXS'. yes, even our shoe laces can do that here... um.

gaks:so the browser axs the syntax file. notice that i ax'd it from w3c.org, rather than the more popular one located at Apple.com.

leon:apple?

gaks:since Apple.com bought microsoft.org they own the spec to c-sharp as well.

leon:dot org? did you say microsoft.org? HA!

gaks:typo sorry. microsoft.borg. they got their own top level domain, right before steve ballmer went insane and crushed bill gates to death in his giant grip, then ate him.

leon:that happened in your reality?

gaks:oh, that happens in every reality. it's one of the five universal constants. you mustn't have reached that bit yet.

leon:i'll.. i'll look out for it.

gaks:so anyway, the syntax file tells the browser that the language has certain symbols for comments, certain keywords, operators and the like. this is all simple stuff that has been well understood in every reality for a long time. And it's the next attribute that tells the browser how to style each of these particles; what colors and fonts and so on. This is the 'highlight' attribute:

<textarea syntax="http://www.w3c.org/syntax/microsoft/CSharp.syntax"
    highlight="http://www.csszengarden/styles/highlights/DancingSea.css" >
</textarea>

leon:and that's it? syntax highlighting in the browser?

gaks:oh it doesn't stop there. there's intellisense as well -- just specify the dictionary of possibilities:

<textarea syntax="http://www.w3c.org/syntax/microsoft/CSharp.syntax"
    highlight="http://www.csszengarden/styles/highlights/DancingCfamily.css"
    intellisense="http://www.apple.com/microsoft/csharp.terms" >
</textarea>

gaks:one more trick -- we let the user expand the intellisense possbilities with their own, local, list of terms.

<textarea syntax="http://www.w3c.org/syntax/microsoft/CSharp.syntax"
    highlight="http://www.csszengarden/styles/highlights/DancingCfamily.css"
    intellisense="http://www.apple.com/microsoft/csharp.terms"
    clientIntellisense="csharp.terms" >
</textarea>

gaks:It works like a Custom Dicionary in Apple Word.

leon:abra cadabra

** gaks may not reply because his/her status has changed to 'no available ripple in trans-reality fibril or offline' **


Ah... there you have it. Maybe i'll share again, next time i hear from Gaksloope. Best of luck.

 

Fun Color-Pickin Background Image Blend Thing

Before i forget -- you need to see the improved Gradient Maker application i fixed last week.

It's got a color picker now, thanks to Eric Meyer (the css guru)

Hence, it's more fun. Fun-of-use, is important, apparently.

I kind of hoped it would get a coupla-hundred del.icio.us recommendations, but it hasn't yet.

An approximation of the GDI+ .net code it uses is stored in a previous entry.

On the topic of GDI+ .net restful webservices for rendering images, check out Shital Shah's technique for rendering equations online. (Be warned about his page transitions... they are frightening ;-) )

 

Winderrrr XP

Here's a usability goof in windows xp. And I'm not making this up.

I walk up to the computer and here's what's on the screen:

Shazoleon has 1 program running. Running too many programs can slow down your computer. If your computer is running more slowly than normal, try closing some programs.

Let me repeat that, in text, for those with screen readers:



i  {Username} has 1 program running

Running too many programs can slow down your computer.
If your computer is running more slowly than normal, try
closing some programs.


One program! One! Yet they recommend a little less of that crazy multi-taskng.



i  {Username} has 1 program running

We are windows xp. We are smooth. Uncluttered.
We are windows xp. All your thread belongs to us.
We are smooth. Uncluttered.


 

Delpino -- Last Ever Show

Brisbane Band Delpino are playing their last ever show this Friday (12th Aug) at the Troubadour.

If you've never seen or heard this special Brisbane act, seize your last chance.


Other Brisbane news...

I ran the Bridge to Brisbane, (euphemistically known as a 'fun run') on the weekend. I haven't found out my "place" yet, but I'm guessing somewhere in the top twenty (...thousand that is). You can watch me (competitor 29062) crossing the finish line, very exhausted -- if you're a freaky stalker type, that is.

Also, I've used tada to compose (and share) my ToDo list for the world's 3rd simplest code generator. That tool might be coming soon.

 

Gradient Maker



secretGeek's Gradient-Maker!

StartColor
#         
EndColor
#         
Length
Direction

Right-click the background and choose 'save background as'

 

The color-picker at right is taken from eric meyer's excellent color blend tool.

 

Add or view comments

If you wish to use this often, Full Source Code is Now Available.

 

A Color Gradient Webservice

(In which I demonstrate a GDI+, asp.net, color gradient webservice which lets you create blend images in firefox, not just IE)

Three strange and interesting technical things have converged on me recently....

If you wish to use this often, Full Source Code is Now Available.

First, I read about a Sparklines webservice that lets you inject funky little sparklines into your html, like this: or like this: , just by specifying an image source url such as:

"http://bitworking.org/projects/sparklines/spark.cgi? type=smooth&d=10,20,30,90,80,70&step=4"

(where those comma separated values are the datapoints in the sparkline!)

Second, I've taken an inordinate fondness to the gradient transformation features of IE, which let you create smooth color gradients. (If you've got IE you can see some at work in the World's 2nd Simplest Code Generator (or if you've got Opera/Firefox you can see evidence of the filters in these screen shots.)

And third, I've downloaded firefox, which doesn't render gradient transformations, because those mozilla kids are fairly fussy about standards compliance and things like that.

So I find myself wishing for a browser-independent way of generating color gradients, and thanks to the sparklines article, and sunday's hangover (cheers jeb), I had an idea.

With a little bit of .Net GDI+ magic, I've managed to generate pixel-thin 'blend' images for use as backgrounds.

So what does it do?

If you call out to my 'web-service' in an IMG tag, like this:

You'll get a result like this:

Basically, a one pixel-wide blend image. Here, i'll stretch it out wide to make it easier to see:

By changing the query string around, you can have any start and end color you want, you can go horizontal or vertical. Plus a few other options.

Tastes better with CSS

Like most things in life, this tastes better with CSS. Use the service (or the test page) to create an image for you, then save it to your server. Set it as the background-color (sic.) using CSS. For 'V' (vertical) images, specify a repeat direction of Y. For 'H' (horizontal) images, specify a repeat direction of X.

Warning! Use this service to generate images ONCE, and store them on your own server. I'd rather you didn't use the webservice to generate images dynamically from within your webpages! I may not be able to afford the bandwidth -- and I reserve the right to alter the service to output nasty images, as a retaliation against bandwidth hogs, at any moment.

To Test the Service...

Use this rather natty little test page to test the service. I have, for once in my damn life, tested it on two different browers. So, with luck, it might work.

Here are some samples of the webservice in use:

image: https://secretgeek.net/Gradient.aspx?Direction=H&Length=100&StartColor=00FFFF&EndColor=00FF00&Format=jpeg
image: https://secretgeek.net/Gradient.aspx?Direction=H&Length=100&StartColor=FF0000&EndColor=000000&Format=jpeg
image: https://secretgeek.net/Gradient.aspx?Direction=H&Length=100&StartColor=FFFF00&EndColor=000000&Format=jpeg
image: https://secretgeek.net/Gradient.aspx?Direction=V&Length=300&StartColor=0088FF&EndColor=FFFFFF&Format=jpeg
image: https://secretgeek.net/Gradient.aspx?Direction=V&Length=100&StartColor=FFFFFF&EndColor=0088FF&Format=jpeg
image: https://secretgeek.net/Gradient.aspx?Direction=H&Length=100&StartColor=FF0000&EndColor=FF8800&Format=jpeg

Parameters...

Parameter Description
Direction V for vertical or H for horizontal. Not sure which is which...
Length How long should the image be? It will always have a breadth of 1-pixel. (Whether Length refers to height or width, depends on whether the image is vertical or horizontal!)
StartColor The rgb value of the Starting color, excluding the '#' character.
EndColor The rgb value of the Final color, excluding the '#' character.
Format Jpeg, Gif or Png?

Error Handling

If parameters are wrongly setup, or if something else goes wrong, you get an image like this one:

The Code

Imports System.Drawing

Imports System.Drawing.Drawing2D

 

...

Private Sub Page_Load(ByVal sender As System.Object, _

����������� ByVal e As System.EventArgs) Handles MyBase.Load

��� 'Put user code to initialize the page here

��� Dim sMessage As String

��� Try

������� 'Parameters:

������� Dim _Direction As String 'Horizontal or Vertical

������� Dim _Length As Long

������� Dim _StartColor As String

������� Dim _EndColor As String

������� Dim _Format As String

 

������� sMessage = "retrieving parameters"

������� _Direction = Request.QueryString.Item("Direction")

������� _Length = Request.QueryString.Item("Length")

������� _StartColor = Request.QueryString.Item("StartColor")

������� _EndColor = Request.QueryString.Item("EndColor")

����� ��_Format = Request.QueryString.Item("Format")

 

������� Dim lWidth As Integer

������� Dim lHeight As Integer

������� Dim m_Color1 As Color

������� Dim m_Color2 As Color

������� Dim myFormat As System.Drawing.Imaging.ImageFormat

��� ����Dim myGradientMode As LinearGradientMode

 

������� sMessage = "processing parameters"

 

������� 'Now use the parameters

������� If _Direction.ToUpper.StartsWith("H") Then

����������� lWidth = 1

����������� lHeight = _Length

����� ������myGradientMode = LinearGradientMode.Vertical

������� Else

����������� lWidth = _Length

����������� lHeight = 1

����������� myGradientMode = LinearGradientMode.Horizontal

������� End If

 

������� If _Format.ToUpper.StartsWith("J") Then

����������� myFormat = Imaging.ImageFormat.Jpeg

������� Else

����������� myFormat = Imaging.ImageFormat.Gif

������� End If

������� sMessage = "determining colors"

������� m_Color1 = Color.FromArgb(255, _

��������������� CLng("&H" & _StartColor.Substring(0, 2)), _

��������������� CLng("&H" & _StartColor.Substring(2, 2)), _

��������������� CLng("&H" & _StartColor.Substring(4, 2)))

�� �����m_Color2 = Color.FromArgb(255, _

�� �������������CLng("&H" & _EndColor.Substring(0, 2)), _

�� �������������CLng("&H" & _EndColor.Substring(2, 2)), _

�� �������������CLng("&H" & _EndColor.Substring(4, 2)))

 

�� �����'GO!

�� �����sMessage = "determining size"

�� �����Dim bmpGradient As New Bitmap(lWidth, lHeight)

������� Dim m_BrushSize As New Rectangle(0, 0, lWidth, lHeight)

������� Dim grBitmap As Graphics = Graphics.FromImage(bmpGradient)

������� sMessage = "creating gradient brush"

��� ����Dim myLinearGradientBrush As New LinearGradientBrush( _

������������������� m_BrushSize, m_Color1, m_Color2, _

������������������� myGradientMode)

������� sMessage = "filling rectangle"

������� grBitmap.FillRectangle(myLinearGradientBrush, 0, 0, _

� �����������������lWidth, lHeight)

� ������sMessage = "saving image to response stream"

 

� ������'Write the image to the client!!������������

� ������bmpGradient.Save(Response.OutputStream, myFormat)

 

� ��Catch ex As System.Exception

 

� ������Dim bmpGradient As New Bitmap(600, 100)

� ������Dim m_BrushSize As New Rectangle(0, 0, 600, 100)�����������

� ������Dim grBitmap As Graphics = Graphics.FromImage(bmpGradient)

� ������Dim myLinearGradientBrush As New LinearGradientBrush( _

� ��������������m_BrushSize, _

����� ����������Color.FromArgb(255, 255, 0, 0), _

����� ����������Color.FromArgb(255, 0, 0, 0), _

����� ����������LinearGradientMode.Vertical)

���� ���grBitmap.FillRectangle(myLinearGradientBrush, 0, 0, _

���� �����������600, 100)

���� ���grBitmap.DrawString("Error while " & _

���� �����������sMessage & " for '" & Request.UserHostAddress & _

���� �����������"'." & vbCrLf & ex.Message, _

���� �����������New System.Drawing.Font("Arial", 12, _

���� �����������System.Drawing.FontStyle.Italic), _

���� �����������System.Drawing.Brushes.White, 10, 12)

���� ���'Write the error message image to the client

���� ���bmpGradient.Save(Response.OutputStream, _

����� ����������System.Drawing.Imaging.ImageFormat.Jpeg)

 

��� End Try

 

End Sub

 

Related articles

Button Makers

 

Another Day for Mort

Help Mort solve this common computing conundrum...

It's early on a Monday morning and our hero, Mort Visibasicus, is about to do some typing when he should, instead, be programming.

He's already written this rather boring and repetitive chunk of code, which populates controls based on local variables:

  txtFirstName.Text = _FirstName
  txtLastName.Text = _LastName
  cboTitle.SelectedValue = _Title
  txtAddressLine1.Text = _AddressLine1
  txtAddressLine2.Text = _AddressLine2
  txtAddressLine3.Text = _AddressLine3
  (and so on for twenty controls...)

Now, Mort needs to write the complementary code.

Mort needs to write code that will read from the controls to populate local variables.

He needs code like this:

  _FirstName = txtFirstName.Text
  _LastName = txtLastName.Text
  _Title = cboTitle.SelectedValue 
  _AddressLine1 = txtAddressLine1.Text
  _AddressLine2 = txtAddressLine2.Text
  _AddressLine3 = txtAddressLine3.Text
  (and so on... twenty times)

Mort refuses to do all that typing. He considers using cut and paste... maybe block selecting.... perhaps a regular expression, or Excel... but no... still too laborious, too methodical.

Screw this, Mort shakes his fist at the sky. I don't enact algorithms. I write them.

Mort considers the pattern he is after... it is just the same thing, but switched around, back to front... he thinks.

His eyes glaze over. He has one of those all-too-rare Mort Epiphanies.

He cranks up his friend -- the world's 2nd simplest code generator.

He sets the column delimiter to the equals sign "="

Delimiters: Column; '='

He turns on the option to 'trim each field'.

checkbox 'trim each field' is checked

He pastes the existing code into the 'Input box'

the first code snippet is pasted into the input box

And he types in this pattern:

  $2 = $1
The pattern is '$2 = $1'

Mort smashes the [calculate] button.... and Voila!

The desired code is created as if by digital magic.

Now while the geek in the next cubicle is still slaving over her hand-crafted, carefully typed code, Mort has finished his tasks for the day and can devote the remainder of his time chuckling away at the Daily Wtf.

Mort has discovered the essence of 'Micro Code-Generation'.

Laziness is its own reward.

Can you think of cleverer ways to use the world's 2nd simplest code generator?

(Note for C# programmers: set ";" as the row delimiter, and use the pattern: "$2 = $1;")

 

MS Paint //Master Class//

Okay, I've been meaning to run an "MSPaint.exe" master class for a while now.

Here's the first lesson.... This could save you a lot of paper, and a lot of sticky tape.

mspaint master class -- page setup

MSPaint, (or "Ms Paint" as she prefers to be known) doesn't have much, but she does have a "Page Setup" dialog.

The clever thing about this is that it contains the option:

Hence, when printing, there is no need for your screenshot to span over two portrait pages. (And screenshots, of course, are what Ms Paint is best at.)

This is bad news for companies that sell sticky tape.

mspaint master class -- page setup