My mac is ventilating – it is lifting off.. Help

Questions I get lately, is that the mac is making a lot of noise. The Fans are spinning in high gear and OSX itself is slow. Responding slow.

There are some wise-ass answers like buy a new mac, but that is actually not nescecary in some cases. First look in activity of your system. Start the following app:

In my case the process “accountSD” was using about 500% of CPU. This process is used to check and handle all objects related to your account. Online and offline. But it appeared to be running in a loop. Solution, SMC and NV Ram reset!

For SMC you need to check which version of hardware you have. with or without T2 chip.

In dutch: SMC herstellen. NV-RAM opnieuw instellen
In english: reset SMC. reset NV RAM

OSX 10.15.6 – bit buggy – but there is a solution now!

OSX 10.15.6 was a bit buggy. I updated my mac, and while working on normal power, it seems to work fine. No problems, no bugs.

I started to work on the battery and time after time, computer just stops. just restarts when I came back to my desk, or wanted to browse or see mail, and ………. nothing. Just frozes.

So, reset NV-RAM did not work, reset SMC did not work, called apple care, well, they gave me the standard points first while I already knew and tried. So, I was sending in reports and keeping my mac on regular power… until… new update 10.15.7.

I installed it. I kept my breath, and kept it and kept it.. Hmmm.. Needed to breath. no more freezing. Pfffff.. YEAH I CAN WORK AGAIN!

So, now you can update. When you still find some weird points, first thing to do is reset the NVRAM and SMC. For SMC you need to check which version of hardware you have. with or without T2 chip.

In dutch: SMC herstellen. NV-RAM opnieuw instellen
In english: reset SMC. reset NV RAM

OSX El capitan will not install

There is a problem with installing El Capitan. On installation, when the server is being checked, the installation will fail with a messaging saying the os x could’nt be install on the computer, please contact the software editor to get help.

I called apple and they said they can’t give me any tech support, i guess cause my computer is too “old”.. I tried a few times, can’t go back with my old os and i’m stuck on the installation program.

Solution was actually very simple. El Capitan disk has an embbed security certificate that has expired in 2016. Just change your system date, let’s say to 01/01/2015, install El Capitan, then change the date back to today. Actually, this will be done automatically.

Open terminal and enter:

-bash-3.2#  date 0101010116

Then reboot!

Verify and Repair Disk Permissions via Terminal (Mac OS X)

Verify Permissions

diskutil verifyPermissions /

Repair Permissions

diskutil repairPermissions /

Verify and Repair Volume via Terminal (Mac OS X)

Launch Terminal from your Dock, Utilities folder, or via an app launcher like Alfred. Once launched, type or paste in the following command.

diskutil verifyVolume [drive name]

So, for your main hard drive, you could type or paste in something like:

diskutil verifyVolume /

Or, if you have an external drive attached, you can type or paste in the following:

diskutil verifyvolume /Volumes/[drive name]/

So for an external drive named “BackupStuff” you would enter:

diskutil verifyvolume /Volumes/BackupStuff/

If you see no messages, then you can assume that diskutil hasn’t found any errors, and you can move on. If, however, you get an error like “The volume Macintosh HD was found corrupt and needs to be repaired,” then you can repair the drive using diskutil as well.

To repair the drive, you can issue the following command into Terminal:

diskutil repairvolume /

Or, for that external drive as above:

diskutil repairvolume /Volumes/BackupStuff/Rawif-unable-to-unmount-drive-mac.md

If unable to unmount drive on Mac

You can try booting from OS X recovery by holding CMD + R at the time of startup. Once booted from OS X recovery, select Terminal from the utilities and then at the unix prompt enter:

  • diskutil list
  • then press return and look for the disk identifier and enter the following command with the disk identifier:
  • sudo diskutil unmountDisk /dev/(enter here disk identifier name)
  • Press return and enter your admin password if prompted. This should unmount all volumes of the physical drive.
  • If still the above method didn’t work, then the last option is to force the entire disk to unmount.
  • For that using the terminal application again, enter the following command: sudo diskutil unmount force /dev/(enter here disk identifier name)
  • Then press return and enter the admin password if prompted. This will definetely unmount the entire disk and all its related volume.

Rawsofwareupdate.md

