Monday, 22 December 2014

Speed up your Wordpress 1.000x with REDIS

I was bored so I decided it was time to upgrade my server with new distro and switch to NGIX. My current installation was Debina6 PHP5.3 running Lighty web server. My typical cached server response was around 1s. Considering my server uses 12 CPUs this was really bad. But the page load is low and I didn't care to much:)

Having problem with
apt-get dist-upgrade 
in the past I decided rather to install fresh version of debian/jessi
 I like jesse because I got accustomed with systemd and jessie is finnaly on board with it.
I decided that I will also cut down on number of CPUs down to just 4 (AMD Buldozer 2Ghz) and 4Gb of ram.

So my new LAMP stack is now LNMP. Just migrating to NGINX and enabling OPCache the typical response time became 3-4x faster on 3x less CPUs. I didn't bother with server load at this point since this was just learning exercise.

Now my page load time was about 300ms. Things are getting brighter I thought.

But I was not happy yet. I found a great tutorial on how to configure Wordpress to use REDIS

I don't like caching plugins like W3C because It has so much overhead and I like to use as few plugins as possible. Wordpress core is really great but plugins... Plugins are hell:)

Redis implementation to wordpress was however almost trivial. I took me 30 minutes to set thing up and push changes to production. And now a bomb shell.

 Page generated in ~0.84239 seconds Apache without php cache

Page generated in 0.34239 seconds  NGIX with OPCache

Page generated in 0.00084 seconds !!! NGIX wit OPCache and REDIS

I took just a few hours with almost no effort to archive 1.000x faster page load.

So to paraphrase Microsoft 365 commercial. UPGRADE UPGRADE UPGRADE

Thursday, 13 November 2014

Transcoding RM and WMA with Node.js under Windows

I just love Node.js!

You can do just about anything with it. My task was to transcode media files and keep the folder structure. I also had to check for media ype. RM videos, RM audio and WMA audio files were used at input.

If you are planning to try it out you must install ffpmeg, mencoder and ffprobe. Make sure you add installed files to Windows path!

So first I used 'final-fs' => 'npm install final-fs' to read all files from my input forder and create the same folder structure at my output.

Because each file was different I had to use ffprobe => 'npm install node-ffprobe' to inspect media info. I using under windows you have tho change source file so it uses win-spawn. So also you need to 'npm install win-spawn'. We will also need win-spawn to spawn ffmpeg or mencoder processes...

So after we get media file info we are ready to use the appropriate codec...

You can check the code here. The code is robust because I took only a few hours to write but it does the job done!

Wednesday, 12 March 2014

Simple way to copy multiple files under windows

The problem was simple. I had to copy a whole lot of files (from a txt file) from one location to another in order to optimize file structure. I was thinking about using batch scripting but than I realized that the only thing I really need is to use copy.exe. So other stuff like opening file, reading it line by line, parsing the line could be done in some simple manner. So I choose python that I haven't used since collage and give it a try. Phython is simple and all you need to do is just install execution environment, write a couple of line of code and It should work just fine.

So my input was:

So first i had to open the file, splice it to get source and destination file and than just call copy function under windows. This is the result:

You have to have the fil you want to read from saved under same location in order to script to work.

Just open cmd.exe and run command py and wait a bit:)

Tuesday, 12 November 2013

Batch copy files from list and preserve folder structure

@echo off
set src_folder=F:\AVA3

set dst_folder=F:\AVA3_UNIQ

set file_list=F:\recordings.txt

