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
#!/bin/bash
# supervisor job control
function job()
{
if [ $# -gt 0 ]; then
cmd=$1
else
cmd="status"
@moolex
moolex / business.php
Last active December 11, 2015 11:28
OOP连贯操作管理
<?php
/**
* 实际业务操作
*/
class business
{
/**
* 操作入口
*/
@moolex
moolex / douban.album.download.php
Created January 20, 2013 05:02
豆瓣相册下载(单文件)
<?php
$start = @$_GET['start'];
$start || $start = 0;
$d = file_get_contents('http://www.douban.com/photos/album/20987752/?start='.$start);
preg_match_all('/\/photos\/photo\/(\d{10})\/"/i', $d, $photo_ms);
preg_match_all('/http:\/\/img(\d{1})\.douban\.com\//i', $d, $server_ms);
preg_match_all('/class="photolst_photo" title="(.*?)"/is', $d, $title_ms);
@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)
{
@moolex
moolex / bbp.pi.php
Last active December 11, 2015 00:28
Bellard的基于BBP公式的Pi计算程序(PHP版)
<?php
/**
* 圆周率计算(BBP)
* @author Moyo <[email protected]>
* @url http://moyo.uuland.org/code/php-pi-calc/
* @version 1.0
* @date 2013.01.12
*/
@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 / 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 / class.proxy.demo.php
Last active December 10, 2015 21:58
PHP中类代理机制的简单实现
<?php
/**
* 代理管理
*/
class ProxyManager
{
/**
* 创建类代理
* @param type $className
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 / 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