sourcecode

Tuesday, July 16, 2013

php gearman

and unpack

2. under the unpacked folder,
$phpize
$./configure
$make
$sudo make install

if $phpize gives you an "not found error", install php5-dev:
$sudo apt-get install php5-dev

3. edit ini file
$php --ini
then choose a file, e.g.
$sudo vi /etc/php5/cli/php.ini
and add the line  extension=gearman.so

4. verify
$php --info | grep "gearman support"
or
$php -a

php > print gearman_version();
http://edvanbeinum.com/how-to-install-gearman-php-ubuntu


5. Test as a gearman client (An Example Client):
http://gearman.org/gearman_php_extension
save the file as hello.php
and in terminal, run
$php hello.php

6. More to read:
http://www.php.net/manual/en/book.gearman.php
http://toys.lerdorf.com/archives/51-Playing-with-Gearman.html
https://www.rssinclude.com/blog/36_how_to_run_php_scripts_in_html_or_htm_files

7. Running on a web browser:
  a. create a script to be executed, name it cal.php
and "chmod 500" to it
  b. in same folder, created a file to be displayed, name it hello.php
and now open the browser address: http://127.0.0.1/hello.php
it should work, provided there's a gearman worker already up. 

Wednesday, July 10, 2013

The peripheral stuff

feedback system: helpscout : https://www.helpscout.net/
ticket system: redmine: http://www.redmine.org/
monitoring heartbeat: http://www.linux-ha.org/wiki/Main_Page
Qgis, amazon aws

Monday, July 8, 2013

OpenTripPlanner

Getting OpenTripPlanner to work and more:

1. Download, configure and test run on http
https://github.com/openplans/OpenTripPlanner/wiki/TwoMinutes

note: once the browser opens http://localhost:8080/opentripplanner-webapp
the background maybe empty. On the far right of the  page, click the "+" sign. Then under "Base Layer" and choose "Open Street Map" (or others, instead of the default "Mapbox Steets")



2. Test the Stand-alone mode, which is used as an API
https://github.com/openplans/OpenTripPlanner/wiki


3. Json or Xml (default) result can be generated:
 https://github.com/openplans/OpenTripPlanner/wiki/JsonOrXml

EXAMPLE:
curl --header "Accept: application/json" "http://maps5.trimet.org/osm?mode=BICYCLE&toPlace=45.504966%2C-122.654349&fromPlace=45.5115225%2C-122.647633"
vs.
curl --header "Accept: application/xml" "http://maps5.trimet.org/osm?mode=BICYCLE&toPlace=45.504966%2C-122.654349&fromPlace=45.5115225%2C-122.647633"

4. Build graphs:
https://github.com/openplans/OpenTripPlanner/wiki/GraphBuilder

protoc protobuf Protocol Buffers

This blog entry lists the process to use google's Protoco Buffers, on x64 Linux Mint 14.

1. Download protobuf-2.5.0.tar.bz2 from
https://code.google.com/p/protobuf/downloads/list


2.  Extract the file anywhere.

3. Under the extracted folder, run
$./configure
$make
$make check
$sudo make install

4.  View the README file in the folder, and test some common:
  $pkg-config --cflags protobuf         # print compiler flags
  $pkg-config --libs protobuf           # print linker flags
  $pkg-config --cflags --libs protobuf  # print both


5.  Download a proto file. e.g. from
https://developers.google.com/transit/gtfs-realtime/gtfs-realtime-proto

6.  Go to the proto file folder and generate the C++ header and source file:
$protoc gtfs-realtime.proto --cpp_out=./
Ref: https://developers.google.com/protocol-buffers/docs/proto


7. If there are some errors, check the environment variables 
$export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib   $export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
Ref:  http://blog.csdn.net/programmer_h/article/details/8890800


8.  Write a sample main file:
#include <iostream>
#include <string>
#include <fstream>
#include "gtfs-realtime.pb.h"
using namespace std;

int main()
{
   fstream file("alert2.dat");
   string outline;
   getline(file, outline);
   cout <&lt outline << endl;
}

9. Download a sample encoded binary data file: e.g.
 http://www.bart.gov/dev/gtrtfs/alerts.aspx


10. Compile:
$clang++ main.cpp gtfs-realtime.pb.cc `pkg-config --cflags --libs protobuf`