Skip to content

Instantly share code, notes, and snippets.

View suncle1993's full-sized avatar
🎯
Focusing

Suncle Chen suncle1993

🎯
Focusing
View GitHub Profile
@suncle1993
suncle1993 / getTimeOClock.py
Created December 13, 2017 07:35
1、获取当天0点的时间戳 2、获取指定时间戳所在天0点的时间戳
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import re
import datetime
import os
import time
@suncle1993
suncle1993 / wordpress_post.py
Created December 13, 2017 07:50
使用python和wordpress_xmlrpc发布wordpress带特征图片的文章
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import re
import datetime
import os
import time
@suncle1993
suncle1993 / print_server.go
Created August 30, 2018 07:43
go csp channel print_server
package main
import (
"fmt"
"time"
)
func main() {
c := make(chan string)
go print(c)
@suncle1993
suncle1993 / print_server.erl
Created August 30, 2018 07:43
erlang print_server
%%%-------------------------------------------------------------------
%%% @author Suncle
%%% @doc
%%% print_server
%%% @end
%%% Created : 2017/12/18 14:53
%%%-------------------------------------------------------------------
-module(print_server).
-author("Suncle").
@suncle1993
suncle1993 / bank.erl
Created August 30, 2018 07:45
erlang bank example
-module(bank).
-export([start/1,
init/1,
withdraw/1, %% 取款
deposit/1, %% 存款
print/0 %% 打印帐号信息
]).
start(Money) ->
%% spawn,开启进程,并注册进程名为当前模块名
erlang:spawn(?MODULE,init,[Money]).
@suncle1993
suncle1993 / bank_account.erl
Last active September 20, 2020 15:18
erlang gen_server bank_account
%%%-------------------------------------------------------------------
%%% @author Suncle
%%% @copyright (C) 2017, <COMPANY>
%%% @doc
%%% @end
%%% Created : 13. 十一月 2017 17:19
%%%-------------------------------------------------------------------
-module(bank_account).
-author("Suncle").
-behaviour(gen_server).
@suncle1993
suncle1993 / pre-commit
Created October 23, 2020 08:08
git禁止在master上commit
#!/bin/bash
protected_branch='master'
current_branch=$(git rev-parse --symbolic --abbrev-ref HEAD)
if [ "$protected_branch" == "$current_branch" ]; then
echo "git hooks: Do not commit to $current_branch branch"
exit 1
fi
@suncle1993
suncle1993 / pre-push
Created October 23, 2020 08:09
git 禁止在master上push
#!/bin/bash
protected_branch='master'
remote_branch_prefix="refs/heads/"
protected_remote_branch=$remote_branch_prefix$protected_branch
while read local_ref local_sha remote_ref remote_sha
do
if [ "$protected_remote_branch" == "$remote_ref" ]; then
echo " git hooks: Do not commit to $protected_branch branch"
@suncle1993
suncle1993 / forbid-master.sh
Created October 23, 2020 08:10
一键配置在master上禁止commit和push操作
#!/usr/bin/env bash
set -e
MIN_GIT_VERSION="2.9"
HOOKS_DIR="$HOME/.git-hooks"
function checkGitVersion() {
# check if git is installed
if ! command -v git &>/dev/null; then
echo "git could not be found"
@suncle1993
suncle1993 / .golangci.yml
Created October 15, 2021 03:38
golang ci config example
# options for analysis running
run:
# timeout for analysis, e.g. 30s, 5m, default is 1m
timeout: 5m
# which dirs to skip: issues from them won't be reported;
# can use regexp here: generated.*, regexp is applied on full path;
# default value is empty list, but default dirs are skipped independently
# from this option's value (see skip-dirs-use-default).