PHP – detecting new uploaded images and sending an e-mail with attachments

Quick example today if a php script that I wanted to detect new uploaded images, and then send an e-mail.
I think it’s pretty self-explanatory so won’t go into details. However, keep in mind that it’s mostly simple PHP (not too object-oriented) and also that I make use of the wp_mail function.

$menPath = "path-to-uploaded-files/*.jpg";    
 $menLast  = file_get_contents('timestampFile.txt');    
 if($menLast === false){
     echo 'it is zero';
     $menLast = 0;
 $menFiles = glob($menPath);
 $menFiles = array_filter($menFiles, function ($file) use ($menLast) { 
    $mentest = $menLast - filemtime($file);
    return filemtime($file) > $menLast; });
 file_put_contents('timestampFile.txt', time());

 if (count($menFiles) > 0 )
 $menText =     "images uploaded\r\nFound images count:".count($menFiles)       
        ."Current last timestamp recorded:".date('d-m-Y h:i:s', $menLast )."\r\n"
        ."Images found:\r\n";
 <code>foreach ($menFiles as &$file) {     $menText = $menText.date('d-m-Y h:i:s', filemtime($file))."-".basename($file)."\r\n"; }</code>
     wp_mail( "yourEmail@gmail.com", "files-uploaded", $menText ,'',$menFiles);

Amazon Workspaces in Full screen – Switching back to host desktop

This specific content was written 3 years ago.
Please keep this in mind as it may be outdated and not adhering to best-practices.

Quick solution for the problem related to amazon workspaces in full-screen mode.
The only way to switch back to the host system, is to exit full screen – but this is a problem since all the application windows are resized and re positioned.

Unfortunately amazon does not have a fix for this from 2014 to 2018 – as far as  I know.
Link: https://forums.aws.amazon.com/thread.jspa?messageID=566726

I usually have word open on my host machine, and since I didn’t want to install visual studio or make a java application.. I decided to make a VBA macro.
The following VBA macro creates for me an Always On Top dialog (even on top of the full-screen dual monitor amazon workspaces).

Clicking the on the dialog causes me host start-menu to pop up, and I can access any of my running host applications or run new ones.

And this works without having to disconnect or leave my full screen mode.

The code follows:


Configuring proxychain with viber on linux

This specific content was written 4 years ago.
Please keep this in mind as it may be outdated and not adhering to best-practices.

I wanted to use viber on ubuntu linux but couldn’t connect due to being behind a proxy.
I had to do two things:

  1. Install proxychains and configure my proxy information in the proxychains configuration file.
  2. Run viber using proxychains. Finally make a special sh file to do this.


root@mbak1-VirtualBox:~/Desktop# nano /etc/proxychains.conf 

# add proxy here ...
# meanwile
# defaults set to "tor"
http xxx.xxx.xx.xx 8012 user password
https xxx.xxx.xx.xx 8012 user password

Created the following SH file to run viber with the proxy:


proxychains /opt/viber/Viber %u

How to convert an HTML5 project into a standalone Android application

This specific content was written 5 years ago.
Please keep this in mind as it may be outdated and not adhering to best-practices.

A WebView is a mobile application that acts like a real-world window to a website. The user however doesn’t see any browser at all. One would ask: “OK! And what good is to have an application when the same website can be opened by just typing its address in the address-line of the browser?” The whole thing may sound like the ultimate nonsense but actually it is very interesting and useful. First of all, it offers to the user a simpler and friendlier way to open a website. That presentation has the advantage to be of a more professional look, since the webpage is opened without having on the screen the menus and the borders of the web-browser. Thus it is not the same like just creating a link-shortcut on the Home Screen of the mobile device. It can also be used, so that a website will be only a part of the functionality of an application, by first displaying to the user a UI navigation’s menu, like it is such an application called VMedia that I created for a friend who runs a web TV-station.

But that what is of more interesting is that a WebView application can encapsulate a local site with all sub-directories, including the ability to execute JavaScript programs.
In other words, such an application can turn a complete HTML5-project into a standalone package ready for uploading to the market, like it is Google Play or the App Store of Apple.

I will describe in this tutorial the case of creating a WebView application for the Android using the SDK, in the shortest way it can be done. It could come along with a whole bunch of other checking mechanisms (like error handling on loading, alert messages, progress bar, etc.) but I will write another tutorial for this reason.

For the lazy ones, there are several free tools (even online) that pick the main directory of an HTML/HTML5 project and produce an APK package from it but …if we always use tools, not knowing how to do it ourselves …then who’s gonna write the tools?

In the following, I will describe how I created a standalone application from an HTML5 game that I developed, called Spaceball. More

Dealing with “Could not find artifact com.oracle:ojdbc6:jar”

This specific content was written 5 years ago.
Please keep this in mind as it may be outdated and not adhering to best-practices.


Chris Georgoulis and I describe solutions to working around the following maven error:

Could not find artifact com.oracle:ojdbc6:jar: in central (https://repo.maven.apache.org/maven2) -> [Help 1]

Below I describe 3 ways how to handle this but there are also other solutions available. Check reference at the bottom.

If you plan on using your Project as a dependency:

The simplest solution is to manually install the JAR into the local maven repository. Using the example from stackoverflow:

With the maven entry:


Run the following command in the command line:

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc14 \
     -Dversion= -Dpackaging=jar -Dfile=ojdbc.jar -DgeneratePom=true

If you plan on using your Project as a dependency & want the process automated:

Instead of installing the JAR to the repository manually, there’s actually a plugin for that – thanks Chris for the info.

Add the following entry:


If your don’t plan on using your Project as a dependency in another project:


Reducing RTMPT disconnects on RED5

This specific content was written 5 years ago.
Please keep this in mind as it may be outdated and not adhering to best-practices.

RED5RTMPT streams provided by RED5 are notorious for randomly disconnecting.

Chris Georgoulis and I extensively debugged this for a project and were able to reduce the disconnection rate from 90% to 40% for connections that lasted over 5 minutes. This was for a teleconferencing application that required 4 RTMPT streams in total (2 outgoing, 2 incoming) with a maximum buffer of 200ms.

RED5 by default has a maximum of 100 keep-alive requests. On the 100th request the server returns connection-close . By setting the limit to infinite we were able to improve the performance. RTMPT is quite vulnerable to disconnections and closing and reopening the socket connection plays a role.

As described by Chris, please go to /{red5_folder}/conf/jee-container.xml and modify the following element group with the extra <property> tags(this should be at line 21), and then restart red5:


Quick Case: Apache Reverse Proxy for Tomcat, Red5, and Websockets, on Redhat Linux

This specific content was written 6 years ago.
Please keep this in mind as it may be outdated and not adhering to best-practices.

reverse proxyQuick post outlining the steps and config I used to forward 2 different ports to 2 different servers (tomcat and red5), and to enable websockets on a Redhat server running apache 2.4.5 .

Servers/Apps and Ports:

Apache  – port 80
Red5 – port 5081
Tomcat – port 8585


Create cross platform HTML5 games – Level 1

This specific content was written 6 years ago.
Please keep this in mind as it may be outdated and not adhering to best-practices.

Creating games is the most exciting and challenging area of the software development. Once you have created the next hit game of the year, the challenge for your newborn baby is to support as many different platforms as possible since there are thousands of different devices out there. Thus, unless your target is a specific device, like iPhone, Android, Smart watch, Windows PC, Mac, etc. with previously known technical characteristics, then the need of such a wide support could become a real headache.

responsive_spaceballAn approach to this is to re-write the source code (or specific parts of it) for every platform using the SDK and the tools for this platform.

Another approach is to write the game using technologies that come with the promise “write once, run everywhere”. One such very promising technology is HTML5. Orienting your coding habits into this direction, a cross-platform implementation becomes feasible.

In this tutorial I am going to show you how I have used HTML5 to write such a cros-platform game. The reader could easily be confused with the term“HTML5” believing that somehow it is possible to write such complex applications using HTML-tags (something like <game><img src=”….”, …, put some game logic here </game> and …that’s all. NO!).  In fact, HTML5 is 1% HTML and 99% JavaScript. The tutorial assumes that you already have a basic experience with JavaScript programming, or with …programming.

Actually, an HTML5 game (or application) runs inside a browser that supports this level of the markup language. Fortunately, almost every browser on any device of the last half decade can translate HTML5.

You can play a game that I have created with HTML5 and combines all these promises. Just visit from everywhere the link bellow. If you open it from a desktop browser please keep changing the dimensions to experience the effect of responsive resizing in real-time.


Now, let’s begin with the fun.


Tips for beginners: How to align text & content with html & css

This specific content was written 6 years ago.
Please keep this in mind as it may be outdated and not adhering to best-practices.

Html-cssQuick Example: How to align text & content in CSS

In this post we show how to vertically align your text even if the text is changing its font size dynmically and also how to

align horizontally content (aka divs – otherwise you can do it with span tags) using the old fashioned floats. At the end you can find 

the code in jsFiddle for further practice.


Git: How to merge your branch

This specific content was written 6 years ago.
Please keep this in mind as it may be outdated and not adhering to best-practices.

gitIn this post I will show you four ways to merge your branch with the main branch, which we will call develop, of the project.

1. Merging on develop

git checkout develop

git pull origin develop

git merge yourBranch

This method is the most frequently used. It uses the recursive automatic merging method of Git to merge the changes of your branch upon the main develop branch.

2. Merging with rebase

git checkout yourBranch

git rebase develop

In this method you are applying the develop branch upon yourBranch. If there is a conflict in the process of merging the process stops and you must fix your conflicts manually which may be an advantage some developers. Moreover it does not produce a merge commit message, so it helps to keep the commit history clean.

3. Merging with pull on your branch

git checkout yourBranch

git pull origin yourBranch

git pull origin develop