Skip to content

Instantly share code, notes, and snippets.

@daohoangson
daohoangson / proxy.php
Last active September 20, 2018 07:55
Simple PHP proxy script
<?php
$url = 'https://httpbin.org/anything?';
function proxyDoHeader($curl, $headerLine)
{
$trimmed = trim($headerLine);
if (strlen($trimmed) > 0 && !preg_match('/^(Date|Server|Transfer)/', $trimmed)) {
header($trimmed);
}
@daohoangson
daohoangson / build.php
Last active December 15, 2017 07:29
Simple script demo for [bd] API add-on for XenForo (https://github.com/xfrocks/bdApi). For complete demo, see http://j.mp/1BA1CzC
<?php declare(strict_types=1);
$inputPath = __DIR__ . '/script.php';
$outputPath = __DIR__ . '/script.min.php';
$markerStart = "/* API SCRIPT FUNCTIONS START */\n";
$markerEnd = "/* API SCRIPT FUNCTIONS END */\n";
$lines = file($inputPath);
$f = fopen($outputPath, 'w');
$buffer = null;
@daohoangson
daohoangson / sample.js
Last active December 3, 2017 18:54
AES128 CBC encryption
// input
const secret = 'top secret'
const userData = {'version_id': 1, 'user_id': 123, 'username': 'xxx'}
// prepare
const password = crypto.createHash('md5').update(secret).digest()
const json = JSON.stringify(userData)
const cipher = 'aes-128-cbc'
const ivLength = 16
@daohoangson
daohoangson / curator_cli.sh
Created August 12, 2017 07:07
curator_cli usage
#!/bin/sh
docker run --rm -it --network=bkvn_default --entrypoint=curator_cli olalonde/curator \
--host elasticsearch \
delete_indices \
--filter_list '[{"filtertype":"age","source":"creation_date","direction":"older","unit":"days","unit_count":7},{"filtertype":"pattern","kind":"prefix","value":"logstash"}]'
<!DOCTYPE html>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="google-site-verification" content="ht9lmeQSHFSNMyrd1PcB-qqzkNuw5M5lN_L6eYEfWIU">
<meta name="description" content="Đây là phần mềm tự động tăng view theo từ khóa và link đã định trước. Yêu mến CSM hãy chạy link này thường xuyên">
<meta name="keywords" content="cuoc song moi,cong ty cuoc song moi,ky nang mem,danh thuc tiem nang,huan luyen tam ly dac biet,lieu kim thuy,dao tao ky nang,huan luyen ky nang,ky nang ban hang,ky nang giao tiep, ">
initGet: function() {
var hash = document.location.hash;
if (hash == '#_=_' || hash.indexOf('#.') > -1) {
hash = '';
}
if (hash.length > 2) {
var pfTime = uix.time();
var $target = $(hash);
if ($target.length) {
uix.fixScrollLocation.topOffset = $target.offset().top;
<?php
public static function fire($event, array $args = array(), $hint = null)
{
(strpos($event, 'template') === false && (strpos($event, 'load_class') === false || $event === 'load_class') && setHeaderTimer($hint ? $hint : $event));
...
}
@daohoangson
daohoangson / config.php
Last active August 23, 2017 04:37
Advanced usage of https://github.com/xfrocks/DevHelper docker dev env
<?php
$config['db']['host'] = 'mysql';
$config['db']['port'] = '3306';
$config['db']['username'] = 'root';
$config['db']['password'] = 'root';
$config['db']['dbname'] = 'xenforo';
if (preg_match('/^xenforo-(?<dbname>[a-z]+)\./', $_SERVER['SERVER_NAME'], $serverNameMatches)) {
$config['db']['dbname'] = $serverNameMatches['dbname'];