Skip to content

Commit

Permalink
2018-05-30 AC: Adds all the code examples from the book.
Browse files Browse the repository at this point in the history
* Adds all the code examples from the book
  Mastering the Faster Web: PHP, MySQL and JavaScript.
  • Loading branch information
andrewscaya committed Jun 5, 2018
1 parent 469f0a4 commit aa2851f
Show file tree
Hide file tree
Showing 115 changed files with 55,538 additions and 2 deletions.
Empty file modified LICENSE
100644 → 100755
Empty file.
14 changes: 12 additions & 2 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
# fasterweb
Mastering the Faster Web
<h1>Mastering the Faster Web with PHP, MySQL and JavaScript</h1>
<p>Develop state of the art Web applications using the latest Web technologies</p>
<p><br><br><br><br></p>
<h2>Official code repository</h2>
<p><br><br><br><br><br></p>
<h3>Andrew Caya</h3>
<p><br><br><br><br><br></p>
<p><a href="https://commons.wikimedia.org/wiki/File:Packt_Logo.png#/media/File:Packt_Logo.png"><img src="https://upload.wikimedia.org/wikipedia/commons/b/bc/Packt_Logo.png" alt="Packt Logo"></a><br>By <a href="//commons.wikimedia.org/w/index.php?title=User:Dalston.nazareth&amp;action=edit&amp;redlink=1" class="new" title="User:Dalston.nazareth (page does not exist)">Dave Maclean</a> - <span class="int-own-work" lang="en">Own work</span>, <a href="https://creativecommons.org/licenses/by-sa/4.0" title="Creative Commons Attribution-Share Alike 4.0">CC BY-SA 4.0</a>, <a href="https://commons.wikimedia.org/w/index.php?curid=63328928">Link</a></p>
<br>
BIRMINGHAM - MUMBAI


416 changes: 416 additions & 0 deletions bash_history_container.txt

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions bash_history_host.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#################
### Chapter 1 ###
#################
git clone https://github.com/andrewscaya/fasterweb
cd fasterweb/
docker run -it --rm -p 8181:80 -v ${PWD}/:/srv/fasterweb asclinux/linuxforphp-8.1:7.1.16-nts /bin/bash
#################
### Chapter 2 ###
#################
docker run -d --name influxdb -p 8086:8086 andrewscaya/influxdb
docker network inspect bridge
docker run --rm andrewscaya/telegraf -sample-config > telegraf.conf
docker run --net=container:influxdb -v ${PWD}/telegraf.conf:/etc/telegraf/telegraf.conf:ro andrewscaya/telegraf
docker run -d --name grafana -p 3000:3000 andrewscaya/grafana
#################
### Chapter 4 ###
#################
docker run -it --rm -p 8282:80 -v ${PWD}/:/srv/fasterweb asclinux/linuxforphp-8.1:7.0.29-zts /bin/bash
docker exec -it $( docker ps -q | awk '{ print $1 }' ) /bin/bash
#################
### Chapter 9 ###
#################
docker run --rm -it -p 8383:80 asclinux/linuxforphp-8.1:src /bin/bash -c "cd ; wget -O tmp http://bit.ly/2jheBrr ; /bin/bash ./tmp 7.2.5 nts ; echo '<?php phpinfo();' > /srv/www/index.php ; /bin/bash"
docker run -it -p 6082:6082 -p 8484:80 asclinux/linuxforphp-8.1:src /bin/bash
docker network inspect bridge
curl -v 172.17.0.3 | grep Forwarded
curl -v https://linuxforphp.net
23 changes: 23 additions & 0 deletions chapter_1/cachegrind.out.412
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: 1
creator: xdebug 2.5.5 (PHP 7.1.3)
cmd: /srv/www/index.php
part: 1
positions: line

events: Time

fl=(1) php:internal
fn=(1) php::phpinfo
3 1221

fl=(2) /srv/www/index.php
fn=(2) {main}

summary: 12235718

1 12234496
cfl=(1)
cfn=(1)
calls=1 0 0
3 1221

10 changes: 10 additions & 0 deletions chapter_1/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>It works!</title>
</head>
<body>
<p>It works!</p>
</body>
</html>
9 changes: 9 additions & 0 deletions chapter_1/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

phpinfo();

$test = 'This is a test!';

$test1 = $test;

echo $test1;
3 changes: 3 additions & 0 deletions chapter_1/phpinfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

phpinfo();
Binary file added chapter_1/sakila-db.tar.gz
Binary file not shown.
Binary file added chapter_1/siege-4.0.2.tar.gz
Binary file not shown.
4 changes: 4 additions & 0 deletions chapter_1/urlfile_1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
http://localhost/index.html
http://localhost/index.html
http://localhost/index.html
http://localhost/index.html
4 changes: 4 additions & 0 deletions chapter_1/urlfile_2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
http://localhost/index.php
http://localhost/index.php
http://localhost/index.php
http://localhost/index.php
102 changes: 102 additions & 0 deletions chapter_10/chap10_slow_after.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<!DOCTYPE html>

