Skip navigation

Category Archives: Software

Posts and entries related to software, libraries, personal projects, bug fixes, code hacks, and workarounds

A friend recently gave me an old macbook, [from about 2009-ish?]

TL;DR
Linux Mint with it’s Cinnamon desktop resulted in the fewest headaches out of the box for me and my needs.

I’ve been looking for a lightweight PC to serve as a dock for my portable hard drives, kind of functioning as an ugly sort of NAS. I have been using my 2011 Macbook Pro with a USB hub. However, it is a pain to disconnect all the USB drives from it if I need to move. But with another small computer I can permanently untether the Macbook and use it around the house again!

So when I was gifted another old Macbook, I set about finding what Linux distro would work best with it.

TIP: To get to the boot select screen on this version of a Macbook, press and hold the Option key when the machine is first booted until the boot device selection menu appears.

As I dabbled, I came up with a list of features I was looking for.

  • Does it boot without error?
  • Does it resume from sleep?
  • Does it resume from a lid close?
  • Does the bluetooth work?
  • Does the wifi work out of the box?
  • Other notes

These are the distros I ended up trying

  • Manjaro
  • ElementaryOS
  • Pop! OS
  • Ubuntu
  • Deepin
  • Ubuntu with MATE
  • Mint
Boots?Resume from sleep?Resume from lid close?Bluetooth?Wifi OOTB?Notes
Manjaro KDEYes, but with errorsYesNonot testedYes
Manjaro XFCEYesYesYesNo, headphones not recognized as outputNo/Yes, when installed on EthernetNo option to add nVidia drivers from install disc
Wifi works OOB
elementaryOSYesNoNonot testedNo
Pop! OSYesYesNonot testedNo
UbuntuYesYesNoYesNo/Yes, when installed on Ethernet
Linux MintYesYesYesYesNo, but an easy add from discwifi & nVidia drivers easily added from disc
DeepinYes, but slowNoNoYesYestrackpad X-axis input is Y-axis cursor movement & no x-axis cursor movement possible
App Store and default browser don’t work
The test results

The most difficult hurdle for any of these distros to overcome was resuming from sleep due to the lid being closed. All but Mint and Manjaro XFCE failed this test. I imagine this is more of a desktop environment issue than related to any particular underlying Linux distro.

The results of these simple tests put Linux Mint with it’s default Cinnamon desktop as the clear winner for my needs.

Worth noting is the utter failure of the Deepin distro. It was unusable on this Macbook and disappointing to such a degree that I doubt I’ll bother with it ever again.

UPDATE: 09/22/21 – added technique for non-admins to perform this action

Here’s how I open two instances of unity on the same project

There are numerous times that I’ve wanted to compare two scenes in the same unity project. Unfortunately, Unity doesn’t allow an already open Unity project to be opened again. However, I found a hack that lets me open the same project more than once. So let’s open an elevated Windows Powershell and get started.

  1. Close all instances of Unity, Visual Studio, MonoDevelop, etc.
  2. Open an elevated Powershell
  3. Change to the parent folder of the unity project
  4. Copy the entire unity project to a new folder
    1. Copy-Item -Path .\GameProject\ -Destination .\GameProjectCopy\ -Recurse -Force
    2. -Recurse to copy all the folder and sub-folder contents
    3. -Force is optional, but errors get thrown if folders already exist. This just overwrites them without any fuss or complaints on the command line
  5. Delete the ‘Assets’ folder inside the new project
    1. Remove-Item .\GameProjectCopy\Assets\ -Recurse
  6. Symbolically link the Assets folder of the original project (GameProject) to a folder in the newly cloned project (GameProjectCopy)
    1. New-Item -Path .\GameProjectCopy\Assets\ -ItemType SymbolicLink -Value .\GameProject\Assets\
    2. (alternate non-admin technique) This is the step that requires the elevated Powershell permissions. If you are unable to get an elevated shell, do this instead:
      1. Open a Command Prompt
      2. Navigate to GameProjectCopy’s parent folder
      3. mklink /J .\GameProjectCopy\Assets\ .\GameProject\Assets\
      4. The following should display, Junction created for .\GameProjectCopy\Assets\ <<===>> .\GameProject\Assets\
  7. Ensure the project are properly linked
    1. Open the Assets folder in Windows Explorer in both projects
    2. Create a file in one folder and ensure the file appears in the other folder
  8. Open Unity for both projects.

This should be enough to trick Unity into opening the same project in two different Editors. The advantage of this technique over just copying the project to another folder is that changes saved in one editor are immediately available in the other one. Both Editors are always in sync!

I just designed and printed my first 3D object.

The broken suction cup support

I have several window mounted cat shelves throughout the house. They are held in place by a series of four suction cups. There are two cups that provide support for straps that hold the bed parallel to the ground and create a surface for the cat to lounge on. This design means that these strapped cups provide most of the support to keep the bed’s occupant resting comfortably in a sunbeam and not catastrophically dumped into the floor. To that end, they have an outer plastic shell that holds the strap in place as well as providing reinforcement for the suction cup underneath.

Professional engineering diagram
Cup designed in Blender
Suction cup brace in Blender
Sliced in Cura
Sliced the design in Cura
First layer
Finished Print
Not a bad approximation
OMG it fits!
Holy crap! It worked first time!

Set up units

Usually, when modeling for 3D printing, you will be using millimeters, so make sure that the scene is using “Metric” units and, specifically, set to millimeters.

Set up the view for small objects

When zooming in close to these small models, the view clipping is sometimes too far out from the camera. This can cause some visual oddities, like the following. The camera is outside of the isosphere’s mesh, but the clipping of the camera hides the faces of the sphere closest to the camera, making it appear as though the camera is inside the mesh.

A view of the Blender viewport clipping a mesh

To fix this, adjust the properties of the view.

  1. Bring up the Properties menu by pressing ‘n’.
  2. Select the ‘View’ tab from the right side of the panel that appears
  3. Change the ‘Clip Start’ to something smaller, until the object in question comes into view as you’d like.
A view of the Blender viewport with more appropriate view clipping settings

Turn on the 3D printing plugin

A “3D-Print Toolbox” plugin is available. I haven’t used it yet, so I don’t know anything about it yet.

Enabled 3D-Print Toolbox plugin

Right now, I’m spending some of my free time getting up to speed with Spring Boot. Opinionated frameworks like Spring seem like they’d be a great way to build some quick prototypes for some ideas I’ve got bouncing around my head without having to go through the learning curve a whole new language. I’m already overwhelmed enough with my operations (Linux, networking, security, application servers, etc) and Unity automation for work. And now I’m throwing some AWS into the mix for some side work with a friend.

In my experimentation with Spring Boot, I threw together a quick cat fact web service. Running mvn spring-boot:run and accessing the endpoint at http://localhost:8080/getcatfact returns some super-simple JSON with a random cat fact. Yay kitties!

I created another package, based on the Spring Boot tutorial, designed to be a “Hello, World” example. When I run the application, everything starts up fine, and the Cat Fact endpoint still works. But trying to access the http://localhost:8080/greeting endpoint results in a weird “White Label Error Page”. After some internet searching, I found a decent answer. It seems the error is related to having my packages at the wrong level. Spring will search for and load Boot applications at the initial application’s package level and any sub-packages. Since the net.bencarson.catfact and net.bencarson.hello packages were siblings and didn’t share a parent, it was obvious how to fix my problem. I just needed to create a common parent SpringBootApplication and package and move these existing applications underneath.

I created a new class for net.bencarson.services.MyServicesApplication and moved the catfacts and hello packages under the new net.bencarson.services package, the application was still throwing the White Label error for ‘greeting’.

Proper application hierarchy for Spring Boot
Moved the Spring applications under a parent package and application

The final piece I was missing was that I needed to modify my pom.xml. Inside, I had to change the <start-class> element.

<start-class>net.bencarson.services.MyServicesApplication</start-class>

Now the service starts correctly and both ‘catfacts’ and ‘greeting’ endpoints are accessible!

I’ve been working on automating the builds for our Unity project at work and been stymied the past couple of days with the project refusing to compile when I try to build from the command-line.

Here’s the situation, I just want to build a prototype build pipeline for a Unity project for our continuous integration efforts. In order to do that, I need to use Unity’s command line features so that a build server of some flavor can hook in to the Unity application and perform the build automatically.

In order to actually build something executable, in my case a Windows EXE file, the BuildPipeline object needs to be used. Specifically, the BuildPipeline.BuildPlayer function (see the sample code on that page).

Now comes the problem. The UnityEditor library is NOT allowed to be used in a built game! So every attempt at building my simple project resulted in compilation errors. Errors stating:

