Tuesday, October 22, 2019

Faulty power cords can cause your old laptop to freeze or run slow

While there is plenty of reasons your old laptop to be slow or freeze, I would tell you about one that might not be so obvious. I came across this issue 2 times in the past months and I decided to share it, because it might be useful for you.

It turns out the issue with bad performing laptop can come from inadequate power supply, and more precisely from the laptop cable or cable connector.

Here are two examples where I came across this issue:

Lenovo T500

This laptop can be running extremely slow, but it will not overheat.

This model comes with 20V power supply and cylindrical connector. Its very common for the cable to start to break near the cylindrical connector from the years of flexing. Look for exposed wires near connector, if thats the case you might consider replacing the power cord. Sometimes outside layer of wires inside of the power cord can be broken off even if no wires are exposed. Bulge near the connector is sign the cable is starting to go bad.

Lenovo G560

This models can start freeze. They are equipped with external video card and its normal to run at slightly hotter temperatures. Before start thinking of thermal compound replacement check the power cord connector! Dirty metal leads can reduce current flow which will cause the laptop to crash on high load. If metal leads are partly broken off laptop may power off when you fiddle with the connector. In that case you might consider replacing the cord.


This sums up my experience with faulty power cords of old laptops.

Wednesday, October 2, 2019

Time for CV update

More than a year passed since the last time I did some updates on my CV.

Its was hard to even remember where I store the source file. Looked at the usual locations: Desktop, Documents, Downloads, but nothing.

File had many iterations in the past, in spite of the fact current version is 2. I always export to .pdf and the source itself is .odt file (Yes, its not a MS format).

