Upgrading to PHP 7 – Mini eBook by O’Reilly

A couple of days ago, O’Reilly published a free mini eBook from Davey Shafik about Upgrading to PHP 7. This eBook has around 80 pages and is available in ePub, Mobi, and PDF at this link.

 

upgrade-php7

“Upgrading to PHP 7” book review:

PHP 7—the most dramatic update to the language in over a decade—has arrived. This O’Reilly report provides you with a short guide to the major changes in this new release, including a revamped engine (Zend Engine 3), a bunch of new features, and lots of language cleanup. You’ll learn about basic language changes, deprecated features, Unicode enhancements, changes in Object-Oriented programming, and other enhancements.

 

The book also covers why it took more than 10 years for the next major version of PHP since PHP 5 – and also what happened to version 6 in the meantime.

Important details regarding changes to PHP 7, include:

– Deprecated features, starting with alternative PHP tags and POSIX-compatible regular expressions
– Uniform Variable Syntax, including consistency fixes and new syntax
– Basic language changes, such as new operators, constant arrays, new functions, and regular expressions
– Expectations and Assertions
– Error handling
– Enhancements to PHP’s Unicode, closure, and Generator features
– Changes in Object-Oriented programming
– Scalar type hints (perhaps the most polarizing and exciting new feature)

– Quoted from daveyshafik.com

PHP Security YouTube Series by Codecourse

php_security

This YouTube series from Codecourse gives you a good overview of the most common PHP security issues. They use a very practical approach, showing how the attacks are done and how to protect your code from them.

This course is a series of useful tips and tutorials around the basics of PHP security, which makes it really accessible to all levels of PHP developers.

And, although most of these security problems are already taken care if you use a modern MVC framework like Laravel or Symfony, it’s always good to be aware of how they work and how they are protected within those frameworks.

PHP Security Series Contents:

  1. Include/require file extensions – 3:10
  2. XSS (Cross-site Scripting) – 14:59
  3. Password hashing – 7:47
  4. Directory listing – 3:10
  5. HttpOnly Cookies – 3:52
  6. What you shouldn’t store in cookies – 3:51
  7. CSRF (Cross-site Request Forgery) – 11:32
  8. User defined file includes – 6:51
  9. SQL Injection – 9:16
  10. Error Reporting – 5:53

Total Time – ~1:10:00

Continue reading

Run multiple command line scripts and redirect their outputs on Linux

Recently, I had a situation where I needed to run multiple command line scripts on Linux at the same time while redirecting their outputs to separated log files and wait for them to finish.

If you ever need to do something like that, I leave here the command line script that I used to accomplish this task:

#!/bin/bash

# Add the full path processes to run to the array
PROCESSES_TO_RUN=("/home/joao/Code/test/prog_1/prog1" \
                  "/home/joao/Code/test/prog_2/prog2")
# You can keep adding processes to the array...

for i in ${PROCESSES_TO_RUN[@]}; do
    ${i%/*}/./${i##*/} > ${i}.log 2>&1 &
    # ${i%/*} -> Get folder name until the /
    # ${i##*/} -> Get the filename after the /
done

# Wait for the processes to finish
wait

Gulp vs Grunt in an awesome presentation

Gulp vs Grunt…

Ever used Grunt or Gulp? Both or none? Don’t worry!

This awesome presentation by Mark Dalgleish called build Build Wars will give you a little overview of the differences and similarities between those two builders and hopefully guide you to a final decision.

This presentation was built using Mark’s DIY Presentation Micro-Framework Bespoke.js.

(To see it, just click on it and use your keyboard arrows to navigate.)

If you are having any problem with viewing the presentation, click here.

(NOTE: This presentation is a little old, and back then Gulp was still pretty new. But still gives a nice overview on both.)

How to play an alarm/sound notification in your (python) application

On the other day, I decided to add a sound notification to my unity pomodoro applet and I did a little research. Turns out there are a few options to do this, but not many examples on the internet. And some of those options depend heavily on the operating system and the installation of external modules.

So I ended up being grateful, again, for the invention of Stack Overflow! :)

My solution:

from os import popen

popen("canberra-gtk-play --file=" +
      os.path.join(os.path.dirname(os.path.realpath(__file__)), 'sounds/sound.ogg') + 
      " > /dev/null 2>&1 || true")

Continue reading