TF201 – update to custom rom

This is list of my notes when updating my Asus Transformer Prime (TF201) to latest custom rom.

Unlock TF201 with asus tool

nvflash

twrp

hairy bean

energy rom

stock jelly bean

Other

nginx and fast-cgi – tips and tricks

How to pass full path to fast-cgi app

It’s necessary to configure which parameters are passed to fast-cgi application from nginx server. For this purposes serves fastcgi_param keyword. It’s a good practice to keeps all fastcgi params together. For this purposes nginx has fastcgi.conf file. This file already contains most of useful fastcgi_param bindings.

fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
...

To include this file use include statement:

location / {
   include fastcgi_params;
   fastcgi_pass 127.0.0.1:9345;
 }

How to pass custom headers to fast-cgi app

Default configuration pass only default headers to fast-cgi. It’s necessary to add few more configurations statements:

fastcgi_pass_request_headers on;

After that headers are passed as HTTP_* parameters:

HTTP_HEADER1=2222

External links

How to run fastcgi and nginx on windows

Step by step guide how to configure nginx on windows….

Download and installation

Download nginx package from nginx site. Unpack it and installation is done 😉

Example of fast-cgi application

No create and complie fast-cgi application. (How to compile fast-cgi on windows)

    #include "fcgi_stdio.h"
    #include <stdlib.h>

    void main(void)
    {
        int count = 0;
        while(FCGI_Accept() >= 0)
            printf("Content-type: text/html\r\n"
                   "\r\n"
                   "<title>FastCGI Hello!</title>"
                   "<h1>FastCGI Hello!</h1>"
                   "Request number %d running on host <i>%s</i>\n",
                    ++count, getenv("SERVER_NAME"));
    }

How to connect fast-cgi with web-server

There are two ways. When web-server supports fast-cgi you will be able to connect fast-cgi directly with web-server via configuration files. In all other cases fast-cgi offers cgi-fcgi  executable as bridge between webserver and your app. More info about both these approaches you can find here http://www.fastcgi.com/devkit/doc/fcgi-devel-kit.htm#S4.

Working way how to get fastcgi apps working

None of two ways described in previous article and in official documentation works for me on windows. I wasn’t able to get cgi-fcgi or spawn-fcgi running. First mentioned crashed everytime app tries to initialize STD_OUT, the second one isn’t possible to compile it because of missing unistd.h header.

Fortunately there is one more way. FCGI library offers one more way how to utilize FCGI mechanism. It’s necessary add two more lines to example above and everything works perfectly.

    #include "fcgi_stdio.h"
    #include <stdlib.h>

    void main(void)
    {
        //initialize library & open listening socket at port 9345
        FCGX_Init();
        FCGX_OpenSocket(":9345",500);

        //rest is the same as in example above
        while(FCGI_Accept() >= 0) ...
    }

After this change application initialize listening port and waits for incoming data. All you need to do is directly execute the app.

Configure nginx to connect with fast-cgi

This step compared to previous ones is pretty easy. You need to tell nginx server what and where to pass. Open file nginx.conf and add following statement:

http {
  server {
    location / {
      fastcgi_pass 127.0.0.1:9345;
     }
  }
}

fastcgi_pass statement forward all requests to localhost:9345 address. Now when you start your nginx server, everything should work as expected.

nginx server cfg

Troubleshooting

bind() to 0.0.0.0:80 failed

This error is caused by another application which uses port 80. In my case it was Skype which automatically uses port 80.

nginx: [emerg] bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket in a way forbidden by its access permissions)

External links

How to compile FastCGI library in Visual Studio 2010 C++

FastCGI comes with Win32 project for VisualStudio6. Unfortunately when you try to open it in VisualStudio2010 the project will be corrupted. To correctly compile it for VS2010 it’s necessary to download library sources, get patches from cybozu.co.jp site and apply it.

Download library

Download latest version of Development Kit here and extract it to standalone directory.

FastCGI

Get and update patches

Download all five patches from Cybozu site. Now when you have patches it’s necessary to convert all files to correct windows-ending format. This can be done for example in Notepad++.

Convert to windows EOL

Get patch.exe application

Now you need some application capable to apply the patches. Unfortunately windows doesn’t contain any application for this task and also lot of comparing/merging applications can’t do that.

The simplest way is to download windows conversion of linux patch.exe app. Get it from gnuwin32 site – patch for windows.

Apply patch to project files

Apply patches

Open directory with fastcgi library, copy all patch files to this directory and open command line. As next run patch command for all fives patches:

...\fcgi-2.4.1-SNAP-0311112127>patch -Np1 < 4-vc9.patch
patching file Win32/FastCGI.sln
patching file Win32/authorizer.vcproj
patching file Win32/cgifcgi.vcproj
patching file Win32/config_h.vcproj
patching file Win32/echo-cpp.vcproj
patching file Win32/echo.vcproj
patching file Win32/echox.vcproj
patching file Win32/libfcgi.vcproj
patching file Win32/logdump.vcproj
patching file Win32/size.vcproj
patching file Win32/threaded.vcproj