<html lang="en">
<head>
<meta charset="UTF-8">
<title>Slow page</title>

<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
/* Center the loader */
#se-pre-con {
position: absolute;
left: 50%;
top: 50%;
z-index: 1;
width: 150px;
height: 150px;
margin: -75px 0 0 -75px;
border: 16px solid #f3f3f3;
border-radius: 50%;
border-top: 16px solid #3498db;
width: 120px;
height: 120px;
-webkit-animation: spin 2s linear infinite;
animation: spin 2s linear infinite;
}

@-webkit-keyframes spin {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
}

@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}

/* Add animation to "page content" */
.animate-bottom {
position: relative;
-webkit-animation-name: animatebottom;
-webkit-animation-duration: 1s;
animation-name: animatebottom;
animation-duration: 1s
}

@-webkit-keyframes animatebottom {
from { bottom:-100px; opacity:0 }
to { bottom:0px; opacity:1 }
}

@keyframes animatebottom {
from{ bottom:-100px; opacity:0 }
to{ bottom:0; opacity:1 }
}

#contents {
display: none;
text-align: left;
}
</style>
</head>

<body onload="myAnimatedAjax()" style="margin:0;">

<div id="se-pre-con"></div>

<div id="contents"></div>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.2/modernizr.js"></script>

<script type="text/javascript">

jQuery.ajaxSetup({
beforeSend: function() {
$("#contents").html("Loading page... One moment please...").toggle();
},
complete: function(){
$("#se-pre-con").fadeOut("slow"); //toggle visibility: off
},
success: function(result) {
$("#contents").html(result);
}
});

function myAnimatedAjax() {
var myVar = setTimeout(animatedAjax, 500);
}

function animatedAjax() {
$.ajax({
type: "GET",
url: "/chap10_slow_before.php"
});
}

</script>

</body>

</html>
7 changes: 7 additions & 0 deletions chapter_10/chap10_slow_before.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

// chap10_slow_before.php

sleep(5);

echo 'The original page loads very slowly...';
10 changes: 10 additions & 0 deletions chapter_10/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>It works!</title>
</head>
<body>
<p>It works!</p>
</body>
</html>
9 changes: 9 additions & 0 deletions chapter_10/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

phpinfo();

$test = 'This is a test!';

$test1 = $test;

echo $test1;
3 changes: 3 additions & 0 deletions chapter_10/phpinfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

phpinfo();
9 changes: 9 additions & 0 deletions chapter_2/.blackfire.travis.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
; .blackfire.travis.ini
[blackfire]

server-id=BLACKFIRE_SERVER_ID
server-token=BLACKFIRE_SERVER_TOKEN
client-id=BLACKFIRE_CLIENT_ID
client-token=BLACKFIRE_CLIENT_TOKEN
endpoint=https://blackfire.io/
collector=https://blackfire.io/
5 changes: 5 additions & 0 deletions chapter_2/.blackfire.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
tests:
"Pages should be fast enough":
path: "/.*" # run the assertions for all HTTP requests
assertions:
- "main.wall_time < 10ms" # wall clock time is less than 10ms
33 changes: 33 additions & 0 deletions chapter_2/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
language: php

matrix:
include:
- php: 5.6
- php: 7.0
env: BLACKFIRE=on

sudo: false

cache:
- $HOME/.composer/cache/files

before_install:
- if [[ "$BLACKFIRE" = "on" ]]; then
openssl aes-256-cbc -K [ENCRYPT_KEY_HERE] -iv [ENCRYPT_IV_HERE] -in .blackfire.travis.ini.enc -out ~/.blackfire.ini -d
curl -L https://blackfire.io/api/v1/releases/agent/linux/amd64 | tar zxpf -
chmod 755 agent && ./agent --config=~/.blackfire.ini --socket=unix:///tmp/blackfire.sock &
fi

install:
- travis_retry composer install

before_script:
- phpenv config-rm xdebug.ini || true
- if [[ "$BLACKFIRE" = "on" ]]; then
curl -L https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$(php -r "echo PHP_MAJOR_VERSION . PHP_MINOR_VERSION;")-zts | tar zxpf -
echo "extension=$(pwd)/$(ls blackfire-*.so | tr -d '[[:space:]]')" > ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/blackfire.ini
echo "blackfire.agent_socket=unix:///tmp/blackfire.sock" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/blackfire.ini
fi

script:
- phpunit
Loading

0 comments on commit aa2851f

Please sign in to comment.