Skip to content

Instantly share code, notes, and snippets.

@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;
@douo
douo / RequestParams.java
Created August 15, 2013 03:42
Encoding Supported RequestParams
/*
Android Asynchronous Http Client
Copyright (c) 2011 James Smith <james@loopj.com>
http://loopj.com
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
# -*- coding: utf-8 -*-
require 'json'
str = '{"a":"string","b":12,"c":2.12,"d":9223372036854775807,"e":0.142318719237491324918231415143121324,"f":[1,3,4,5,6] }'
class JavaGenerator
def initialize(name, config={})
@name = name
@config = config