Skip to content

Instantly share code, notes, and snippets.

View HoangPV's full-sized avatar

Hoang Phan HoangPV

  • Ho Chi Minh City, Vietnam
View GitHub Profile
@HoangPV
HoangPV / is-prime.php
Created September 20, 2017 08:00
checks if a number is prime
<?php
/**
* checks if a number is prime
*
* @return bool
* @author Phan Vu Hoang <vu-hoang.phan@ekino.com>
*/
function la_snt( $n ) {
if($n < 2) return false;
@HoangPV
HoangPV / step.php
Created September 21, 2017 02:59
Steps in Primes
<?php
function step($g, $m, $n) {
$pairs = $primes = [];
if ($g >= 2 && $m >=2 && n >= 2) {
for ($i=$m; $i <=$n ; $i++) {
if (isPrime($i)) {
@HoangPV
HoangPV / dashatize.php
Created September 25, 2017 08:43
Dashatize it
<?php
/**
* Dashatize it
*
* @author Phan Vu Hoang <vu-hoang.phan@ekino.com>
*/
require '../vendor/autoload.php';
@HoangPV
HoangPV / TicTacToeChecker.php
Created November 1, 2017 09:43
Tic-Tac-Toe Checker
<?php
$arr = array(
array( 1, 0, 0 ),
array( 2, 0, 0 ),
array( 1, 0, 0 ),
);
function is_solved( $arr ) {
@HoangPV
HoangPV / password_hash_example.php
Created November 2, 2017 02:52 — forked from jeremykendall/password_hash_example.php
Example of password hashing and verification with password_hash and password_verify. This script is intended to be run from the command line like so: 'php -f password_hash_example.php'
<?php
/**
* Example of password hashing and verification with password_hash and
* password_verify
*
* This script is intended to be run from the command line
* like so: 'php -f password_hash_example.php'
*
* @see http://stackoverflow.com/a/20809916/1134565
@HoangPV
HoangPV / session_example_config.php
Last active May 19, 2021 16:26
PHP MySQL Login System
<?php
define('DB_USERNAME', 'root');
define('DB_PASSWORD', 'Hoang123');
define('DB_NAME', 'session_example');
define('DB_SERVER', 'localhost');
/* Attempt to connect to MySQL database */
/** @var mysqli $mysqli */
$mysqli = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
@HoangPV
HoangPV / MaxiLenDiff.php
Last active November 3, 2017 07:48
MaxiLenDiff.php
<?php
namespace CodeBundle\Functions;
/**
* Class MaxiLenDiff
* @package CodeBundle\Functions
* @see https://www.codewars.com/kata/maximum-length-difference/train/php
*/
class MaxiLenDiff
<?php
/*
* @see https://www.codewars.com/kata/gap-in-primes/train/php
*/
function gap( $g, $m, $n )
{
$prime = FALSE;
@HoangPV
HoangPV / Ciphers.php
Created November 7, 2017 03:57 — forked from hinchley/Ciphers.php
Caesar Cipher and Vigenère Cipher in PHP
<?php
class Map {
/* $table = [
* 'encrypt' =>
* ['A' => 'A', 'B' => 'B', ...],
* ['A' => 'B', 'B' => 'C', ...],
* ...
* 'decrypt' =>
* ['A' => 'A', 'B' => 'B', ...],
@HoangPV
HoangPV / install-docker.md
Created July 8, 2021 03:48 — forked from npearce/install-docker.md
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command

UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.

Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/

Docker CE Install

sudo amazon-linux-extras install docker
sudo service docker start