Skip to content

Instantly share code, notes, and snippets.

View bitristan's full-sized avatar
😀
happy coding everyday

Ting Sun bitristan

😀
happy coding everyday
View GitHub Profile
@bitristan
bitristan / minigrep.rs
Last active August 1, 2020 03:34
minigrep demo from rust book.
use std::env;
use std::process;
use std::fs;
use std::error::Error;
fn main() {
let args: Vec<String> = env::args().collect();
let config = Config::new(&args).unwrap_or_else(|err|{
println!("Problem parsing arguements: {}", err);
@bitristan
bitristan / ContactUtil.kt
Created July 31, 2020 03:17
读写通讯录
import android.app.Activity
import android.content.*
import android.database.Cursor
import android.provider.ContactsContract
import android.util.Log
object ContactUtil {
private const val TAG = "ContactUtil"
fun getContacts(context: Context): StringBuilder {
import android.media.AudioFormat
import android.media.AudioRecord
import android.media.MediaRecorder
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
import android.util.Log
import android.view.View
import android.widget.Button
import java.io.*
@bitristan
bitristan / jdk_alternative
Last active June 1, 2021 07:14
Add jdk version
1 #!/bin/bash
2
3 sudo update-alternatives --install /usr/bin/java java /home/sunting/tools/jdk1.8.0/bin/java 1070
4 sudo update-alternatives --install /usr/bin/javac javac /home/sunting/tools/jdk1.8.0/bin/javac 1070
5 sudo update-alternatives --install /usr/bin/jar jar /home/sunting/tools/jdk1.8.0/bin/jar 1070
6 sudo update-alternatives --install /usr/bin/javah javah /home/sunting/tools/jdk1.8.0/bin/javah 1070
7 sudo update-alternatives --install /usr/bin/javap javap /home/sunting/tools/jdk1.8.0/bin/javap 1070
@bitristan
bitristan / queue.py
Created April 10, 2020 05:41
八皇后问题
N = 8
def isVaild(path, dcolumn):
drow = len(path)
for row, column in enumerate(path):
if column + drow - row == dcolumn:
return False
if column - (drow - row) == dcolumn:
return False
return True
private static final String HTTP_END = "\r\n";
private static final String HTTP_START = "--";
private static final String HTTP_BOUNDARY = "*******";
private boolean uploadFileToServer(File file) {
if (file == null || !file.exists()) {
LogUtil.d(TAG, "file not exists, ignore upload.");
return true;
}
@bitristan
bitristan / repopick.py
Created December 11, 2019 07:15
download topics from gerrit.
#!/usr/bin/env python
#
# Copyright (C) 2013-15 The CyanogenMod Project
# (C) 2017 The LineageOS Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
package com.leaf.library;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.os.Build;
import android.support.annotation.ColorInt;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
@bitristan
bitristan / .vimrc
Created October 30, 2019 14:33
Vim config
imap fd <Esc>
@bitristan
bitristan / .ideavimrc
Last active May 17, 2020 14:35
Idea vim config.
let mapleader = "," " leader is comma
let localleader = "," " leader is comma
set tabstop=4 " number of visual spaces per TAB
set softtabstop=4 " number of spaces in tab when editing
set shiftwidth=4 " spaces in newline start
set expandtab " tabs are spaces
set number " show line numbers
set rnu " show relative line numbers
set showcmd " show command in bottom bar