In case you will see following error message:

patching file Win32/FastCGI.sln
Assertion failed: hunk, file ../patch-2.5.9-src/patch.c, line 354

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

it’s necessary to convert ALL patch files to correct Windows format (correct EOL) as mentioned in previous section.

More patches…

When you apply patches by cybozu it’s time to apply my own patches ;-).

Manually updated rejected file

As first, it’s probably that you will see following message:

1 out of 26 hunks FAILED -- saving rejects to file libfcgi/os_win32.c.rej

It’s because original patch is for older version of library and file os_win32.c  is slightly different. To fix that, edit this file at line 841 and manually update following line:

//original
int len = p - bindPath + 1;

//updated line
intptr_t len = p - bindPath + 1;

Update VS project file

Now turn off generating the Map Files in project configuration. These files aren’t necessary and it isn’t possible to compile project correctly with this settings.

Turn off .map files

DONE

And that’s all. Now you will be able to sucesfully compile fast-cgi library.

Compilation complete

External links

FastCGI c++ library for all platforms (Windows, Mac and Linux)

List of existing libraries

Snippets

Stackoverflow articles

Tutorials

Other links

CGICC – how to update it for VS2010 COMPILATION

  •  error C2668: ‘cgicc::copy_if’ : ambiguous call to overloaded function – add cgicc:: to all cgicc::copy_if instances
  •  error LNK2019: unresolved external symbol – add compiled .lib path (…Debug\cgicc.lib) to all dependend projects

Problem installing Fedora18/19 on VMWare

During my attempts to install Fedora as virtual machine we got following error:

VMWare Fedora problem
dracut-initqueue[350]: mount: /dev/sr1 is write-protected, mounting read-only
dracut-initqueue[350]: warning: Could not boot

Entering emergency mode. Exit the shell to continue
Type "journalctl" to view systm logs.

dracut:/#

The solution is pretty simple. The problem is inside VMWare automatical installer and VMWare’s autoinst.iso image which is automatically connected to virtual machine.
To resolve this issue, stop your virtual machine, open Edit virtual machine settings and remove first CD drive with mounted autoinst.iso.

How to fix problem when installing Fedora on VMW

When you remove this iso from you VM, run it again and everything will work as expected.

Fedora installation

C++ Code coverage tools for Windows and Linux (DRAFT)

Linux

  • CovTool – Free test coverage analyzer for C++
  • ggcov –  GTK+ GUI for exploring test coverage data produced by C and C++ programs compiled with gcc –coverage.
  • lcov – graphical front-end for GCC’s coverage testing tool gcov. Creates HTML pages containing the source code annotated with coverage information.
  • Trucov – open source program that works with the GCC compiler to display the control flow of a program and its test coverage information

STEPS:

1) add CXX, CFD + LINKER FLAGS

2) remove OBJS output dir and generate .o .gcov,… to root project directory

3)remove MOC directory output for Qt app

3)run gcov xx.cpp

— generate html

