Skip to content

Instantly share code, notes, and snippets.

@premitheme
premitheme / README.md
Last active March 23, 2024 22:08
Recover MAMP MySQL database using .frm and .ibd files after InnoDB crash

Recover MAMP MySQL database using .frm and .ibd files after InnoDB crash

After a power faliur (also can be a sudden restart or system crash), I ended up with corrupted database and lost the access to my local hosted websites for development. Even the MAMP's MySQL server was not starting.

Preparation

You will need to find the databases folders, in case of MAMP they are located in Applications/MAMP/db/mysql56 (or mysql57 depending on MySQL version).

You will find folders containing the database name, inside them you will find .frm and .ibd files. Take a copy of the entire folder for backup in another place, the desktop for example.

@premitheme
premitheme / README.md
Last active March 22, 2022 14:15
Reset and organize MacOS Launchpad apps

Reset and organize MacOS Launchpad apps

Type the following line in the terminal...

defaults write com.apple.dock ResetLaunchPad -bool true; killall Dock

This will group all system applications in one page then all your installed applications in the rest of pages.

@premitheme
premitheme / get_string_between.php
Created August 23, 2018 18:13
Get string between specified two strings
function get_string_between($string, $start, $end){
$string = " ".$string;
$ini = strpos($string,$start);
if ($ini == 0) return "";
$ini += strlen($start);
$len = strpos($string,$end,$ini) - $ini;
return substr($string,$ini,$len);
}
$fullstring = "this is my [tag]dog[/tag]";
@premitheme
premitheme / README.md
Last active May 3, 2018 07:08
Extract zip files on the server on the fly and chmod

Extract zip files on the server on the fly and chmod

Upload zip file (ex. WordPress package) and extract.php to the same folder, then type the following:

http://path/to/extract.php?file=filename.zip

On success you will get "ZIP archive extracted" message.

@premitheme
premitheme / README.md
Last active April 30, 2022 16:54
Create automator service to clean zip files

Clean Zip Service for Mac

In Automator create new workflow with the following settings

Service recieves selected: files or folders in: Finder.app

Run Shell Script

Shell: /bin/bash Pass input: to stdin

@premitheme
premitheme / README.md
Last active May 2, 2018 06:28
Show/Hide hidden files in macOS High Sierra

macOS Show/Hide hidden files

command + shif + .

@premitheme
premitheme / README.md
Last active May 2, 2018 06:21
Generate POT file for WP themes and plugins on Mac

Generate POT file

1. Install gettext GNU tools with Homebrew using Terminal

  1. Install Homebrew: Install Homebrew : /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  2. Install GNU gettext: brew install gettext
  3. Then you must add that package to your path: echo 'export PATH="/usr/local/opt/gettext/bin:$PATH"' >> ~/.bash_profile
  4. Restart your computer! (Otherwise you will get "sh: msguniq: command not found" error).
@premitheme
premitheme / README.md
Last active March 25, 2018 16:23 — forked from rynaldos-zz/wc-hide-cats-archive-page.php
Exclude WooCommerce categories from shop and other pages

Exclude WooCommerce categories

For Shop & Pages

Replace woo with the product category slug of the category you need to exclude. Multiple categories can be excluded like this array( 'woo1', 'woo2', 'woo3' ).

To exclude from another page, replace is_shop() with is_page( 'YOUR_PAGE_SLUG' ) and enter your page slug in place of YOUR_PAGE_SLUG.

For Woo Categories Widget

@premitheme
premitheme / README.md
Last active May 2, 2018 06:18
Restore Finder's folder view options on OS X

Restore macOS Finder's folder view options

  1. Open the Terminal then type sudo find followed by a single space.

  2. Drag your starting folder from any Finder window to the Terminal window (or use a forward slash "/" to indicate the system root for the whole system. Takes too much time. Not recommended).

  3. Type -name followed by a space and then the file name pattern you would like to search for .DS_Store.

  4. Type -delete to have the command delete files.

@premitheme
premitheme / 1-README.md
Last active December 19, 2017 01:38 — forked from hofmannsven/README.md
Virtual Hosts with MAMP on OS X

MAMP Virtual hosts

Files Need Editing:

/etc/hosts

/Applications/MAMP/conf/apache/httpd.conf

/Applications/MAMP/conf/apache/extra/httpd-vhosts.conf