Skip to content

Instantly share code, notes, and snippets.

@rainyear
rainyear / vimrc
Created March 28, 2015 04:48
Vim as Golang IDE
" 设置显示行号
set number
" 开启语法高亮功能
syntax enable
" 允许用指定语法高亮配色方案替换默认方案
syntax on
" 自适应不同语言的智能缩进
filetype indent on
" 将制表符扩展为空格
@rainyear
rainyear / show_bytes.c
Created July 20, 2014 15:25
Show bytes and check which endian the machine is.
#include <stdio.h>
typedef unsigned char* byte_ptr;
void show_bytes(byte_ptr start, int len){
for(int i = 0; i < len; i++)
printf("\t%.2x", start[i]);
printf("\n");
}
int main(){
@rainyear
rainyear / tmux.conf
Created July 8, 2014 02:44
tmux config file.
set -g prefix ^a
unbind ^b
bind a send-prefix
unbind '"'
bind - splitw -v -c "#{pane_current_path}"# 分割成上下两个窗口
unbind %
bind = splitw -h -c "#{pane_current_path}"# 分割成左右两个窗口
bind c new-window -c "#{pane_current_path}"
WebView webView = new WebView(this);
webView.getSettings().setJavaScriptEnabled(true);
//this.setScrollBarStyle(SCROLLBARS_OUTSIDE_OVERLAY);
webView.loadUrl("http://www.google.com");
//webView.loadUrl("file:///android_asset/XX.html");
private void checkInput() {
input = (EditText) findViewById(R.id.passpwd);
input2 = (EditText) findViewById(R.id.passpwd2);
submit = (Button) findViewById(R.id.submit);
imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
// imm.showSoftInput(null, 0);
String url = "URL";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
AlertDialog.Builder info = new AlertDialog.Builder(this);
info.setTitle(getResources().getString(R.string.about_matters_txt).toString());
info.setMessage(getResources().getString(R.string.about_matters_txt_cont).toString());
info.setNegativeButton("隱藏", null);
AlertDialog showedInfo = info.show();
//DisplayMetrics metrics = getResources().getDisplayMetrics();
//showedInfo.getWindow().setGravity(Gravity.CENTER);
//showedInfo.getWindow().setLayout(LayoutParams.FILL_PARENT,
//(int) (metrics.heightPixels * 0.7));
@rainyear
rainyear / Android_Share_all.java
Last active August 29, 2015 14:01
Android Share to all codes
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, getResources().getString(R.string.WAHT_YOU_WANT_TO_SAY));
shareIntent.setType("text/plain");
startActivity(Intent.createChooser(shareIntent, "WHAT_YOU_WANT_DISPLAY"));
git rm -r --cached .
git add .
git commit -m "fixed untracked files"
@rainyear
rainyear / Mapwalk.py
Last active January 1, 2016 23:19
map a command(function) to all the files in current directory.
#!/usr/bin/env python
#-*- coding:utf-8 -*-
"""
Walking the destination directory(arg3) and using the command(arg2)
to process every file.
USAGE:
Mapwalk `function` /path/to/walk
"""
import sys