Mac OS X Software Update via Terminal

To get a list of available software updates, type the following command:

softwareupdate -l

You will see a list of available updates. You can then install all available software updates with the following command:

sudo softwareupdate -iva

The use of sudo is required to get superuser privileges to actually install the updates. You can also install only the recommended updates with:

sudo softwareupdate -irv

Or you can just install specific software updates by specifying the shorthand package name from the previous list, like so:

sudo softwareupdate -i iPhoneConfigurationUtility-3.2

If there are any updates you want to ignore, you can do so with the -–ignore flag, for example:

sudo softwareupdate --ignore iWeb3.0.2-3.0.2

If you want to see all the available command line shortcuts for Software Update, just type:

softwareupdate -h

This is really useful for remotely updating Macs, setting up automated updates via a bash script, or if you just want to geek out.Rawtime-machine-via-terminal.md

Control Time Machine from the command line

Time Machine is a great tool for ensuring that your data is safe, and it’s pretty easy to set up and use. But for some users, the basic Time Machine interface isn’t enough. As with most of OS X’s functions, there is a command-line tool that lets you do many things with Time Machine. Here’s how you can use the tmutil command to control and tweak Time Machine from Apple’s command-line tool, Terminal.

The basics

Most people won’t need to use this command for their backups because the Time Machine interface will suffice. Who will need it? People who want to manage remote Macs or who want to run scripts containing commands for Time Machine.

The basics of the tmutil command can be found by typing man tmutil in Terminal. (You’ll find the Terminal app in your /Applications/Utilities folder.) The man page tells you what you can do with this command.

For example, to turn Time Machine on or off, you can run these commands:

sudo tmutil enable

sudo tmutil disable

The sudo command is required for many of the commands you issue with tmutil because you need administrative privileges; you’ll have to enter your password after running the above commands.

If you want to run a Time Machine backup right away, on a Mac that either has Time Machine disabled, or, say, just before updating to a new version of OS X, you can run this command:

tmutil startbackup

This is the same as choosing Back Up Now from the Time Machine menu in the menu bar at the top of your screen.

And if you ever want to stop a backup, just run this:

tmutil stopbackup

Save disk space on your laptop

Since your laptop isn’t always connected to its backup disk, Time Machine retains “local snapshots,” or files that it will copy to your backup disk the next time it is available. However, these local snapshots take up space, and you may want to turn this feature off if you don’t have much room on your hard disk. You can do so with the following command:

sudo tmutil disablelocal

Running this command will also delete any local snapshots. You can turn local snapshots back on by running:

sudo tmutil enablelocal

If you love delving into the nitty-gritty, and especially if you manage remote Macs, you’ll find this to be a very useful tool.

Exclude files and folders

You can exclude certain files and folders from your Time Machine backups from the Time Machine pane in System Preferences. Naturally, you can also do this from the command line, too. Run this command:

sudo tmutil addexclusion

The part stands for the path to a file or folder. For example, if I want to exclude my Downloads folder from Time Machine backups, I would run the following:

sudo tmutil addexclusion ~/Downloads

The tmutil addexclusion command has an interesting property: it’s sticky. When you use this command, the item you exclude remains in the Time Machine exclusion list even if you move it, which is not the case when you exclude items from the Time Machine preference pane. If you use the above command with the -p flag, then it will not be sticky, and will be the same as an exclusion you add from the Time Machine preference pane.

Manage remote backups

If you’re managing a remote Mac, such as a server, you may want to change Time Machine settings for that computer. You can start by finding where Time Machine backups are stored. Run this command:

tmutil destinationinfo

You’ll see something like this in Terminal:

Name : TM Backup

Kind : Local

Mount Point : /Volumes/TM Backup

ID : B9DAT9A6-0C37-4C39-A2AE-10A3403C97F9

To change the destination, you can use two commands. First, remove the current destination like this:

tmutil removedestination

In place of , type in the text string returned by the destinationinfo command. Then run this command to set up a new destination disk:

tmutil setdestination _volume_name_

Replace _volume_name_ with the name of the disk or volume you want to use. You can add multiple destinations as well, since Time Machine can rotate its backups on several disks or volumes. See man tmutil for more on setting up multiple backup destinations. (You can now do this without the command line too, see “How to create redundant Time Machine backups.”)

