markdown 欢迎来到Cacher

以下是一些可帮助您开始构建代码段库的提示。

cacher_intro.md
# Getting Started with Cacher

<p align="center">
<img src="http://www.cacher.io/assets/intro-snippet-splash-a90755aca4db13aac1e5140e8d7c2a7c01d9b69a640e51b55093421dff432039.png" width="480" />
</p>


## Use snippets to quickly recall commands

Snippets are the most useful when you want to re-use a shell command or a specific code pattern. Here are a few we have in our library:
- "How to delete a git tag"
- "Nginx configuration for staging server"
- "Crash handler AWS Lambda function"

## Use snippets for customer service

Engineers are often second-line customer agents. Use Cacher to store snippets for performing common support tasks.

## Labels are your friend

Labels are a great way to organize your snippets. A good practice is to have one for every major product feature. We've created the first label for you - **Documentation**.

## Create or join a team to share knowledge

Teams allow you and your colleagues to build a shared knowledge base. Use [Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) to write beautifully formatted documentation. (This snippet itself is a Markdown file.)

## Use snippets for onboarding new team members

Let's face it. Having the new engineer decipher a 500 thousand-line codebase might not be an efficient use of her time. Use snippets as examples to help new members get up to speed fast.


markdown 在日期#js中领先零

在日期#js中领先零

zeroleading.js
var MyDate = new Date();
var MyDateString;

MyDate.setDate(MyDate.getDate() + 20);

MyDateString = ('0' + MyDate.getDate()).slice(-2) + '/'
             + ('0' + (MyDate.getMonth()+1)).slice(-2) + '/'
             + MyDate.getFullYear();
readme.md
EDIT:

To explain, .slice(-2) gives us the last two characters of the string.

So no matter what, we can add "0" to the day or month, and just ask for the last two since those are always the two we want.

So if the MyDate.getMonth() returns 9, it will be:

("0" + "9") // Giving us "09"
so adding .slice(-2) on that gives us the last two characters which is:

("0" + "9").slice(-2)
"09"
But if MyDate.getMonth() returns 10, it will be:

("0" + "10") // Giving us "010"
so adding .slice(-2) gives us the last two characters, or:

("0" + "10").slice(-2)
"10"

markdown Usuario Personalizado en Windows 10

Usuario Personalizado en Windows 10

Usuario Personalizado en Windows 10.md
## Crear Usuario Windows 10

> Para crear la carpeta de usuario con un nombre personalizado y que no lo tome del hotmail, hay que crear un cuenta sin conexión al formatear y luego iniciar sesión.

markdown Daftar ekstensi Visual Studio Code yang patut direkomendasikan dan sangat membantu optimalisasi workflow dalam menggunakan vscode sebagai Co

Daftar ekstensi Visual Studio Code yang patut direkomendasikan dan sangat membantu optimalisasi workflow dalam menggunakan vscode sebagai Code Editor ++

rekomendasi-ekstensi-visual-studio-code.md
# Daftar Ekstensi Visual Studio Code yang direkomendasikan
> Notes in Progress

