Skip to content

Instantly share code, notes, and snippets.

View fatelei's full-sized avatar
:octocat:
Focusing

wangxiaolei fatelei

:octocat:
Focusing
View GitHub Profile
git config --global http.https://github.com.proxy socks5://127.0.0.1:7890

在 $HOME/.ssh/config 新增如下配置

Host github.com
 Hostname ssh.github.com
 User your username
import (
"encoding/binary"
"net"
)
func IpToUint32(addr string) uint32 {
ip := net.ParseIP(addr)
return binary.BigEndian.Uint32(ip.To4())
}

Problem

The go command line tool needs to be able to fetch dependencies from your private GitLab, but authenticaiton is required.

This assumes your private GitLab is hosted at privategitlab.company.com.

Environment variables

The following environment variables are recommended:

export GO111MODULE=on
export GOPRIVATE=privategitlab.company.com
from datetime import datetime
def start_of_day():
now = datetime.today()
return datetime(year=now.year, month=now.month, day=now.day, hour=0, minute=0, second=0)
def end_of_day():
now = datetime.today()
return datetime(year=now.year, month=now.month, day=now.day, hour=23, minute=59, second=59)
@fatelei
fatelei / webpack.common.js
Last active August 28, 2019 08:03
webpack config for typescript project
const path = require('path');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: {
app: path.resolve(__dirname, '../src/index.tsx'),
},
resolve: {
[Unit]
Description=sonic server
[Service]
Type=simple
PIDFile=/var/run/sonic/sonic.pid
ExecStart=/usr/bin/sonic -c /etc/sonic.cfg
ExecReload=cat /var/run/sonic/sonic.pid | xargs kill && /usr/bin/sonic -c /etc/sonic.cfg
ExecStop=cat /var/run/sonic/sonic.pid | xargs kill
@fatelei
fatelei / linkify.js
Last active June 11, 2019 01:32
Using linkify-it to auto link content.
import * as LinkifyIt from 'linkify-it';
import * as React from 'react';
import * as tlds from 'tlds';
/* Pass tests
describe('linkify work as expected', () => {
let rst: React.ReactNode[] = [];
it('linkify empty content', () => {
rst = linkify('');
expect(rst[0]).toBe('');
[program:es_exporter]
command = /path/elasticsearch_exporter-1.0.1.linux-amd64/elasticsearch_exporter -es.all false
autostart = false
stdout_logfile_backups = 0
stderr_logfile_backups = 0
stderr_logfile = /data/log/supervisor/%(program_name)s.stderr.log
stdout_logfile = /data/log/supervisor/%(program_name)s.stdout.log
{
"Working Directory" : "\/Users\/wanglei",
"Prompt Before Closing 2" : 2,
"Selected Text Color" : {
"Green Component" : 0.3566595613956451,
"Red Component" : 0.2767199277877808,
"Blue Component" : 0.3829848766326904
},
"Rows" : 25,
"Ansi 11 Color" : {
# -*- coding: utf8 -*-
import argparse
import csv
INSERT_SQL_TPL = 'insert into {table} {columns} values {values!r};\n'
def generate_sql(table, csv_file):
data = []
with open(csv_file, 'rb') as f: