Add a User to the Sudoers File in Mac OS X

Adding users to the sudoers requires the usage of vi, which can be fairly confusing if you’re not accustomed to it. For the unfamiliar, we’ll outline the exact key command sequences to edit, insert, and save the file in vi, follow the instructions carefully.

  1. Launch Terminal and type the following command:
    sudo visudo
  2. Use the arrow keys to navigate down to the “#User privilege specification” section, it should look like this:
    # User privilege specification
    root ALL=(ALL) ALL
    %admin ALL=(ALL) ALL
  3. Put the cursor on the next empty line below the %admin entry and then press the “A” key to insert text, then type the following on a new line, replacing ‘username’ with the users short name of the account you wish to grant privilege to (hit tab between username and ALL):
    username ALL=(ALL) ALL
  4. Now hit the “ESC” (escape) key to stop editing the file
  5. Hit the : key (colon) and then type “wq” followed by the Return key to save changes and exit vi

You should be good to go, you can cat the sudoers file to be certain the file was modified:

How to remove all the histories from repository

To make a git repository fresh like new, follow the steps below:

  1. Checkout

    git checkout --orphan latest_branch

  2. Add all the files

    git add -A

  3. Commit the changes

    git commit -am "commit message"

  4. Delete the branch

    git branch -D master

  5. Rename the current branch to master

    git branch -m master

  6. Finally, force update your repository

    git push -f origin master

Set fields default value for visual composer

I am developing a WordPress theme which will be run via WPBakery visual composer and I had to set a default value for some of the fields. I was looking on the web if there any solution to set the default value but I could not find any so I start looking the plugin and found a way of setting default value though the original plugin developer have not listed that on any of the documentation.

So if you want to set a default value for dropdown field setting default value then:
vc_add_param( 'vc_row', array(
'type' => 'dropdown',
'heading' => __( 'Text Color Scheme', 'js_composer' ),
'param_name' => 'color_scheme',
'value' => array(
'Light' => 'light',
'Dark' => 'dark',
'Custom' => 'custom'
'std' => 'dark'
) );

From the above code you can see the ‘std’ key in the array that sets the default value.

Badge OS User data manipulation programmatically

There are a couple different ways you can interact with the user-related data created by BadgeOS. The first and most obvious is to use the provided helper functions, but if you choose you can also interact with the data directly using the user meta keys referenced below.

$args = array(
'user_id' => 0,
'site_id' => 1,
'achievement_id' => false,
'achievement_type' => false,
'since' => 0,
badgeos_get_user_achievements( $args )

Returns an array of a user’s earned achievements for the given site.

$args = array(
'user_id' => 0,
'site_id' => 1,
'all_achievements' => false,
'new_achievements' => false,
badgeos_update_user_achievements( $args )

Updates the user’s earned achievements array. We can either replace the achievement’s array, or append new achievements to it.

badgeos_get_users_points( $user_id )
Return a user’s total earned points.

badgeos_update_users_points( $user_id, $new_points, $admin_id, $achievement_id )

Updates the user’s points total and posts a log entry. If an $admin_id is specified the admin will be credited with the point alteration and the $new_points value is assumed to be the user’s altered total.

badgeos_get_user_triggers( $user_id, $site_id )
Returns an array of a given user’s array of sprung triggers. On a multisite network $site_id can be specified to limit results to a given site (default is site 1).

badgeos_get_user_trigger_count( $user_id, $trigger, $site_id )
Get the count for the number of times a given user has triggered a particular trigger. On a multisite network $site_id can be specified to limit results to a given site (default is site 1).

badgeos_update_user_trigger_count( $user_id, $trigger, $side_id )
Reset a user’s trigger count for a given trigger to 0, or reset ALL triggers. On a multisite network $site_id can be specified to limit edits to a given site (default is site 1).

badgeos_update_user_trigger_count( $user_id, $trigger, $site_id )
Update the user’s trigger count for a given trigger by 1. On a multisite network $site_id can be specified to limit edits to a given site (default is site 1).

How to make a bootable macOS Sierra USB drive

To make a bootable macOS Sierra USB drive please follow the steps below. Assuming you have already downloaded the OS from app store.

Here is what you need to do:

  • Connect the USB drive to your Mac.
  • Using Disk Utility (it is typically found in the Other folder, under Launchpad), format the USB drive as Mac OS Extended (Journaled), using the GUID Partition Mac scheme, and name it macOSSierra. This can be done from the Erase tab within the app; make sure that there are no multiple partitions (turn to the Partition tab to verify and correct this).
  • Open Terminal (it is found in the same folder as the Disk Utility app).
  • Use (paste) the following command:
    sudo /Applications/Install\ macOS\ --volume /Volumes/Untitled --applicationpath /Applications/Install\ macOS\
  • Type in your user password, when required, to start the process.

Based on my experience, this is the best method of creating a bootable macOS Sierra USB drive. It delivers consistent results every time, and does not cause any issues.

Contact form 7 – Javascript API

Contact Form 7 emits a number of Javascript events that bubble up to the document object. In version 4.1 they can be found in contact-form-7/includes/js/scripts.js. If you’re using jQuery you can access those events like this:

$(document).on('spam.wpcf7', function () {
console.log('submit.wpcf7 was triggered!');

$(document).on('invalid.wpcf7', function () {
console.log('invalid.wpcf7 was triggered!');

$(document).on('mailsent.wpcf7', function () {
console.log('mailsent.wpcf7 was triggered!');

$(document).on('mailfailed.wpcf7', function () {
console.log('mailfailed.wpcf7 was triggered!');

Sync AMPPS with multiple machines

Here is a roadmap to establish AMPPS with Dropbox:

  • Download and install the latest version of AMPPS. In the Programs folder will include the folder “var” and “www” are created. In the database files already come “var” folder and “www”, all individual files of your website.
  • Create a folder under your Dropbox account “AMPPS” on it. Move the folder “var” and “www” in your AMPPS folder to your Dropbox folder. The folders are so removed from your Application folder. With the following commands, create a symlink from the Dropbox folder, and the folder AMPPS. To do this to you Mac Terminal.

cd ~ / Dropbox / AMPPS

ln -s ~ /Dropbox/AMPPS/var /Applications/AMPPS/var

ln -s ~ /Dropbox/AMPPS/www /Applications/AMPPS/www

To see if everything is linked correctly, you can check this yet:

cd /Applications/AMPPS

ls -ll

Reset “Use Secure in Front End or Admin” in Database – Magento

I ran into an issue this week where I switched on SSL on a development site and then realized the SSL cert was not installed correctly. This is a big issue in Magento because there is no way to get back to the admin to switch it back off.

If this ever happens do the following to switch back:

1. Open up your admin panel (cPanel or other)
2. Go to phpMyAdmin (if MySql)
3. Find your Magento Database
4. Find table “core_config_data”
5. Look for the columns “web/secure/use_in_frontend” and “web/secure/use_in_adminhtml”
6. Edit both values, make them equal to “0”

After this is done you will be back in action.