Get Time Machine stats

Time Machine saves a lot of backups: one per hour for the past 24 hours; one a day for the past week; and one a week before that. You can get a list of all the backups on your Time Machine disk with this command:

tmutil listbackups

This will show the full path of each backup.

If you’re curious about how much has changed in your Time Machine backups, there’s a command that will let you find out how much of each backup is new. Run this command to see the delta between each of the Time Machine backups on your backup disk or volume:

tmutil calculatedrift _backup_folder_

Replace _backup_folder_ with the path of the folder containing your backups. This is not the Backups.backupdb folder at the top level of your Time Machine volume, but rather the next folder down; this is generally labeled with your Mac’s name.

For example, when I ran this command on my backups, I saw data like this:

Here’s what I saw when I ran the tmutil calculatedrift backup_folder command on my Mac.

Note that this command takes a long time to run, as your Mac has to calculate a lot of information.

The tmutil command offers many other options, such as the ability to inherit destinations, perform detailed comparisons of backups, restore items and much more. See man tmutil to find out all that you can do.

If you love delving into the nitty-gritty, and especially if you manage remote Macs, you’ll find this to be a very useful tool.

Article via MacWorld

How to Move Your Email to Another Mac

If you use Apple’s Mail application, there will probably come a time when you’ll want to move your email messages and email account to another Mac. Maybe you just purchased a new Mac. Or maybe you’ve kept your personal email at work, and you now want to move those emails and that account to your Mac at home. Fortunately, there’s an easy way to move your mail!

We’ll assume that your email account is located on only one Mac, and that you do not yet have an email account set up in Apple Mail on the Mac you’ll be moving your email to.

Here’s how to do it:

  1. You will need to copy some files off the Mac that already contains the email account. To do this, you can use an external hard drive or USB flash drive to transfer the files directly from one Mac to the other. Connect the drive to your Mac now.

  2. The files are located in your User Library. Open this folder now.
    • Mac OS X 10.6 and earlier: Here’s where you want to go: Macintosh HD → Users → Your User Folder → Library.
    • Mac OS X 10.7 and later: See:

The user’s Library folder, which is different than the root Library folder at the top-level of the hard drive, contains hundreds files that store important preferences and settings for many of the applications on your Mac. It’s good to learn how to access this folder, even if you don’t need to open it right now. Here’s how to access the Library folder in OS X 10.7 Lion and 10.8 Mountain Lion:

  1. Switch to the Finder.
  2. Press and hold down the Option key on the keyboard.
  3. From the Go menu, select Library, as shown below. The Library folder will open.

A word of warning: Think twice before editing the files in the OS X Library folder. These files are used by the applications on your Mac, and modifying them could change how the applications work. However, it doesn’t hurt to explore the Library folder and see where some of the most essential files on your Mac are stored.

  1. Now you need to copy the Mail folder, as shown below. (Yes, the entire folder.) To do so, hold down the Option key and drag the Mail folder to your external drive. That will copy your mail while leaving the original files right where they are.
  2. You should also copy the preferences file for Mail.app. Here’s where you can find it: Macintosh HD → Users → Your User Folder → Library → Preferences. The name of the file is com.apple.mail.plist.
  3. Disconnect the external drive, and then reconnect to the new Mac. Copy the Mail folder and the preferences file to the Library and Preferences folder. Make sure that the folder and file are in the correct location!

If you now open Apple Mail on your second Mac, it will look exactly the same as it did on the other Mac. This means your accounts, messages, and folders have all been moved to the second Mac. Good work!

Change Prices of Items added to Cart in WooCommerce

Sometimes we have to recalculate product prices and their totals when products are already added to the cart depending on some Luckily the Cart Object allows to do cool stuff and create any condition.

First off all let me show you a very simple example, where we just set the custom price for all products in cart.

1
2
3
4
5
6
7
add_action( 'woocommerce_before_calculate_totals', 'misha_recalc_price' );
 
function misha_recalc_price( $cart_object ) {
	foreach ( $cart_object->get_cart() as $hash => $value ) {
		$value['data']->set_price( 10 );
	}
}

My today’s task is the following: When a customer adds to the cart a certain amount (3 for example) of products of a specific category (ID 25), these products will receive 50% discount. But this shouldn’t affect Lambo product (with ID 12345).

