TO Explore

*** VAS and MSISDN
*** chrome 3 types of proxy

***route 53 / elsatic cache eg. redis/memcache

***

*** shell script!!!!

***php -a: can be always used, but need to write codes (command line??)

geoads are cache collation??

SUS how to pull instead of push, when there are two many threads

vargrant and docker and composer

shell script and usage

VR: Virtual Reality,  VR gear, android phones support

eg. Google Card Board???

collation: no unique key

hashing functions

== wifi/network ==

apple airport express

http://www.apple.com/shop/product/MC414LL/A/airport-express

apple airport time capsule

http://www.apple.com/airport-time-capsule/

myrepublic fiber plan

https://myrepublic.com.sg/pricing/

Routher: ASUS AC87U

== PHP ==

namespace in PHP

autoloading namespace

dummy object to use in message body

static typing

Learn GIT

https://git-scm.com/book/en/v2/Getting-Started-Git-Basics

https://git-scm.com/book/en/v2/Git-Basics-Getting-a-Git-Repository#_git_basics_chapter

3 states: committed, modified, staged

Committed means that the data is safely stored in your local database. Modified means that you have changed the file but have not committed it to your database yet. Staged means that you have marked a modified file in its current version to go into your next commit snapshot.

This leads us to the three main sections of a Git project: the Git directory, the working directory, and the staging area.

Working directory, staging area, and Git directory.

The basic Git workflow goes something like this:

  1. You modify files in your working directory.
  2. You stage the files, adding snapshots of them to your staging area.
  3. You do a commit, which takes the files as they are in the staging area and stores that snapshot permanently to your Git directory.

== install ==

windows: follow installation guide, download exe file

https://git-for-windows.github.io/

3 components: Git BASH – BASH emulation simiar with *NIX command line

Git GUI – graphic interface, Shell Integration – right click windows folder to access BASH and GUI

linux VB: whereis git, git –version

older version 1.7 already installed (suspect prev codes for protobuf etc required git)

most recent version is 2.1, how to update to 2.1???

== set up ==

//list all settings
$ git config --list
//get user name setting
$ git config user.name

//first time, set identity
$ git config --global user.name "John Doe" 
$ git config --global user.email johndoe@example.com

help: $ git help {VERB}

== basic command to use ==

https://git-scm.com/book/en/v2/Git-Basics-Getting-a-Git-Repository

$ echo “# helloworld” >> README.md    //create a README.md file

$ git init                                                             //init, create .git repo file

$ git add README.md                                   //add file to git

$ git commit -m “first commit”              //commit with a msg

$ git add *.php

$ git commit -m “second commit”

at this moment, files are only versioned on local machine, not yet pushed to remote

//push to repository (created at github UI)

$ git remote add origin https://github.com/wangkun-buzzcity/helloworld.git

$ git push -u origin master

//pull to update local copy to recent from remote

//Do this before branching

$ git pull origin master

//use git fetch to update local repo (include all commits)

$ git fetch origin

//merge branch to master, under master do below

//after merging, do a push to update remote

$ git merge {branch name}

//merge master to branch is similar, under branch

//keeep a practice that do a final merge and testing to branch if master has new changes

$ git merge master

//check status, this will list all files status:

untracked: not yet in git tracking,  use “git add”: to add in and then go to staged status

modified : file has local changes that not yet updated,use same “git add” to add modified files into staged

staged: ready for commit, Changes to be committed

unmodified: clean status

  • every modify and change, needs to use “git add” to stage

$ git status

$ git status -s     //short status: ?? untracked, A added to staging, M modified

$ git diff   //to see waht you have changed but not yet staged

$ git diff  –staged //to see what you’ve staged that will go into your next commit

//check commit history

$ git log

$ git log –oneline –decorate

$ git log –oneline –decorate –graph –all   //history with graph

clone

//clone a project from git repository, helloworld reponame as directory

//clone is different from SVN checkout, clone includes all the history

$ git clone https://github.com/wangkun-buzzcity/helloworld.git

//close to a different folder name

$ git clone https://github.com/wangkun-buzzcity/helloworld.git helloworld2

//ignoring files, use .gitignore to track

$ cat .gitignore
*.[oa]
*~

