Skip to content

Instantly share code, notes, and snippets.

View apampolino's full-sized avatar

apampolino apampolino

  • Manila, Philippines
View GitHub Profile
NGINX - PHP
yum install nginx
yum install php5.6 or 7.0
yum install php56-fpm or php7-fpm
edit /etc/nginx/conf.d/default.conf
server {
listen 80;
@apampolino
apampolino / google_maps.html
Last active May 24, 2018 08:54
sample code for embedding google maps
<!DOCTYPE html>
<html>
<head>
<style>
#map {
height: 400px;
width: 100%;
}
</style>
</head>
@apampolino
apampolino / pdo.php
Last active August 27, 2018 11:54
pdo object instantiation
try {
$pdo = new PDO("mysql:host=localhost; dbname=dbname", 'user', 'password', array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"));
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
@apampolino
apampolino / progess_bar.php
Created May 18, 2018 13:57
terminal progess bar for processing
<?php
function loadProgressBar($current, $total, $max_progress = 50) {
$percentage = number_format((float) ($current / $total) * 100, 2);
$progress_ctr = floor($max_progress * ($percentage / 100));
$progress_bar = floor($max_progress * ($percentage / 100)) < 1 ? str_repeat("=", 1) . str_repeat(" ", $max_progress - 1) : str_repeat("=", $progress_ctr) . str_repeat(" ", $max_progress - $progress_ctr);
@apampolino
apampolino / database-backup.sh
Last active August 27, 2018 11:54
shell script for database backup
#!/bin/bash
host="ip_address"
dbname="dbname"
user="dbuser"
password="dbpass"
path=/directory/path
date=$(date +"%Y%m%d")
mysqldump --host=$host --user=$user --password=$password -v $dbname > $path/$dbname-$date.sql
@apampolino
apampolino / rsync-backup.sh
Last active May 24, 2018 09:00
Directory loop with rsync and sshpass
#!/bin/bash
date=$(date +"%Y%m" -d "-1 month")
day=$(date +"%d")
path=/path/to/your/source
sync_path=/your/destination
password="yourpassword"
cd $path
<?php
class Singleton {
public static $instance = null;
private function __construct() {
}
<?php
final class Container {
private static $instance = null;
private $services = array();
private function __construct() {
<?php
function hook($method, &...$params) {
$function_list = get_defined_functions()['user'];
foreach ($function_list as $func) {
$pattern = '/.*\_' . $method . '|' . $method . '/';
@apampolino
apampolino / backup_rules.txt
Last active August 27, 2018 11:54
shell script for files backup
.git/
cache/
_*cache/
cache*/