Skip to content

Instantly share code, notes, and snippets.

View hoai's full-sized avatar

hoai hoai

View GitHub Profile
@hoai
hoai / Apache_PHP.sh
Created June 3, 2021 07:51 — forked from hemantshekhawat/Apache_PHP.sh
Gearman Job Server for CentOS 7
###### Install Apache/httpd and PHP
# Before you begin any installation, make sure that your software is up to date:
sudo yum update
#Install Apache:
sudo yum install httpd
#Start Apache:
sudo systemctl start httpd.service
#Set Apache to start on server boot:
sudo systemctl enable httpd.service
@hoai
hoai / gist:dc37116f6a17a45232647dcfe8090e51
Created May 31, 2021 08:31
vue-tables-2 add checkbox to header
<template>
<div class="">
<header class="jumbotron">
<h3> Products </h3>
<div class="d-flex justify-content-start mb-3">
<router-link :to="{name: 'products-add', params: {siteId: siteId}}" class="btn btn-sm btn-outline-secondary"><b-icon-plus></b-icon-plus>Add product
</router-link>
</div>
<div>
<button class="btn btn-toolbar" type="submit" @click="runRestock()"><b-icon-caret-right-fill></b-icon-caret-right-fill> Run restock</button>
@hoai
hoai / Uppercase.php
Created May 28, 2021 04:45 — forked from adamwathan/Uppercase.php
Unit Testing Custom Validation Rules
<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
class Uppercase implements Rule
{
public function passes($attribute, $value)
{
@hoai
hoai / Upgrade vim
Created May 20, 2021 04:43 — forked from yevrah/Upgrade vim
Update to Vim8 on Centos 7
################################################################################
# Method 1: Install using rpm packages (credit to DarkMukke)
#
rpm -Uvh http://mirror.ghettoforge.org/distributions/gf/gf-release-latest.gf.el7.noarch.rpm
rpm --import http://mirror.ghettoforge.org/distributions/gf/RPM-GPG-KEY-gf.el7
# WARNING: removing vim-minimal uninstalls `sudo` if you skip the second step
# make sure to at least run `yum install sudo`
yum -y remove vim-minimal vim-common vim-enhanced
@hoai
hoai / keys.go
Created May 19, 2021 09:58 — forked from sdorra/keys.go
Golang RSA Key Generation
/*
* Genarate rsa keys.
*/
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
@hoai
hoai / tour_golang_org__methods__18.go
Created May 19, 2021 07:14 — forked from russtanevich/tour_golang_org__methods__18.go
Exercise: Stringers Make the IPAddr type implement fmt.Stringer to print the address as a dotted quad. For instance, IPAddr{1, 2, 3, 4} should print as "1.2.3.4".
package main
import (
"fmt"
"strings"
)
// Exercise: Stringers
// Make the IPAddr type implement fmt.Stringer to print the address as a dotted quad.
// For instance, IPAddr{1, 2, 3, 4} should print as "1.2.3.4".
@hoai
hoai / S3-to-GCS.js
Created April 22, 2021 09:46 — forked from lokeshjawane/S3-to-GCS.js
Script to sync s3 obj to GCS in realtime
//This script is to copy S3 object to GCS in asynchronously using Lambda function
//set var "gcp_proj_id" with value of you GCP project ID
//set var "gcp_client_email" with value of your client email address from JSON key file & make sure that user has GCS create object permission
//set var "cred_bucket", here provode a s3 bucket from where lambsa will fetch the JSON creds file to GCP auth
//Set vat "cred_s3_obj", here you provide a json keyfile name which is uploaded in "cred_bucket" s23 bucket
//**NOTE**: set HOME env var with value "/tmp" in lambda function, because google-cloud/storage create file locally & in lambda only /tmp is writable. Run lambda function on S3 create object event based.
//
'use strict';
@hoai
hoai / ajax-file-download.js
Created April 8, 2021 06:34 — forked from jasonweng/ajax-file-download.js
handle file download from AJAX POST
// XMLHttpRequest
var xhr = new XMLHttpRequest();
xhr.open('POST', url, true);
xhr.responseType = 'arraybuffer';
xhr.onload = function () {
if (this.status === 200) {
var filename = "";
var disposition = xhr.getResponseHeader('Content-Disposition');
if (disposition && disposition.indexOf('attachment') !== -1) {
var filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/;
[master my.cnf]
server-id = 1
log_bin = /var/log/mysql/mysql-bin.log
binlog_do_db = newdatabase
=> /etc/init.d/mysql restart
[permission on replicate]
GRANT REPLICATION SLAVE ON *.* TO 'slave_user'@'%' IDENTIFIED BY 'password';
apt-get install php5-xhprof
pecl install xhprof
php.ini
extension=xhprof.so
xhprof.output_dir=/var/log/xhprof
php -i | grep xhprof
=> /etc/php5/cli/conf.d/xhprof.ini
xhprof
xhprof => 0.9.2