remove files and move files

$ git rm {FILE}        //stage the file’s removal. after commit, file will be deleted

undoing things

$ git commit –amend

== remote repository ==

$ git remote -v  //show URL, origin is the default one

SASS

Sass (Syntactically Awesome Stylesheets)

Sass is a scripting language that is interpreted into Cascading Style Sheets (CSS)

extension .sass and .scss

https://en.wikipedia.org/wiki/Sass_(stylesheet_language)

http://sass-lang.com/

http://sass-lang.com/install

Netbeans 7.4, install sass

http://stackoverflow.com/questions/20804021/sass-in-netbeans-7-4

need to follow the sass install:

  1. install ruby 2.2 on windows, Ruby command line is installed (Start Command Prompt with Ruby)
  2. start ruby command line, install sass “gem install sass”
  3. in netbeans options -> miescellinous -> CSS preprocessor->sass path-> select ruby bin eg. C:\Ruby22-x64\bin\sass.bat

 

netbeans project property configration

right click->properties->CSS preprocessors->check compile Sass files on save

->set input path: eg for BAR, set /assets/css/, output /assets/css/

 

 

 

Referer Header

https://en.wikipedia.org/wiki/HTTP_referer

the address of webpage that linked to the resource being requested. By checking the referrer, the new webpage can see where the request originated.

In the most common situation this means that when a user clicks a hyperlink in a web browser, the browser sends a request to the server holding the destination webpage. The request includes the referrer field, which indicates the last page the user was on (the one where they clicked the link).

 

Client-side (browser making the request)

*proxy browser should support passing the header around

image URL and click URL is similar.

redirection URL is still able to trace the original referer URL, will not see the one that redirects to it. (status code is 302 Found for the page that doing redirection) *meta refresh not able to keep I guess, and not standard way of doing redirection

iFrame will overwrite the referer URL

The behaviror depends on browsers, there might be differences among the browsers???

 

 

eg1. publisher Site A is displaying image B with click url C, C is redirecting to D

B, C is able to know referer URL A

redrection URL D also knows referer A (depends on browser)

 

 

eg2 Site A is loading iframe source A1, and A1 is daplaying image B click url C, C is redirecting to D

A1 sees referer as A

B, C sees A1, can not see A

D also sees A1

 

Set Http Headers & PHP tags

issue:

In one system(BAR), php header(…) function is not setting headers, and in CodeIgniter application logs, there is this error:

Severity: Warning  –> Cannot modify header information – headers already sent by

Problem:

one of the file which declares a class, unintentionally having a new line before <?php starting tag.

NOTES:

No output before sending headers, functions that send/modify http headers must be invoked before any output made, this is why always try to set header on top before any codes start (even before include)

New lines outside of <?php ?> treated as output, generally treated as whitespace and ignored in HTML

But it will cause problem for header(…) function, setcookie() function etc.

BEST Practice:

do not use closing tag ?> to avoid unintentional new lines

CAN NOT have new line before <?php, or after ?>, after ?> need to have >=2 enter

== More info ==

Some functions modifying the HTTP header are:

header / header_remove
session_start / session_regenerate_id
setcookie / setrawcookie
Output can be:

Unintentional:

Whitespace before <?php or after ?>
The UTF-8 Byte Order Mark specifically
Previous error messages or notices
Intentional:

print, echo and other functions producing output
Raw <html> sections prior <?php code.

refer:

http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php

new lines:

http://petewarden.com/2008/07/21/beware-of-new-l/

Application Flow Chart

https://ellislab.com/codeigniter/user-guide/overview/appflow.html

CodeIgniter application flow
  1. The index.php serves as the front controller, initializing the base resources needed to run CodeIgniter.
  2. The Router examines the HTTP request to determine what should be done with it.
  3. If a cache file exists, it is sent directly to the browser, bypassing the normal system execution.
  4. Security. Before the application controller is loaded, the HTTP request and any user submitted data is filtered for security.
  5. The Controller loads the model, core libraries, helpers, and any other resources needed to process the specific request.
  6. The finalized View is rendered then sent to the web browser to be seen. If caching is enabled, the view is cached first so that on subsequent requests it can be served.