• VPS Ubuntu 10.04 config (1)

    1. 新增日常管理的用户:   myname

               adduser  myname

    2. 将用户加入sudo组:

          gpasswd -a myname sudo

    3.  启用sudo功能:   visudo在/etc/sudoers文件里root那行后面添加入新加的管理用户:

          root ALL=(ALL) ALL
         myname ALL=(ALL) ALL

    4.  重新以 myname 账户登入, 并测试 sudo 功能

             sudo myname

    5. 禁用root账户

             sudo passwd -l root

    6.  修改ubuntu的软件更新源:  

            sudo nano /etc/apt/sources.list

              deb     http://us.archive.ubuntu.com/ubuntu lucid main restricted universe multiverse
              deb     http://us.archive.ubuntu.com/ubuntu lucid-security main restricted universe multiverse
              deb     http://us.archive.ubuntu.com/ubuntu lucid-updates main restricted universe multiverse
              deb     http://us.archive.ubuntu.com/ubuntu lucid-proposed main restricted universe multiverse
              deb     http://us.archive.ubuntu.com/ubuntu lucid-backports main restricted universe multiverse
              deb-src http://us.archive.ubuntu.com/ubuntu lucid main restricted universe multiverse
              deb-src http://us.archive.ubuntu.com/ubuntu lucid-security main restricted universe multiverse
              deb-src http://us.archive.ubuntu.com/ubuntu lucid-updates main restricted universe multiverse
              deb-src http://us.archive.ubuntu.com/ubuntu lucid-proposed main restricted universe multiverse
              deb-src http://us.archive.ubuntu.com/ubuntu lucid-backports main restricted universe multiverse

    7.  更新系统:

                sudo apt-get update

                sudo apt-get upgrade

    8.  安装需要软件:

            sudo apt-get install language-pack-en language-pack-zh

            sudo apt-get install bash-completion

            sudo apt-get install vim ctags vim-doc vim-scripts

            sudo apt-get install screen byobu

            #安装压缩解压缩软件

            sudo apt-get install bzip2 unzip unrar p7zip

    #安装基本的语言环境和开发包

           sudo apt-get install perl python python-dev ruby ruby-dev sqlite sqlite3 openssl

     #安装编译环境和开发包

           sudo apt-get install gcc g++ make autoconf automake patch gdb libtool cpp build-essential libc6-dev libncurses-dev expat

    #安装第三方类库的开发包

          sudo apt-get install libbz2-dev libexpat1-dev libssl-dev libdb-dev libgmp3-dev   liblzo2-dev

    #安装版本控制工具

          sudo apt-get install git-core subversion mercurial

  • Cripper Prodigy Cheap VPS 20$/year

    http://client.cripperz.sg/clientarea.php?action=invoices

    http://vps.cripperz.sg:5353/

     

     

     

  • Flowplayer

     

     

    Flowplayer is an Open Source video player for the web. Embed the video streams into your web pages. User will get rich media experience by viewing video streams from your site. Player could be extended with Flash plug-ins, JavaScript plug-ins or Streaming plug-ins. Give a new look and feel to the player by extending it.

    It could play the video irrespective of location. The video could be stored in any CDN network like Akamai, Amazon Cloudfront or even local web server. It has built-in slow motion and fast forward support. Social sharing is an important need for almost all web sites. Its viral plug-in helps to spread the videos to most popular social media.

    It has ability to detect bandwidth speed and adjust the bit-rate transferred. It supports MPG, WMV, MOV and AVI formats.

     

    http://flowplayer.org/

    http://flowplayer.org/plugins/streaming/rtmp.html

     

    http://code.google.com/p/flowplayer-plugins/source/checkout

    svn checkout http://flowplayer-plugins.googlecode.com/svn/ flowplayer-plugins-read-only

     

     

  • Play Flash based on HTML path in Red5

    For each flash file,  setup a HTML file with the same name as the flash file, except for the extension.

    The HTML pass the file name to SWF, and SWF play the video.

     

    http://commondatastorage.googleapis.com/red5.zhenglei.net/PlayStreamByPath.7z

     

  • Passing Variables from HTML to Flash in Adobe CS4

    Suppose we need to pass the currnet URL from HTML to Flash:

     

    1.   Add the following  ActionScript into FLA:

    # #  myVIDEO is the parameter from HTML,  and we display it on screen

    var my_fmt = new TextFormat();
    my_fmt.color = 0xFF0000;
    my_fmt.underline = true;
    this.createTextField(“myTxt”, 1, 320, 10, 200, 20);
    myTxt.autoSize = “left”;
    myTxt.setTextFormat(my_fmt);

    if (myVIDEO == undefined) {
    myTxt.text = “Keynote_1.flv”;
    } else {
    myTxt.text = myVIDEO;
    }

     

    2.  Generate the SWF and HTML from FLA

     

     

    3. Modify the generated HTML to add myVIDEO parameter,

       3.1 ==> Add the following line in the  AC_FL_RunContent block:

           ‘flashvars’,”,

     

       3.2 ==> Add the handle of flashvars in function AC_GetArgs, as following:

         case “flashvars”:
            ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = “myVIDEO=”+window.location;
            break;

      // Here myVIDEO the variable in AS2, and window.location is the variable in JavaScript indicating the current URL of HTML page

  • How To Get URL Parts in JavaScript

     

    This JavaScript Tutorial article explains the Location object, and how to retrieve the URL from it in several parts, including how to parse, split, and rebuild URLs.

    This JavaScript tutorial article concentrates on:

    • Obtaining the URL from the window.location object
    • Changing the current location with window.location.href and window.location.reload
    • Splitting and rebuilding URLs with Array and String splitting functions

    The first step is understanding the JavaScript Location object.

    The Location Object

    This is a JavaScript class that is used to store URLs. It comes with properties that represent each part of the URL, and can be updated by changing the href property. The key properties that this article deals with are:

    • location.href : the full URL
    • location.protocol, location.host & location.pathname : the parts of the URL

    In addition there are various methods that

    • location.reload
    • location.replace

    These shall be discussed with reference to the window.location object.

    The window.location Object

    The window.location object is the specific object that stores the URL of the currently loaded page. If a JavaScript function changes the window.location.href property, then the page should reload with the new location.

    However, this may not always be the case, and so the location.reload and location.replace methods have also been provided in the Location object. These were introduced in JavaScript 1.2, and give a little more control over the way that browsing history and current page location URLs are handled. In some cases it may not be enough to set the window.location.href, and so calling window.location.reload will force the page to be refreshed.

    The window.location.replace method is used to overwrite the history entry in the browser, for the current page

    Splitting and Rebuilding URLs

    The URL is stored as the following parts:

    protocol://host/pathname

    Each part can be accessed using the appropriate property of the Location object:

    • location.protocol : for web pages, the value http
    • location.host : for this site www.suite101.com
    • location.pathname : the path to a page i.e. mypages/page1.html

    It is important to note that:

    • The protocol is store without the : or // that make up the whole URL
    • The host will contain a port, where appropriate
    • the pathname does not contain the leading /

    So, to rebuild a URL based on the above information, code such as the following can be used:

    newURL = window.location.protocol + “//” + window.location.host + “/” + window.location.pathname;

    This makes it very easy to create inline links that are context sensitive, and that refer pages that should exist on the server. For example, a site might have a tag page that collects all content that has the tag marketing associated with it. If the word marketing were to appear in a block of text, then JavaScript could be used to pre-process that block of text, and add a URL based on the current URL, but containing the reference to the marketing tag page.

    One final note is that the pathname will be a / separated string, which can be split into an array of strings using the following code:

    pathArray = window.location.pathname.split( ‘/’ );

    Using this approach, it is easy to rebuild URLs, as each component will be contained in one array element. Again, however, it is necessary to put the / back:

    newPathname = “”;
    for ( i = 0; i pathArray.length; i++ ) {
    newPathname += “/”;
    newPathname += pathArray[i];
    }

    The JavaScript Split List or String article contains more details about using arrays and strings in this way.

    Original URL:
  • Passing parameter from HTML to Flash in Adobe CS4

    Suppoe we need pass the video name from HTML to Flash.

    1.   Add the following  ActionScript into FLA:

    # Display the video in screen

    var my_fmt = new TextFormat();
    my_fmt.color = 0xFF0000;
    my_fmt.underline = true;
    this.createTextField(“myTxt”, 1, 320, 10, 200, 20);
    myTxt.autoSize = “left”;
    myTxt.setTextFormat(my_fmt);

    #  myVIDEO is the parameter from HTML
    if (myVIDEO == undefined) {
    myTxt.text = “Keynote_1.flv”;
    } else {
    myTxt.text = myVIDEO;
    }

    // create basic netConnection object
    var nc:NetConnection = new NetConnection();

    // connect to the local Red5 server
    nc.connect(“rtmp://192.168.127.127/oflaDemo”);

    // create the netStream object and pass the netConnection object in the constructor
    var ns:NetStream = new NetStream(nc);

    // attach the netStream object to the video object
    videoContainer.attachVideo(ns);

    // Play the video
    ns.play(myTxt.text);

     

     

    2.  Generate the SWF and HTML from FLA

     

     

    3. Modify the generated HTML to add myVIDEO parameter,

       Three parts to be modified in HTML:

     

       A)  Add the following line in the  AC_FL_RunContent block:

           ‘FlashVars’,’myVIDEO=Keynote_2.flv’,

     

      B)  Add the following line in the  Object block:

          <param name=”FlashVars” value=”myVIDEO=Keynote_2.flv” />

     

      C)  Add the following into the embed scr block:

         FlashVars=”myVIDEO=Keynote_2.flv”

     

    http://commondatastorage.googleapis.com/red5.zhenglei.net/Pass_Variable_From_Html_To_Flash.7z

     

  • setup red5 on ubuntu 10.10

    sudo apt-get update

    sudo apt-get upgrade

    sudo apt-get install sun-java6-jdk

    sudo apt-get install sun-java6-jre

    sudo apt-get install ant

    sudo apt-get install subversion

    sudo apt-get install ivy

    cd /usr/share

    sudo svn export  http://red5.googlecode.com/svn/java/server/trunk/

    sudo mv trunk red5

    sudo chown lzheng -R red5

    sudo chgrp lzheng -R red5

    cd red5

    ant clean

    ant dist

     

    #  Install oflaDemo:

     

     

    # Method 1:    Install from snapshots

    wget http://red5.googlecode.com/svn/snapshots/oflaDemo-r3989-java6.war

    mkdir oflaDemo && cd oflaDemo && unzip  ../oflaDemo-r3989-java6.war && cd ..

    sudo mv oflaDemo  /usr/share/red5/dist/webapps/

     

     

    # Method 2:    Install from dev trunk

    # Download

    svn export http://red5.googlecode.com/svn/java/example/trunk/oflaDemo/

     

    # Setup build property

    echo red5.root=/usr/share/red5/dist > ~/build.properties

    #echo build.optimize=true >> ~/build.properties

    # echo debug.status=false >> ~/build.properties

     

    cd oflaDemo

    ant clean

    ant

    # Result:   dist/oflaDemo.war

    mkdir oflaDemo && cd oflaDemo && unzip  ../dist/oflaDemo.war && cd ..

    sudo mv oflaDemo  /usr/share/red5/dist/webapps/

     

     

     

     

  • VPS ubuntu 10.10 config (9) *** PPTP VPN***

    # Install

    sudo apt-get update

    sudo apt-get upgrade

    sudo apt-get install pptpd

     

    #Config DNS

    sudo nano /etc/ppp/pptpd-options,  and enter the following:

      ms-dns 8.8.8.8

      ms-dsn 8.8.4.4

     

    #Config Password:

    sudo nano /etc/ppp/chap-secrets

        acount [TAB] pptpd [TAB] password [TAB] IP addresses

     

    # Config IP

    sudo nano /etc/pptpd.conf,   and enter the following:

    localip 10.168.10.1  
    remoteip 10.168.10.10-20



    # Config IP forward and IP Nat

    net.ipv4.ip_forward=1
    sudo iptables -t nat -A POSTROUTING -s 10.168.10.0/24 -o eth0 -j MASQUERADE