Skip to content

Instantly share code, notes, and snippets.

View kookxiang's full-sized avatar
🪲
code once, bug everywhere

Xiang Liu kookxiang

🪲
code once, bug everywhere
View GitHub Profile
<?php
class PHPLock {
private $_PHP_LOCK = array();
private $code;
private $lockId = 1;
public function __construct(&$code){
$this->code =& $code;
$this->_PHP_LOCK = array();
#!/usr/bin/env bash
# Usage:
# $(curl -sSL https://gist.githubusercontent.com/kookxiang/2fb6d9e3f811f59f0b3c2c4353161f64/raw/centos7_init.sh | bash)
if [[ -e /etc/redhat-release ]]; then
RELEASE_RPM=$(rpm -qf /etc/centos-release)
RELEASE=$(rpm -q --qf '%{VERSION}' ${RELEASE_RPM})
if [ ${RELEASE} != "7" ]; then
echo "CentOS release is not 7."
@kookxiang
kookxiang / SS-Redir.sh
Created October 6, 2015 06:47
SS-Redir config file for OpenWRT
#!/bin/sh
# Notice: hosts file is required
killall ss-redir > /dev/null
ss-redir -v -c /etc/ss-redir.json &
iptables -t nat -N SHADOWSOCKS > /dev/null
iptables -t nat -F SHADOWSOCKS > /dev/null
@kookxiang
kookxiang / snow.css
Last active December 23, 2017 17:54
Snow Effect for Winter~ (aka White Album Season)
body {
margin: 0;
background: #202020;
}
body > .snow {
display: block;
position: fixed;
z-index: 1000;
top: 0;

Keybase proof

I hereby claim:

  • I am kookxiang on github.
  • I am kookxiang (https://keybase.io/kookxiang) on keybase.
  • I have a public key ASCYbL9eMKBZFMhA4_L3_OE4dn2uwaH2tWkL1K3B6_NfyQo

To claim this, I am signing this object:

@kookxiang
kookxiang / Database.php
Last active September 24, 2019 11:45
PDO with multi server support
<?php
/**
* This file is a part of KK Framework
* Author: kookxiang <r18@ikk.me>
*/
namespace Core;
class Database {
const MASTER = 'MASTER';
const SLAVE = 'SLAVE';
@kookxiang
kookxiang / cnmp.sh
Last active April 28, 2020 15:34
CNMP (Centos 7 + Nginx + MariaDB + PHP7) Install Script
#!env bash
installCNMP(){
if [[ -e /etc/redhat-release ]]; then
RELEASE_RPM=$(rpm -qf /etc/centos-release)
RELEASE=$(rpm -q --qf '%{VERSION}' ${RELEASE_RPM})
if [ ${RELEASE} != "7" ]; then
echo "Not CentOS release 7."
exit 1
fi
else
@kookxiang
kookxiang / ddns.sh
Last active July 24, 2020 09:22
simple ddns script for cloudflare
#!/usr/bin/env bash
set -e
CF_TOKEN="********************************"
CF_ZONEID="*************************"
while true
do
sleep 10
#!/usr/bin/env sh
TARGET_DIR='/home/kookxiang/.ssh'
GITHUB_USERNAME='kookxiang'
if ! [ -d ${TARGET_DIR} ]; then
mkdir ${TARGET_DIR}
chmod 0700 ${TARGET_DIR}
fi
if ! [ -f ${TARGET_DIR}/authorized_keys ]; then
@kookxiang
kookxiang / disable_page_visibility_api.user.js
Created November 2, 2020 04:36
Disable Page Visibility API
// ==UserScript==
// @name Disable Page Visibility API
// @namespace https://www.kookxiang.com/
// @version 0.1
// @description Disable Page Visibility API
// @author kookxiang
// @match https://*/*
// @grant none
// @run-at document-start
// ==/UserScript==