Skip to content

Instantly share code, notes, and snippets.

View dcb9's full-sized avatar

Du, Chengbin dcb9

View GitHub Profile
@dcb9
dcb9 / ANSI.md
Created July 5, 2023 15:27 — forked from fnky/ANSI.md
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@dcb9
dcb9 / aes_encryption.go
Created May 22, 2019 01:31 — forked from stupidbodo/aes_encryption.go
AES Encryption Example in Golang
// Playbook - http://play.golang.org/p/3wFl4lacjX
package main
import (
"bytes"
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"encoding/base64"
@dcb9
dcb9 / entrypoint.sh
Created August 15, 2018 10:44 — forked from nurrony/entrypoint.sh
Shell init for docker container with signal handling
# Uncomment to print commands being executed
# set -x
pid=0
# SIGTERM-handler
term_handler() {
echo "Handler INT";
if [ $pid -ne 0 ]; then
kill -SIGTERM "$pid"
wait "$pid"
@dcb9
dcb9 / tmux-cheatsheet.markdown
Created August 3, 2018 15:56 — forked from ryerh/tmux-cheatsheet.markdown
Tmux 快捷键 & 速查表

Tmux 快捷键 & 速查表

启动新会话:

tmux [new -s 会话名 -n 窗口名]

恢复会话:

tmux at [-t 会话名]
@dcb9
dcb9 / lambda-basic-auth.js
Created May 30, 2018 10:58 — forked from lmakarov/lambda-basic-auth.js
Basic HTTP Authentication for CloudFront with Lambda@Edge
'use strict';
exports.handler = (event, context, callback) => {
// Get request and request headers
const request = event.Records[0].cf.request;
const headers = request.headers;
// Configure authentication
const authUser = 'user';
const authPass = 'pass';
@dcb9
dcb9 / http-status-codes.md
Created November 1, 2017 07:53 — forked from subfuzion/http-status-codes.md
General REST API HTTP Status Codes

Reference: RFC 2616 - HTTP Status Code Definitions

General

  • 400 BAD REQUEST: The request was invalid or cannot be otherwise served. An accompanying error message will explain further. For security reasons, requests without authentication are considered invalid and will yield this response.
  • 401 UNAUTHORIZED: The authentication credentials are missing, or if supplied are not valid or not sufficient to access the resource.
  • 403 FORBIDDEN: The request has been refused. See the accompanying message for the specific reason (most likely for exceeding rate limit).
  • 404 NOT FOUND: The URI requested is invalid or the resource requested does not exists.
  • 406 NOT ACCEPTABLE: The request specified an invalid format.
@dcb9
dcb9 / README.md
Created March 14, 2016 23:20 — forked from cornernote/README.md
How to use PsySH with a Yii2 application

Using PsySH (GitHub) as the Yii2 shell

  • Issue the following commands from the command line in your Yii application directory:
    • chmod +x psyii
    • mkdir extensions/yiishell
    • wget -O extensions/yiishell/psysh psysh.org/psysh
    • chmod +x extensions/yiishell/psysh
  • Copy the file init.php below to psysh/init.php and update any paths to work with your application configuration
  • Copy the file config.php below to psysh/config.php. Change or add to the config array with the options you'd like to use (available options)
  • Now you can start PsySH with the command ./psyii psysh/init.php --config psysh/config.php
@dcb9
dcb9 / zsh.md
Created January 29, 2016 06:45 — forked from tsabat/zsh.md
Getting oh-my-zsh to work in Ubuntu
@dcb9
dcb9 / Readme.md
Created October 28, 2015 14:58 — forked from jaymecd/Readme.md
ngrok self-hosting
安装zsh
brew install zsh
设置zsh为默认shell
mate /etc/shells
在文末增加:
/usr/local/bin/zsh
将zsh设置为默认的Shell: