How to get the user role for the current logged in user in Wordpress

  1. $current_user = wp_get_current_user();
  2. $current_user_role = ($current_user->roles);
Technology: 

The Importance of Code Review

Bruno Skvorc wrote a very nice introductory article on why code review is important.

Every developer knows the pain of banal mistakes. A wrong attribute here, a misspelled property there, an accidentally duplicated line of code which you missed because of the coffee-fueled 16 hour hackathon you’ve been on.

TL/DR
Code review is important

PHP Composer Package Manager 101

Philip Sturgeon the daddy of Pyrocms and godfather of FuelPHP and Codeigniter wrote a nice introductory article on nettuts regarding Composer (an alternative PHP package manager).


Let’s face it: PHP has had a rocky history with package management, and as a result, it is pretty rare to find a developer who actively uses systems like PEAR. Instead, most developers have chosen their favorite framework, which has code specifically written for it to handle various things, like DB interaction, ORM's, OAuth, Amazon S3 integration, etc.

Key Principles of Maintainable JavaScript

If you ever wondered how to make your JavaScript code a bit more manageable this is the article for you to read.
Lightweight and with nice beginner level information.

Tags: 

Simple MVC system in Drupal 6

I've recently started working on a custom module in Drupal 6 and i really disliked the idea to use built in functions for tables and/or to use embedded html into my module.

Technology: 

linux chown files based on previous owner

if you want to change all files owned by an user to be owned by a different user, there is a trick. figure our old owner id. for example with

ls -n

this will list you numeric ids of the owner. use the id with the command bellow

find /path/ -uid numeric_uid -exec chown newgroup.newuser '{}' ';'

Technology: 

Mysql Alter Table Select all Tables

In case you wanted for eg: change all your innodb tables into myisam, and you didn't want to go over the tables one by one, you can do the following queries.

  1. USE information_schema;
  2. SELECT TABLE_SCHEMA, TABLE_NAME FROM TABLES WHERE TABLE_SCHEMA = "your_table_name";

If it returns what you need ?

  1. SELECT CONCAT("ALTER TABLE `", TABLE_SCHEMA,"`.`", TABLE_NAME, "` ENGINE = MYISAM; ") as MySQLCMD FROM TABLES WHERE TABLE_SCHEMA = "your_table_name";
Technology: 

virtualmin/webmin BIND not starting on CentOS 6.2

webmin and centos will usually default to bind-chroot installation and webmin will have the chroot paths set for named.conf
for some reason, in my centos 6.2 setup there was a folder permission issue which prevented the pid file from being created.
chmod 770 /var/named/chroot/etc/
and then it started

one more thing to pay attention to. if you setup virtualmin and use the local named for your domains, then you have to set 127.0.0.1 as the first entry in /etc/resolv.conf

Postfix error: "mailbox_size_limit is smaller than message_size_limit"

After some digging, it appears that mailbox_size_limit and message_size_limit variables are stored as int.
So even if you set them correctly make sure they're not over the int limit (2147483647)

Why using "or die()" in PHP is a bad practice

Daniel wrote a nice article on phpfreaks.com describing why it's bad practice to use "or die()" in your php code.

Reasons such as:

  1. It's not a very nice way to present the user with an error message.
  2. Using for instance the mysql_error() call with it, as many people do, exposes information that should never get output in a production environment
  3. You cannot catch the error in any way.
  4. You cannot log the error.
  5. You cannot control whether it should be output to the screen or not. It's okay to do that in a development environment, but certainly not in a production environment.
  6. It prevents you from doing any sort of cleanup. It just ends the script abruptly.
Technology: 

Pages

Subscribe to at-byte.com RSS