Skip to content

Instantly share code, notes, and snippets.

@xinhangliu
xinhangliu / .slate
Created April 26, 2018 08:49
Slate configuration
# Config
config menuBarIconHidden true
# Prefix keys
alias POS shift;alt # Prefix for positions
alias MOV ctrl;alt # Prefix for movement
alias FOC ctrl;cmd # Prefix for Focus window
alias MIS ctrl;alt;cmd # Prefix for miscs
bind esc:${MIS} relaunch
#! /bin/sh
# Check network
[ -f /tmp/old_wan_ip ] || touch /tmp/old_wan_ip
timeout 10 ping -c 3 baidu.com > /dev/null 2>&1
if [[ $? != 0 ]]; then
echo "Network error"
# echo "network error" > /tmp/old_wan_ip
exit 0
fi
#!/bin/bash
ARGUMENTS=()
function parse() {
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
# Parse -a or --argument [value]
-a | --argument)
shift
#!/bin/bash
LOG_FILE=''
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NORMAL='\033[0m'
function logger() {
#! /bin/bash
DOC="""
DESCRIPTION
Function for answering yes or no.
AEGUMENTS
-m, --message {string} message for display
-r, --retry {int}(3) times for retry
-d, --default {string}<y|n>() default option
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Date : 20180209
# @Author : xinhangliu <xhliume@gmail.com>
# @Version : 1.0.0
def pagination(total, current, lspace, rspace, spacer='...'):
res = []
res.append(1) # Append page 1
start = current - lspace