Archive for the ‘Uncategorized’ Category

ASP.NET Core System.Runtime.CompilerServices.Unsafe does not match

This error popped up randomly for me when I created a new ASP.NET with our standard framework.

Why this happens, even though this project is 100% identical to our other ASP.NET web projects is not quite clear; the SDK for ASP.NET is 2.1 and all packages are pinned to specific versions for our framework. However, Kestrel will pop an error saying it cannot load CompilerServices.Unsafe because it does not match the assembly reference.

One workaround, which is not very nice, is to remove the conflicting reference from *.deps.json in our bin directory; of course we are not supposed to touch that file, but studying it can give insight which package tries to load the wrong version.

A better approach is to just pin the version you require:

<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.5.1" ExcludeAssets="all" />

This seems to be caused by an issue with the Manifest file from a particular version of ASP.NET in a particular .NET Core install (2.1.503 in my case); it somehow sets the version of the assembly to while it means to use 4.5.1.

Ghost linux exploit on Ubuntu 12.04 and 12.10

If you have a version of Ubuntu that old, you usually cannot even run the ‘fix’ all the blogs are talking about. Everyone advices;

apt-get clean; apt-get update; apt-get upgrade

but that will probably give you a lot of file not found. When you update to the old distro repository for Ubuntu there is a good chance, especially on 12.10 that it will tell you libc is fine and updated already; no newer versions while the ghost test script tells you it’s vulnerable.

What to do then is


and follow the steps. Things to notice;

– if your connection cuts out you have to SSH back in via the extra ssh session on 1022 and run screen -r to continue
– when you get the question that the boot drive is no longer found (happens in a read config / udev situation), just pick the drives the boot up raid device is built from, all of them, to place grub on

After this the test script will report you are ok and you can sleep again.

Bulk extract MP3 from MKV

Because I always spend too much time on finding this script and some computers I have I cannot really update ffmpeg anymore, here is a conversion method using an old mplayer & lame I thought I would share;

  1. #!/usr/bin/perl
  3. @x = `find .|grep mkv\$`;
  4. print `mkdir encdir`;
  5. foreach(@x) {
  6. chomp;
  7. $f = $_;
  8. /.*\/(.*).mkv/;
  9. print "$1\n";
  10. $wav = "encdir/$1.wav";
  11. $mp3 = "encdir/$1.mp3";
  12. next if -f $mp3;
  13. $mplayer = "mplayer -vc dummy -vo null -ao pcm:file=\"$wav\",fast \"$f\"";
  14. print `$mplayer`;
  15. $lame = "lame -h -b128 \"$wav\" \"$mp3\"";
  16. print `$lame`;
  17. print `rm "$wav"`;
  18. }

UITableView not showing data / refreshing while data is there

Was in Xamarin, but the same issue applies to ObjC/XCode. 

It was a late night on the 25th and when I got up quite early the 26th to some inspiration for coding I added a UITableView like I did so many times before. I added the source and thought all was fine. But it didn’t work. It didn’t show anything.

First I decided to view.SetNeedsDisplay() and that actually then did show the table, but without any data. Just a BackgroundColor rectangle. At least now it had BackgroundColor and not white (the color of Superview.BackgroundColor).

After a lot of swearing I found that;

  1. this.ReloadRows (new NSIndexPath[]{ NSIndexPath.FromItemSection (0, 0) }, UITableViewRowAnimation.None);

would actually load and show all data.

But the table wouldn’t scroll and you could not select any rows; this, in my tired mind, made an alarm go off. I did this so many times before and it always worked, this time it didn’t and all stackoverflow answers where based on mistakes I had not made for a long time, so it must be another mistake.

It took me 1 hour to figure out what was going on as I did not know that tableviews who do not receive inputs do not get refreshed which is related to the UIViews which receive no inputs not getting they LayoutSubviews() called.

Long story short; the UITableView was in a UIView which was not big enough and ClipToBounds was false, so it did show up but nothing else. My overlapping tools and debugging tools did not detect this, so I lost any hour.

In my library I have all Apple view classes inherited by my own for tooling, debugging and convenience methods, so it was not hard to fix this once and for all by overriding Frame{get;set;} and, for DEBUG add the following which warns me and makes sure I actually checked everything (ShowStack is an Extension which allows me to see the linenumber + file name the issue happens to be appear in);

  1. public override System.Drawing.RectangleF Frame {
  2.             get {
  3.                 return base.Frame;
  4.             }
  5.             set {
  6.                 base.Frame = value;
  8.                 if (Superview == null)
  9.                     return;
  11.                 if (value.X < 0
  12.                     ||
  13.                     value.X > Superview.Frame.Width
  14.                     ||
  15.                     value.X + value.Width > Superview.Frame.Width
  16.                     ||
  17.                     value.Y < 0
  18.                     ||
  19.                     value.Y > Superview.Frame.Height
  20.                     ||
  21.                     value.Y + value.Height > Superview.Frame.Height) {
  23.                      this.ShowStack   (“Warning: Frame is out of bounds of the superview frame:+ this.ToString() + “ trying to fit in+ Superview.ToString(),1);
  24.                 }
  25.             }        
  26.   }

Edit: The data loading issue is not related to this, but I don’t know yet what it is related to. I just call ReloadRows for now as I have no time to debug it.