Android(Java) 中的单例类的实现

单例模式(Singleton) 是我们常用的一种设计模式,通常用来保证在全局情况下总是能够拿到同样的一个类实例来实现相关的工作。
单例模式很常见,因此也有戏称:

单例的写法茴香豆的的写法还多。

Read more   1/26/2018 posted in  Android

Android MediaPlayer setData 0X8000000 error

This issue might be caused by ringtone permission, if using a custom ringtone or ringtone set by other apps, must ensure your app has storage permission, otherwise, you cannot setDataUri to MediaPlayer instance.

11/28/2017 posted in  Android

[Dive into Ruby] Ruby 中的方法、类与模块

介绍完了 Ruby 的语言基础与控制流,对于 Ruby 也算有了一个比较亲密的接触了,接下来是一些比较常用的面向对象(Object Oriented)的思想与方法。 这一部分与其它的面向对象语言比较的类似,但依然有很多地方有着鲜明的 Ruby 特色。

Read more   10/15/2017 posted in  编程语言

[Dive into Ruby] Ruby Control Flow 控制语句

[Dive into Ruby] Ruby 的介绍 主要介绍了 Ruby 的一些特性,[Dive into Ruby] Ruby Basic 变量、常量以及对象 则介绍了关于对象、变量常量的一些知识,这一篇将主要介绍 Ruby 中的程序控制语句,这一部分是每个编程语言的重点,因此会介绍的比较的详细,也会有一些小技巧。

Read more   10/8/2017 posted in  编程语言

[Dive into Ruby] Ruby Basic 变量、常量以及对象

上一篇博客主要介绍了一下 Ruby 的一些语法糖,以及作为脚本语言 Ruby 的优势所在。这一篇则开始正式介绍 Ruby 的基础语法,以及语言细节。由于 Ruby 是完全面向对象式的,因此,有 Java 基础的人能够很快的了解到 Ruby 的大部分特性,但是有一些是 Ruby 特有的,或者 Java 有而 Ruby 不支持的,这一部分会更加特别说明。

Read more   10/6/2017 posted in  编程语言

[Dive into Ruby] Ruby 的介绍

Ruby is

A dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write.

Read more   10/3/2017 posted in  编程语言

Keep three decimal places and throw the third if it's "0"

For example:

14.98812 -> 14.988
1.8731312 -> 1.873
2.33045 -> 2.33

Read more   8/10/2017 posted in  编程

Ruby Sample code of 2d Hash set

In fact, this can be a n dimension hash set code sample, actually I create a 3-d hash to construct some kind of data structure for API rendering, it's not so beautiful, but easy to work, and not cost so much.

Read more   7/22/2017 posted in  编程

Ruby on Rails + Mongodb + AngularJS develop environment setup

Before start, make sure that:
1. You are using macOS or Ubuntu 14.04(or higher)

  1. basic system tools like git are installed. If you are using macOS, make sure you have Xcode/ Xcode Tool Chain installed.
Read more   3/9/2017 posted in  编程

Some Mongodb problems and solutions

Recently I have encountered some problems during my internship. One of our server suddenly goes very very slow, when I try to ping the server, it's always 2000-5000. After checked everything I think may cause the problem and got no answer, I decided to reboot the server.

Read more   1/13/2017 posted in  Server