WooCommerce: 50% discount to a specific product category when selected a certain amount of products
Cart totals are outside the image on the last frame, but trust me, cart totals was updated.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
add_action( 'woocommerce_before_calculate_totals', 'misha_recalc_price' );
 
function misha_recalc_price( $cart_object ) {
	foreach ( $cart_object->get_cart() as $hash => $value ) {
		$value['data']->set_price( 10 );
	}
}

My today’s task is the following: When a customer adds to the cart a certain amount (3 for example) of products of a specific category (ID 25), these products will receive 50% discount. But this shouldn’t affect Lambo product (with ID 12345).

WooCommerce: 50% discount to a specific product category when selected a certain amount of products
Cart totals are outside the image on the last frame, but trust me, cart totals was updated.
add_action( 'woocommerce_before_calculate_totals', 'misha_recalculate_price' );
 
function misha_recalculate_price( $cart_object ) {
 
	if ( is_admin() && ! defined( 'DOING_AJAX' ) )
		return;



add_action( 'woocommerce_before_calculate_totals', 'misha_recalculate_price' );
 
function misha_recalculate_price( $cart_object ) {
 
	if ( is_admin() && ! defined( 'DOING_AJAX' ) )
		return;
 
	// you can always print_r() your object and look what's inside
	//print_r( $cart_object ); exit;
 
	// it is our quantity of products in specific product category
	$quantity = 0;
 
	// $hash = cart item unique hash
	// $value = cart item data
	foreach ( $cart_object->get_cart() as $hash => $value ) {
 
 
		// check if the product is in a specific category and check if its ID isn't 12345
		if( in_array( 25, $value['data']->get_category_ids() ) && $value['product_id'] != 12345 ) {
 
			// if yes, count its quantity
			$quantity += $value['quantity'];
 
		}
 
 
	}
 
	// change prices
	if( $quantity > 3 ) {
		foreach ( $cart_object->get_cart() as $hash => $value ) {
 
 
			// I want to make discounts only for products in category with ID 25
			// and I never want to make discount for the product with ID 12345
			if( in_array( 25, $value['data']->get_category_ids() ) && $value['product_id'] != 12345 ) {
 
				$newprice = $value['data']->get_regular_price() / 2;
 
				// in case the product is already on sale and it is much cheeper with its own discount
				if( $value['data']->get_sale_price() > $newprice )
					$value['data']->set_price( $newprice );
 
			}
 
		}
	}
 
}

If you’re wondering where I found all those methods like set_price()get_category_ids(), look at the Abstract Product Object, you can find it in WooCommerce plugin directory in /includes/abstracts/abstract-wc-product.php. And by the way, Variations don’t have categories.

If you read my blog and still don’t know where to insert this type of code, it is sad. Try your current theme functions.php then.

If you cart in WooCommerce is custom coded and our hook doesn’t apply to it, use WC()->cart->calculate_totals().

P.S. While working with woocommerce_before_calculate_totals action hook, be careful with plugins that affect cart prices too, like YITH Dynamic Pricing and Discounts.

Hosts tabel aanpassen i.v.m. verhuizingen

Wanneer u bezig bent met het verhuizen van uw website en u nog niet de dns hebt aangepast kunt u de nieuwe site niet bereiken onder de domeinnaam. De dns wijst immers nog steeds naar de oude locatie.

We kunnen hier gebruik maken van het hosts file dat op zowel unix (gebaseerde) systemen linux, freebsd, macosx als op het windows platform bestaat.

Op elk unix systeem staat het hosts bestand in de /etc directory. Alleen root heeft rechten dit bestand aan te passen.

Op de Mac is het net een beetje anders. Hier wordt uitgelegd hoe het op de Mac moet.

Ga naar Applicaties -> Utilities -> Terminal. U krijgt nu een terminal scherm te zien met alleen tekst. Vervolgens tikt u in:

sudo nano /private/etc/hosts

/private/etc/hosts is het hosts bestand waar we het eerder over hadden. nano is het tekstbewerkingsprogramma dat we gaan gebruiken om dit bestand aan te passen. sudo zorgt ervoor dat we tijdelijk root (beheerder) rechten krijgen om het bestand aan te mogen passen.

Wanneer we op enter drukken wordt ons om een wachtwoord gevraagd. Dit is uw eigen wachtwoord. Wanneer u uw wachtwoord invult lijkt het alsof er niet op gereageerd wordt. Dit is normaal. Wanneer er toevallig iemand met u meekijkt kan deze persoon namelijk niet zien uit hoeveel tekens uw wachtwoord bestaat.

Vervolgens wordt het onderstaande scherm getoond.
macosxterminalhosts-org

Onderaan voegen we de volgende regel toe: [het ipadres van de server waarop uw site gehost wordt] [tab] [uw websiteadres en uw domeinnaam] [tab] is simpelweg de tab-toets, maar u mag hier ook een spatie gebruiken. Het ipadres van de server kunt u vinden in de email die u gekregen hebt met de inloggegevens van uw hostingaccount. Dit zal beginnen met 109.237.220.* Het volgende voorbeeld zal het iets duidelijker maken. Onze domeinnaam is ermis.nl, het ipadres van de server is 109.237.220.13. De regel die we dan toevoegen is:

109.237.220.13 www.jouwdomein.nl jouwdomein.nl

Het resultaat is dan:
Schermafbeelding 2015-09-16 om 15.20.15

Vervolgens slaan we het hosts bestand op. Druk op ctrl-X. U wordt dan gevraagd of u het bestand op wilt slaan. Druk op Y (yes) om dit te doen. Vervolgens ziet u de naam van het bestand getoond en drukt u op enter. Het scherm van het tekstbewerkingsprogramma sluit. Nu moeten we alleen nog 1 commando uitvoeren:

dscacheutil -flushcache

De website is nu bereikbaar op onze server en u kunt uw nieuwe website alvast gaan inrichten. Wanneer u klaar bent of u wilt weer terug naar de oude site moet u dit nogmaals uitvoeren maar in plaats van het toevoegen van de eerder beschreven regel moet u deze weghalen. Wilt u alleen tijdelijk terug naar de oude website zou u dan daarna weer de regel toe moeten voegen. Voor het tijdelijk uitschakelen van de regel volstaat het ook om een ‘#’ voor de regel te zetten zoals u in de schermafdrukken hierboven ziet. De regel veranderd dan in commentaar en wordt genegeerd. Het blijft echter nodig om na elke verandering

dscacheutil -flushcache

uit te voeren.

SSH backup website

Well sometimes it is time consuming and very irritating to backup a website using FTP/web interface.

Login using SSH on your website.

Via terminal (apple), putty (windows), use the following commands:
mysql db:  mysqldump -u dbusername databasename -p > outputfile.sql
websites:   zip -9 -r zipfilename.zip [relative folder to path]
unzip zipfilename.zip

then download it via your website. FTP goes too slow.

And your done…

 

Restore database:

Create in the destination server a new database, user for the new database, and password for the user to that database. Let us say that the three you created are respectively, database_name, database_user, and database_password.

Download the dump file to the destination server from the origin server. Issue the following command:

wget http://www.example.com/dump.gxx
mv dump.gxx dump.sql

What is the meaning of the code above?
The line wget http://www.example.com/dump.gxx will download the file dump.gxx to the destination server. That is the reason why I work under public_html directory of the origin server so that I can access the file easily. The code mv dump.gxx dump.sql rename the file dump.gxx to dump.sql.

Finally start the import process,
mysql -u database_username -p -D database_name --default_character_set utf8 < dump.sql

It will ask you a password, give the database_password you just created.

Magento: Fatal error: Allowed memory size of X bytes exhausted (tried to allocate Y bytes)

Usually this is due to an miscoded or misguided error, but in case you try to login into magento on the front end, and you get this message, think back!

In our case, we made an account field mandatory. When a user tried to login and he/she did not fill that field before we made it mandatory, than the above message can occur.

MySqlD does not start in newest OSX Yosimite version.

Start Terminal and sudo as root user

In you Applications folder find your installation. For magento bitnami you will find magento-version.. so you will have to look for it.

In …/mysql/scripts/ edit the file  ctl.sh

Right after #!/bin/sh  add on a new line:     unset DYLD_LIBRARY_PATH

 

And start all.