Skip to content

Instantly share code, notes, and snippets.

@beta
beta / 7file.sh
Last active August 29, 2015 14:10
7file - a simple file manager in (BSD) bash
#!/bin/bash
# 输出分隔符
function separator () {
echo '-------------------------------------------------------------------------------'
}
# 输出当前目录中的文件列表
function show_files () {
count=0
@beta
beta / main.c
Created April 2, 2015 07:04
My operating system lesson homework - a simple Unix shell with history feature
//
// main.c
// Shell
//
// Created by Bitex Kuang on 4/2/15.
// Copyright (c) 2015 Bitex. All rights reserved.
//
#include <stdio.h>
#include <unistd.h>
@beta
beta / client.py
Created April 12, 2015 05:56
Homework of my Python lesson, a half-duplex server-client chatting program
#!/usr/bin/env python
import socket
import time
BUFFSIZE = 1024
NS_HOST = 'localhost'
NS_PORT = 53333
@beta
beta / Android.mk
Last active March 13, 2016 05:16
Codes for blog "Using Native OpenCV Code in Android Projects"
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
OPENCV_INSTALL_MODULES:=on
OPENCV_CAMERA_MODULES:=on
OPENCV_LIB_TYPE := STATIC
include $(LOCAL_PATH)/OpenCV.mk
@beta
beta / com_example_yourapp_CvUtil.h
Last active March 13, 2016 06:43
Codes for blog "Using Native OpenCV Code in Android Projects"
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class com_example_yourapp_CvUtil */
#ifndef _Included_com_example_yourapp_CvUtil
#define _Included_com_example_yourapp_CvUtil
#ifdef __cplusplus
extern "C" {
#endif
/*
@beta
beta / CvUtil.java
Last active March 13, 2016 07:37
Codes for blog "Using Native OpenCV Code in Android Projects"
package com.example.yourapp;
import android.util.Log;
import org.opencv.android.OpenCVLoader;
import org.opencv.core.Mat;
import java.util.ArrayList;
public class CvUtil {
@beta
beta / weibo-better-layout.css
Last active March 22, 2016 05:59
Custom CSS for Sina Weibo
body {
font-family: "Helvetica Neue", Helvetica, "Nimbus Sans L", Arial, "Liberation Sans", "PingFang SC", "Hiragino Sans GB", "Source Han Sans CN", "Source Han Sans SC", "Microsoft YaHei", "Wenquanyi Micro Hei", "WenQuanYi Zen Hei", "ST Heiti", SimHei, "WenQuanYi Zen Hei Sharp", sans-serif;
}
.WB_feed_detail {
padding: 0px;
}
.WB_feed_detail .WB_screen {
margin-right: 20px;
@beta
beta / areas.xml
Created May 27, 2016 06:40
XML for provinces & cities of China
<?xml version="1.0" encoding="utf-8"?>
<provinces>
<province name="北京市">
<city>东城区</city>
<city>西城区</city>
<city>朝阳区</city>
<city>丰台区</city>
<city>石景山区</city>
<city>海淀区</city>
<city>门头沟区</city>
@beta
beta / MainActivity.java
Last active August 2, 2016 06:51
Switching fragments
// Blablabla
/**
* Loads and switches to a new fragment.
* If a fragment with {@code tag} has already been loaded and was detached from the container,
* this method will detach the current fragment and reattach the fragment back again, instead
* of creating a new instance of the target fragment.
*
* @param cls {@code Class} of the new fragment
* @param tag a tag to identify a fragment
@beta
beta / BottomSheetDialog.java
Last active August 18, 2016 08:01
android/support/design/widget/BottomSheetDialog.java of Android Design Support Library 23.4.0
private View wrapInBottomSheet(int layoutResId, View view, ViewGroup.LayoutParams params) {
final CoordinatorLayout coordinator = (CoordinatorLayout) View.inflate(getContext(),
R.layout.design_bottom_sheet_dialog, null);
if (layoutResId != 0 && view == null) {
view = getLayoutInflater().inflate(layoutResId, coordinator, false);
}
FrameLayout bottomSheet = (FrameLayout) coordinator.findViewById(R.id.design_bottom_sheet);
BottomSheetBehavior.from(bottomSheet).setBottomSheetCallback(mBottomSheetCallback);
if (params == null) {
bottomSheet.addView(view);