Skip to content

Instantly share code, notes, and snippets.

View pokk's full-sized avatar
🌀

Jieyi pokk

🌀
View GitHub Profile
@pokk
pokk / README.md
Created July 3, 2017 06:23
a Block, a Proc, a Lambda, and map class shorthand

[TOC]

Interduction

Using block, proc, lambda or shorthand for devleoping easily. We don't need to code so many words and coding style is elegant.

Map class shorthand

We're often using the simplest way to code a map lambda method. A well-known example:

@pokk
pokk / README.md
Last active July 1, 2017 04:13
Using one pic to simulate a clicking button

Interduction

How to do

First way

First step

@pokk
pokk / README.md
Created May 29, 2017 09:09
Awaring a view is on measured or drawed by ViewTreeObserver

Introduction

If you can control your view size, for example as loading an imageview. You observe it then you can get the view size after the image is downloaded. You don't have to worry about when it is drawed and measured.

Example

OnCreate()

In Kotlin code:

@pokk
pokk / README.md
Created May 23, 2017 15:44
Make Mac speed up by using Ramdisk

Introduction

Script

We have this script for creating a ramdisk.

  • $((5x100x2048x2x__4__)) = 4096MB

You can change the number with bold and itan. Basic is 1024 * N size.

@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()]
@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 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 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
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 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>