Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

liu lei leolovenet

🏠
Working from home
View GitHub Profile
@leolovenet
leolovenet / Self-Documented Makefile
Last active Nov 27, 2020
Automatically have "make help" print the usage of your Makefile. from https://www.thapaliya.com/en/writings/well-documented-makefiles/
View Self-Documented Makefile
.DEFAULT_GOAL:=help
SHELL:=/bin/bash
##@ Dependencies
.PHONY: deps
deps: ## Check dependencies
$(info Checking and getting dependencies)
View fishshell, man pages with colors
#add this function to your $HOME/.config/fish/config.fish
function man
set -x LESS_TERMCAP_mb (printf "\e[01;32m")
set -x LESS_TERMCAP_md (printf "\e[01;32m")
set -x LESS_TERMCAP_me (printf "\e[0m")
set -x LESS_TERMCAP_se (printf "\e[0m")
set -x LESS_TERMCAP_so (printf "\e[01;33m")
set -x LESS_TERMCAP_ue (printf "\e[0m")
set -x LESS_TERMCAP_us (printf "\e[1;4;31m")
@leolovenet
leolovenet / net.Listener.SetsockoptInt.IP_TRANSPARENT.for.Linux.go
Created Oct 21, 2018
SetsockoptInt IP_TRANSPARENT for net.Listener in golang
View net.Listener.SetsockoptInt.IP_TRANSPARENT.for.Linux.go
package main
import (
"fmt"
"net"
"os"
"os/signal"
"reflect"
"syscall"
)
@leolovenet
leolovenet / fishshell luarocks path
Last active Jun 27, 2020
luarocks path command for fishshell
View fishshell luarocks path
for i in (luarocks path | awk '{sub(/PATH=/, "PATH ", $2); print "set -gx "$2}'); eval $i; end
@leolovenet
leolovenet / install_StrongSwan.sh
Created Jul 6, 2016
IPSEC VPN on Centos6 with StrongSwan for iOS9
View install_StrongSwan.sh
#!/bin/bash
## Main reference https://raymii.org/s/tutorials/IPSEC_vpn_with_CentOS_7.html
yum -y install epel-release
yum -y install haveged strongswan
/etc/init.d/haveged start
chkconfig haveged on
cd /etc/strongswan || exit
cat > strongswan.conf <<'EOF'
View zipzag.c
//一个压缩小整数的算法,原文来自这里
//http://mp.weixin.qq.com/s?__biz=MzA3MDExNzcyNA==&mid=2650392086&idx=1&sn=6a2ecfe2548f121a4726d03bf23f4478
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <unistd.h>
typedef unsigned char byte;
////http://stackoverflow.com/questions/111928/is-there-a-printf-converter-to-print-in-binary-format?page=1&tab=active#tab-top
@leolovenet
leolovenet / jquery.circle.js
Last active Aug 29, 2015
jQuery Knob draw with animation
View jquery.circle.js
/**
* Created by leolovenet@gmail.com on 7/2/15.
*/
(function(){
"use strict";
var Circles = function(e,op) {
this.options = $.extend({}, Circles.DEFAULTS, op);
this.$e = $(e);
this.$e.val(this.options.to);
this.$e.knob(this.options);
@leolovenet
leolovenet / terminal-colors.sh
Last active Jun 11, 2016
make terminal colors
View terminal-colors.sh
#!/bin/bash
cd ~
WGET_CMD=$(type -P wget)
if [ "X$WGET_CMD" = "X" ];then
yum -y install wget coreutils
fi
if [ ! -f ~/.dir_colors ]; then
@leolovenet
leolovenet / detection.sh
Created Mar 28, 2014
一个检测 Linux 服务器硬件资源脚本,包含服务器的型号,U 数,Dell 序列号,内存数,最大内存数,可以插的内存条数,已经用的内存条数,内存类型,硬盘大小,CPU 信息. A Linux server hardware detection resource script that contains the server model, U number, Dell serial number, the number of memory, the maximum amount of memory, the memory can be inserted in the number, the number of memory has been used, the type of memo…
View detection.sh
#!/bin/bash
ISINSTALLED_D=$(rpm -qa |grep dmidecode)
if [ -z $ISINSTALLED_D ]; then
yum -y install dmidecode
fi
export PATH=$HOME/bin:/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin
@leolovenet
leolovenet / commentdel
Created Feb 23, 2014
use this script to remove comment line in config file. e.g. $commentdel nginx.conf
View commentdel
#!/bin/bash
#set -x
if [ $# -lt 1 ]; then
echo "Usage: $0 < filepath > [ \# | \; | \/\/ | \<other comment sign>, default: \# ]"
exit 1;
fi
CONFIG_FILE=$1
if [ ! -f ${CONFIG_FILE} ]; then
You can’t perform that action at this time.