Skip to content

Instantly share code, notes, and snippets.

View khoinv's full-sized avatar
🏠
Working from home

Nguyen Van Khoi khoinv

🏠
Working from home
View GitHub Profile
@khoinv
khoinv / 3proxy_install.sh
Last active October 1, 2025 15:37
3proxy_install.sh
#!/bin/sh
sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
echo "sslverify=false" >> /etc/yum.conf
echo "IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
IPV6ADDR=$IPV6ADDR/64
IPV6_DEFAULTGW=$IPV6_DEFAULTGW" >> /etc/sysconfig/network-scripts/ifcfg-eth0
#!/bin/sh
random() {
tr </dev/urandom -dc A-Za-z0-9 | head -c5
echo
}
array=(1 2 3 4 5 6 7 8 9 0 a b c d e f)
gen64() {
ip64() {
echo "${array[$RANDOM % 16]}${array[$RANDOM % 16]}${array[$RANDOM % 16]}${array[$RANDOM % 16]}"
@khoinv
khoinv / TextValueBaseConstant.php
Last active May 17, 2021 09:05
TextValueBaseConstant
<?php
abstract class TextValueBaseConstant
{
/** @var array Memorized queried values. */
protected static $caches = [];
/**
* Get value of text
*
@khoinv
khoinv / extend_css
Created April 21, 2021 02:57
extend_css
.field {
@extend .form-group, .row;
input[type="text"],
select,
textarea,
input[type="password"] {
@extend .form-control;
}
&.remember {
@khoinv
khoinv / check_assets_cached_status
Last active February 18, 2021 04:10
check_assets_cached_status
<script>
const resourcesStatus = window.performance.getEntriesByType('resource')
.reduce(function(formattedOutput, resourceDetails) {
return formattedOutput.concat({
resourceName: resourceDetails.name,
cached: resourceDetails.transferSize ? false : true,
transferSize: resourceDetails.transferSize
})}, [])
resourcesStatus.filter(_ => !_.cached)
function seeInDatabaseAndHasProperties($table, array $filter, array $properties, $connection = null){
$this->seeInDatabase($table, $filter, $connection);
$model = (array)DB::table($table)->where($filter)->first();
$this->assertEquals($properties, Arr::only($model, array_keys($properties)));
}
@khoinv
khoinv / sniff.php
Created September 8, 2020 03:42 — forked from lt/sniff.php
Minimal PHP packet sniffer
<?php declare(strict_types=1);
$socket = socket_create(AF_INET, SOCK_RAW, SOL_TCP);
if (!$socket) {
$errorCode = socket_last_error();
throw new \RuntimeException(socket_strerror($errorCode), $errorCode);
}
const IP_HDR = 'Cversion_ihl/Ctos/ntot_len/nid/nfrag_off/Cttl/Cprotocol/ncheck/Nsaddr/Ndaddr/';
@khoinv
khoinv / overpunch_gmn_ok_good_converter.ex
Last active August 14, 2020 03:20
Convert an overpunch string to float - Divided the integer string to a number passed as argument
defmodule OverpunchGmnOkGoodConverter do
@overpunch_characters %{
"{" => {"0", ""},
"}" => {"0", "-"},
"A" => {"1", ""},
"B" => {"2", ""},
"C" => {"3", ""},
"D" => {"4", ""},
"E" => {"5", ""},
"F" => {"6", ""},
<html>
<head>
<style>
.grid{
margin-bottom: 5px;
text-align: center;
border: 1px solid green;
}
.xs{
width: 576px;
@khoinv
khoinv / webpack.config.js
Created September 23, 2019 19:05
Use css hot reload in dev.
const path = require('path');
const glob = require('glob');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = (env, options) => {
const devMode = options.mode !== 'production';
// với devMode sẽ sử dụng webpack-dev-server để xử dụng các tính năng như HRM