sudo apt-get install lcov (http://ltp.sourceforge.net/coverage/lcov.php)

lcov --capture --directory ~/dev/Applications/AtomixApp/AtomixApp --output-file coverage.info

How to use articles

How to integrate with jenkins

StackOverflow questions

DD-WRT Monitoring bandwidth per IP

For detailed bandwidth tracking there is a great plugin ip_conntrack available on dd-wrt.com forum.

Step 1 – upload plugin to DD-WRT

The easiest way how to upload any content to DD-WRT is build-it ProFTPD server. To enable it, open Services -> NAS and check ProFTPD server.

DD-WRT FTP

Now you can upload any content to your router by any FTP client.

Step 2 – connect to router by telnet

My DD-WRT firmware has some problems with SSH so it isn’t possible to use it. It’s not a big deal because we can connect to router by telnet (in Win7 it’s necessary to install it Add or Remove program->Turn Windows Features -> Telnet client). Run Telnet from start menu and type (use IP address based on your own configuration)

<br />o 192.168.0.1<br />
Telnet

Step 3 – Install ip_conntrack plugin

Now it’s necessary to execute all steps described in ip_conntrack post.

#Extract and set correct permissions
chmod +x /tmp/MyPage/*.sh
ln -s /tmp/MyPage/www/qos_conntrack.js /tmp/www/

#register new page
nvram set mypage_scripts="/tmp/MyPage/qos_conntrack.sh"
nvram commit

#activate new page
/tmp/MyPage/traffic_monitor.sh&

Step 4 – Configure automatic execution of script

Not tested, more info on plugin page

External links

Jenkinks and MacOS application signing

After re-installing our MacOS building machine which we’re using for ORM Designer deploy, we started to getting following message:

./OrmDesigner2.app: User interaction is not allowed.

After short searching on the internet I found it’s required to click on “Always Allow” dialog…. which unfortunately we don’t have on the console ;-).

The trick is in the keychain unlock. For this purpose we can use following command:

security unlock-keychain -pPASSWORD ~/Library/Keychains/login.keychain

That’s all. After this command I’m able to sign my application from Jenkinks command line again.

External links

Slow execution of application from Visual studio

Today my Visual Studio 2010 started to execute my application super slowly. When I tried to execute my application (without any changes in source-code) the delay between “Start Debugging” and application start was about one minute.

I know that too many breakpoints or breakpoints in templates could caused this, but I don’t see any breakpoint in my Breakpoints window.

Breakpoint window

But as I have found that the problem was really caused by breakpoints. In some special cases – when you’re using some external tools to modified your project file (.sln/.vcxproj) – breakpoints can disappear and begin to make a trouble (I’m using Qt qmake to update my project based on .pro files.)

The solution is pretty easy. Use Delete All Breakpoins from Debug menu:

Delete all breakpoints

And your problem will be solved ;-).

List of online (live) chat services for your web

Service Free plan Basic paid plan Features/Notes
www.clickdesk.com
pricing
$0/month

  • 1 Agent
  • 30 chats/month
  • 1 department
  • 1 domain
  • 25 help desk/month
  • GTalk integration
  • 1 concurent chat
$9.99-14.99/month/agent

  • price per agents
  • 3 departures
  • 3 domains
  • Skype, webchat
  • visitor info
  • 5 concurent chat
  • IM integration support
mylivechat.com
pricing
$0/month

  • 1 Agent
  • 1 departure
  • unlimited domains
  • unlimited chats
  • basic visitor monitoring
$25/month

  • 2 agents
  • unlimited departures
  • advanced monitoring
  • $12 for additional agent
  • Doesn’t support IM clients
flexytalk.com
pricing
$0/month

  • 1 Agent
  • 1 domains
  • 1 channel
$4-9/month

  • 1 agent
  • 2 channels/agent
  • $8 for additional agent
  • Gtalk/Jabber support
  • 2months for free on annual payment
zopim.com
pricing
$0/month

  • 1 Agent
  • 1 concurrent chat
  • 14-day chat history
$9.80/month/agent

  • Unlimited chats
  • 2 triggers
  • 2 departments
  • Gtalk/Skype support
  • HTML5 dashboard
  • See visitor webpath
www.livechatinc.com
pricing
No free plan $39/month/agent

  • Unlimited chats
  • Groups
  • Reports
  • Browser/Win/MacOSX/iPhone/Android support
  • Integration to several other products
www.userlike.com
pricing
No free plan $29/month

  • 3 operators
  • 3 widgets
  • Chat panel
  • Automatic Invites
  • CRM integration
  • 20% discount on yearly subscriptions
  • 6 months for free for startups
  • Integration to several other products
  • IM integration (jabber, pandion)
www.purechat.com Completely free

  • 100% free
  • no ads
  • unlimited chats/operators
  • Missing IM support
  • “Failed to connect to PureChat!” error when I tried it
www.velaro.com
pricing
No free plan $29.95/month/operator

  • basic plan (business plan for $99/month)
  • Click-to-Chat
  • 3-rd party integration only for business plan
  • for $29.95 very limited
  • Integration to several other products
  • Missing IM integration
www.boldchat.com
pricing
free license
$0/month

  • Multi-domain deployment
  • 1 simultaneous license allowed
  • 750 monthly chats
  • 3 concurrent chats
  • no visitors tracking
  • no UI customization
$99.95/month/operator

  • basic plan (business plan for $499 and $999/month)
  • super-expensive 😉
  • 3-rd party integration only for business plan
  • for $29.95 very limited
  • Integration to several other products
  • Missing IM integration
www.olark.com
pricing
free license
$0/month

  • 1 operator
  • 20 monthly chats
$17.00/month

  • 1 operator
  • Gold plan for $49/month for 4 operators
  • CRM integration
  • IM integration
  • 10% discount on 1 year subscription
www.websitealive.com
pricing
No free license $29.95/month

  • 2 operator
  • Additional operators for $9.95/month
  • Visitors tracking
  • Mobile chat
  • Customization
  • Missing IM integration

Another web-chats:

Service for translating IP to geolocation (country)

Today I need for our statistic server translate IP of our users to country codes. After short searching I found following services:

Winner 😉

Free

Paid

List of services

How to unroot Samsung Galaxy S3 device

Because of warranty I needed to unroot my S3. After a lot of searching I found following articles which helped me to revert my phone to factory defaults.

Used software

  • TrianglAway – tool for reseting flash-counter inside the android firmware
  • SamMobile – server with all Samsung S3 firmwares
  • Samsung Updates – Official Samsung site with all firmwares