Firefox not caching

After spending the day trying to figure out why firefox was not caching images from my website even though chrome seems to honor the caching headers from the server correctly, it turned out that my browser settings were not correct

Somehow, caching was disabled in firefox, to enable it i did the following

visit about:config (fill it into your address bar), this will give you your browser settings

in the top box, type in browser.cache

Make sure both browser.cache.memory.enable and browser.cache.disk.enable are set to true, if they are not, you simply double click it to flip it.

Close this window and try (no need to restart firefox).

nginx rewriting sub domain into a directory internally

To make a long story short, the most efficient way of doing this is simply to change the document root according to the sub domain

So within your server stanza, you can simply do the following

server_name ~^(?.+)\.tech-g\.com$;
    root /var/www_nginx/$sub;

This way, when you add a directory such as myothersite.com inside your nginx web directory, visitors comming to myothersite.com.tech-g.com will end up being served content from the directory /var/www_nginx/myothersite.com

No rewriting URLs needed, and no evil if statements either

MySQL would not install on debian

Had problems with

apt-get install mysql-server
dbconfig-common: writing config to /etc/dbconfig-common/phpmyadmin.conf
Setting up mysql-server-5.5 (5.5.37-0ubuntu0.14.04.1) ...
/var/lib/dpkg/info/mysql-server-5.5.postinst: line 146: logger: command not found
ATTENTION: An error has occured. More info is in the syslog!
/var/lib/dpkg/info/mysql-server-5.5.postinst: line 236: logger: command not found
dpkg: error processing package mysql-server-5.5 (--configure):
subprocess installed post-installation script returned error exit status 127
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-5.5; however:
Package mysql-server-5.5 is not configured yet.

So the sollution was to remove mysql completely,

sudo apt-get purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean

then run

apt-get dist-upgrade

then installing mysql-server again

apt-get install mysql-server

Datacenters

Here is a list of services i use, this list is for my reference, but i might as well share it with you guys.

1- Hetzner- general purpose
2- online.net personal range, 6 Euro via nano dedicated servers with 500GB drives
3- oneprovider.com Something about getting your servers anywhere in the world, good for local services, like getting a server next to it’s customers for low latency
4- Softlayer (God knows why i pay this much, still not sure why I’m using them)
5-Database mart – I have 1 Windows VPS from them (4GB ram for $18 along with windows server 2012), running ok up to now (Invoices out on the first, due by the 15th).

Flash sticks speed tests and use with MySQL

So i need a few SSDs for a certain project that i will be starting in a few months, but before i shell some money into SSDs while i have so many SSDs and USB flash drives, I want to try and replace the SATA SSDs with USB flash sticks and see how it goes, if all goes well, i will be using the FLASH sticks in place of the SSDs and take the SSDs into my new project.

What i will be testing later on is

1- Speed

2- Reliability (They will write once read millions of times on this MySql server).

But first, i took out all my flash sticks, and decided to run speed tests on them (With the DD command).

Most of the candidate sticks are USB3, but one of the host machines does not have USB3 ports, so i will test every stick on USB2 and USB3 before i use them.

So, basically, the test results are as follows. Even when the data transfer rate does not exceed the USB2 specification, the USB 3 sticks function better on a USB port.

Please note that USB flash disks do not have wear leveling functionality, they are only for that tables that are not written into often (but read many times)

I will be installing the USB 3 drives on the production machines now and I will report any failures caused by the USB flash disks.

For SD cards, i used the USB reader (FOR MRG1 31123-004. A001F 121412 5V CHINA)

Short Name Size Speed Read USB 2 Speed Write USB2 Speed Read USB 3 Speed Write USB3
Lexar Korea – LJDS33-64G 100-104 B 33800-64GBA 1813SV:05dc P:a833 S33 64G 64G 35.17 19.30 U3 106.89 U3 26.11
Lexar OrangeV:05dc P:a205 32G 32.60 19.10 U3 43.37 U3 24.55
Lexar 32GB Class 10 8296952A SD card with our card readercard reader V:05e3 P:0736 32G 17.48 9.98 SD 18.85 SD 11.38
V:05dc P:a205 16G 32.60 15.47 U3 43.39 U3 17.27
SanDisk 16GB Cruzer Blade V:0781 P:5567 16G 20.68 6.77 21.53 7.58
Lexar (Orange) V:05dc P:a833 8G U3 93.07 U3 8.99
Lexar (Blue) V:05dc P:a205 8G 32.60 10.84 U3 42.41 U3 10.99
Lexar S70 V:05dc P:a202 17.90 5.73 17.97 5.23
Old lexar V:05dc P:c75a (Stick 142) 8G 20.37 4.53 21.11 4.69
Sony 8GB Class 10 cardcard reader 8G 18.73 7.57 19.23 7.30

 

Split a 40 GB file into 5GB files

I would like to employ multiple connections to download a file from my server on the internet, the best way to do that is to split the file into 5GB chunks…

In linux, to split a file, i don’t need to decompress it then re-compress it in chunks, the easiest way is to use this command

split -b 5120MB file_to_split.bin

If you want the split parts to have a numeric suffix for example, try this, pay attention to the dot at the end which the numeric suffix will follow

split -d -b 9000m –suffix-length 3 myfile.zip myfile.zip.

The result to the above would be

myfile.zip.000 myfile.zip.001 myfile.zip.002 etc…

That’s it, happy downloading

Now, to put it back together (Assuming your system orders them correctly by name ;))

cat file_to_split.bin.* > file_to_split.bin

If it does not or your dont want to take any chances,

cat file_to_split.bin.000 file_to_split.bin.001 file_to_split.bin.003 > file_to_split.bin

To combine files split up with linux split on windows, you can use the copy command to concatenate them such as

copy /b xaa + xab + xac + xad + xae + xaf + xag + xah + xai resulting.tar.bzip2

All about my Huawei E1750 – Unlocking et al

I have a Huawei E1752 Dongle from Orange Jordan (Formerly known as Mobilecom) that will only connect to the Orange Jordan network, the name E1752 is just a variant of E1750.

At first, i thought unlocking those required flashing new firmware, turns out i was wrong, this one in particular, all you need to do is enter the unlock code !

So i made sure it was unlocked on more than 1 computer, and then i made sure it was unlocked on more than one other service provider (i tried SIM cards from both umniah and zain)

To unlock the card, all you ever need to do is enter the unlock code ONCE and the dongle is permanently unlocked, What you need after that is to make sure you use the official Huawei software to connect it (unless you are connecting on Linux), you should be able to connect the dongle using any software for Windows that supports this, i chose to use the official “Huawei mobile partner) software, which is the software for this dongle before it gets modified by telcos.

What happened was this, at first, i tried to connect with mobile partener, and it asked me for an unlock code.

Then i went to http://a-zgsm.com/freecode/huawei/submit/ and entered the IMEI code printed on the back of the dongle, and that was it, it was unlocked, permanently ! on any computer that has never seen this dongle before.

 

Things i notices
I unlocked 2 of those, and they both share the starting part of the IMEI code (35463904) then the remaining part is different for both dongles

The other computer i tested on could not find drivers for the thing, so i downloaded some drivers, I will post them here for you to download them whenever i have the time and i make sure it wont be a copyright issue.

I downloaded some software from Huawei’s website thinking it was the new version of mobile partner, something about windows 8.1, ran it on windows 7, and the software claimed to have updated my modem or modified it, but that is not relevant to the unlocking because i did not run this on the second USB dongle that i unlocked.

Anyways, if you have any questions, Let me know and i will certainly share my thoughts.

Installing pecl_http on fresh debian

So here are the quick steps

apt-get install ssh openssh-server fail2ban

apt-get install php5-cli whois php5-mysql mysql-client php5-curl php5-mcrypt apache2 php5 openssl wget ssl-cert php5-imagick php5-gd dnsutils
apt-get install apache2 php5 php5-common php5-mysql php5-xmlrpc php5-cgi php5-curl php5-gd php5-cli php5-dev php5-imap php5-mcrypt

apt-get install rsyslog iptraf

For the PECL
apt-get install apache2-threaded-dev php5-dev php-pear make


For the pecl_http
apt-get install zlib1g zlib1g-dev libcurl4-openssl-dev libpcre3-dev php5-curl libevent-dev


pecl install raphf
pecl install propro
pecl install http://pecl.php.net/get/pecl_http-1.7.6.tgz


Then, create the following file in the php config directory with the following contents

/etc/php5/conf.d/http.ini

extension=raphf.so
extension=propro.so
extension=http.so

Installing APC

Since i keep this blog for my own records, i could not find the post about installing APC.

So, here are the quick steps since i don’t have enough time today to explain the whole installation

1- Install the tools
apt-get install apache2-threaded-dev php5-dev php-pear make
pecl install apc
Add the file /etc/php5/conf.d/apc.ini with the contents extension=apc.so (And any other relevant settings)
vi /etc/sysctl.conf Add the line kernel.shmmax = 67108864 (or whatever space you need)