|
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! |
|
| Wednesday, August 06, 2014 | |
|
I know there's really no market on Windows Phone 8+, relatively speaking, and even after reading Sinclair's thoughts on making a living as an app maker in general, I've got to say that Windows Phone is pulling me back in, and it's solely about the tools. Xamarin just went to an optional subscription model, and $25 for a month of Android porting puts that platform back on the table, but I still couldn't get Xamarin.Android up and running in the Android emulator, even using the Android Designer Walkthrough. Apparently the emulators that Xamarin Studio installed for me by default weren't recent enough to work with the designer, and then when I created a Nexus 5 emulator to nuke that issue, the simplest case app never opened. Xamarin's neat, but it's still very rough around some edges. I'll use it on OS X for iOS, but the Android side drives me crazy. Visual Studio Express 2012 for Windows Phone seems much nicer than Xamarin.Studio on Windows 8. My biggest pain is that the version of .NET for Windows Phone is a painful subset of .NET for desktop -- or even for other mobile platforms via Xamarin, an irony I've lamented before. But the emulator and IDE interaction is, so far, top notch. So I've cleaned up SqlDb# a bit and thankfully fairly painlessly got it at least running on WP8 again. Ah, the only big "find" for Windows Phone 8 here is the path to the "home folder", so to speak. Here's the code, straight for MSDN, though it took some Googling to find it. Windows.ApplicationModel.Package package = Windows.ApplicationModel.Package.Current;
Windows.Storage.StorageFolder installedLocation = package.InstalledLocation;
String output = String.Format("Installed Location: {0}", installedLocation.Path);
Finally, right?
Labels: SqlDbSharp, windows phone posted by ruffin at 8/06/2014 12:23:00 AM |
|
| Sunday, March 23, 2014 | |
|
Guidelines and rules for GetHashCode - Fabulous Adventures In Coding - Site Home - MSDN Blogs: How do hash tables and similar data structures use GetHashCode? I'm using SqlDbSharp to store lots of records and want a quicker way to determine if an entry is already in a table than pulling out and comparing strings. I think storing hash codes in the table for the strings I'm worried about is smarter, especially when things get large, though I'm not absolutely sold on the idea. Regardless, interesting reading, as pretty much always, from Lippert. EDIT: My idea is bad. Guideline: the integer returned by GetHashCode should never change However, this is only an ideal-situation guideline; the actual rule is: So there's no guarantee the serialized values will be useful going forward. Likely, but not guaranteed. I can, of course, make my own implementation, which I might. It's a good idea in general -- two equal values mean possible equality and different values mean "not same". Saves a lot of time if we really push this into an index. Or, as Lippert says about putting things into hash dependent data structures... Now if we have ten thousand items in the set then we are looking through one of a hundred buckets, each with on average a hundred items; the Contains operation just got a hundred times cheaper. Labels: c#, noteToSelf, SqlDbSharp posted by ruffin at 3/23/2014 09:11:00 PM |
|
| Saturday, February 08, 2014 | |
|
TL;DR -- Download a YesSQL database for Windows Phone 8 from here, then use it at your own risk. Not too long ago, I finished up a "fun" project for myself that involved writing a chicken wire and duct tape dbms from scratch. It actually works fairly well, though I occasionally find additional stupid oversights (like splitting commands on "AND" without checking to see if it's part of a string literal) every so often while using it. Actually, from my point of view, it works great. It's always insanely surprising when I try something fairly complicated in SQL and SqlDbSharp just works. That's fun. Anyhow, since my best laptop's still a Windows 8, I've been spending some time playing with Windows Phone 8. I ebulliently detailed coming across some great tutorials a couple of weeks ago. And then, about a half-hour later, I completely 180-ed, whining that WP8 doesn't support pretty much any of the key stuff from System.Data, which bothered me enough to write more about the ORM mentality everything's taking on to the point that it arguably drove the choice of Microsoft's next CEO. That's a topic for another post. Windows Phone 8 Port For today, I'll just say I've thrown away hours of free time, of and on and off again, porting my crazy database to Windows Phone 8. The biggest thing missing was, of course, System.Data, but I didn't really use enough of that namespace to make shimming up a DataTable too difficult. Jon Skeet's DictionaryBackedSet example helped a ton, and made shimming up my DataColumn usage easy. The only other strange thing was figuring out the origin of lots of PlatformNotSupportedException errors that were masked by TypeInitializationException errors for me. As it turns out, Windows Phone 8 doesn't support calls to GetFolderPath like... System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal) ... that I was using to initialize directories, and the PlatformNotSupportedException painfully meant that though it compiled, WP8 wasn't going to honor the call. Compiling code that'll later throw PlatformNotSupportedExceptions is, in my limited playing around, apparently pretty common. Makes some sense, as that allows you to reuse a ton of C#'s tools very quickly, but it's a real pain in the rear at run time. Since I had the codebase's "base" directory defined in a static readonly variable that used that GetFolderPath call, I got the TypeInitializationException whenever I tried to access any static variable on that file -- the file where I have all my psuedo-global, readonly settings. So the errors popped up only at the time I tried to read a static variable or method on that class, even legitimate ones that didn't depend on GetFolderPath, as the code seemed to be sort of lazy-initialized, which red herringed the crud out of me. Turns out, instead of the SpecialFolder setup, I needed to use some variation on... ApplicationData.Current.LocalFolder.Path ... to make WP8 happy. Which means I really needed to abstract how I set my base directory with one more level of abstraction that checks platform. But the bottom line is that, yes, there's now an alternative to the now unsupported (?) C#-SQLite that lets you use SQL on Windows Phone 8 (link to dll in the readme displayed on that page). Sorta. ;^D File bugs, and I'll start fixing them, though the code's simple enough I think any mid-level C# coder should be able to understand what's going on pretty quickly. Labels: SqlDbSharp, windows phone posted by ruffin at 2/08/2014 08:53:00 PM |
|
| Saturday, January 25, 2014 | |
|
Windows Phone Mango Local Database(SQL CE): Introduction | GeekChamp: LINQ is used to query data, T-SQL queries are not supported I've already complained about the lack of DataTables on Windows Phone 8. That still boggles my mind. Why not make code supra easy to port over to Windows Phone? When it's easier to reuse my C# code on iOS and Android ($300 a piece and I'm ready to go) than on Windows' own native platforms, something's wrong. And then I see alternatives like the one above. Admittedly, that article is pretty old, and mentions WP 7.1, but the use of LINQ exclusively instead of supporting SQL I don't quite understand. I mean, I know ORMs are the [conventional] way to do things now. But even they, at least on your standard server-side or desktop stacks, usually end up translating object relations to SQL. I haven't seen a huge practical advantage for ORMs on the systems I've worked on. I keep hearing that it makes swapping database engines easier, but I'll keep ignoring that until someone actually replaces SQL Server with PostgreSQL -- and it's painless enough to make up for carrying, eg, NHibernate around for years. It's really not that all difficult to custom hydrate objects with SQL results, and when it is, you often run into similar trouble trying to shoehorn your data into your ORM via AutoMapper or something similar anyhow. And in most of those complex cases, it would be much easier for those who know how to do just a little bit more than spell "SQL" to have scripted up a sproc to do what the ORM is doing -- and to have that logic processed on the database server, where it's supposed to be happening anyhow. I'm almost speechless at this point. I mean, you're paying how much to have software (the rdbms, to be clear) that's designed to handle complex relationships quickly and efficiently? Quickly processing complex relationships in your data is your database server's job. Why do we push that to middleware? Sorry. I'll try not to step so close to that soapbox again, as it's horribly difficult not to step up off of Britannia and start spewing. Anyhow, this convention of object-ing your way to data rather than SQLing your way has gone from convention to serious technical block with Windows Phone. I don't see how Xamarin abstracts twice -- once from whatever XCode is pushing out to Objective-C or Eclipse to a Java VM, and then again to C# -- on a platform that dips as low, performance-wise, as Android can, and still gives a more fully fledged development platform than Windows Phone. I mean, heck, VB.NET was a non-trivial attempt to pull VB6 programmers onto the web and OO programming with the least amount of head rethreading possible, and it happened because having Microsoft stack developers on .NET was crucial to that platform's success. Why the huge investment during the move to .NET but not Windows Phone and "Metro"/Windows App Store? One platform has been adopted very quickly. I realize the WP numbers are low, but don't you think some developer love would push adoption in business pretty danged quickly too? It's all about the barriers to entry, stupid. Guess this stayed a pretty ranty post. Sorry. Anyhow, so my answer so far, since my mobile apps are just for fun, is to create a DataTable shim for Windows Phone, DataTableWP8, that shims just enough to let me use my buggy SQL database, now called SqlDbSharp (because naming is difficult ;^D), on WP8 without rewriting anything. So far, it's still fun to do, and I've been playing with Visual Studio on my Lenovo laptop as much or more as Xamarin Studio on my new iMac in my free time this week. Labels: c#, DataTableWP8, mono, SqlDbSharp, windows phone, xamarin posted by ruffin at 1/25/2014 02:37:00 PM |
|
| Saturday, November 02, 2013 | |
|
Finally started seriously scratching a new itch. I really disliked how difficult I'd found it to get a database engine working crossplatform for my C# "hobby" projects with MonoDevelop and, now, Xamarin Studio. I'd considered using JSON or DataSet's WriteXML method to serialize data, but up until now, I'd been just writing stuff to text files to get hobby projects running more quickly. After using home-grown text file formats for years, though, it seemed dumb not to leverage SQL syntax. Yet every time I tried to find a good, crossplatform solution, I would waste hours not quite finding a great answer. As I write in the new project's readme... MVED# was written largely because of setup hurdles encountered attempting to deploy other obvious embedded database solutions for C# crossplatform. SQL Server Express is not crossplatform. SQLite must be installed on Windows and has a few nontrivial setup requirements on OS X, both of which create a clear barrier to entry out of proportion for applications with modest data serialization needs. C#-SQLite is an interesting alternative, but still had issues when I tried it out in May of 2012. So back in February 24th of this year, I started hacking a database engine. And 121 commits to Bitbucket later, I finally have enough to put up on GitHub. (The GitHub/Bitbucket dynamic is also very interesting...) I can CREATE TABLE, INSERT, DELETE, SELECT, even INNER JOIN. I'm an UPDATE away from 80% of what I use "real" databases to accomplish. Well, if you ignore speed. It's fun to look back over my commits, as always. There are almost zero commits in June and July, when work took a real turn for the busier. Seems like tons of late night commits. Also some interesting comments about where I was while I was coding... Admittedly, there are tons of *cough* idiosyncratic behaviors in the engine, but much of this was an enjoyable alternative to the horribly defensive coding you have to do for customer-facing code. If I don't want to support ORs in WHERE clauses yet, well, I don't have to. If I want to support only INNER JOINs at first, that's my "right". Case sensitivity? Whitespace rules? All my decision. Bizarre! Want FLOATs to be stored as conventional DECIMALs for now? No problem (and more accurate too)! Unicode? Not yet! Why not? Because I chose [not] to! I'm drunk with power. It was a heck of a lot of fun dealing with how to serialize each of the datatypes I'm supporting now. I did take a few old school-ish routes with storage while writing. Every column's length is absolutely fixed (VARCHARs really aren't VAR at all), largely to make the file's format really easy for users to eyeball, probably a leftover from having played around with 6507 assembler too much years ago. I even slap lines of 0x11s between columns to make it super-easy to view. Having easier-to-read files is probably not the best motivation for creating formats, but I'm happy with how it turned out. Here's a crappy example of a raw "Moore's DataBase File (mdbf)" in the quick file viewer I wrote for the engine (click to see in any real detail). Figuring out ways to serialize strings and decimal values was, honestly, fun. Doing this without much heavy "cheating" (more accurate would be "researching") was also a refreshing break from "serious" work, as this project is intended to be almost completely for [my] relaxation. Getting close to finished in about a tenth of the lines of C#-SQLite is, well, interesting. There's a lot that's not here. Parsing commands, even when you do get to choose what's syntactically legal, quickly gets, well, ugly. JOINs tend to bust what would otherwise be a pretty simple paradigm for parsing SELECTs -- heck, even SQLite currently doesn't support RIGHT OUTER JOIN. (Actually, reading that page, I feel a little of Hipp's pain (though let's make clear, since I'm talking about both in the same paragraph, that C#-SQLite is a port of SQLite by Noah Hart). GRANT and REVOKE don't mean so much when you're just hitting the file system, do they?) Ultimately, writing MVED# reminded me a great deal of the shareware app I wrote years back. Eventually, even when you have nobody to answer to, code reaches the point where it's difficult to keep things idealistically organized. (Insert tangent about why it's so much more important to see a candidate's solution to a real-world problem than to simply interview, say, a new graduate about patterns when you're hiring.) This project was also my first "real-world" use of the GNG Manfiesto. Even though MVED# could have easily gone under LGPL, I think there are going to be times where it's easier to use with the project's files compiled into a single app with new, closed files, so I opted for MPL 2.0 for now. Either way, it's open, demands changes by others to be shared, but allows others to use it as they'd like without compromising their own original, unrelated contributions, just as GNG demands. Anyhow, to advert a little more plainly, the Minimally Viable Embeddable Datastore in C# (MVED#) or, as I called it as I developed it (since I wasn't worried a whit about performance), Moore's Database, can be found here: https://github.com/ruffin--/mved/ It's not feature complete yet -- I'd like to sneak an UPDATE command handler in there before I do too much clean-up of existing code, which will be an easy refactor and then edit of the SELECT code -- but it's surprisingly close for what I think I'd like to use it for. A quick class for testing should follow UPDATE. The code is hilariously simple. Optimizations are almost non-existent. Yet, at the same time, I think it's a horribly accessible codebase. We'll see. I'm going to use it. It works just as well on OS X as Windows, and that's a great start for my apps that need an embedded database solution. I can only assume Xamarin's going to make it pretty easy to use MVED# on Andriod and iOS too. But okay, fine. I hear what you're thinking. If I have 121 commits and each one is, say, 30-45 minutes (let's go on the high side of that range and say 45 min, though admittedly I wonder how good of an estimate that is), that's 90 hours I didn't spend writing The Next Great Piece of Software with an existing engine. And it's not like I'm done yet. To me, that sort of cuts both ways. I'm surprised I'll be able to get a first functioning database engine in well less than three full-time weeks' of work, and I wonder if I'd waste that much time trying to get existing DBMSes working crossplatform. But then if I'd kept development to a primary platform and used the obvious DBMS engine for it, that's ~90 hours of work and months of free time I'd be ahead of where I am now to release an app for someone. Regardless, it's been, and hopefully will continue to be, a fun project. Happy hacking. posted by ruffin at 11/02/2013 10:56:00 PM |
|
|
| |
|
|
All posts can be accessed here: Just the last year o' posts: |
|||||||||||||||||||||
|
||||||||||||||||||||||
|
|
|
|