About Menelaos Bakopoulos

Mr. Menelaos Bakopoulos is currently pursuing his PhD both at Center for TeleInFrastruktur (CTiF) at Aalborg University (AAU) in Denmark and Athens Information Technology (AIT) in Athens, Greece. He received a Master in Information Technology and Telecommunications Systems from Athens Information Technology and a B.Sc. in Computer Science & Management Information Systems from the American College of Thessaloniki. Since April 2008 he has been a member of the Multimedia, Knowledge, and Web Technologies Group.

Posts by Menelaos Bakopoulos:

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

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 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 6 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:

More

Configuring proxychain with viber on 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.

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 

[ProxyList]
# 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:

#!/bin/bash

proxychains /opt/viber/Viber %u

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

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

Introduction

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

Could not find artifact com.oracle:ojdbc6:jar:11.2.0.4.0 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:

<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.3.0</version>

Run the following command in the command line:

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc14 \
     -Dversion=10.2.0.3.0 -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:

<build>
 <plugins>
 <plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-install-plugin</artifactId>
 <inherited>false</inherited>
 <executions>
 <execution>
 <id>install-external</id>
 <phase>clean</phase>
 <configuration>
 <file>${basedir}/lib/ojdbc14.jar</file>
 <repositoryLayout>default</repositoryLayout>
 <groupId>com.oracle</groupId>
 <artifactId>ojdbc14</artifactId>
 <version>10.2.0.3.0</version>
 <packaging>jar</packaging>
 <generatePom>true</generatePom>
 </configuration>
 <goals>
 <goal>install-file</goal>
 </goals>
 </execution>
 </executions>
 </plugin>
 </plugins>
 </build>

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

More

Reducing RTMPT disconnects on RED5

This specific content was written 8 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:

More

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

This specific content was written 8 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

More

Removing duplicate objects using Underscore for Javascript in Coffeescript

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

underscore
Below an example to show how to remove duplicate objects from an array using underscore in Coffeescript.

My answer is based on the following stackoverflow q/a: http://stackoverflow.com/a/9923961/1688441

array=  _.uniq(_.collect(initialArray, (x) ->  JSON.stringify x  )).map((v) -> JSON.parse(v))

More

WordPress Revisr Plugin: Connecting with Github

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

Revisr“Revisr is a Git and WordPress database plugin that allows you to keep track of your web projects in version control. Revisr eliminates redundant interfaces in your workflow and allows you to focus on the task at hand.” – Revisr

That sounds well and good. However, configuration required a few steps and below we document them.
It is needed to install git, create certificates, upload them to github, and also set appropriate permissions.

Steps

            1. Temporarily allow login by the www-data account.
              Open /etc/passwd with nano or vi, and replace :usr/sbin/nologin with :/bin/bash
              See: http://programster.blogspot.gr/2014/05/ubuntu-1404-allow-login-as-www-data-user.html


            2. Install git.
              sudo apt-get install git

            3. Create a certificate for www-data user and set permissions.
              a) Go to www directory and change owners:

              ~/# cd /var/www
              /var/www# chown www-data .
              

              b) Generate a certificate:

              sudo -u www-data ssh-keygen -t rsa
              

              You shouldn’t enter a passphrase and you should see the correct key.


            4. Open the generated certificate and copy the text inside:
              root@server:/var/www/# cd .ssh
              root@server:/var/www/.ssh# cat id_rsa.pub
              ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDOL…etc

            5. Go to Github site and upload the certificate.
              A) See step 4 of https://help.github.com/articles/generating-ssh-keys/
              B) Add your specific key to the github website at: https://github.com/settings/ssh


            6. Test the connection to github:
              sudo -u www-data bash
              ssh -T git@github.com

              You should see:

              Hi username! You've successfully authenticated, but GitHub does not # provide shell access.
              Type "Exit" to exit www-data terminal and type "sudo bash" to start root terminal.
              

              Type:

              exit
              sudo bash

            7. Go to the wordpress directory and set the correct permissions. Reference: http://stackoverflow.com/questions/18352682/correct-file-permissions-for-wordpress

              chown www-data:www-data -R *          # Let apache be owner
              find . -type d -exec chmod 755 {} \;  # Change directory permissions rwxr-xr-x
              find . -type f -exec chmod 644 {} \;  # Change file permissions rw-r--r-

            8. Create a github repository and then connect revisr with this:
              Use the notation for SSH remote URL ( do not use https address).
              Example: in Remote URL enter: git@github.com:developerAccount/project.git


            9. Create a github repository inside the wordpress folder (see here for more info):
              A) Go to your folder and execute

              git init

              B) You should now be able to add and commit files using either the command line or the revisr command panel


            10. Check to see that permissions are correct for your wordpress git repository. You can run ls -lqa to check the owner and check within the .git folder as well. The following commands should be sufficient to set correct ownership to www-data:
              chown www-data:www-data -R .[^.]*
              chown www-data:www-data .
              

The following steps should do it. Post your comments or questions below or send me an e-mail.

Redirecting varnish to new backend on the fly

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

varnishCache1) Change VCL backend config

Go to your vcl file (in my case /etc/varnish/default.vcl). Edit the backend param to point to another server. Also increase the timeouts since it will take longer than accessing localhost.

backend default {
 .host = "backupserver.org";
 .port = "80";
 .connect_timeout = 120s;
 .first_byte_timeout = 600s;
 .between_bytes_timeout = 60s;
}

2) Validate VCL script on the fly

sudo varnishd -C -f /etc/varnish/default.vcl

This will notify if any syntax issues exist.

 

3) Reload the VCL Script without restarting varnish

I utilized:

$varnishadm -T localhost:6082
vcl.load reload01 /etc/varnish/default.vcl 
vcl.use reload01

More

Changing user agent for RESTClient firefox extension

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

Intro

If you are using RESTClient (and don’t want to switch to CURL) but need to modify the user-client when testing a request, there are two ways:

  • Adding a custom “user-agent” header through RESTClient
  • Changing the user agent through an extension.

Since RESTClient is an extension, by default it uses the user-agent of firefox.

As a start we can do a test and access the page http://whatsmyuseragent.com/ through the RestClient.

More

if(!cn_cookies_accepted()){ location.href="http://www.google.com"; } alert('test');