Skip to content

Instantly share code, notes, and snippets.

@spetacular
spetacular / walk.go
Created December 24, 2019 09:58 — forked from tdegrunt/walk.go
Replace some text in a bunch of files with golang
package main
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
)
@spetacular
spetacular / gen_uuid.php
Last active December 11, 2018 07:19
uuid generator for php
function gen_uuid(){
return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low"
mt_rand(0, 0xffff), mt_rand(0, 0xffff),
// 16 bits for "time_mid"
mt_rand(0, 0xffff),
// 16 bits for "time_hi_and_version",
// four most significant bits holds version number 4
@spetacular
spetacular / docker-php-fpm
Created September 4, 2017 07:45
config php-fpm using docker
Use docker-compose
1. Dockerfile
FROM php:5.6-fpm
RUN docker-php-ext-install pdo pdo_mysql mysql mysqli
EXPOSE 9000
2. docker-compose.yml
php:
@spetacular
spetacular / Dockerfile
Created August 25, 2017 03:00 — forked from ebuildy/Dockerfile
Install Php 7 with MongoDB driver on Docker from Ubuntu trusty base image.
FROM ubuntu:trusty
ENV HOME /root
ENV LC_ALL C.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.UTF-8
RUN add-apt-repository ppa:ondrej/php && \
apt-get update
@spetacular
spetacular / node-proxy.conf
Created August 15, 2017 02:42
nginx反向代理到noodjs
server{
listen 80;
server_name abc.com;
index index.html index.htm index.php default.html default.htm default.php;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
@spetacular
spetacular / magic_code.js
Last active August 4, 2017 08:26
简单粗暴的万能优惠码、活动码生成器js版
var magic_code = {
NUMBER: '0123456789',
ALPHPA: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
ALL: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
/**
* 生成编码。其中‘数’代表0-9,‘字’代表A-Z,‘全’代表0-9A-Z。其它字符照常显示
* @param 模版字符串
* @return string 字符串
*/
gen_code: function (str_fmt) {
@spetacular
spetacular / MagicCode.php
Last active August 4, 2017 08:26
简单粗暴的万能优惠码、活动码生成器php版
<?php
class MagicCode{
const NUMBER = '0123456789';
const ALPHPA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
const ALL = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
/**
* 生成编码。其中‘数’代表0-9,‘字’代表A-Z,‘全’代表0-9A-Z。其它字符照常显示
* @param string 模版字符串
* @return string 字符串
/**
* data为数组
*/
private function _download_excel($filename,$data){
require_once __DIR__ . '/Lib/Excel/PHPExcel.php';
$objPHPExcel=new \PHPExcel();
$alphas = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
foreach($data as $line_index => $line){
$column_index = 0;
foreach($line as $key => $filed){
var newman = require('newman'); // require newman in your project
var nodemailer = require('nodemailer');
var fs = require('fs');
var export_file = './htmlResults_for_mail.html';
var collection_file = './postman_echo.postman_collection.json';
// call newman.run to pass `options` object and wait for callback
newman.run({
collection: require(collection_file),
reporters: ['cli','html'],
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Smoke Test Report</title>
</head>
<body>
<div class="container">
{{#if summary.failures}}<h1 style="color:red;">SomeThing Is Wrong! Check The Following Contents and Attachments To Find Out!</h1><hr/>{{/if}}
<h3>Smoke Test Report</h3>