for /f "delims=" %%a in (%file_list%) do (

 echo "%%~pa"

 echo "%src_folder%%%a"

 echo "%src_folder%\%%a"

 if not exist "%dst_folder%\""%%~pa" mkdir "%dst_folder%\""%%~pa"

    xcopy "%src_folder%\%%a" "%dst_folder%\""%%~pa" /E


Wednesday, 12 December 2012

How to invite all your Facebook friends to an event at once

UPDATED 12.12.2012

Step#1. Open Google Chrome
Step#2. Open any invitation dialog for Facebook pages, groups or events.
Step#3. Don’t forget to check on “Search all Friends” in dialog box and scroll down until all your facebook appears.
Step#4. Press CTRL+SHIFT+J, A window will open at the bottom.
Step#5. Paste the JavaScript code given below in the console and hit enter button.


Wednesday, 31 August 2011

Callback functon - Fixed

I just love people who make the effort and help to teach others new stuff. But with code samples i don't understand why you don't test the code before publishing. I found an interesting example off callback function example but it was not working. Here is the proper stuff:)

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. typedef struct
  4. {
  5.  int age;
  6.  char name[10];
  7.  char surname[10];        
  8. }person;

  9. // Simple fuction to be called as callback
  10. void callMe(person *m)
  11. {
  12.  printf("%d %s %s \n\r", m->age, m->name, m->surname);
  13. }

  14. int main(int argc, char *argv[])
  15. {
  16.   // Declaration of pointer to function with same signiture as callMe
  17.   void (*callback)(person*)
  18. ;
  19.   // Create struct and fill with data
  20.   person s;
  21.   s.age = 27;
  22.   //Don't forget how to copy strings in C/C++
  23.   strcpy(, "Dejan");
  24.   strcpy(s.surname, "Cencelj");
  26.   // Init
  27.   callback = (void*)callMe;
  28.   // Call to callMe with callback
  29.   callback(&s);
  31.   system("PAUSE"); 
  32.   return 0;
  33. }

Monday, 23 May 2011

Bit manipulation

a |= 0x4; /* Set bit 2 */

b &= ˜0x4; /* Clear bit 2 */

c &= ˜(1 << 3); /* Clear bit 3 */

d ˆ= (1 << 5); /* Toggle bit 5 */

e >>= 2; /* Divide e by 4 */

f <<= 2; /* Multiplay f by power 2 of 2 = 4 */

Friday, 20 May 2011

Delay .bat script

Windows is a strange thing, especially at startup. Things are just loading and loading:) Sometimes strange things happen if a program in startup folder starts before everything is loaded. There is simple way to delay your program to start with ping command.

Save bellow command to file and name give it an arbitrary name with bat extension. For example: run.bat

ping -w 1000 -n 10 localhost

 Create link to this file in windows startup folder and your program will start after it pings itself 10 times. Bellow I also copied explanation about ping command.

PING is used to test TCP/IP connectivity with another host and
gives information about the length of time test data takes to be sent to the
host and a reply received.
Its most basic use is as follows:

C:\ping IP address or hostname
Pinging with 32 bytes of data:

Reply from bytes=32 time=10ms TTL=252
Reply from bytes=32 time<10ms TTL=252
Reply from bytes=32 time<10ms TTL=252
Reply from bytes=32 time<10ms TTL=252

From the above you can see it send 32 bytes to host and each
time a reply was received in 10ms or less, this shows a good connection.
PING does have a number of option parameters to accomplish different

In Windows 2000 you can press Ctrl-Break when running the -t option for a
list of statisitics. Press Ctrl-C to actually stop the ping.
It can be useful to have a small batch file ping various hosts and terminal
servers at regular intervals to ensure all are still present (although there
are commercial software packages that do this). A simple command like:

C:\ping -f -n 1 -l 1
Pinging with 1 bytes of data:
Reply from bytes=1 time<10ms TTL=128
pings a host once with one byte of data.

You should be aware that PING works by sending ICMP echo packets and some routers etc may filter
these out meaning a PING will not work.

Tuesday, 17 May 2011

Copy array from round buffer with memcopy()

Since I started to work with embedded systems I had to start thing about pointers... A subject foreign in my previews Java development. Bellow is a small spinet of my code to copy arrays with pointers. Also the use of some Microblaze functions use are shown...

