Skip to content

Instantly share code, notes, and snippets.

View pokk's full-sized avatar
🌀

Jieyi pokk

🌀
View GitHub Profile
@pokk
pokk / Mackito.md
Last active April 5, 2017 02:41
Android unit test

[TOC]

Mockito

Generating a kind of virtual object for verifying the method reacting output which fits our expecting.

Concept

  1. Verifying the using status of a assignment object's method and how many times was executed, and what's the parameters, etc.

[TOC]

Introduction

Optimize the Android's memory usage by using SparseArray and ArrayMap to instead of HashMap.

HashMap

HashMap's default capacity is 16 for keeping the data. Inside of the data struct we will explain as below.

@pokk
pokk / README.md
Last active April 5, 2017 02:37
How to implement callback method

[TOC]

Introduction

How to implement a callback method.

Callback's callbacker

public class SubClass {
<!-- 允許應用訪問精確(如GPS)性的定位 -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- 允許應訪問額外的提供定位的指令 -->
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<!-- 允許應用創建用於測試的模擬定位提供者 -->
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<!-- 允許應用訪問網絡上的信息 -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- 允許應用使用低版本視圖的特徵 -->
<uses-permission android:name="android.permission.ACCESS_SURFACE_FLINGER" />
@pokk
pokk / README.md
Created March 31, 2017 07:49
Click a button and copy the content

Introduction

Click a button and copy the assigned textarea or input's content to clipboard.

Html

<input type="text" id="copy_target" value="Text to Copy">
<button id="copy_button">Copy</button>
@pokk
pokk / README.md
Last active April 4, 2017 09:49
Show raw html data into HTML

Introduction

Show raw HTML data and ruby variable.

Front xxx.html.erb

Concat

concat this key word is the same as echo in PHP.

@pokk
pokk / README.md
Created April 21, 2017 09:44
Add the html loading ready in Javascript

Introduction

Add the html loading ready in Javascript.

Javascript

There is a standards based replacement,DOMContentLoaded that is supported by over 98% of browsers, though not IE8.

@pokk
pokk / README.md
Created May 7, 2017 05:56
Splash View for avoiding the cold start app

[TOC]

Introduction

The app will show white screen or black screen each time when you cold start the app. For UX or UI, this is not good user experenice.

For that, we will fix knid of small problem with the splash view.

How to do

@pokk
pokk / README.md
Created May 11, 2017 10:13
Android run on the new thread.

Introduction

Thread category in Android.

Java

  • Thread
  • Handler
  • AsyncTask
  • IntentService
@pokk
pokk / README.md
Created May 16, 2017 01:34
Create array from 0 to N-1 in Javascript

Introduction

In Javascript to create an array of number from 0 to n-1, we can use spread operator. It is part of ECMAScript (version 6). Currently IE does not have good support for it. It can be used in node scripts safely though.

array of number from 0 to n-1

We can use array of empty values and keys function. Note that Array(10) generates array of empty values of size 10.

var arr = [...Array(10).keys()]