Skip to content

Instantly share code, notes, and snippets.

View struCoder's full-sized avatar
☀️
Working and Working

david zh struCoder

☀️
Working and Working
  • Shanghai China
View GitHub Profile
MD5 checksum
In order to find the MD5 checksum value of a file using the following command in the terminal.
$ md5 /path/to/file
To find the SHA1 checksum value use the following command in the terminal.
$ shasum -a 1 /path/to/file
To find the SHA256 checksum use the following command in the terminal.
$ shasum -a 256 /path/to/file
@struCoder
struCoder / gen_dockerfile
Created May 16, 2017 04:09
gen_dockerfile
FROM alpine:3.4
ENV TZ 'Asia/Shanghai'
RUN apk upgrade --no-cache && \
apk add --no-cache bash tzdata && \
mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2 && \
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo "Asia/Shanghai" > /etc/timezone && \
@struCoder
struCoder / install_pmgo.sh
Last active April 11, 2017 05:58
install_pmgo
#!/bin/sh
version="0.1.0"
UNAME=$(uname)
# Check to see if it starts with MINGW.
if [ "$UNAME" ">" "MINGW" -a "$UNAME" "<" "MINGX" ] ; then
echo "current release do not support windows"
exit 1
@struCoder
struCoder / csv.js
Created March 2, 2017 10:17
nodejs csv乱码解决方案
// https://cnodejs.org/topic/516e0ab46d382773067a5473
var http = require('http');
var url = require('url');
var Iconv = require('iconv').Iconv;
var crypto = require('crypto');
var server = http.createServer(function(req, res){
var path = url.parse(req.url).pathname;
if(path == '/favicon.ico'){
res.end('');
@struCoder
struCoder / convert_gbk_utf8.js
Created December 25, 2016 13:28
遍历文件夹将gbk编码的文件专为utf8
'use strict';
const fs = require('fs');
const iconv = require('iconv-lite');
const path = require('path');
const p = console.log;
function readText(path) {
let buf = fs.readFileSync(path);
return iconv.decode(buf, 'gbk');
@struCoder
struCoder / multi_hash.go
Created December 16, 2016 09:01
figure file multi hash with go
package main
import (
"bufio"
"crypto/md5"
"crypto/sha1"
"crypto/sha256"
"crypto/sha512"
"encoding/hex"
"fmt"
// from here: http://marcio.io/2015/07/handling-1-million-requests-per-minute-with-golang/
// great example !!
func payloadHandler(w http.ResponseWriter, r *http.Request) {
if r.Method != "POST" {
w.WriteHeader(http.StatusMethodNotAllowed)
return
}
// Read the body into a string for json decoding
@struCoder
struCoder / ffmpeg_compress_mp4.md
Created September 7, 2016 06:20
use fmpeg to compress mp4 video

use fmpeg to compress mp4 video

ffmpeg -i "input.MP4" -vb xxxk -vcodec libx264 -ab 64k -ar 44100 -y "output_.MP4"

xxxk: You should adjust its size according to your needs.

For example i use 2000k to compress Gopro mp4 videos.

@struCoder
struCoder / express-plugin.js
Created July 6, 2016 09:25
exress管理路由插件
function customRouter(originRouter, prefix) {
let urlArr = [];
let slice = [].slice;
let methods = ['get', 'post', 'delete', 'put'];
function array2ArrayLike(array) {
let arrayLike = {
length: 0
}
for(let i = 0; i < array.length; i++) {
local redis_c = require "resty.redis"
local ok, new_tab = pcall(require, "table.new")
if not ok or type(new_tab) ~= "function" then
new_tab = function (narr, nrec) return {} end
end
local _M = new_tab(0, 155)