void BufferMemoryCopy(void* dest, GPS_BUFFER* buff, u16 buff_offset, u32 size)
// Microblaze -- typedef Xuint16 u16;
u16 pos = (buff->Tail16 + buff_offset) & GPS_FIFO_MASK; // Fifo mast is used in roun buffer
if ((pos + size) <= GPS_FIFO_SIZE)
        memcpy(dest, &buff->Buffer[pos], size);
memcpy(dest, &buff->Buffer[pos], GPS_FIFO_SIZE - pos);
memcpy(dest  + (GPS_FIFO_SIZE - pos), &buff->Buffer[0], size - (GPS_FIFO_SIZE - pos));

Tuesday, 23 February 2010

Galaxy I7500 1.6 firmware & 2.1 alfa

Firmware 1.6 I7500XEFJB2 link

Firmware 2.1 work in progress link1 and link2

Thursday, 10 September 2009

Flash ROM Samsung I7500 Galaxy for dummies

Disclaimer: Note there are probable risk in flashing ROM. I didn't have any problems but don't say I din't warn you!

Here is a quick tutorial for those who can't use Samsung New PC studio for flashing their phone.

I't is quite simple actually. First you need to download new firmware. I downloaded version I7500XXIH8 from this link. Hope nobody removes this file from the server.

Then you need to download flash program called Odin Multi Down loader. My is version 3.95. If you can't find this file write to me!

Before connecting device in the computer you must start it in download mode.
To do this: when phone is powered off press VOLUME DOWN key + OK + power on

I used Windows XP under Windows 7 to flash my device. There was no problem with drivers. My OS recognized device as some gadget serial and installed modem drivers .

Now connect device to computer and wait for drivers to install. Picture bellow shoves you if everything is OK.

Click on the picture to make it bigger!

Now you must choose One Packege, find and select Orion.ops (Is part of Odin archive) and final find and select the firmware you wan't to update to. The file you got from link above must be extracted once. Extracted file is called: I7500XXIH8-PDA-CL53973-REV5(VIA).tar

That's IT. Now just press start and wait 5 min!

Follow me, if you thing this was useful.


Friday, 28 August 2009

Univerzitetni diplomirani inženir telekomunikacij

Od danes naprej lahko koristim ta dooolgi naziv:)

Hvala vsem za podporo!

p.s. Ker ni bilo druge so mi danes podelili začasno diplomo! (Spodaj!)

Wednesday, 1 April 2009

GPS sledenje z mobilnim telefonom

Super vohunska zadeva, ki pa se lahko uporabi tudi za kaj koristnega:) Na telefon si najprej namestite brezplačno aplikacijo. Na spletni strani si ustvarite račun in že imate pregled kje ste, kje ste bili in še polno dodatnih informacij. - Za lene ki se jim ne da brat:=.)

Saturday, 21 March 2009

Online odklepanje PDF datotek

Nekaj kar mi dostikrat jemlje živce so zaklenjeni PDF dokumenti. Zato sem našel priročno spletno stran, ki omogoča enostavno odpravitev mojih frustracij:) 

Saturday, 7 March 2009

Mednarodno leto Astronomije

Na Slo 1 sem zasledil zelo zanimivo reklamo. Res prvič po dolgem dolgem času nekaj pametnega:)

Mednarodna astronomska zveza (The International Astronomical Union- IAU) pripravlja v letu 2009 – mednarodnem letu astronomije (MLA2009) – številne aktivnosti pod skupnim naslovom »Vesolje je nad tabo. Odkrij ga!« MLA2009 obeležuje 400. obletnico prvih Galilejevih astronomskih opazovanj s teleskopom. To leto bo globalna proslava astronomije in njenih prispevkov naši družbi in kulturi, z velikim poudarkom na izobraževanju in vključevanju širše javnosti ter predvsem mladih ljudi, z dogodki na nacionalni, regijski in svetovni ravni skozi vse leto 2009. Pokrovitelj MLA2009 je UNESCO, leto 2009 pa so za mednarodno leto astronomije razglasili Združeni narodi 20. decembra 2007.

Samo za vas še koledar dogodkov in link.