Skip to content

Instantly share code, notes, and snippets.

View dianjuar's full-sized avatar

Diego Julião dianjuar

  • Medellín - Colombia
  • 00:56 (UTC -05:00)
  • X @dianjuar
View GitHub Profile
@dianjuar
dianjuar / Copy the remaining files that are not copied form at all.py
Last active May 20, 2016 15:25
Imagine a huge amount of files, you copy some of then to do something, then you want the files left. This code in python copy the files that are not copied yet that all. You need to generate a list of the copied files, you can do it with `ls > copied.txt`. At the end this script will generate a list with the remaining files
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
def loadVectorFromFile( archiveName ):
vector = []
with open( archiveName, "r") as archive:
for line in archive:
vector.append(line)
@dianjuar
dianjuar / a stop job is running for session c2 of user.md
Last active May 15, 2022 12:39
Fixing "a stop job is running for session c2 of user xxx (xs / 1min 30s)"

Fix a stop job is running for session c2 of user xxx (xs / 1min 30s)

enter image description here

This advice is pointing to arch based distributions. Manjaro in special

Install watchdog

# pacman -S watchdog >

@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"
],
@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 / 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 / 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 / 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 / Install update WordPress puglins directly.md
Last active April 16, 2024 12:21
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 / 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 / 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.