![](https://i.imgur.com/2RUFl5V.jpg)

Ekstensi di visual studio code merupakan interface yang disediakan oleh pengembang vscode untuk menambahkan atau melakukan kostumasi fungsi untuk lebih sesuai dengan workflow masing-masing pengguna.
Interface tersebut dirancang dengan baik sehingga ikut mempopulerkan penggunaan vscode sebagai code editor baik untuk web developer maupun hardcore programmer.

### Cara install Ekstensi di Visual Studio Code

Dapat diinstal dengan beberapa cara diantaranya adalah:

- Melalui Command Input vscode yang dapat diakses melui shortcut <kbd>Cmd ⌘</kbd><kbd>shift</kbd></kbd><kbd>p</kbd>, masukkan perintah `ext install kode-ekstensi`
- Cara kedua melalui sidebar Extensions yang dapat dibuka langsung menggunakan <kbd>Cmd ⌘</kbd><kbd>shift</kbd></kbd><kbd>x</kbd>, masukkan kata kunci pencarian di input yang berada di atas dan kemudian pilih ekstensi yang ingin diinstall

### Rekomendasi Ekstensi untuk Web Design (UI) dan Web Programming

- [Prettier formatter for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)

### Rekomendasi Konfigurasi

markdown 欢迎来到Cacher

以下是一些可帮助您开始构建代码段库的提示。

cacher_intro.md
# Getting Started with Cacher

<p align="center">
<img src="http://www.cacher.io/assets/intro-snippet-splash-a90755aca4db13aac1e5140e8d7c2a7c01d9b69a640e51b55093421dff432039.png" width="480" />
</p>


## Use snippets to quickly recall commands

Snippets are the most useful when you want to re-use a shell command or a specific code pattern. Here are a few we have in our library:
- "How to delete a git tag"
- "Nginx configuration for staging server"
- "Crash handler AWS Lambda function"

## Use snippets for customer service

Engineers are often second-line customer agents. Use Cacher to store snippets for performing common support tasks.

## Labels are your friend

Labels are a great way to organize your snippets. A good practice is to have one for every major product feature. We've created the first label for you - **Documentation**.

## Create or join a team to share knowledge

Teams allow you and your colleagues to build a shared knowledge base. Use [Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) to write beautifully formatted documentation. (This snippet itself is a Markdown file.)

## Use snippets for onboarding new team members

Let's face it. Having the new engineer decipher a 500 thousand-line codebase might not be an efficient use of her time. Use snippets as examples to help new members get up to speed fast.


markdown 如何解决Rails(OSX)中的OpenSSL错误?

如何解决Rails(OSX)中的OpenSSL错误?

openssl.md
How this fix OpenSSL error in Rails (OSX)?

To be more specific, this errors:

```
OpenSSL::SSL::SSLError in XxxController#action
SSL_connect returned=1 errno=0 state=error: certificate verify failed
```

![](http://i.imgur.com/CM7d8AT.jpg)

**How to fix?**

If you need install [wget](http://brewformulas.org/Wget) first.

```
$ cd /usr/local/etc/openssl/certs/
$ wget https://curl.haxx.se/ca/cacert.pem
$ nano ~/.zshrc
```

Add this line into the `.zshrc` file:

```
export SSL_CERT_FILE=/usr/local/etc/openssl/certs/cacert.pem
```

And, run this command:

```
$ source ~/.zshrc
```

**Note**

If you don't have `.zshrc` file, use `.bash_profile` file. I'm using [Z Shell](https://en.wikipedia.org/wiki/Z_shell) - that's why I have `.zshrc` file.

markdown Menempatkan动作快捷方式在Visual Studio Code di工具栏中打开Finder App MacOS untuk langsung membuka文件夹yang diselect di dalam apli

Menempatkan动作快捷方式在Visual Studio Code di工具栏中打开Finder App MacOS untuk langsung membuka文件夹yang diselect di dalam aplikasi vscode

open-in-vscode-finder-toolbar-macos.md
# Open in Visual Studio Code Shortcut di Toolbar Finder App MacOS

> [https://gist.github.com/tajidyakub/12ad18a0f1a462be42f65a3f54b9f622](https://gist.github.com/tajidyakub/12ad18a0f1a462be42f65a3f54b9f622)

- Untuk membuka langsung folder terkait juga dapat dilakukan melalui Shell Extensions vscode 
- Pindah ke direktori target terlebih dahulu atau bisa langsung menjalankan perintah `code /path/target`

```
$ code /path/project/terkait/
$ cd /path/project/terkait/ && code .
```

- Untuk melakukan langsung dari Finder harus terlebih dahulu membuka terminal (Open New Terminal)
- Action tambahan untuk ditambahkan ke dalam sub menu services di dalam context menu dapat didefinisikan melalui fasilitas service melalui script tambahan yang dapat dibuat menggunakan automator
- Script yang sama dapat kita tarik ke toolbar Finder sekaligus diubah iconnya agar tidak menggunakan default

![](https://i.imgur.com/L2K2nt0.jpg)

### Menambahkan Service baru ke Context Menu Finder

- Jalankan Automator dan pilih New Service di layar awal

![](https://i.imgur.com/H08BG5I.jpg)

- Pilih service received selected `folder` in `Finder.app`
- Kemudian masukkan Action `Get Selected Finder Item` yang dapat ditemukan di dalam Library > Files & Folder
- Setelah action tersebut masukkan Action `Run Shell Script` yang dapat ditemukan di dalam Library > Utilities
- Ubah Pass input sebagai Argument, untuk menangkap result dari action sebelumnya dimasukkan ke dalam arguments ke script yang dijalankan di action ini
- Input tersebut berupa `array` karena mungkin memiliki value lebih dari satu (multiple folder selection)
- Jalankan looping yang memilah value di dalam array tersebut dan jalankan Shell Extension vscode `code /path/to/folder/`

![](https://i.imgur.com/PkLd7lp.jpg)

![](https://i.imgur.com/3CwX479.jpg)

![](https://i.imgur.com/u6R0IvK.jpg)

- Jangan lupa disave file .workflow tersebut,apabila tidak download sendiri silahkan dimasukkan ke dalam folder `~/Library/Services/`
- Tes jalankan service tersebut dengan menggunakan menu `Steps ->` di Automator, pilih folder yang ingin dibuka di vscode dan perhatikan script berjalan
- Apabila sudah selesai action tersebut akan muncul di dalam sub-menu Service di context menu Finder MacOS

### Membuat Shortcut di Toolbar

- Script yang sama dapat kita tarik dari dalam finder ke dalam Toolbar Finder untuk menjadi shortcut yang bersifat permanen
- Right click di Toolbar dan pilih `Customize Toolbar`
- Click dan Drag file `.workflow ke` posisi yang kita inginkan
- Untuk mengubah icon shortcut tersebut bisa di copy paste ke gambar yang ada di kiri atas window `Get Info` file `.workflow` terkait
- Gambar icon yang ingin dipakai silahkan dicari dengan kualitas yang proporsional

![](https://i.imgur.com/zsDMNw0.jpg)

![](https://i.imgur.com/9HQ7F9d.jpg)

![](https://i.imgur.com/V0RpFHb.jpg)

markdown 欢迎来到Cacher

以下是一些可帮助您开始构建代码段库的提示。

cacher_intro.md
# Getting Started with Cacher

<p align="center">
<img src="http://www.cacher.io/assets/intro-snippet-splash-a90755aca4db13aac1e5140e8d7c2a7c01d9b69a640e51b55093421dff432039.png" width="480" />
</p>


## Use snippets to quickly recall commands

Snippets are the most useful when you want to re-use a shell command or a specific code pattern. Here are a few we have in our library:
- "How to delete a git tag"
- "Nginx configuration for staging server"
- "Crash handler AWS Lambda function"

## Use snippets for customer service

Engineers are often second-line customer agents. Use Cacher to store snippets for performing common support tasks.

## Labels are your friend

Labels are a great way to organize your snippets. A good practice is to have one for every major product feature. We've created the first label for you - **Documentation**.

## Create or join a team to share knowledge

Teams allow you and your colleagues to build a shared knowledge base. Use [Markdown](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) to write beautifully formatted documentation. (This snippet itself is a Markdown file.)

## Use snippets for onboarding new team members

Let's face it. Having the new engineer decipher a 500 thousand-line codebase might not be an efficient use of her time. Use snippets as examples to help new members get up to speed fast.


markdown 码头工作票据

Docker Cheat Sheet <br/>来自https://medium.com/statuscode/dockercheatsheet-9730ce03630d

.md
## Docker Registries & Repositories

### Login to a Registry

```docker
docker login
docker login localhost:8080
```

### Logout from a Registry

```docker
docker logout
docker logout localhost:8080
```

### Searching an Image

```docker
docker search nginx
docker search nginx --stars=3 --no-trunc busybox
```

### Pulling an Image

```docker
docker pull nginx
docker pull eon01/nginx localhost:5000/myadmin/nginx
```

### Pushing an Image

```docker
docker push eon01/nginx
docker push eon01/nginx localhost:5000/myadmin/nginx
```

## Running Containers

### Creating a Container

```docker
docker create -t -i eon01/infinite --name infinite
```

### Running a Container
```docker
docker run -it --name infinite -d eon01/infinite
```

### Renaming a Container
```docker
docker rename infinite infinity
```

### Removing a Container
```docker
docker rm infinite
```

### Updating a Container
```docker
docker update --cpu-shares 512 -m 300M infinite
```

## Starting & Stopping Containers

### Starting

```docker
docker start nginx
```

### Stopping

```docker
docker stop nginx
```

### Restarting

```docker
docker restart nginx
```

### Pausing

```docker
docker pause nginx
```

### Unpausing

```docker
docker unpause nginx
```

### Blocking a Container

```docker
docker wait nginx
```

### Sending a SIGKILL

```docker
docker kill nginx
```

### Connecting to an Existing Container

```docker
docker attach nginx
```

## Getting Information about Containers

### Running Containers

```docker
docker ps
docker ps -a
```

### Container Logs
```docker
docker logs infinite
```

### Inspecting Containers

```docker
docker inspect infinite
docker inspect --format '{{ .NetworkSettings.IPAddress }}' $(docker ps -q)
```

### Containers Events

```docker
docker events infinite
```

### Public Ports

```docker
docker port infinite
```

### Running Processes

```docker
docker top infinite
```

### Container Resource Usage

```docker
docker stats infinite
```

### Inspecting Changes to Files or Directories on a Container’s Filesystem

```docker
docker diff infinite
```

### Manipulating Images

#### Listing Images

```docker
docker images
```

#### Building Images

```docker
docker build .
docker build github.com/creack/docker-firefox
docker build - < Dockerfile
docker build - < context.tar.gz
docker build -t eon/infinite .
docker build -f myOtherDockerfile .
curl example.com/remote/Dockerfile | docker build -f - .
```

#### Removing an Image

```docker
docker rmi nginx
```

#### Loading a Tarred Repository from a File or the Standard Input Stream

```docker
docker load < ubuntu.tar.gz
docker load --input ubuntu.tar
```

#### Save an Image to a Tar Archive

```docker
docker save busybox > ubuntu.tar
```

#### Showing the History of an Image

```docker
docker history
```

#### Creating an Image Fron a Container

```docker
docker commit nginx
```

#### Tagging an Image

```docker
docker tag nginx eon01/nginx
```

#### Pushing an Image

```docker
docker push eon01/nginx
```

## Networking

### Creating Networks

```docker
docker network create -d overlay MyOverlayNetwork
docker network create -d bridge MyBridgeNetwork
docker network create -d overlay \
  --subnet=192.168.0.0/16 \
  --subnet=192.170.0.0/16 \
  --gateway=192.168.0.100 \
  --gateway=192.170.0.100 \
  --ip-range=192.168.1.0/24 \
  --aux-address="my-router=192.168.1.5" --aux-address="my-switch=192.168.1.6" \
  --aux-address="my-printer=192.170.1.5" --aux-address="my-nas=192.170.1.6" \
  MyOverlayNetwork
```

### Removing a Network

```docker
docker network rm MyOverlayNetwork
```

### Listing Networks

```docker
docker network ls
```

### Getting Information About a Network

```docker
docker network inspect MyOverlayNetwork
```

### Connecting a Running Container to a Network

```docker
docker network connect MyOverlayNetwork nginx
```

### Connecting a Container to a Network When it Starts

```docker
docker run -it -d --network=MyOverlayNetwork nginx
```
### Disconnecting a Container from a Network

```docker
docker network disconnect MyOverlayNetwork nginx
```

## Cleaning Docker

### Removing a Running Container

```docker
docker rm nginx
```

### Removing a Container and its Volume

```docker
docker rm -v nginx
```

### Removing all Exited Containers

```docker
docker rm $(docker ps -a -f status=exited -q)
```

### Removing All Stopped Containers

```docker
docker rm `docker ps -a -q`
```

### Removing a Docker Image

```docker
docker rmi nginx
```

### Removing Dangling Images

```docker
docker rmi $(docker images -f dangling=true -q)
```

### Removing all Images

```docker
docker rmi $(docker images -a -q)
```

### Stopping & Removing all Containers

```docker
docker stop $(docker ps -a -q) && docker rm $(docker ps -a -q)
```
### Removing Dangling Volumes

```docker
docker volume rm $(docker volume ls -f dangling=true -q)
```

## Docker Swarm

### Installing Docker Swarm

```docker
curl -ssl https://get.docker.com | bash
Initializing the Swarm
docker swarm init --advertise-addr 192.168.10.1
```

### Getting a Worker to Join the Swarm

```docker
docker swarm join-token worker
```

### Getting a Manager to Join the Swarm

```docker
docker swarm join-token manager
```

### Listing Services

```docker
docker service ls
```

### Listing nodes

```docker
docker node ls
```

### Creating a Service

```docker
docker service create --name vote -p 8080:80 instavote/vote
```

### Listing Swarm Tasks

```docker
docker service ps
```

### Scaling a Service

```docker
docker service scale vote=3
```

### Updating a Service

```docker
docker service update --image instavote/vote:movies vote
docker service update --force --update-parallelism 1 --update-delay 30s nginx
docker service update --update-parallelism 5--update-delay 2s --image instavote/vote:indent vote
docker service update --limit-cpu 2 nginx
docker service update --replicas=5 nginx
```

markdown 突出显示ListView中的项目。

突出显示ListView中的项目。

listViewHighlight.md
*Source:* [StackOverflow](https://stackoverflow.com/a/23248559), [StackOverflow](https://stackoverflow.com/a/15917947)

**Question:** How to highlight `ListView` item by touch and by code?

**Answer:** 

```java
ListView mListView;
private ArrayList<String> mList = new ArrayList<>();
private ArrayAdapter mAdapter;

...

mAdapter = new ArrayAdapter(act, R.layout.list_item, mList);
mListView.setAdapter(mAdapter);

//register item click listener
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            //do something
        }
    });

//now just add some random String to mList and
mAdapter.notifyDataSetChanged();

//to manually select an item
mListView.setItemChecked(mHistoryList.size() - 1, true);

//to find out which item is currently checked
mListView.getCheckedItemPosition();
```

```xml
<!--Listview xml-->
<ListView
        android:id="@+id/history_view_listView"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintTop_toBottomOf="parent"
        app:layout_constraintBottom_toTopOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        android:choiceMode="singleChoice"/>

```

```xml
<!--list_item xml-->
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:padding="16dp"
          android:textColor="@color/white_tint_1"
          android:textSize="16sp"
          android:background="@drawable/list_item_selector">
</TextView>

```

```xml
<!--list_item_selector xml in drawable folder-->
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:state_activated="true"
          android:drawable="@color/activity_edit_color_widget_active_30"/>

    <item android:drawable="@color/transparent" />
</selector>

```