Skip to content

Instantly share code, notes, and snippets.

@wulinlw
wulinlw / bar.py
Last active February 17, 2020 09:56
#题目是给一个方法 foo(),能以各 50%的概率随机返回 0 或者 1。
#问题是基于 foo()方法,实现一个 boo()方法,该方法能以各 10%的概率返回[0-9]中的一个数字。
for i in range(10):
print("{:0>32b}".format(i), i)
import random
def foo():
return random.randint(0,1)
# 0000 0
@wulinlw
wulinlw / History\5ad06433\WgsF.json
Last active April 3, 2022 14:54
vscode setting
{
"php.executablePath": "D:\\xampp\\php\\php.exe",
"search.exclude": {
"!/system/*/.ps*": true,
"system/": true
},
"sync.gist": "48d0310bb13166211cb6e15e0b4bc2ab",
"sync.autoUpload": true,
"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
"tabnine.experimentalAutoImports": true,
@wulinlw
wulinlw / query.sql
Created December 19, 2018 09:47
使用变量的分表查询
set @uid=12345;
SET @tb=CONCAT('table_', lpad(mod(@uid, 64),2,0));
SET @sql = CONCAT('SELECT *,FROM_UNIXTIME(usedtime) FROM ',@tb,' where uid=', @uid);
PREPARE st FROM @sql;
EXECUTE st;
DEALLOCATE PREPARE st;
@wulinlw
wulinlw / redisConnection.php
Created December 19, 2018 09:26
redis连接函数
$redis['redis'] = array(
'host' => '192.168.41.33',
'auth' => '8GLjx3tdi',
'port' => 6379,
'db' => 2
);
redisConn($redis['redis']);
function redisConn($c)
{
$redis = new Redis();
@wulinlw
wulinlw / findPhpFuncs.php
Last active January 22, 2017 02:39
列出目录中所有文件中的php函数
<?php
$files = showDir(".");
foreach ($files as $key => $value) {
file_put_contents('funcs.txt', $value.PHP_EOL, FILE_APPEND);
$funcs = getFunc($value);
foreach ($funcs as $k2 => $v2) {
file_put_contents('funcs.txt', $v2.PHP_EOL, FILE_APPEND);
}
file_put_contents('funcs.txt', PHP_EOL, FILE_APPEND);
}
@wulinlw
wulinlw / 清除.svn目录
Created January 17, 2017 03:17
clean_svn.bat
@echo off
:start
::启动过程,切换目录
set pwd=%cd%
cd %1
echo 工作目录是:& chdir
:input
::获取输入,根据输入进行处理
@wulinlw
wulinlw / specialLog.go
Last active December 22, 2016 08:24
从json日志文件中找出指定类型日志,写入独立类型的文件 -h查看参数
package main
import (
"bufio"
"bytes"
"fmt"
"os"
"runtime"
//"runtime/pprof"
"flag"
@wulinlw
wulinlw / client.go
Created December 15, 2016 09:44
golang解包的例子
func receiveMsg(conn *net.TCPConn) {
var data bytes.Buffer
var buffer []byte
buffer = make([]byte, 500)
for {
readLen, err := conn.Read(buffer)
if err != nil {
if err == io.EOF {
fmt.Println("io.EOF error:", err)
@wulinlw
wulinlw / removeDom.py
Created October 28, 2016 06:50
清除文件bom头
#coding=utf-8
'''
* 去除指定类型文件的bom头
* 版权所有
* @author t6760915<t6760915@gmail.com>
* @version $Id: trim_bom.py $
* 原版 https://gist.github.com/yhben/5169561
* 原版不能检测所有的UTF-8 + bom的文件
'''
@wulinlw
wulinlw / updateSvn.py
Created February 18, 2016 09:01
paramiko更新测试环境svn的脚本
#!/usr/bin/env python
import sys
import paramiko
alpha = {
'hostname' : '192.168.9.1',
'username' : 'root',
'password' : 'xxxxxx',
'port' : 22,