Website Performance, Code, Images and SEO Testing Tools

Published 2017-09-29, 12:48

There are loads of web site and page analyzer tools out there that look at them under performance, quality, image compression, code or SEO aspects. Many are just (thinly veiled) lead generation tools that don’t really tell the true story, but some are actually useful. As I need them again and again, I collected them here:

More on the marketing-y, rarely even questionable side, but sometimes still interesting to look at:

Visualize `git reflog` in a GUI (and put it in context) with SmartGit

Published 2017-09-28, 11:31

Recently I messed up an important git repository that I was working on. I had created some content in a specific file a few weeks ago. After multiple merges, commit squashing, git reset, rebases and other types of history rewrites  I noticed that this content was missing.

Oh-oh, seems what everybody warns you about when rewriting history happened: I lost some stuff.

But lucky for me, git never really deletes anything. Even if you do stupid things, each commit that was there before still is – just orphaned and without a connection to your normal branches.

Unlucky for me the tool to fix this is called git reflog and not supported by my usual git GUIs that I use, SourceTree and GitKraken.

I tried to use git reflog on the command line, but to be honest this didn’t help much. reflog just outputs a list of changes to the repository, and you have to sift through these manually to find the one you are looking for. There is no context which files where changed or what changes to these files were made. (Disclaimer: There probably is a way to work around this with some bash scripts – here or here for example – but I have no idea about how exactly. That’s why I normally use a GUI.) I had no idea when in the last month stuff broke, so I had no idea where to start looking.

After quite some time googling around I (re)found SmartGit.
SmartGit is also a Git GUI and calls itself „Git for Professionals.“. This means it doesn’t look as fancy as SourceTree or Gitkraken (its design reminded me of working in the Delphi IDE back in the day…), but it is indeed powerful. And most importantly, it can visualize lost commits in a way that is useful!

Funny enough this feature is only very lightly mentioned in the documentation, so here is how it works:

How to visualize lost and „orphaned“ commits with SmartGit

We are looking for the „Recyclable Commits“ branch in the „Log“ view: Open the repository in SmartGit, right click on the repository in the „Repositories“ panel,  select „Log“ in the context menu, then in the opened „Log“ view, select „Recyclable Commits“ in the „Branches“ panel additionally to the already selected branch or „HEAD“:

The light orange-dot entries (vs. the bold black-dot ones) are the „orphans“ that are not part of the current tree any more.

You can filter these down by using a „Filter“ input, which optionally can search for File name and even File content! (So I could just type the filename I knew I had put my content into, and look only through these relevant commits – and even search for a few words I knew I wrote about in the file – how awesome is that!)

Important and super useful is that these commits are shown in the context of the current tree, so you can click the individual commits and see the file changes it includes, click the files to see the diff as you normally would. So much easier than on the command line.

After you found the missing commit, either copy the text over to your editor manually or cherry pick that commit with all its changes to your current branch by right clicking on it and selecting „Cherry-Pick…“. Then commit as usual (and dance a bit as you just saved a few days of work).

How to commit and version changes in a git fork/branch but not merge them back

Published 2017-09-21, 11:38

Recently I tried to figure out how to have both a production and staging environment of a Jekyll website hosted with Github Pages.

This turned out to be not that simple, as both repositories (Github Pages can only host one branch per repository, so you need two – one organization repository and one personal for example) need to have a CNAME and _config.yml file with different content.

So the actual question to answer was how can one commit and version changes to files in a git fork/branch but then not merge them back into the source, while still having a fully merged branch (so actual changes can be merged back via Pull Requests)?

The answer is to use the ours merging strategy when merging the changes that should be skipped:

  1. Assume we have our production repo and staging repo both checked out locally, for now being identical (and having the same CNAME and _config.yml).
  2. Check out staging, make the changes to the files and commit and push them.
  3. If we were to do a normal merge to production, this change would now get merged over.
  4. But now we run these commands:
    git checkout production
    git merge --strategy=ours staging

    (Source)
    --strategy=ours makes sure that during this merge, the production file remain unchanged. But the commit is still marked as merged.
    If we want, we can now also edit the merge commit messageto be a bit more descriptive what we just did: We merged the two branches, but made it keep „our“ (in this case: production) version of the files.
  5. Then push the changes to production:
    git push production production:master

Your next changes to staging can the be merged with production normally, without getting the CNAME and _config.yml changes.

Windows 10: WLAN/Netzwerk von „Öffentliches Netzwerk“ auf „Privates Netzwerk“ umstellen

Published 2017-03-30, 13:20

Mit Windows 10 hat sich (mal wieder) geändert, wie man sein WLAN/Netzwerk von „öffentlich“ auf „privat“ umstellen kann. Das ist relevant weil die Windows Firewall zwischen diesen beiden Klassen von Verbindungen unterscheidet und manche Verbindung aus Versehen falsch kategorisiert werden kann. Also muss man es ändern. Nur wo?

Die Einstellung findet sich nun in den „Einstellungen“ (bzw. „Eigenschaften“, je nach dem wo man es findet) des jeweiligen WLANs/Netzwerkes und wird dort als „Dieser PC soll gefunden werden“ bezeichnet. Ist dieser Schalter auf „Ein“, wird die Verbindung als „privat“ gehandhabt, bei „Aus“ eben als „öffentlich“.