error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing an assembly reference?

After two days of internet searching and following lots of blogs, forums, and youtube videos, I threw my hands up and posted on Stackoverflow. Within a few hours, I had the answer.

Create a folder with the name ‘Editor’, and place your scripts in there. According to the Unity’s Special Folders documentation, scripts place in this folder add “functionality to the Editor during development, and are not available in builds at runtime”.

I also confirmed that the pre-processor wrapping that was suggested worked as well.

So the answer was very easy to implement, but I am still frustrated that this critical piece of information is not made more apparent, especially by Unity’s own documentation.

This weekend, I made an interesting (re)discovery. I was digging though some old emails and found an email with details about how an acquaintance and I were creating a centralized git workflow.

I figured out how to keep my project in sync with yours.
I use git on the command-line, but I imagine it should translate to a GUI tool pretty easily

git add remote upstream
git fetch upstream
git stash //I had uncommitted changes that I had to get off the stack first
git rebase upstream/master
git stash apply //to reapply my changes, I had to manual merge a few issues.

Anyway, thought I’d share with you in case you get other contributors to your IDE.

Later,

Ben

This was highly relevant for me personally, as we have been discussing the benefits of SVN vs Git at work lately. SVN’s centralized structure is simple enough to understand that everyone groks it from the jump. But keeping Git in sync, with its distributed workflows, is a much more convoluted process for new users.

With the above setup to a git instance, it allows a user to maintain local changes, while still being able to keep up-to-date with the latest pushed changes. Being able to rebase, based on the most recent changes to the upstream repo (aka, the centralized shared home of the project) makes keeping everyone in a centralized git workflow so much easier.

If you add ‘–‘ to your git command, git will know not to process anything after the double hyphen as a command-line argument.
This was useful to know for the situation I just found myself in. I had accidentally cloned a repo into a directory called “–force”. I had placed the –force argument in the wrong sequence in the clone command. But when I went to remove it from git, I found I could not. Every ‘git rm --force‘ command was throwing up the usage guide for the rm command; git thought I was passing in ‘–force’ as an argument. I found out about using the ‘–‘ argument with git and ‘git rm -- --force‘ got rid of my bad directory.

I encountered a rather obscure IE bug at work this week. After coding up a series of text inputs that enable/disable other radio buttons based on their values, I was dismayed to find out my javascript code wasn’t working in a test environment. I opened Internet Explorer’s F12 Developer Tools to check for any errors.  Unfortunately, the javascript console was useless; nothing was there! No errors, no warnings, nothing. Maybe the console hadn’t recorded an error because it wasn’t open at the time or something, I thought. So I entered another value and found that the javascript was all of a sudden activated! The radio buttons were disabled appropriately and the console was displaying my console.log statements. I was confused. I attempted several other scenarios and variations of input, attempting to lock down what exactly was causing my code to become active. No luck. Fortunately, a colleague of mine had experienced this exact problem before and let me know how to fix it.

Simply remove the console.log lines.

Did you know that console.log does not work in IE unless you have the F12 Dev Tools open?! I sure as hell didn’t. And not only doesn’t work, it breaks other javascript on the page too.

Here is a stackoverflow link that explains the issue in more detail.

So I learned my lesson here, be certain that all javascript debug statements are removed from my code before delivering it.

Inside WordPress’s WYSIWYG editor, if you start a line of text, inside a code tag with a bad character, in my case, the ‘#’ character, the output gets screwed up. Here’s how to fix it.

If anyone looked at my previous post in the first week or two after I posted it, you may have noticed how ugly the post was when it came to the displaying my console’s output. This is because I put the console’s output inside a <code> tag in the WordPress WYSIWYG editor. My intent was to differentiate my blog post text from the output of the console I was using as an example. However, after wrapping the console output in the tag, this is what it looked like:

Code Tag with Incorrect Output

 

I have successfully used the <code> tag in WordPress before to stylize blocks of text, so that’s what I was using here to represent the console output. I didn’t have any trouble in any previous posts, so I wasn’t sure what was different this time. After experimenting a bit, I found that the “#” character that begins each line was the culprit.

code tag with a bad character at the start of each line

 

The fix was simple, I added a space before each line.

Code tag with a bad character, but prepended with spaces

 

This small change gave the output the desired effect.

Code output with corrrect formatting

 

%d bloggers like this: