Find the size of a MySQL database from CLI

Need: To run a single command in the MySQL console / CLI to show the size of a paricular database.

Solution: This command, when logged in with a user that has permssions to read the information_schema table, substituting “the_database” with the name of the db you want to check (include the double quotes!)

SELECT table_schema "the_database", sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MiB" FROM information_schema.TABLES GROUP BY table_schema;

Example result: 

mysql> SELECT table_schema "db", sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MiB" FROM information_schema.TABLES GROUP BY table_schema;
+--------------------+-----------------------+
| db                 | Data Base Size in MiB |
+--------------------+-----------------------+
| db                 |            5.53125000 |
| information_schema |            0.18750000 |
+--------------------+-----------------------+
2 rows in set (0.01 sec)

Please let me know if this was useful? Nope, not helpful...Yep, more useful than not! (No Ratings Yet)
Loading...

Open a Folder or File in a new VS Code window on Mac OS

Problem: When opening a new folder in VS Code (Mac OS), I want it to open a new VSCode window, and not add the folder to the already open window. I’m used to the Atom IDE behaviour from years back.

Fix: There are two settings that help here:
window.openFoldersInNewWindow controls whether a folder should be opened in the same window or a new one.

window.openFilesInNewWindow does the same for Files, i.e. when you open just a single file.

These settings can be found in the ‘Code > Preferences > Settings’ menu item. OR easier still, with the shortcut  ⌘, (or ‘Command’ plus ‘comma’ keys, if you can’t see the shortcut to the left here)

Once in Settings, start typing window.openF and you should see both options there. Set one or both to on for the desired behaviour. Can’t remember if you have to restart VS Code or not after changing this. Try it!

Please let me know if this works for you Nope, not helpful...Yep, more useful than not! (No Ratings Yet)
Loading...

Fixing ReflectionException: Class scope does not exist in file when setting up Laravel Passport Scopes

Problem: I’m retro-fitting ‘scopes’ to an existing Laravel Passport API to allow some different levels of client access. After adding the available scopes with Passport::tokensCan, and default scopes with Passport::setDefaultScope, and attempting to specify a scope on a route like so:

Passport::setDefaultScope([
    'other-access'
]);

Passport::tokensCan([
    'write-access' => 'Read-write access',
    'read-access' => 'Read-only access',
    'other-access' => 'Other access'
]);
Route::get('endpoint/count', 'API\EndpointController@count')->middleware(['auth:api', 'scope:read-access']);

And an attempt to query the route gives this error:

ReflectionException: Class scope does not exist in file /path/to/webroot/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 790

Solution: READ THE DOCS. Again, I didn’t read the docs FULLY. In order to use token scopes, the docs say…

To get started, add the following middleware to the $routeMiddleware property of your app/Http/Kernel.php file:

'scopes' => \Laravel\Passport\Http\Middleware\CheckScopes::class,
'scope' => \Laravel\Passport\Http\Middleware\CheckForAnyScope::class,

🤦🏻‍♂️ 🤦🏻‍♂️ 🤦🏻‍♂️ 🤦🏻‍♂️ 🤦🏻‍♂️ 🤦🏻‍♂️

Stop WordPress installing new bundled themes and plugins when the core is upgraded.

Problem: Every time WordPress updates to a newer major version it tries to install the newest default Theme too, i.e. WP5.0 arrived with the theme Twenty Nineteen.

In many – maybe MOST cases – we aren’t going to want this to happen on an existing WordPress installation, especially if you are already using a custom theme.

Solution: Thankfully there’s a config value to stop this happening. The value is:

define('CORE_UPGRADE_SKIP_NEW_BUNDLED', true);

…and if you add this line to your `wp-config.php` file (usually found in the root of your site) it will skip new bundles items when the core is upgraded, as the name suggests.

Please let me know if this post was useful with a click, be honest 🙂
Nope, not helpful...Yep, more useful than not! - +3 thumb, 7 overall.
Loading...

Vacuum advance hose fix with WD40 nozzle

Problem: On a trip home from North Wales, the vacuum hose in my GT6 came loose and fell on the exhaust, melting and fusing it. Nasty sluggish acceleration  resulted.