Took a while to find the source and finally I found it. I'm almost ready to start with v3 of my CV, but
something is wrong with the fonts :(. Aah, yeah, last time I added custom fonts (Font-Awesome & Roboto).  Installations is as simple as opening a terminal and typing:

sudo apt update
sudo apt-get install fonts-font-awesome fonts-roboto


After font issue is now resolved, let's get back to work!

Next challenge is to fit all relevant information and employment history on two pages.

Monday, February 25, 2019

Converting video files to Google cast compatible format (MP4)

Have you used Google Chrome browser to cast video to your devices? If you do its likely sometimes the video file you drop to chrome does not play, but start downloading instead. This situation is a bit confusing right?

Google chrome is a web browser and as such support only web video formats such a mp4, webm, etc.
If you want to cast or play video with Chrome, you'll have to convert it to one of the supported formats.

If you are a Windows user you can use software as Format Factory to convert your file (https://duckduckgo.com/?q=format+factory). I used it very long time ago and recently I haven't heard of better options. Converting the files will take some time.

Linux and Mac users which have ffmpeg install on the other hand can try just change the video container. Depending on the video you have and its format you have get lucky and only repackage it in mp4 container. This will take seconds.


Here is example with converting Matroska to mp4.

ffmpeg -i input.mkv -vcodec copy -acodec copy output.mp4

The i flag specifies the input file.
vcodec flag specifies the video codec, if stream is mp4 compatible (h264) you can use copy to leave video stream as it is.
acodec flag specifies the audio codec, if stream is mp4 compatible (aac, mp3) you can use copy to leave audio stream as it is.
At the end of the command is our output file.

If the video stream or audios stream is not in mp4 compatible format you'll have to wait a bit longer.

Here is how you transcode the video stream only.


ffmpeg -i input.mkv -vcodec h264 -acodec copy output.mp4

Here is how you transcode the audio stream only. You can probably use aac too, but usually mp3 codec is already installed.


ffmpeg -i input.mkv -vcodec copy -acodec mp3 output.mp4


If you are really unlucky then you'll have to transcode both video and audio streams. Depending on your computer specs can take longer than the video file duration. Combining the flags from the commands above we should run something like this:



ffmpeg -i input.mkv -vcodec h264 -acodec mp3 output.mp4


Tuesday, March 25, 2014

How to setup HHVM on Ubuntu 12.04 (amd64)

You want your website to perform better or you are just curious about HHVM's performance. Follow this simple steps to setup your HHVM + NGINX.

Make sure you are running  Ubuntu 12.04 64bit. HHVM will not install on the 32bit version

1. Installing prerequisites for HHVM

sudo apt-get install python-software-properties

2. Install HHVM

sudo add-apt-repository ppa:mapnik/boost
wget -O - http://dl.hhvm.com/conf/hhvm.gpg.key | sudo apt-key add -
echo deb http://dl.hhvm.com/ubuntu precise main | sudo tee /etc/apt/sources.list.d/hhvm.list
sudo apt-get update
sudo apt-get install hhvm

3. Install HHVM fastcgi

echo deb http://dl.hhvm.com/ubuntu precise main | sudo tee /etc/apt/sources.list.d/hhvm.list
sudo apt-get update
sudo apt-get install hhvm-fastcgi

4. Configure Nginx

Here is example of simple nginx configuration

server {

        error_log /var/log/nginx/example.error.log;

        access_log /var/log/nginx/example.access.log;

        root /home/example/www/web;

        index index.php index.html index.htm;

        server_name example.org;

        location / {

                try_files $uri $uri/ /index.php?$args;

        }


        location ~ \.php$ {

               fastcgi_keep_conn on;

               fastcgi_pass 127.0.0.1:9000;

               fastcgi_index index.php;

               fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

               include fastcgi_params;

        }

}

server {

    server_name www.example.org;

    return 301 $scheme://example.org$request_uri;

}

5. Restart services

sudo /etc/init.d/nginx restart
sudo /etc/init.d/hhvm-fastcgi restart


Saturday, December 7, 2013

Follow this simple advice to never get hacked again

The story began last Friday when friend of mine called on the phone stressed from the fact his sites were down. It turns out his shared hosting provider shutdown the sites because of multiple hacking attempts the putted too much load on the servers. 

Without adding too much details in the story, the problem was two sites php-fusion and joomla based. Both sites are legacy sites, which nobody support, but serve some purpose on the web. After couple of minute to asses the situation and considering the sites don't need to be super dynamic. We decided to go with static HTML files and I had to come up with quick solution.

The solution I came is fairly simple, my plan was to use wget to crow the site and then publish the generated files. I have to say not many people know how many useful features wget have. The plan worked like a charm.

Read on for details on how I did the trick.


The first site I converted to static HTML pages had less pages, but surely more difficult. I needed to convert download.php?cat=[:digit]&download_id=[:digit] to the real name of the file. The good news is wget parameters that can do that for me.





‘--trust-server-names’

If this is set to on, on a redirect the last component of the redirection URL will be used as the local file name. By default it is used the last component in the original URL.



‘--content-disposition’

If this is set to on, experimental (not fully-functional) support for Content-Disposition headers is enabled. This can currently result in extra round-trips to the server for a HEAD request, and is known to suffer from a few bugs, which is why it is not currently enabled by default.
This option is useful for some file-downloading CGI programs that use Content-Disposition headers to describe what the name of a downloaded file should be. 

The final command looked something like that:

$ wget --recursive --no-clobber --page-requisites --adjust-extension --convert-links --restrict-file-names=windows --domains {$domain.com} --trust-server-names --content-disposition --no-parent {$domain.com}

Of course there were some adjustments later, but the wget did the difficult part. Finally we have two static sites, and the complains from the shared hosting provider should stop because they the are impossible to hack again.

Tuesday, June 25, 2013

What to do when hackers injected hidden links in your Joomla website

If you are a victim of pseudo-hackers or script kiddies injecting hidden links, the following article can help or at least shed some light on the subject. These attacks are very common in Joomla and Wordpress world.


Why they do it?


This is well known black SEO technic. Probably somebody is paying for quick and dirty Google ranking ascendance and your site is being targeted for the relatively high rank position.


How to detect that kind of attacks?


You can use online tools or run this command when you have doubts:
find path/to/your/site -name '*.php' -type f -exec grep -l -E '<\!--\s+([0-9a-z]+)\s+-->.*?<\!--\s+\1\s+-->' {} \;
this will print something similar to 
path/to/your/site/templates/template-name/index.php
which means this file is being injected with hidden links

The command above will detect this kind of code:
<!-- 60fc708db9 --><style>.519lokju{position:absolute;top:-9999px;}</style><div class="519lokju"><a href="http://www.iolanipalace.org">payday loans</a></div><!-- 60fc708db9 --><!-- 016ea82535 --><div style="display:none"></div><!-- 016ea82535 -->


Why should I care and don't simply leave them as they are ?


The obvious reason is that you are going to loose you Google rank. You are going down for sure.


What to do if you find injected hidden links?


Remove the links from your template.


How to prevent that kind of attacks in the future?


There is no 100% sure way to prevent that unless run your website from read-only files system.
But you might try to protect your template at least by ensuring its file permissions are set to 444!

Friday, May 31, 2013

Migrating Joomla the expert way

Here I am again migrating Joomla site, last time I was using standart migration script which migrated joomla 1.7 to 2.5 or something similar. But this time things are different, I'm about to migrate 1.6 beta to 3.1, no migration script available or I'm going to waste time with updating through 25 updates manually.
I've looked migration scripts and components for Joomla, but didn't found what I was looking for. As we know form experience many of 3rd party extensions are poorly written and often don't work.

Finally I got to decision to do it manually, because there aren't much data other than in com_content. This should be several moderately simple SQL queries, right ?