Skip to content

Instantly share code, notes, and snippets.

Avatar
🤷‍♂️
how to exit vim

h2O codcodog

🤷‍♂️
how to exit vim
  • ShenZhen, China
View GitHub Profile
@codcodog
codcodog / lock-for-cron.sh
Created May 19, 2021
crontab 防止重复执行
View lock-for-cron.sh
0 23 * * * (flock -xn ./test.lock -c "sh /root/test.sh")
@codcodog
codcodog / big-file.sh
Last active Apr 26, 2021
大文件生成
View big-file.sh
# 生成 500M 大小的文件
dd if=/dev/zero of=test bs=1M count=500
View json-format.vim
:%!python -m json.tool
@codcodog
codcodog / sql_dump.sh
Last active May 5, 2021
mysqldump 导出数据库表结构
View sql_dump.sh
# 只导出表结构
mysqldump -uroot -p -d DB_NAME | sed 's/ AUTO_INCREMENT=[0-9]*//g' > FILENAME.sql
# 导出表结构和数据
mysqldump -uroot -p DB_NAME > FILENAME.sql
@codcodog
codcodog / bias.py
Created Nov 13, 2020
bias calculate
View bias.py
#!/usr/bin/env python
import sys
avg_price = float(sys.argv[1])
new_price = float(sys.argv[2])
bias = float(sys.argv[3])
unit = (new_price - avg_price) / bias
View upload_image.go
import (
"image"
_ "image/gif"
_ "image/jpeg"
_ "image/png"
)
// 注意,需要 import 图片格式的包,要不 decodeConfig 会报 image: unknown format
func uploadOpcategoryImage(c *bm.Context) {
websiteID := middlewares.GetCurrentWebsiteID(c)
if websiteID == 0 {
@codcodog
codcodog / uploadImage.go
Created Aug 25, 2020
golang 上传图片
View uploadImage.go
// 上传图片
func UploadImage(websiteID uint64, name string, file io.Reader, uploadCdn bool) (uint64, string, error) {
url, err := getImageUrl()
if err != nil {
return 0, "", err
}
var isLocal uint64
if uploadCdn {
isLocal = 0
@codcodog
codcodog / curl.md
Created Aug 6, 2020 — forked from subfuzion/curl.md
curl POST examples
View curl.md

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@codcodog
codcodog / created_updated.sql
Last active Jun 30, 2020
Mysql created_at updated_at 字段定义
View created_updated.sql
CREATE TABLE demo (
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@codcodog
codcodog / url.php
Created Apr 28, 2020
PHP get, post 请求实例
View url.php
<?php
namespace common\helper;
class Url
{
static function get($url, $params, $timeout = 30){
$url = $url.'?'.self::makeQueryString($params);