Solution: I had no tools besides a knife and no spare hose, but DID have a small can of WD40 in the boot.  Continue reading “Vacuum advance hose fix with WD40 nozzle”

Homemade 6v Conlog type alarm fob battery.

Problem: A few old 90’s alarm key fobs use 6 volt batteries made up of 4 separate 1.5v button cells. Last year I needed one quick-like – same day – for the Golf Mk3 I’d just bought. There are plenty online, eBay etc, for about £5 to £10 but I couldn’t wait 2 days for one.

Solution: Nipped down to the Pound Shop and bought an assorted selection of hearing-aid button cell batteries for a quid! Taping four AG3’s together with Sellotape or Electrical Tape didn’t make a good enough electrical connection between the cells. Turns out a piece of Heat Shrink tubing, placed over all 4, then gently shrank (shrunk?) with a lighter forces the cells together nicely! After this is done, trim the top and bottom of the tubing to make sure the battery contacts are able to make connection. Continue reading “Homemade 6v Conlog type alarm fob battery.”

Bower update failed with ‘ERR! error rolling back’

2018 update: Bower might not be the right thing to be using nowadays. Here’s a note from the Bower website: “…psst! While Bower is maintained, we recommend using Yarn and Webpack or Parcel for front-end projects read how to migrate!”


Problem: I just tried to update Bower with:

$ npm update -g bower

Which resulted in failure, and Bower wasn’t able to roll back so the install was fudged. Here’s some output of the errors:

$ npm ERR! error rolling back Error: EACCES, unlink '/usr/local/lib/node_modules/bower/.editorconfig'
$ npm ERR! error rolling back  bower@1.2.8 { [Error: EACCES, unlink '/usr/local/lib/node_modules/bower/.editorconfig']
$ npm ERR! error rolling back   errno: 3,

Solution: Firstly I stopped being a dork and remembered I’d need to add ‘sudo’ (the ‘Error: EACCES’ gives it away)… Continue reading “Bower update failed with ‘ERR! error rolling back’”

Golf MK3 Boot / Tailgate ‘grip molding’ fixing missing

Vehicle: 1996 Golf Mk3 VR6 Highline.

Problem: One of the 4 machine screws attaching the trim surrounding the hatchback / tailgate / boot lid lock mechanism was missing. This resulted in rattling, which is an irritation, but more seriously the trim bent every time the boot was opened. The original fixings are Torx headed with an integral washer.

Solution: The original fixing’s part number is N90626201 but it’s no longer available. Taking measurements from an existing fixing shows that the size is M5 x 14mm (standard 0.8 mm pitch), and fixings of this size are available all over the place. Be careful with the length, this fixing screws into a closed-head Rivet Nut welded into the panel. Continue reading “Golf MK3 Boot / Tailgate ‘grip molding’ fixing missing”

Can’t activate Spotify Premium account on VodaFone 4G Red contract.

2017 Update: This tips is very old now, and the information is almost certainly out of date.

Problem: Just bought a new VodaFone contract that includes Spotify Premium (or Sky Sports something or other), and we website / in-store / 191 support don’t seem to know how I should actually activate it.

Solution: Send a text with the word ‘Entertainment’ to 97613. You’ll get a reply from VodaFone with a link and instructions. This worked at time of posting, 5s’s are new, 4G-ready contracts are new. Expect this to change.

How to use wp_get_attachment_image_src() properly…

Problem: No matter WHAT I do, wp_get_attachment_image_src() is NOT working. I JUST want the featured image source of this $post->ID.

Solution: Yes is probably is working… but stupidly I’m trying to pass it the POST ID and not the ATTACHMENT ID like I should be. The Attachment ID can be found with the get_post_thumbnail_id() function, and then passed like this:

1
2
$thisimg = wp_get_attachment_image_src(get_post_thumbnail_id($arr->ID),full);
print_r($thisimg); //shows the Array of bits you need.

Duh… me.

Please let me know if this post was useful with a click, be honest 🙂
Nope, not helpful...Yep, more useful than not! (No Ratings Yet)
Loading...