Skip to content

Instantly share code, notes, and snippets.

View lunaczp's full-sized avatar

Lunac lunaczp

View GitHub Profile
@lunaczp
lunaczp / onchange.sh
Created September 30, 2017 10:07 — forked from senko/onchange.sh
Watch current directory and execute a command if anything in it changes
#!/bin/bash
#
# Watch current directory (recursively) for file changes, and execute
# a command when a file or directory is created, modified or deleted.
#
# Written by: Senko Rasic <[email protected]>
#
# Requires Linux, bash and inotifywait (from inotify-tools package).
#
# To avoid executing the command multiple times when a sequence of
@lunaczp
lunaczp / elf.h
Last active January 23, 2018 21:27 — forked from mlafeldt/elf.h
elf.h for OSX
/* This is the original elf.h file from the GNU C Library; I only removed
the inclusion of feature.h, which is not needed.
On OSX, simply copy the file to /usr/local/include/.
Mathias Lafeldt <[email protected]> */
/* This file defines standard ELF types, structures, and macros.
Copyright (C) 1995-2003,2004,2005,2006,2007,2008,2009,2010,2011
Free Software Foundation, Inc.
@lunaczp
lunaczp / rabbitmq-server
Created September 11, 2018 07:21 — forked from krmcbride/rabbitmq-server
RabbitMQ 3.0 Server init.d script
#!/bin/sh
#
# rabbitmq-server RabbitMQ broker
#
# chkconfig: - 80 05
# description: Enable AMQP service provided by RabbitMQ
#
### BEGIN INIT INFO
# Provides: rabbitmq-server
@lunaczp
lunaczp / httpserver.py
Created February 23, 2020 04:23 — forked from jplazcano87/httpserver.py
SimpleHttpServer with ip and port
import sys
from SimpleHTTPServer import SimpleHTTPRequestHandler
import BaseHTTPServer
def test(HandlerClass=SimpleHTTPRequestHandler,
ServerClass=BaseHTTPServer.HTTPServer):
protocol = "HTTP/1.0"
host = ''
@lunaczp
lunaczp / CheckEmoji.php
Created August 11, 2020 04:09 — forked from hnq90/CheckEmoji.php
Check Emoji exist in string
/**
* Check emoji from string
*
* @return bool if existed emoji in string
*/
function checkEmoji($str)
{
$regexEmoticons = '/[\x{1F600}-\x{1F64F}]/u';
preg_match($regexEmoticons, $str, $matches_emo);
if (!empty($matches_emo[0])) {
@lunaczp
lunaczp / squidanonymousproxy.md
Created September 28, 2020 11:11 — forked from RobinDev/squidanonymousproxy.md
Install a SQUID anonymous proxy
  1. Install SQUID
apt-get install squid
  1. Create an user
htpasswd -md /etc/squid3/users myuserlogin`
@lunaczp
lunaczp / md_file_tree.py
Created October 11, 2020 11:26 — forked from elfnor/md_file_tree.py
Generate a file tree table of contents for a directory of markdown files
# -*- coding: utf-8 -*-
"""
Generate a file tree table of contents for a directory of markdown files
run from command line:
$ python md_file_tree.py
will generate a markdown index of all markdown files in the current working
directory and its sub folders and insert it into a file `index.md`.
@lunaczp
lunaczp / haproxy.sh
Created October 13, 2020 15:54 — forked from ergoz/haproxy.sh
RabbitMQ cluster with HAProxy & Keepalived for high availability
# install haproxy
yum install -y haproxy
# config haproxy for rabbitmq
cat > /etc/haproxy/haproxy.cfg << "EOF"
global
log 127.0.0.1 local0 notice
maxconn 10000
user haproxy
@lunaczp
lunaczp / nginx.service
Created December 3, 2020 08:48 — forked from chuyik/nginx.service
OpenResty Centos 7 启动脚本配置
# OpenResty 默认安装在 /usr/local/openresty
# 该文件应该放在 /usr/lib/systemd/system/nginx.service
# 放好后请运行:
# - systemctl enable nginx.service
# - systemctl start nginx.service
# 然后之后就可以用 service nginx [start/reload/stop] 等命令了
[Unit]
Description=The nginx HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target