Skip to content

Instantly share code, notes, and snippets.

View RavenZZ's full-sized avatar
🎯
Focusing

Raven RavenZZ

🎯
Focusing
View GitHub Profile
@RavenZZ
RavenZZ / .md
Last active April 27, 2018 07:46
CentOS firewall 命令

CentOS 防火墙

Centos 7 firewall 命令:

查看已经开放的端口:

firewall-cmd --list-ports
echo $@
if [[ $@ != *"monitor"* ]] ; then # 没有monitor参数
echo "执行cp"
else
echo "不执行"
fi
@RavenZZ
RavenZZ / postgres cheatsheet.md
Created April 3, 2018 05:37
postgres cheatsheet

Postgres Cheatsheet

This is a collection of the most common commands I run while administering Postgres databases. The variables shown between the open and closed tags, "<" and ">", should be replaced with a name you choose. Postgres has multiple shortcut functions, starting with a forward slash, "". Any SQL command that is not a shortcut, must end with a semicolon, ";". You can use the keyboard UP and DOWN keys to scroll the history of previous commands you've run.

Setup

installation, Ubuntu

http://www.postgresql.org/download/linux/ubuntu/ https://help.ubuntu.com/community/PostgreSQL

@RavenZZ
RavenZZ / main.go
Created April 3, 2018 05:37
A binary search is a search strategy used to find elements within a list by consistently reducing the amount of data to be searched and thereby increasing the rate at which the search term is found. To use a binary search algorithm, the list to be op
// Binary Search in Golang
package main
import "fmt"
func binarySearch(needle int, haystack []int) bool {
low := 0
high := len(haystack) - 1
for low <= high{
@RavenZZ
RavenZZ / main.go
Created April 3, 2018 05:37
This technique pass over the list of elements, by using the index to move from the beginning of the list to the end. Each element is examined and if it does not match the search item, the next item is examined. By hopping from one item to its next, t
// Linear Search in Golang
package main
import "fmt"
func linearsearch(datalist []int, key int) bool {
for _, item := range datalist {
if item == key {
return true
}
@RavenZZ
RavenZZ / main.go
Created April 3, 2018 05:37
The Interpolation Search is an improvement over Binary Search for instances, where the values in a sorted array are uniformly distributed. Binary Search always goes to middle element to check. On the other hand interpolation search may go to differen
// Interpolation Search in Golang
package main
import "fmt"
func interpolationSearch(array []int, key int) int {
min, max := array[0], array[len(array)-1]
low, high := 0, len(array)-1
package main
import (
"fmt"
"log"
"regexp"
)
func main() {

Docker Registries & Repositories

Login to a Registry

docker login
docker login localhost:8080

Logout from a Registry

@RavenZZ
RavenZZ / .conf
Created April 3, 2018 05:36
combine two request by openresty
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
@RavenZZ
RavenZZ / nginx.conf
Created April 3, 2018 05:35
Full request/response body logging in nginx
http {
log_format bodylog '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" $request_time '
'<"$request_body" >"$resp_body"';
lua_need_request_body on;
set $resp_body "";
body_filter_by_lua '