Skip to content

Instantly share code, notes, and snippets.

@biaocy
biaocy / 0_reuse_code.js
Created June 14, 2014 14:14
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static
@biaocy
biaocy / regenerate_persistent_net_rules.sh
Created June 22, 2015 07:51
Centos 6 mac address unmatch solution
#delete persistent net rules
rm /etc/udev/rules.d/70-persistent-net.rules
#reboot, then it will regenerate
reboot
@biaocy
biaocy / weibo4b.js
Last active September 9, 2017 08:28
block weibo keyword
// ==UserScript==
// @name weibo4b
// @namespace http://tampermonkey.net
// @version 0.3
// @description 屏蔽匹配关键字的微博
// @author biaocy
// @match https://weibo.com/*
// @grant none
// ==/UserScript==
@biaocy
biaocy / image-proxy.conf
Created June 20, 2016 17:27 — forked from tmaiaroto/image-proxy.conf
Nginx Image Filter Resize Proxy Service
# Feel free to change this path of course (and keys_zone value as well, but also change the usage of it below).
proxy_cache_path /var/www/cache/resized levels=1:2 keys_zone=resizedimages:10m max_size=1G;
# Gzip was on in another conf file of mine...You may need to uncomment the next line.
#gzip on;
gzip_disable msie6;
gzip_static on;
gzip_comp_level 4;
gzip_proxied any;
# Again, be careful that you aren't overwriting some other setting from another config's http {} section.
@biaocy
biaocy / change_java_home.bat
Created May 19, 2017 05:48
change java home
@echo off
rem This batch program will switch java env version in 1.6/1.8
set @v1_6=C:\Program Files (x86)\Java\jdk1.6.0_45
set @v1_8=C:\Program Files\Java\jdk1.8.0_121
set @cur=%JAVA_HOME%
echo Current path is %@cur%
@biaocy
biaocy / pi.js
Created September 25, 2017 07:54
割圆术(刘徽)求π
function cx(lastM, r) { //求圆心到等边形的垂直距离
return Math.sqrt(r-Math.pow(lastM/2, 2));
}
function cm(lastM, r) { //求等边形边长
var x = cx(lastM, r); //圆心到等边形边的垂直距离
return Math.sqrt(Math.pow(r-x, 2) + Math.pow(lastM/2, 2));
}
function pi(t) {
@biaocy
biaocy / neo-alert.sh
Last active December 22, 2017 12:42
bittrex neo coin alert script
#curl -s https://bittrex.com/api/v1.1/public/getmarketsummary?market=btc-neo | awk -F , '{print }' | awk -F : '{print }'
date=`date +"%FT%T"`
log="/var/log/neo.log"
url="https://bittrex.com/api/v1.1/public/getmarketsummary?market=btc-neo"
subject="NEO"
threshold="0.003"
mailto="email" # email here
msg=`curl -s $url`
@biaocy
biaocy / random.sh
Last active April 6, 2023 12:09
linux generate 32 length alphanumeric string
cat /dev/urandom | tr -cd 'a-zA-Z0-9' | fold -w 32 | head -n 1
@biaocy
biaocy / date_normalize.js
Created December 17, 2017 09:54
javascript normalize date time
//from https://stackoverflow.com/a/11172083
var date = new Date();
date.setMinutes(date.getMinutes() - date.getTimezoneOffset());
date.toJSON(); //2017-12-17T17:51:45.055Z