Skip to content

Instantly share code, notes, and snippets.

@slv922
slv922 / computeHmac.go
Created June 19, 2018 02:16
Hmac Example
package main
import (
"crypto/hmac"
"crypto/sha256"
"fmt"
"io"
)
func main() {
@slv922
slv922 / list_all_files_in_folder.py
Created February 23, 2018 08:42
recursively get a list of all the files in a directory
#!/usr/bin/python
import glob
import os
import sys
SRC = sys.argv[1]
@slv922
slv922 / gist:d47853e241b8505a36d6a870ca265aef
Last active December 20, 2017 11:25
Golang Cross-compile
# 编译到 linux 64bit
$ GOOS=linux GOARCH=amd64 go build
# 或者可以使用 -o 选项指定生成二进制文件名字
$ GOOS=linux GOARCH=amd64 go build -o app.linux
# 编译到 linux 32bit
$ GOOS=linux GOARCH=386 go build
# 编译到 windows 64bit
@slv922
slv922 / http_get_request.go
Created August 29, 2017 16:32
golang http post request
package main
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
"net/url"
)
@slv922
slv922 / mv_file_to_folder.py
Last active April 27, 2017 09:55
搬移某目錄中的大量檔案到多個目錄並控制每個目錄中的檔案數量
from glob import glob
import os
filelist=glob('MSGS/00/*')
# folder number
for i in range(900):
#os.system("mkdir %03d" %i)
print("mkdir %03d" %i)
#file number in folder
@slv922
slv922 / install-c9-on-centos.md
Created March 15, 2017 16:04 — forked from gbraad/install-c9-on-centos.md
Install C9 on CentOS

Install C9 on CentOS as SSH remote workspace

To setup a SSH remote workspace for C9 on CentOS do the following on the host:

yum install git
git clone https://github.com/c9/core.git /opt/c9sdk
yum groupinstall "Development Tools"
yum install glibc-static
@slv922
slv922 / send-msg.pl
Created March 13, 2017 06:54
Send Message to Slack Channel with curl by perl
#!/usr/bin/perl
$token = "your token";
$text = "test";
$cmd = "curl -F channel=#test -F token=\'$token\' -F text=\'$text\' -k https://slack.com/api/chat.postMessage";
system($cmd);
@slv922
slv922 / walk_path.py
Last active March 15, 2017 16:05
Recurcive read files from path
import os
import sys
walk_dir = sys.argv[1]
print('walk_dir = ' + walk_dir)
# If your current working directory may change during script execution, it's recommended to
# immediately convert program arguments to an absolute path. Then the variable root below will
# be an absolute path as well. Example:
@slv922
slv922 / send-message.py
Last active January 2, 2023 18:53 — forked from sosukeinu/send-message.py
PYTHON send E-mail from eml file endswith 'eml' recursively
#!/usr/bin/env python
# -*- mode: python; coding: utf-8-unix -*-
import sys
import os.path
import smtplib
import gzip
import re
from email.utils import make_msgid
from datetime import datetime