First Older Archive Newer Latest

04 Mar 2020 13:42 #sql#training Permalink
Training Day 3 - Continued
The trainer has collected a bunch of SQL books, and stuck them in a public folder on his one drive.

04 Mar 2020 12:55 Permalink
I've got a bit of an idea about automatically creating entries every morning with a weather forecast and moon phase.
I'm not sure about it. It's a bunch of code (hitting the right apis and parsing the data) but it would be useful to wake up to (except that I've tried this sort of thing before and never used it. I've got weather in my phone desktop and Google to ask and most days I don't look it ask)

I could store the weather at entry save time, and display it next to the time, for a little bit of context. (I could do the same thing with location, through the web location API)

I'll look into it.

04 Mar 2020 11:48 #blog#todo Permalink
CSS tweaks:
html {
display: flex;
justify-content: center;

body {
margin: var(--margin-big);

04 Mar 2020 10:59 Permalink
Training Day 3 - Restore

Should be backing up:
* master
* model (if it's not default)
* msdb
as well as user databases.

RESTORE DATABASE command - NORECOVERY if you're going to do more restores (e.g., full then diff then log)

* RESTORE VERIFYONLY FROM DISK =[filename] - Check backup is valid
* RESTORE HEADERONLY FROM DISK = [filename] - Display contents of backup file (to get the file numbers for below)
* RESTORE DATABASE [database] FROM DISK = [filename] WITH FILE = n, NORECOVERY - Restore full backup
* RESTORE DATABASE [database] FROM DISK = [filename] WITH FILE = n, NORECOVERY - Restore partial backup
* RESTORE LOG [database] FROM DISK = [filename] WITH FILE = n, RECOVERY- restore log and restart DB

where FILE = n is the index of a specific backup in a file. (Which gets complicated quick if you're doing a weekly full, daily diff, and hourly log backups).

(But do restores with SSMS since they're not done very often?)

Probably do full backup after any restore.

Point in time: Add STOPAT [date] or STOPATMARK [transaction name] (but EF doesn't support adding marks to transactions)

04 Mar 2020 09:32 #blog#morning Permalink
Woke up around 06:00 feeling pretty good.

Really need to look into styling for small screens. Had some more ideas about 'latest' - showing users only entries that are new from their last visit.

Mostly it's storing the date of the latest entry on the page in a cookie, and then reading that later. Will need to ask users to opt in, and add a 'Vary: Cookie' header for caching.

More todos: Images, User preferences, tag suggestions, direct links to entries, italics, pagnation, keyboard shortcuts for the editor, text search, ids on elements

Images: Three levels of this.
1. img tags in the editor with a popup for the src (Priority: Should have)
2. Upload an image (and insert an img tag) (Priority: Should have)
3. Upload and edit an image (crop and size at least, maybe other stuff later) (Priority: Niceto have)

User preferences: The main one I've got in mind is being able to sort entries with newest at the top, or with newest at the bottom. I'd like to make it easy for people to read the blog from the start, but also for people to keep up with recent entries.

I'd like to highlight to users where they were last time they visited, so they can see if there have been new entries, and I /really/ want to do it in a way that means I don't have to be able to identify users. Storing a last visit date (or last entry seen id) in local storage is easy enough, and since that shows that the client is allowing JavaScript, I can leverage that to either highlight the last entry on screen if it's there (only the last 10 show at the moment, I've added pagnation to the todo list) or load entries if it's not.

Priority: Nice to have

Tag suggestions: As I type tags into the tag entry box, show existing tags that match. HTML5 does the <datalist> thing, and I can probably do something like position a div over the top of the input to show selected tags.

Priority: Nice to have

Direct links to entries: So I can send people links to entries (and to help SEO and maybe people will even like my stuff enough to share it).

I've got a couple of ideas:
1. Entry.ID - This is a Guid so unique, but really unattractive and hard for people to type
2. Can't use title since I don't have one most of the time.
3. Generate hex/base64 short links ("/l/aq6t"). Less ugly than Guid but still not really human friendly. Will need a DB table of short link to ID (but tables are cheap).
4. Same as 3, but use words rather than noise ("/l/cat-lamp-desk"). I'll need a reasonable word list, and people might complain that the link is nothing like the content (and when I say people, I mean Google).

I think 4 is the approach I'm going for, priority Nice to have.

Italics: for emphasis, same code as bold, so easy. Priority: Nice to have.

Pagnation: Having added three bigish updates tonight (so far!), I'm going to need to do pagnation. The basic GetEntries() method takes an offset and a count already, so it's mostly an interface thing. Maybe add 'page size' to user options? Priority: Must have before I have more than 10 entries

Keyboard shortcuts: I keep reaching for Ctrl-B to bold, I'll want Ctrl-I for italics. Maybe Ctrl-S to save a draft (and keep editing), something for save-and-publish (Ctrl-P?): Priority: Nice to have.

Text search: To help me (users? Do I have users?) find entries. Sqlite Full Text Search looks intresting, I'll need to check if the version of sqlite from Microsoft/Entity has it. Priority: Should have

IDs on elements: So I can add links inside an article (e.g. for a table of contents for a long article). Could do it like links with a popup, wrap the text with a <span id="whatever">whatever</span> and show it in the editor with some kind of CSS (including an ::before/::after with the content of the id attribute). Priority: Nice to have

Colors: Maybe? Change font/background color. Needs a colour chooser popup, and colour isn't really my thing. Priority: After everything else

(Phew! Wasn't that a brain dump!)

03 Mar 2020 20:07 #blog development#todo Permalink
Also on the blog todo list, private entries and draft entries.

Drafts are entries that have been saved but not released/posted yet. Private entries are posted but only visible to me.

Once drafts are done, then private entries could be drafts that never get posted but a) that's going to clutter up my list of drafts and b) I don't want to accidentally post a 'private' entry.

So. Two new bool fields on the Entry model, one for draft/live, one for public/private. Except now I'm thinking in terms of 'state' and 'visibility'and those should be enums so I can add new states later.

Drafts depend on Edit, I think. Private is a standalone change.

Thinking about Edit/History, Entries currently have a string Content property. Leave that in place, and create a new History type with valid DateTimeOffset valid from/to, and string Content to keep the old versions. Entries get a ICollection<History> History property, and BlogService gets a SaveEdit(Entry, newContent) method.

Will need to update _Entry to show last edit date where appropriate, so I'm starting to think about an EditVM. I'll also need to add an edit link (just when I'm logged in, obviously).

(Really, I should never use a DB model in a View, there should always be a VM intermediate, but it's kind of convienient to use the DB model at the start).

I think I also want to be able to edit tags, he said realising that I missed a 'todo' tag off the last entry, and maybe should change the tag to 'done' when the features are built.

Private is just adding a checkbox to the editor that will need to be a dropdown if we get more VisibilityTypes. I've got a vague "Friends only" visibility mode in mind, but not untill more than one person is using the site.
I'm consistently adding blank lines between paragraphs, so I need to improve the spacing here.

Phew. That was a day.

Bit of a thing with husband this morning, left me feeling right crap. Nearly fell asleep during trainig, a can of coke woke me up. I'm a bt worried that I'm developing a caffine dependency to offset the tired from the antidepressents. On the other hand, the antidepressents are mostly working (I've been feeling pretty good mostly lately) and taking drugs to help with the side effects of drugs is part of modern medicine.

Traning was OK. Today was database backups (tomorrow is restore). There was a good explanation of the types of backups; roughly full backups are a snapshot of the data, differential are the data that's changed since the last full (not since the last differential), and transaction log backups give enough data to make a point in time restore (more recent than the last full backup).

It looks like a good strategy looks something like take a full backup at the weekend, differntial every night during the week, and transaction backups every 15-30 minutes during the day. Obviously this depends on the database and useage pattern, but it should be a good start for something like Tracker/Ocelot. (COBRA probably wants something like a backup before each run, but we'll think about that later).

The highlight of yesterdays training was database partitioning. That gives databases fairly good isolation from each other, so (e.g.) apps don't/can't tread on each other. The rest of yesterday was hammering in that running everything as the superuser isn't a good idea. Oh, well. It's fixable with scripts once we've got a good way of injecting user/password data into apps.

Blog development is suffering from my brain problems (see above). On the other hand, I've setup a user to isolate the blog server, and written a one-click deploy script that builds the code, ships it to the server, backs up the database, unpacks the code, and restarts the blog server.

I've also enabled client-side caching for the 'static' assets (the site css, and the JavaScript for the editor). Static in quotes because I dont want to just cache them forever - especally doing development they can change fairly frequently, or can be stable for months (if I loose intrest).

Luckily, ASP core has a solution. Add 'asp-generate-version' to the script tag (or the link, or the img) and the src/href will get the hash of the file appended automatically. So I can say cache forever (well, two weeks at the moment) with a clear heart knowing that the next time the files change they'll get reloaded.

Otherwise, the TODO list looks something like:
* Adding editor commands for 'code', 'list', 'strikethrough'
* Fixing the editor to allow the commands to work on elements as well as text nodes
* Support for editing entries. (Editing is easy - just load an existing entry into the editor, but I want to add a history as well, and that's a bit trickier)
* Better mobile formatting

Anyway. Just finished Captain America, time for Avengers Assemble.

02 Mar 2020 22:37 #mobile#sleep Permalink
Hmm. Testing the editor in mobile and it's a bit tall, although I have scrolled the page and I can now see the controls.

However, it's late and I want to get more sleep than I did yesterday.

02 Mar 2020 22:33 #blog software#c# Permalink
SIgh. Hello, again. I lost the first couple of entries because I had


rather than


so when I wanted to add tags (which I've done), I couldn't update the old DB in place.

However, fixed that problem now. The blog is up!
First Older Archive Newer Latest