Fix Stuck Notification on OSX Messages App

Recently I have been switching between my iPhone, iMac and my Macbook Air for reading messages and doing everyday things while working and helping with our newborn. I have found that for some reason I occasionally get a stuck message notification in the OSX Message app like shown here:

 

stuck-message-notification

Stuck OSX Message Notification

 

I have found the best way to fix this without restarting your computer is to do the following steps:

  1. Quit the “Messages” app
  2. Open Activity Monitor (CMD + Spacebar, then type “Activity Monitor” and press “Enter”)
  3. Select the process called “Dock”
  4. Press the “X” that looks like a stop sign. It will “Force the process to quit”. See Below.
  5. This will close the dock and re-open it and should fix your issue.
  6. Now re-open the “Messages” app.

 

quit-dock-app

Click the “Dock” process. Then force quit it by pressing the upper icon noted.

 

I hope this helped someone out since it was a bit frustrating for me until I found the fix! Cheers!

How to Fix Composer Update Failure due to GitHub Authorization

Recently I was doing an “composer update” on a Laravel installation and I was encountering this error repeatedly. Now I was still working on my recently purchased computer so I was trying to figure out all little fixes that needed to be done on this new machine.

This fix assumes that you have installed Composer onto your composer already. If you haven’t done this then it really shouldn’t affect you until you do so. If you need to do that then this guide on their site is very simple and easy to follow.

Heres the error that I was receiving (minus a few of my personal details left out):

Could not fetch https://api.github.com/authorizations, enter your GitHub credentials to go over the API rate limit
The credentials will be swapped for an OAuth token stored in /Users/username/.composer/auth.json, your password will not be stored
To revoke access to this token you can visit https://github.com/settings/applications
Username: username
Password:
An existing OAuth token for Composer is present and will be reused

Now I knew I was entering my password correctly so I had to look up the fix. Luckily I found this issue on composer’s GitHub pretty quick and it solved my issues for me.

You will need to get a token that is connected to your GitHub account by following this simple guide that was provided by GitHub.

GitHub Token Guide

Once you have gotten your key (which you need to keep secret) this is how you save it to your system. You can either save your GitHub token globally by using this command via the terminal:

composer config --global github-oauth.github.com <token>

Or you can set it in your composer.json file on a project level:

{
  "config": {
    "github-oauth": {
      "github.com": ""
    }
  }
}

Once you’ve set this up you can do your “composer update” and everything should be good to go!

Install and Update to Git 2.2.1 on Mac OSX 10.10 Yosemite using Homebrew

After a recent Git vulnerability was released I decided to upgrade my git to the newest version. Now I had just recently done a fresh Git installation on my brand new machine so I already had Git installed but it was giving me a version (running “git –version”) as 1.9.3. Heres what my output looked like:

$ git --version
git version 1.9.3 (Apple Git-50)

If your just looking to update your Homebrew Git then I would just recommend running these commands via terminal:

brew doctor
brew update
brew upgrade git
brew doctor

Otherwise heres some basic instructions:

This installation or update is using Homebrew on Mac OSX 10.10 so if you prefer a different way that is up to you. Heres how I did it.

First you will need to install Homebrew. You can check if you have Homebrew installed by running “brew doctor” in your terminal. If it is installed I would recommend running “brew update” to get the newest version. If you don’t have it installed this is the command to run via the terminal directly from their site:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Once we have Homebrew installed then we will want to install Git via Homebrew by running the “brew install git” command but only after we have run the check and update (just to be on the safe side). After we have installed Git we want to run the “doctor” command again:

brew doctor
brew update
brew install git
brew doctor

The final step of this procedure is to update the path to which bin is used for Git and other options we install.

echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile

This should update your system to be running the newest version of Git on your machine. You will have to restart your terminal but you should see this by running “git –version” in a new terminal window. For me the output would be something like:

$ git --version
git version 2.2.1

I hope this helps!

Store UUID as Binary(16) MySQL data type

I recently had a friend who was needing to store UUID’s in a database table and had some difficulty with figuring out the correct data type to use for storing this field. This wasn’t necessarily for the unique identifier but it definitely could be used in that way. The best simple answer I could find was from this article. Heres a quick run down of what it mentions.

