Skip to content

Instantly share code, notes, and snippets.

View moolex's full-sized avatar
🏠
lazying from home

MOYO moolex

🏠
lazying from home
View GitHub Profile
@moolex
moolex / www.backuper.sh
Created December 3, 2012 10:28
自动执行本地网站增量备份的脚本(centos+rsync)
#!/bin/sh
# Moyo <dev@uuland.org> @ 2012/02/23 10:00
# @url http://moyo.uuland.org/system/rsync-local-auto-sh/
# DEFINED ~~
# 脚本所在目录
workbase=/home/backup/shell
# 需要备份的网站列表(文件名)
listf=web.rsync.list
@moolex
moolex / mysql.backuper.sh
Created December 3, 2012 10:35
mysql 数据库自动热备份脚本(centos+mysqlhotcopy)
#!/bin/sh
# Moyo <dev@uuland.org> @ 2012/02/22 10:00
# @url http://moyo.uuland.org/system/mysqlhotcopy-auto-sh/
# DEFINED ~~
# 需要备份的数据库列表(空格间隔)
dbns="mysql"
# 备份目录
dbsf=/home/backup/database
@moolex
moolex / proxy.check.py
Created January 3, 2013 13:40
自动检测代理速度的Python脚本
#!/usr/bin/python
# -*- coding: utf-8 -*-
# From: ubuntu.org.cn Copyright: GPLv2
import urllib
import re
from datetime import datetime
import socket
def findporxy():
url = "http://www.proxycn.com/html_proxy/http-1.html"
f = urllib.urlopen(url)
@moolex
moolex / ip.set.bat
Created January 4, 2013 05:04
Windows下自动设置IP的批处理脚本
@echo off
::需要设置的网络,一般为“本地连接”或者“无线网络连接”
set name="无线网络连接"
::请根据您的参数修改以下数据
::设置 IP地址
set ipaddress=18.1.16.169
::设置 子掩码
set mask=255.255.252.0
::设置 网关
set gateway=18.1.19.254
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\TypeLib\{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}]
[HKEY_CLASSES_ROOT\TypeLib\{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}\1.1]
@="Microsoft Internet Controls"
[HKEY_CLASSES_ROOT\TypeLib\{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}\1.1\0]
[HKEY_CLASSES_ROOT\TypeLib\{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}\1.1\0\win32]
@="C:\\WINDOWS\\system32\\ieframe.dll"
@moolex
moolex / class.proxy.demo.php
Last active December 10, 2015 21:58
PHP中类代理机制的简单实现
<?php
/**
* 代理管理
*/
class ProxyManager
{
/**
* 创建类代理
* @param type $className
@moolex
moolex / dsn.resolver.php
Last active December 10, 2015 22:08
DSN 字符串解析
<?php
/**
* DSN 字符串解析
* @param string $dsn
*/
function dsn_resolver($dsn)
{
preg_match('/^([a-z]+)\:\/\/(\w+)[\:]?(\w+)?[@]+([\w|\.]+)?[\:]?([0-9]+)?[\/]?(\w+)$/i', $dsn, $matchs);
if ($matchs)
@moolex
moolex / bbp.pi.c
Created January 12, 2013 07:23
Bellard的基于BBP公式的Pi计算程序
/*
* Computation of the n'th decimal digit of \pi with very little memory.
* Written by Fabrice Bellard on January 8, 1997.
*
* We use a slightly modified version of the method described by Simon
* Plouffe in "On the Computation of the n'th decimal digit of various
* transcendental numbers" (November 1996). We have modified the algorithm
* to get a running time of O(n^2) instead of O(n^3log(n)^3).
*
* This program uses mostly integer arithmetic. It may be slow on some
@moolex
moolex / bbp.pi.php
Last active December 11, 2015 00:28
Bellard的基于BBP公式的Pi计算程序(PHP版)
<?php
/**
* 圆周率计算(BBP)
* @author Moyo <moyo@uuland.org>
* @url http://moyo.uuland.org/code/php-pi-calc/
* @version 1.0
* @date 2013.01.12
*/
@moolex
moolex / magic.pi.c
Created January 12, 2013 13:43
一段神奇的代码,仅仅4行就可以算出Pi的800位
int a = 10000, b, c = 2800, d, e, f[2801], g;
main()
{
for(; b - c ;)
{
f[b++] = a / 5;
}
for(; d = 0, g = c * 2; c -= 14, printf("%.4d", e + d / a), e = d % a)
{