Skip to content

Instantly share code, notes, and snippets.

@jamesBan
jamesBan / git-tip.sh
Last active April 5, 2016 09:14
删除远程不存在的分支
git remote show origin
git remote prune origin
@jamesBan
jamesBan / parse_xlsx.php
Created May 26, 2016 09:51 — forked from searbe/parse_xlsx.php
Parse simple XLSX in PHP with SimpleXML and ZipArchive
<?php
/**
* I had to parse an XLSX spreadsheet (which should damn well have been a CSV!)
* but the usual tools were hitting the memory limit pretty quick. I found that
* manually parsing the XML worked pretty well. Note that this, most likely,
* won't work if cells contain anything more than text or a number (so formulas,
* graphs, etc ..., I don't know what'd happen).
*/
@jamesBan
jamesBan / multi_curl.php
Created February 6, 2017 12:42
curl 并行
<?php
$begin = microtime(true);
$url = 'http://cdn-1.yi-you.org/courseware/4202ee83f0d8a3944c4b72dd/4ba56224b2498ae0931fe1f108bee658.pdf';
$total = 71;
$urls = [];
for ($i = 1; $i <= $total; $i++) {
$urls[] = $url . '?odconv/jpg/page/' . $i . '/density/288/quality/92/resize/1280';
}
if(!is_dir('images')) {
@jamesBan
jamesBan / yii-get-modules-actions
Created February 24, 2017 08:40
yii2获取所有module方法
<?php
foreach (\Yii::$app->getModules() as $id => $child) {
if(in_array($id, ['gii', 'debug'])) {
continue;
}
$module = \Yii::$app->getModule($id);
$namespace = $module->controllerNamespace."\\";
$dir = $module->controllerPath;
$fileList = glob($dir."/*Controller.php");
@jamesBan
jamesBan / Dockerfile
Created March 27, 2017 12:37
docker php5命令行镜像
FROM alpine:3.4
RUN apk --no-cache --update add \
php5 \
php5-cli \
php5-pcntl \
php5-posix \
php5-sockets \
php5-mysql \
php5-zip \
php5-phar \
@jamesBan
jamesBan / convert.py
Created April 13, 2017 06:15
python 调用office 转换文档
import sys
import os
import glob
import win32com.client
def convert(files, formatType = 32):
powerpoint = win32com.client.Dispatch("PowerPoint.Application")
powerpoint.Visible = 1
for filename in files:
@jamesBan
jamesBan / docker容器监控
Created June 9, 2017 02:36
docker-stat.sh
#!/bin/bash
docker stats $(docker ps | awk '{if(NR>1) print $NF}')
@jamesBan
jamesBan / fileMd5.go
Created September 29, 2017 07:22
获取文件md5
func calcMd5(filePath string) string {
f, err := os.Open(filePath)
if err != nil {
log.Fatal(err)
}
defer f.Close()
h := md5.New()
if _, err := io.Copy(h, f); err != nil {
log.Fatal(err)
@jamesBan
jamesBan / queue-task.go
Created October 13, 2017 08:55
golang任务队列
package main
import (
"fmt"
"github.com/garyburd/redigo/redis"
"strconv"
"strings"
"time"
)
@jamesBan
jamesBan / sources.list
Created March 21, 2018 01:09
ubuntu aliyun mirror
# Aliyun mirror
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse