Skip to content

Instantly share code, notes, and snippets.

@douo
douo / capitalizeWord.groovy
Created August 19, 2016 15:59
IntelliJ LivePlugin script:将当前单词或下一个单词转换为首字母大写
import com.intellij.openapi.actionSystem.AnActionEvent
import static liveplugin.PluginUtil.*
/**
* 将当前单词或下一个单词转换为首字母大写
*/
registerAction("Capitalize Word", "alt C") { AnActionEvent event ->
runDocumentWriteAction(event.project) {
currentEditorIn(event.project).with {
@douo
douo / HierarchyFragmentPagerAdapter.java
Created July 26, 2016 14:11
可嵌套使用的 FragmentPagerAdapter 主要修复 FragmentPagerAdapter 处理 {@link Fragment#setMenuVisibility(boolean)} 的 bug
/*
* Copyright (C) 2011 The Android Open Source 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
*
* Unless required by applicable law or agreed to in writing, software
@douo
douo / Vagrantfile
Created March 5, 2016 06:20
Vagrantfile for my ruhoh writing system
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
@douo
douo / FloatingActionMenu.java
Created June 23, 2015 08:01
FloatingActionMenu build by android support FloatingActionButton
package com.diaoser.tmr.view;
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
@douo
douo / build.gradle
Last active October 25, 2017 15:00
Android 项目打包成 maven 工件,并发布到 jcenter
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
version = "" // 项目的版本名
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
@douo
douo / chinese_id.rb
Last active September 27, 2018 17:48
Chinese ID card number checksum
module ChineseId
WEIGHT = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
CODE = ["1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2"]
#S = Sum(Ai * Wi)
#Y = mod(S, 11)
#C = Cy
def self.checksum id
@douo
douo / Data.java
Last active March 8, 2017 02:36
一个实现 Recycle 机制的例子
/**
* Created by Tiou on 2014/7/15.
* 一个实现 Recycle 机制的对象
*/
public class Data {
/**
* 对象池,就是上文所提到的对象仓库,用于暂时存放不用的对象。
* 用链表来实现对象池结构,直观,高效,易用。
* sPool 便是指向链表头部的引用
*/
@douo
douo / .gitignore
Created March 8, 2014 07:59
.gitignore for android developer
# Mac
.DS_Store
# Android Studio
.idea/
.gradle
/*/local.properties
/*/out
/*/*/build
/*/*/production
public abstract class BaseActivity extends SherlockFragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mCommit = new LinkedList<FragmentTransaction>();
mStateSaved = false;
}
@Override
@douo
douo / aivia.py
Created September 2, 2013 08:04
auto-increment-version-code-in-android-app
#!/bin/python
#auto-increment-version-code-in-android-app
import re
def readManifest():
f = file('AndroidManifest.xml')
entry = f.read();
f.close();
return entry;