Skip to content

Instantly share code, notes, and snippets.

View dianjuar's full-sized avatar

Diego Julião dianjuar

View GitHub Profile
@dianjuar
dianjuar / Restore the GRUB Bootloader.md
Last active May 22, 2025 07:33
Restore the GRUB Bootloader on Manjaro Linux. Usefull when your fresh windows install eats your grub and can not boot into your linux installation, or for some how your grub is missing

Restore the GRUB Bootloader on Manjaro

  1. Chroot into your linux instalation
    1. The easiest way is with mhwd-chroot
      1. Install it yaourt -S mhwd-chroot
      2. Run it sudo mhwd-chroot
      3. DONE, you have chrooted into your linux installation (open a root console of your installed linux OS, is like just open a console with root access)
  2. Restore your GRUB
    1. Install a new GRUB bootloader with grub-install /dev/sda
  3. Recheck to ensure the that installation has completed without any errors grub-install --recheck /dev/sda
@dianjuar
dianjuar / Create Symbolic links using find command.md
Last active February 10, 2017 01:12
Create symbolic links to all files located using `find` command
@dianjuar
dianjuar / WooCommerce admin bar and dashboard access.md
Last active April 18, 2018 16:43
With the Woocommerse plugin installed, allow some roles to access to the WordPress Dashboard using a hook.

WooCommerce admin bar and dashboard access

Do you wonder why some users at WooCommerce enabled site have access to the top admin bar and WordPress admin dashboard, but some users don’t?

It is by design: WooCommerce plugin developers decided for us for whom they allow access to WordPress admin dashboard and for whom they prohibit it. But thanks them for the professionalism – it is possible to change that default WooCommerce logic via special filters.

Garagulya, V., (2015) Woocommerce Admin Bar Access

Code used.

@dianjuar
dianjuar / How to make a WordPress plugin require another plugin.md
Last active July 18, 2023 19:27
Make a WordPress plugin dependent of another plugin

How to make WordPress a plugin require another plugin?

Put this function on the main php file of your dependent plugin and call it with the rigth parameters.

/**
 * Verify if a plugin is active, if not deactivate the actual plugin an show an error
 * @param  [string]  $my_plugin_name
 *                   The plugin name trying to activate. The name of this plugin
 *                   Ex:
@dianjuar
dianjuar / Install update WordPress puglins directly.md
Last active June 4, 2025 18:16
Install update WordPress plugins without providing ftp access

Install WordPress plugins directly (without FTP)

Put this on your wp-config.php

/* That's all, stop editing! Happy blogging. */
define('FS_METHOD', 'direct');
@dianjuar
dianjuar / wp_has_user_role.md
Last active November 11, 2016 01:38
In Wordpress, if the current user has a determined role

Wordpress

If the current user has a determined role

$current_user = wp_get_current_user();
$isStudent    = in_array( 'student_role' , $current_user->roles);
@dianjuar
dianjuar / How to enqueue Scripts in WordPress, the right way.md
Last active May 7, 2017 23:34
How to enqueue Scipts in WordPress, the rigth way

When you want to enqueue a script in WordPress you need the URL of the JS or CSS!.

To accomplish that, the best way is to use a constant that have the URL of your plugin

if ( !defined( 'XXXXXX_PLUGIN_URL' ) )
	define( 'XXXXXX_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
@dianjuar
dianjuar / Simple PHP Variable Printing with Structure.md
Last active October 2, 2016 20:05
Simple PHP Variable Printing with Structure
<?php
print( '<pre>'.print_r($var,true).'</pre>' );

Written with StackEdit.

@dianjuar
dianjuar / compile_OpenCV.sh
Last active July 27, 2016 14:16
How to compilte OpenCV with g++
g++ m.cpp -o app `pkg-config --cflags --libs opencv`
@dianjuar
dianjuar / Preferences.sublime-settings
Last active December 5, 2016 23:59
Personal general settings of sublime text
{
"always_show_minimap_viewport": true,
"color_scheme": "Packages/User/SublimeLinter/Agila Oceanic Next (SL).tmTheme",
"dictionary": "Packages/Language - English/en_US.dic",
"font_size": 12,
"gutter": true,
"ignored_packages":
[
"Vintage"
],