|
title: Put the knife down and take a green herb, dude. |
descrip: One feller's views on the state of everyday computer science & its application (and now, OTHER STUFF) who isn't rich enough to shell out for www.myfreakinfirst-andlast-name.com Using 89% of the same design the blog had in 2001. |
|||||||||||||||||||||
|
FOR ENTERTAINMENT PURPOSES ONLY!!!
Back-up your data and, when you bike, always wear white. As an Amazon Associate, I earn from qualifying purchases. Affiliate links in green. |
||||||||||||||||||||||
|
x
MarkUpDown is the best Markdown editor for professionals on Windows 10. It includes two-pane live preview, in-app uploads to imgur for image hosting, and MultiMarkdown table support. Features you won't find anywhere else include...
You've wasted more than $15 of your time looking for a great Markdown editor. Stop looking. MarkUpDown is the app you're looking for. Learn more or head over to the 'Store now! |
||||||||||||||||||||||
| Sunday, March 01, 2026 | ||||||||||||||||||||||
|
Okay, I hit a rabbithole today. I'm not saying it's not fun, but probably not my smartest use of time. Long story shorter than I want, I find myself googling "SSMS equivalent on macOS" fairly often, meaning [Microsoft] SQL Server Management Studio, the Windows-specific tool you use not simply to manage SQL Servers via a GUI, but to throw raw T-SQL at it and view the results. It's barely changed since at least the 1990s. I used to use SQuirreL-SQL on Mac a lot when I dabbled (and also worked!) in Java, which really came in handy once when my boss didn't realize we were installing a Java app dbms onto a Linux-only network, and I briefly enjoyed Azure Data Studio until it got 86'd.
It would probably still work great, but it's frustrating that yet another MS tool got tossed into a VS Code extension. Look, VS Code is cool, but it's not an IDE. It feels like chicken wire and duct tape on a good day. And the last thing I want to do is have MORE things living in this single scripting app. I like dedicated apps, for heaven's sake. But you know what I've done for nearly thirty years now? Written apps that interface with SQL Server! Why don't I just write my own query client for SQL Server! Ah, but with what UI? Originally, I figured why not just the console? In an hour or so, I got a pretty simple client up that would send queries and parse up results into columns of plain text. Not too shabby! My introduction to TUIsBut was that enough? Of course not! We need a true console app, whatever that is, that intelligently formatted results and allowed complex SQL edits, not just line by line input. I started by wading into Spectre Console which allows you to style console text like mad and even has some neat widgets like this table, but it also says it's not really about complex UI management:
Also all its widgets are output-minded, not truly interactive. Okay, fine. Fair. Next up was Terminal.Gui, which seems to be a modern, C#-powered take on the sort of 1980s style DOS apps that you still find in backwater DMVs and tax preparer offices (I'm seeing a TurboTax commercial running during Celtics-76ers making fun of just such a UI now). Which is awesome! Except it was immediately buggy on macOS, and even when I got that working, the first text editing widget I tried allowed text entered to bleed into the widget under it. So that's a mess. Next? I've played with C#'s Insanely. It's insanely tough. I've copiloted the heck out of this today, and, you know, it turns out writing a text editor in a console is a pita. The toughest part? You have to manage all the scrolling. And since you're in a console, you lose all the built in cursor movement... if you want to insert instead of overwrite, that takes some work. And if you want to go to the end of the line, well, the macOS Terminal eats command-right arrow (which means "end") and uses that combo as a shortcut to go to the next terminal window instead. Solutions? Well, rather than reinvent the wheel, I find that
I'm starting to see why vi was born. Though apparently I'm also learning Emacs now too (the above shortcuts are the same in Emacs, maybe?). So throw those in. Awesome! A little esoteric, but that'll do, pig. Except the Meta ones aren't working... Guess what?!
[thanks GPT-5 mini] And there you have it. That's a lot learned today. Not sure I needed the history lesson or to write a scrollable text view for a rich console app, but I've taken on both, nonetheless. Labels: c#, console, macOS, SQL Server posted by ruffin at 3/01/2026 10:09:00 PM |
||||||||||||||||||||||
| Tuesday, June 17, 2025 | ||||||||||||||||||||||
|
Okay, was looking back through WCF earlier this week for a prospective client, and figured I'd leave some notes. Here's the stock code, give or take:
And all that's in Again, this is the stock WCF project so far. Not overly fancy. I wanted to be able to hit the stock endpoint from a WCF project in Visual Studio without using a WCF client. Getting to the WSDL file was easy: You can steal that from the page the WCF Test Client refers to if nothing else. For me, that stock page was:
Here's some of the startup page's contents:
Then the WSDL itself:
What you want to be able to do to invoke a service endpoint directly is, of course, find its URL. In my case, with a little help from SoapUI, I figured out it was the same URL that started up initially:
The first key is that you have to set up two headers to the request:
But you seem to have to send it a body in a POST -- GET gives you that stock opening page again. (Since GET and POST are REST conventions, I half-way expected the WCF service not to care, especially since we know GET can have a body now.) I am not yet going to claim I know how the WSDL tells you what your input parameters should have looked like.
Again, do this all in a Postman POST request with a body that's raw with XML as its type and you're golden. Change
I do not miss XML. Update: Ha! Wish I'd talked to myself from 13 years ago first! Labels: c#, noteToSelf, wcf posted by Jalindrine at 6/17/2025 07:27:00 PM |
||||||||||||||||||||||
| Friday, May 30, 2025 | ||||||||||||||||||||||
|
Note to self: It's pretty easy to get a Stripe CheckoutSession in .NET. I talked about writing a Chrome extension and integrating payment through Stripe a few months ago. Unfortunately the "what appears to be an amazingly well-written howto" wasn't, quite. So here's a quick bit of play with the Stripe API using .NET. This looks up information according to a "Checkout Session" id, which is what you'll get sent if you set up a "After Payment" processor URL, which is what I'm doing -- for now in an Azure Function, just to be kewl. (No, you shouldn't use hard-coded paths in your code. No, you shouldn't pass around anonymous classed entities in C#. You're right, there's one instance of insanely not-DRY-ness in this code that almost bugs me. And I hate kludging Steps:
I'd been thinking about having a $3/year [sic] subscription for an extension. After a test, I learned what the comments, above, mention: That'll cost me ($3 x .029 + 30ยข somehow equals...) 41ยข [???] per transaction. Okay, apparently there's a "Usage fee" in addition to the charge?
From togai.com:
From bossrevolution.com:
Cool cool. 13 2/3% of $3. Just below Apple's small dev 15%. Good times. Least the API is simple. More to come. From stripe.com:
good heavens. Labels: .NET, c#, example, noteToSelf, stripe posted by Jalindrine at 5/30/2025 01:26:00 PM |
||||||||||||||||||||||
| Wednesday, October 23, 2024 | ||||||||||||||||||||||
|
From stackoverflow.com:
I often forget what the "right" exception is to throw when it's not an argument issue -- and linters are getting better at reminding me not to be lazy and to stop using I suppose Labels: c#, noteToSelf posted by Jalindrine at 10/23/2024 10:31:00 AM |
||||||||||||||||||||||
| Friday, August 23, 2024 | ||||||||||||||||||||||
|
Okay, look, if there's one thing I'm tired of, it's half-baked example code that doesn't anticipate changes needed to push it into production. Like the good ole
I mean, Visual Studio immediately complains:
Well, duh. We have an endpoint with no logging. When would we need to log? Probably when we're doing something more complicated than creating random 8-ball style forecasts. So let's pretend it's more difficult, throw in a
Guess what? Now we got TWO errors! YAY!!
Dare you to tell me what to do next. Heck, I don't know. I do know WebAPIs have been around so long there are tons of wrong answers on the net. Let's just show one example that does work and call it a day.
Why do I need to wrap the return type with Anyhow, I just want to remember this trick for the next time it happens so to the blog it goes. :sigh: Labels: .NET, c#, noteToSelf, web API posted by Jalindrine at 8/23/2024 05:50:00 PM |
||||||||||||||||||||||
| Friday, February 19, 2021 | ||||||||||||||||||||||
|
One thing thatโs more esoteric than it should be is how to create a good command-line application on macOS, or at least it is for the languages I know, which donโt [really] include C.
I did briefly consider writing it in Swift, but it turns out C# is pretty easy but only if you know the right incantation. The key was finding the term `dotnet publish` (a link to which I found here). But then I needed a little more help to know the precise (or at least one precise) string of characters:
Thank heavens. Thanks again, random StackOverflow answerer. In case you missed it, that means you type this:
...in the same directory as your sln file and then you call the exe that you created (almost certainly without the exe extension) from the publish folder: /usr/local/share/dotnet/myApp/bin/Debug/netcoreapp3.1/osx.10.13-x64/publish/myApp And now you've got a self-contained, macOS specific executable. (I'm doing this to see how much trouble it'd be to write a macOS version of the Chutzpah JavaScript test runner on macOS. The VS Code extension is cross platform, almost by accident, but there's no equivalent for the "real" Windows version of Chutzpah exe that the extension, itself simply a pass-through runner, must call. Shouldn't be tough to recreate, though, at least for the "80%" use cases.) Labels: c#, macOS, noteToSelf, testing posted by Jalindrine at 2/19/2021 03:08:00 PM |
||||||||||||||||||||||
| Wednesday, February 14, 2018 | ||||||||||||||||||||||
|
I've been setting up a new greenfield project, and wanted to use not exactly a new stack, per se, so much as an "all-star" stack that'd capture the lessons I've learned coding recently. For me, that means it needs to be pretty straightforward, minimal dependencies, and minimal compilation. The fewer libraries and snowflake server requirements, the better. On first take, after bypassing Node, which really is the winner,1 my guess was that my all-star stack would be...
VueJS was difficult to pick. I've used React, and almost solely React, for the last year. I like it. But I believe it contributes to monolithic source that's not necessarily factored well. The more interdependencies your code has, the more maintenance is an issue. And doing good React essentially requires, at this point, using Babel, and as soon as you're transpiling, well, the surrounding tooling and library dependencies skyrocket. Not to mention that debugging transpiled code either means you're wading into transpiler-generated muck, or you've got to maintain yet more tooling to step through things in something that's not the browser. I was originally going to use Handlebars, which I've liked for years for its exceptional thinness & the way it encourages minimal business logic on the client, but caught Shawn Wildermuth on Jesse Liberty's Yet Another Podcast, and heard him talk about VueJS. VueJS is essentially Handlebars with, afaict, a few more recent lessons baked in. The syntax is actually very similar to Handlebars in many ways. Here's what eventually won me over:
It looks like we've got good room to grow using VueJS' conventions if we want to do a full SPA in the future. I also debated not using Bootstrap, but I don't think it's worth the time to roll your own responsiveness when Bootstrap does it so well. It's over 200 KB total, but if you have it cached, that's a one-time hit that's smaller than most images. You're fine. jQuery was also debatable, since you can handle DOM manipulation fairly well by wrapping vanilla JS with some convenience wrappers to check for DOM existence, but at 69 KB? Come on. It's well known, rock solid, and has good industry support. Use jQuery. This looked nice. Simple, API-only and REST convention compliant server. No licensing fees. No JavaScript transpilation required, which will pay for itself in spades when you're debugging. Thin client. Clean separation of concerns. I was going to go through my headaches setting everything up here, but I'll split that into a new post later. The quick version? Because of a wack nuget configuration I didn't realize was an issue (command line nugget didn't pick the "right" nugget server; I had a local one set up in VS2017 as well), I'm using SQL Server for now, though I will probably give PostgreSQL another look before I settle on a dbms. 1 If you want the cleanest stack, there's nothing more advantageous than using the same language on the server and the client. Node lets you do that. There's some overhead (learning & setup tedium) standing up a web server -- do you just use Express everywhere, or serve from Nginx? -- but nodejs is The Right Answer, imo. But I'm a C# guy "professionally", and there still seem to be more opening for C# devs than node, so I think there's an argument that a C# server-side should be easier for a customer to have maintained going forward. Labels: c#, javascript, node, noteToSelf, web posted by ruffin at 2/14/2018 11:10:00 AM |
||||||||||||||||||||||
| Thursday, October 20, 2016 | ||||||||||||||||||||||
|
From microsoft.com (via StackOverflow):
[emphasis is mine] That's got to be a joke, right? So I can't use a "nested class" (which would include anything with a java-style like
Look, that's crazy-insane. I'd also had trouble with "namespaced" UserControls I'd created in the past, and lucked into figuring out they'd only work for me when I took them "out" of the non-local namespace, but figured I was doing something wrong. Maybe not. Wow. I've made a wrapper class in my local namespace as a shuttle. UWP unfortunately remains a hacky place. posted by ruffin at 10/20/2016 04:03:00 PM |
||||||||||||||||||||||
| Friday, October 14, 2016 | ||||||||||||||||||||||
|
Let's talk HTML Fragments in your clipboard when coding on Windows. I've created what's arguably the best Markdown editor on Win10 (if I do say so myself), and wanted it to be more intelligent when I was pasting content that comes from web browsers. That is, in the original version of MarkUpDown, if you copied the text I've got highlighted, below, from DaringFireball...
... and you pasted it into MarkUpDown as a quotation (Ctrl-Shift-V), you'd get unstyled text, like this...
I mean, that's okay-ish. Unfortunately, you'd have to go put in an additional line after each line so that it's not all scrunched into one paragraph. And you lose that Gruber was block-quoting Mossberg. And you lose that "they stop trying" was originally in italics. That stinks. Isn't Markdown really supposed to be shorthand for html? Can't we handle pasting html better than that? Yes, yes we can... TL;DRGo pull the HtmlFragmentHelper, a working, in-progress library for turning HTML Fragment strings into view models with these properties...
There are also several convenience methods to help you get, say, the top- and second-level domains for the HTML Fragment's source URL ( Here's an example:
Read how to use it here. Get it from GitHub, though the only file you really need is here. And here's a quick article on how to get code back into the clipboard as html, which I'm not doing. HTML Fragment FormatWant to paste clipboard HTML as HTML? Enter Microsoft's HTML clipboard format. Instead of using the standard code to read the clipboard's contents, like this...
... now you use this...
But when you look at the contents of
What comes back isn't a string with html source, but an "HTML Fragment" formatted string that looks like this: HTML Fragment from Edge
Wow. No, really, wow. That surprised me. I was using Edge this time instead of Chrome, and whoa. Edge includes the entire page's header. That said, that's really not a horrible idea. We have really good context for this fragment, and if we wanted the original CSS, for example, we know where to get it.
HTML Fragment from ChromeBut let's take a look at where I initially started, with Chrome.
See the difference? Chrome's fragment initially looks much more focused, but also provides much less information about the code's original context. Worse, Chrome's puts all the CSS information inline, and repeating each CSS property inside of each pasted html element makes the source a long ways away from DRY. And that out-of-context, inline CSS is lossily translated, which will cause us some rendering problems that we'll see and discuss in a bit. Original SourceNow Edge's fragment isn't perfect. Here's the original html of that snippet straight from the server...
Look how clean the original is! Why can't we just get that? Chrome's CSS injections and line flattening makes for a much less human readable snippet. Edge is close, but still weird. Take another look. For some reason, Edge's fragment makes every tag uppercase like it's 1998. It also trashes Gruber's original (and thoughtful) whitespace. Also yuck. I mean, Gruber's using Markdown to write Daring Fireball. In a perfect world, I'd take that clipboard's html and turn it back into Markdown when it's pasted into MarkUpDown. How do we get this original source? Start and End FragmentThe important thing to catch is that the HTML Fragment format almost always includes a full html doc with html and body tags after the Though Chrome immediately dives into your selected text (the "true" html fragment) immediately after the If you ignore context like this, though, it's an easy enough feat to take the string and parse out the "true fragment's" html by splitting the entire HTML Fragment string on
When we parse out that html and insert it into our Markdown from Chrome, however, we get some, um, interesting results.
I'm going to wrap these pastes in Edge Parsed Code
Though you should remember that the original source has been smeared together, losing its newlines, and all the tags are strangely capitalized, the source looks pretty nice. It's plain, and adopts the local styling for the most part, but the most important markup is still there -- the blockquote, the italics, links if they'd been included, etc. Chrome Parsed Code
Um, ew. Wha' happen'd? Unfortunately, even though Daring Fireball's entire page has the same styles applied, this inline kludge Chrome performs puts it only in each, in this case, Let's look at all the overhead we have for each
And here's what we have from Chrome's Dev Tools' "Computed" style tab:
But note that that's essentially all from one css file, as properties from user agent stylesheets are simply the browser's defaults:
If you'd like, we can compare the fragment's CSS vs. the stylesheet. Spoiler: It's a mess. Not a lot of matching. Click here to see. Ugly. The bottom line is that With HtmlFragmentHelper, I have a couple of choices. One is to strip all inline styles out, or at least some subset of styling. If I want to maintain as much of the original as possible, I might just blast anything that injects colors into the html, like Or I could normalize the CSS and optionally (via a property on I think I'm going to do the former, though it's not in there as of this writing. That Chrome paste looks horrible as is, though. If only there was an easier way... HTML Fragment from FirefoxThere are certainly other applications that create HTML Clipboard values. I ran into LibreOffice's when using Calc, their spreadsheet app, and its html clipboard doesn't include Start and EndFragment tags. Wonderful, folks, wonderful. But isn't there one glaring omission I might want to add here? You know, I think there is at least one... For fun, let's take a look at Firefox's fragment too. Firefox isn't as popular as it used to be, but it's probably worth taking a look. (Remember that this is all on Windows, and Safari is dead enough by now that I'm not going to bother with v5.)
Oh, so beautiful. Same whitespace as the original, with the added bonus (?) that the final paragraph is also text wrapped. No crazy inline CSS attempted. No header overhead or 1998-style HTML TAGS. You could argue that Chrome is better because it has that inline CSS (yuck!) or Edge because it has the full page headers, but honestly, we're only one step farther away from what Edge gave us. We have the URL here. If we have network access to get CSS, we have network access to read the header and figure out where the CSS lives ourselves. Don't overcomplicate things. Beautiful. Good looking code continues to look good when pasted inline with Markdown. Firefox Parsed CodeAnd Firefox's snippet is just as nice when pasted.
I miss Firefox. Labels: c#, howto, html, long, markdown, markupdown, microsoft, tutorial posted by ruffin at 10/14/2016 11:46:00 AM |
||||||||||||||||||||||
| Friday, September 09, 2016 | ||||||||||||||||||||||
|
Oh, Pivots in UWP, you so crazy. You may have heard that I'm writing a Markdown editor, MarkUpDown. It can have several files open at once, of course, and I'm using a UWP Pivot control to handle navigation. As I got closer to releasing, it hit me that Ctrl-W, though common, isn't the most discoverable way to close those PivotItems. And now that I'm maintaining state between starts, so that whatever tabs you have open when you close the app are back on restart, closing each file "on purpose" is a lot more important than when they all closed on each restart. That is, it looks like I need a UI for closeable tabs. Not as easily said as done. You can customize the In that UserControl, I put a I replaced the
That's fun, isn't it?
That looks okay, but there are still two problems.
Okay, three problems -- I really should change the icon to a greyed-out version when the Accessing a property in custom XAML from CI found the answer to the first pretty easily: You have to use a Dependency Property, of course!
But wait! There's more!
I feel like the Knights of the Round Table after they've considered whether to go to Camelot. Okay, nevermind. 'Tis a silly place. I won't make these new headers XAML-friendly for "version mvp". We're going to set the Label somewhere outside of XAML. Moving on to #2... Removing a
|
||||||||||||||||||||||
| Friday, August 12, 2016 | ||||||||||||||||||||||
|
When you write pretty much any code dealing with text, you get used to viewing raw bytes. Probably the most annoying part of it all, once you get your head around Unicode, is dealing with newlines in a tolerant, cross-platform fashion. From today's Wikipedia:
The most annoying part is probably that you can't easily treat newline characters as any fixed number of bytes when you're dealing with crossplatform text. And you should probably always assume you're dealing with crossplatform text. So when I'm breaking things down into informal test cases, I often shove the parsing code I'm writing into a testing console app project to see what's going on. Why I never did the below before when dealing with newlines, I have no idea.
If I ignore Acorn BBC and RISC OS (...and done), every So much nicer to have...
... rather than trying to figure out if a cut caught the Labels: c#, coding, newline, text editors posted by ruffin at 8/12/2016 01:05:00 PM |
||||||||||||||||||||||
|
| ||||||||||||||||||||||
|
|
All posts can be accessed here: Just the last year o' posts: |
|||||||||||||||||||||
|
||||||||||||||||||||||
|
|
|
|