Skip to content

Instantly share code, notes, and snippets.

View leolovenet's full-sized avatar
🏡
Working from home

liu lei leolovenet

🏡
Working from home
View GitHub Profile
@leolovenet
leolovenet / Memory management with and without ARC
Created August 21, 2013 14:38
Memory management with and without ARC
#if ! __has_feature(objc_arc)
#error This file must be compiled with ARC.
#endif
#TARGETS -> Build Settings -> Apple LLVM complier *.* Language -> Object-C Automatic Reference Counting -> YES/NO
#TARGETS -> Build Phases -> Complie Sources -> -fno-objc-arc/-fobjc-arc
@leolovenet
leolovenet / commentdel
Created February 23, 2014 12:35
use this script to remove comment line in config file. e.g. $commentdel nginx.conf
#!/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
@leolovenet
leolovenet / detection.sh
Created March 28, 2014 04:07
一个检测 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…
#!/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 / terminal-colors.sh
Last active June 11, 2016 14:37
make terminal colors
#!/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 / jquery.circle.js
Last active August 29, 2015 14:24
jQuery Knob draw with animation
/**
* 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);
//一个压缩小整数的算法,原文来自这里
//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 / install_StrongSwan.sh
Created July 6, 2016 08:50
IPSEC VPN on Centos6 with StrongSwan for iOS9
#!/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'
@leolovenet
leolovenet / fishshell luarocks path
Last active June 29, 2022 07:41
luarocks path command for fishshell
for i in (luarocks path | awk '{sub(/PATH=/, "PATH ", $2); print "set -gx "$2}'); eval $i; end
@leolovenet
leolovenet / net.Listener.SetsockoptInt.IP_TRANSPARENT.for.Linux.go
Created October 21, 2018 09:33
SetsockoptInt IP_TRANSPARENT for net.Listener in golang
package main
import (
"fmt"
"net"
"os"
"os/signal"
"reflect"
"syscall"
)
#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")