Logisch, oder? *augenroll

Viele weitere Möglichkeiten finden sich hier: https://www.deskmodder.de/wiki/index.php?title=Netzwerk_%C3%B6ffentlich_privat_%C3%A4ndern_Windows_10

git: How to rewrite history on commits that you already pushed to the remote/origin

Published 2017-02-14, 18:42

(Written October 2013)

Let’s phrase this another way:
How to rewrite commits that are already on Github?
Ho to clean up commits that I already synced?
How to rewrite public history on git?

As you probably know git is much more flexible with branches, commits and all that stuff than other CVSs like SVN were. Commits are done locally and more like local snapshots that still can be changed, where commits in SVN are directly on the server/repository and can’t be changed. So there are lot’s of tutorials that explain how all this works:

But the one thing all these instructions don’t tell you, is what to do when you already synced (pushed) these commits to the remote origin. We only get quotes like these:

Once you have published/pushed your work to shared repositories, we very much recommend against going through post-production with it. That is known as rewriting public history and in general requires telling everyone of your failings as a developer so that they can do the necessary work to recover on their side.

A word of caution: Only do this on commits that haven’t been pushed an external repository. If others have based work off of the commits that you’re going to delete, plenty of conflicts can occur. Just don’t rewrite your history if it’s been shared with others.

Don’t include any commit you’ve already pushed to a central server — doing so will confuse other developers by providing an alternate version of the same change.

or my favorite one from the GitHub documentation:

Warning: It is considered bad practice to rebase commits which you have already pushed to a remote repository. Doing so may invoke the wrath of the git gods.

There are good reasons for this if you work with other people.

Obviously this doesn’t help, when you want to rewrite public history. There are lots of cases where you want to do that, especially if you are the only committer to a project and there is noone else to consider.

Before you start playing around with rebase, it’s probably a good idea to make a backup of your current state to a branch:
$ git branch backup-branch
Then if something goes horribly wrong with you workign copy you can just get the old state back:
$ git reset --hard backup-branch

Then you can continue doing the rebase like it is described in one of these tutorials:

And after all that, the magic thing to do is this:
git push --force origin master

By the way, the sources I finally found for this, after fighting for several days, were these:

API Load Testing

Published 2017-02-14, 13:27

Last year I not only needed to log JavaScript errors but also find a way to load test a REST(ish) API. Again some bookmarks that resulted out of my research on how to load test an API:

Software as a Service

Articles / Blog Posts

JavaScript Error Tracking and Logging

Published 2017-02-14, 13:19

Last year I needed a solution for logging and tracking errors in a JavaScript application and spent some time researching services and tools to resolve this need. This is a cleaned up dump of my bookmarks that resulted out of this research:

SaaS

Google Analytics

self-hosted

hacky

Cordova/Ionic support

As I needed it for a Ioinic app and didn’t really have a budget I went with jslog.me which worked totally fine for my needs.

Postman: Use result data in test scripts (and save to environment)

Published 2015-03-10, 21:41

Just use ‚request‘ in the test script:

Makes so many things easier :)

Postman (REST Client) Tests

Published 2014-10-31, 16:04

### VORBEREITUNG ###

// save response in env
var data = responseBody;
postman.setEnvironmentVariable("data", data);

// parse value from json and save in env
var data = JSON.parse(responseBody);
postman.setEnvironmentVariable("device_id", data.id);

// parse array from json and safe as string and save in env
var data = JSON.parse(responseBody);
var product = JSON.stringify(data[0]);
postman.setEnvironmentVariable("contentful", product);

// parse array from json, change value, and safe as string and save in env
var data = JSON.parse(responseBody);
data.locale = "en_US";
var device_update = JSON.stringify(data);
postman.setEnvironmentVariable("device_update", device_update);


### TESTS ###

// test resposonse code
tests["Status code is 200"] = responseCode.code === 200;

// test if response is empty
var data = JSON.parse(responseBody);
tests["Transaction list is empty"] = data.length === 0;

// test if body contains value
tests["Body contains string" + environment.device_id] = responseBody.has(environment.device_id);

// test exact values of json
var data = JSON.parse(responseBody);
tests["transaction.id is " + environment.transaction_id] = data.id === environment.transaction_id;
tests["transaction.state is IN_PROGRESS"] = data.state === "IN_PROGRESS";

WordPress Multisite

Published 2013-11-03, 23:00

Today I spent some time reading up on WordPress Multisite. It was born out of WordPress MU and included in the Core of WordPress since version 3.0, but I never got around to really understand and use it. Here we go:

Information

Plugins

Special Cases

Future

Summary

Multisite seems to work fine but sometimes behaves a bit strange, especially if you want to do special things that it’s not (really) supposed to do. The documentation lacks a lot (note to myself: maybe help) and the not-in-the-focus development from MU to Multisite causes lots of problems with old blogs posts, strange wording and information, confusing everybody. So I’m going to try using it.

20 queries. 0,222 seconds.