Skip to content

Instantly share code, notes, and snippets.

View lbp0200's full-sized avatar
🎯
专注

萝卜皮 lbp0200

🎯
专注
View GitHub Profile
@lbp0200
lbp0200 / demo1.html
Created November 6, 2014 03:01
Javascript生成100个随机中文
<!DOCTYPE html>
<html>
<body>
<p id="demo">Click the button to display a random number.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction()
@lbp0200
lbp0200 / PostMaker.php
Created November 6, 2014 08:10
PHP生成随机中文字符串
<?php
function unicode_decode($name) {
// 转换编码,将Unicode编码转换成可以浏览的utf-8编码
$pattern = '/([\w]+)|(\\\u([\w]{4}))/i';
preg_match_all($pattern, $name, $matches);
if (!empty($matches)) {
$name = '';
for ($j = 0; $j < count($matches[0]); $j++) {
$str = $matches[0][$j];
@lbp0200
lbp0200 / Global.asax.cs
Created February 13, 2015 08:30
Asp.Net 带缓冲Log组件核心代码
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
public override void Init()
@lbp0200
lbp0200 / mysql.php
Created March 16, 2015 08:35
php mysql multiple insert
<?php
try {
$dbh = new PDO('mysql:host=localhost;dbname=mytest', 'root', '123', array(
PDO::ATTR_PERSISTENT => true));
$rows = array(
array(null, 'def', time()),
array(null, 'def', time()),
array(null, 'def', time()),
@lbp0200
lbp0200 / ab.php
Last active August 29, 2015 14:18
压力测试
<?php
function postcurl($curlPost) {
$ch = curl_init(); //初始化curl
curl_setopt($ch, CURLOPT_URL, 'http://host/index.php?url'); //抓取指定网页
//curl_setopt($ch, CURLOPT_HEADER, 0); //设置header
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //要求结果为字符串且输出到屏幕上
curl_setopt($ch, CURLOPT_POST, 1); //post提交方式
curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
$data = curl_exec($ch); //运行curl
echo ($data);
@lbp0200
lbp0200 / guid.js
Last active August 29, 2015 14:18
get-guid
function guid() {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
s4() + '-' + s4() + s4() + s4();
}
@lbp0200
lbp0200 / hosts
Created May 1, 2015 11:02
干掉网络运营商的广告劫持
#无良网络运营商,劫持用户上网信息,牟取广告利润
#制作此hosts文件,让其劫持失效
#内容保存到C:\Windows\System32\drivers\etc\hosts
127.0.0.1 count.chanet.com.cn
127.0.0.1 p.yiqifa.com
@lbp0200
lbp0200 / init.d.php7-fpm
Created May 1, 2015 14:21
php7-fpm、nginx配置文件
#! /bin/sh
### BEGIN INIT INFO
# Provides: php-fpm
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts php-fpm
# Description: starts the PHP FastCGI Process Manager daemon
@lbp0200
lbp0200 / callback.php
Created June 26, 2015 08:54
callback demo
<?php
class person {
public $name;
public $price;
function __construct($name, $price) {
$this->name = $name;
$this->price = $price;
}
}
@lbp0200
lbp0200 / index.js
Last active September 21, 2015 10:34
javascript date format 日期格式化
/*
demo
today = new Date();
var dateString = today.format("dd-m-yy");
alert(dateString);
source http://jsfiddle.net/phZr7/1/
* Date Format 1.2.3
* (c) 2007-2009 Steven Levithan <stevenlevithan.com>