Skip to content

Instantly share code, notes, and snippets.

View longkai's full-sized avatar
🎯
Focusing

kennylong longkai

🎯
Focusing
View GitHub Profile
@longkai
longkai / k8s-install-docker.sh
Last active January 13, 2020 18:42
single node docker/Kubernetes setup script, enjoy!
#!/bin/bash
sudo apt-get update
sudo apt-get install -y \
vim \
tmux \
zsh \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
@longkai
longkai / docker-pull.sh
Last active January 20, 2020 11:22
pull a docker image from a mirror source
#!/bin/bash
repo=azk8s.cn
function rip() {
echo $1 | awk -F '/' '{
{
if (NF == 1)
print "dockerhub." repo "/library/" $0
else if ($1 == "docker.io")
print "dockerhub." repo "/" substr($0, length($1)+2, length($0)-length($1))
@longkai
longkai / Dockerfile
Last active April 17, 2018 19:51
shadowsocks-libev with simple obfs in a single docker image
#
# Dockerfile for shadowsocks-libev
#
FROM alpine
MAINTAINER longkai <i@xiaolongtongxue.com>
ENV SERVER_ADDR 0.0.0.0
ENV SERVER_PORT 8388
ENV PASSWORD=
@longkai
longkai / stack.c
Last active December 11, 2016 05:22
A simple dynamic stack written in C.
#include <stdio.h>
#include "stack.h"
#define STACK_SIZE 5 // or larger, e.g. 1024 ptrs
#define PTR_SIZE sizeof(uintptr_t)
static void err_sys(const char *msg);
void stack_init(Stack *s) {
@longkai
longkai / gocp.sh
Created September 8, 2016 18:03
A simple golang cross compile script
#!/bin/sh
# A simple golang(go 1.5+) cross compile script.
# Usage `gocp.sh [os] [version]`, default OS linux/mac/freebsd/window 64 binary with bzip2 format or zip(only windows) compression format with `latest` version.
# output pattern `os-arch-version.tar.bz2` or `os-arch-version.zip`
name=${PWD##*/}
v=$2
@longkai
longkai / intellij-keymap-mac.md
Last active August 18, 2016 13:29
Relearning Intellij keymap for mac only

Intellij Keymap

Eidting

key decription
⇧ F1 External Doc(not work for all source)
⌘ F1 Show descriptions of error or warning at caret
⌘ N Generate code...
^ O Override methods
^ I Implement methods
package com.xiaolongtongxue.vp1;
import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;
/**
* A customized view pager which listens when user is interacting with itself.
*/
@longkai
longkai / QuickReturnRecyclerOnScrollListener.java
Created April 23, 2015 13:01
A simple RecyclerView scrolling tricks.
/*
* The MIT License (MIT)
*
* Copyright (c) 2015 longkai
*
* The software shall be used for good, not evil.
*/
package android.support.animation;
@longkai
longkai / LineThroughTextView.java
Created March 28, 2015 09:53
A simple line through text view. ie. ----------------- Hello, World --------------
/*
* The MIT License (MIT)
*
* Copyright (c) 2015 longkai
*
* The software shall be used for good, not evil.
*/
package android.support.widget;
@longkai
longkai / LogoView.java
Created March 28, 2015 09:50
A logo view with an isosceles triangle. To use it, provide you distinct angle and the largest edge.
/*
* The MIT License (MIT)
*
* Copyright (c) 2015 longkai
*
* The software shall be used for good, not evil.
*/
package android.support.widget;