Showing posts with label Syntax Highlighting. Show all posts
Showing posts with label Syntax Highlighting. Show all posts

Tuesday, March 25, 2014

Dilbert Me in F#

This is the Dilbert download tool in F#, just because I like playing with F# and making up reasons to do so.

I switched to WebClient here instead of WebRequest. It makes things a little easier and I clearly should have been using it all along.

I wrote it in Visual Studio 2013 as a F# script file. I selected all then hit 'alt+enter' to run it.

FsLight was what I was led to when googling F# code formatters. It was easy to use and seems to have done a good job.

1
2
3
4
5
6
7
8
let webClient = new System.Net.WebClient()
let url = "http://www.dilbert.com"
let dilbert = webClient.DownloadString(url)
let innerUrl = "http://www.dilbert.com/" + System.Text.RegularExpressions.Regex.Match(dilbert, "src=.*strip.gif").Value.Substring(5)
innerUrl
let innerTempFile = System.IO.Path.GetTempFileName() + ".gif"
webClient.DownloadFile(innerUrl, innerTempFile)
System.Diagnostics.Process.Start(innerTempFile)
Created with FsLight

Tuesday, August 9, 2011

How to get powershell syntax highlighting in HTML

Step 1: Use PowerGUI.
Aside from the code-highlighting, it's all kinds of awesome.
Step 2: Select the code
Step 3: From the Menu: Edit->Copy As->HTML
Step 4: Paste and enjoy in your Blog.

Saturday, September 19, 2009

Code highlighting

It took me far to long to figure out how to highlight my code correctly in my last post.

http://www.stevetrefethen.com/highlighter/default.aspx