Lets say you have an UUID of 110E8400-E29B-11D4-A716-446655440000 which is stored in a hexadecimal value. First you would want to do a search/replace to remove all the dashes from this string. This would leave you with 110E8400E29B11D4A716446655440000.

Because this new string is now 32 characters we can store this value into a Binary(16) data type once we use the MySQL command of UNHEX(). The query for this would look like:

INSERT INTO Table (FieldBin) VALUES (UNHEX("110E8400E29B11D4A716446655440000"))

We can also select that value from the table using a query like this:

SELECT HEX(FieldBin) AS FieldBin FROM Table

Thanks to this article again for clearing up this issue for any of those looking!

OpenLayers 3 Hide Popovers on Other Popover Open

If you have setup a popover for your OpenLayers map but would like all other popovers to close when you click another on the map then heres a fix for you (if you declared them the same as me):


map.addOverlay(new ol.Overlay({
position: ol.proj.transform(
[-122.332071, 47.606209],
'EPSG:4326',
'EPSG:3857'
),
element: $('<img class="location-popover" src="/img/marker.png">')
.css({marginTop: '-200%', marginLeft: '-50%', cursor: 'pointer'})
.popover({
'placement': 'top',
'html': true,
'content':'<strong>Location Name</strong>'
})
.on('click', function (e) { $(".location-popover").not(this).popover('hide'); })
}));

As you can see in the end of the “Overlay” declaration I used:

.on('click', function (e) { $(".location-popover").not(this).popover('hide'); })

This just checks all other popovers with the same class and will check if its not the one that being clicked, then close it.

OpenLayers 3 Custom Markers by Latitude & Longitude

Recently I needed to create a OpenLayers map that had many custom makers on it for different locations. I tried a few different ways to do it but found this the easiest. First we will create the map object:


var map = new ol.Map({
  target: 'map',
  layers: [
    new ol.layer.Tile({
      source: new ol.source.OSM()
    })
  ],
  view: new ol.View({
    center: ol.proj.transform([-122.332071, 47.606209], 'EPSG:4326', 'EPSG:3857'),
    zoom: 9
  })
});

This map object has been set to use the OpenStreetMaps background for the layer by calling: new ol.source.OSM()

Next the counterpoint for the map using a latitude and longitude (for Seattle). This has to use the “transform” to convert it to work with the map correctly. This also sets your zoom level.

Once we have created our map object we can start to create the makers by adding a new “Overlay”. We can add as many of these as you want:


map.addOverlay(new ol.Overlay({
  position: ol.proj.transform(
    [-122.332071, 47.606209],
    'EPSG:4326',
    'EPSG:3857'
  ),
  element: $('<img src="/img/marker.png">')
}));

If your feeling very adventureous you can add popovers with the marker (which you will also need bootstrap files included). This code will show a popover with your content. It will also hide any other popovers that are open when you click another:


map.addOverlay(new ol.Overlay({
  position: ol.proj.transform(
    [-122.332071, 47.606209],
    'EPSG:4326',
    'EPSG:3857'
  ),
  element: $('<img class="location-popover" src="/img/marker.png">')
    .css({marginTop: '-200%', marginLeft: '-50%', cursor: 'pointer'})
    .popover({
      'placement': 'top',
      'html': true,
      'content':'<strong>Location Name</strong>'
    })
    .on('click', function (e) { $(".location-popover").not(this).popover('hide'); })
}));

OpenLayers 3 Disable Mouse Wheel on Zoom

Well after jumping straight into some OpenLayers work I found my first problem after building a map. I needed to make it so that the map would not zoom on mouse scroll since this was screwing with users loading into the page and trying to scroll down initially. Heres the code for how to fix it:


var map = new ol.Map({
  target: 'map',
  logo: false,
  interactions: ol.interaction.defaults({mouseWheelZoom:false}),
  layers: [ new ol.layer.Tile({ source: new ol.source.OSM() }) ],
  view: new ol.View({
    center: ol.proj.transform([-122.332071, 47.606209], 'EPSG:4326', 'EPSG:3857'),
    zoom: 9
  })
});

When you are initializing your map object you will pass a interaction which will disable the “mouseWheelZoom”.