-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Noot
committed
Apr 6, 2018
1 parent
b75da24
commit f61c092
Showing
166 changed files
with
2,540 additions
and
1,225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
_site | ||
.sass-cache | ||
.jekyll-metadata | ||
.DS_Store |
9 changes: 1 addition & 8 deletions
9
...017-02-15-Alway-show-an-Intent-chooser.md → Android/Alway-show-an-Intent-chooser.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 1 addition & 7 deletions
8
_posts/2017-9-8-Use-Dagger2-for-DI.md → Android/Use-Dagger2-for-DI.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Enable Android emulator keyboard | ||
|
||
[https://stackoverflow.com/a/30327728](https://stackoverflow.com/a/30327728) |
8 changes: 1 addition & 7 deletions
8
_posts/2017-9-7-gradle-daemon-error.md → Android/gradle-daemon-error.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Amazon EC2 - disk full | ||
|
||
When you run `df`, the output is `/dev/xvda1 100% /`. It means the disk space is full. You can use the following command to find big size files. | ||
|
||
``` | ||
sudo find / -type f -size +100M -exec ls -lh {} \; | ||
``` | ||
|
||
Reference:[http://stackoverflow.com/questions/20031604/amazon-ec2-disk-full](http://stackoverflow.com/questions/20031604/amazon-ec2-disk-full) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# AWS lambda Java read config file | ||
|
||
1. Put the config file under `src/main/resources` | ||
|
||
2. Read the config file using the code below | ||
|
||
```java | ||
InputStream is = WobCredentials.class.getResourceAsStream(serviceAccountPrivateKeyPath); | ||
String content = convertStreamToString(is); | ||
JSONObject privateKeyJson = new JSONObject(content); | ||
|
||
String convertStreamToString(java.io.InputStream is) { | ||
java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A"); | ||
return s.hasNext() ? s.next() : ""; | ||
} | ||
``` | ||
|
||
Reference: [https://stackoverflow.com/questions/35356200/how-to-load-property-file-from-classpath-in-aws-lambda-java](https://stackoverflow.com/questions/35356200/how-to-load-property-file-from-classpath-in-aws-lambda-java) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# AWS Policy generator | ||
|
||
[AWS Policy generator](https://awspolicygen.s3.amazonaws.com/policygen.html) | ||
|
||
|
||
[IAM policy simulator](https://policysim.aws.amazon.com) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Some userful serverless commands | ||
|
||
* `sls invoke local -f funcName` | ||
|
||
* `sls deploy -f funcName` | ||
|
||
* `sls offline start` | ||
|
||
* `sls dynamodb install` | ||
|
||
* `sls deploy --aws-profile profileName` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Serverless function 6 seconds timeout | ||
|
||
Serverless set a Lamdba function timeout to 6.00 seconds, If you didn't write timeout statement in serverless.yml. | ||
|
||
|
||
```yml | ||
# serverless.yml | ||
service: myService | ||
|
||
provider: | ||
name: aws | ||
runtime: nodejs6.10 | ||
memorySize: 512 # optional, in MB, default is 1024 | ||
timeout: 10 # optional, in seconds, default is 6 | ||
versionFunctions: false # optional, default is true | ||
|
||
functions: | ||
hello: | ||
handler: handler.hello # required, handler set in AWS Lambda | ||
name: ${self:provider.stage}-lambdaName # optional, Deployed Lambda name | ||
description: Description of what the lambda function does # optional, Description to publish to AWS | ||
runtime: python2.7 # optional overwrite, default is provider runtime | ||
memorySize: 512 # optional, in MB, default is 1024 | ||
timeout: 10 # optional, in seconds, default is 6 | ||
``` | ||
Reference: [https://github.com/serverless/serverless/issues/2640](https://github.com/serverless/serverless/issues/2640) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Serverless S3 bucket exists error | ||
|
||
To solve this issue there are two steps: | ||
|
||
1. remove s3 reference from events | ||
2. add CORS configruation as below: | ||
|
||
```yaml | ||
resources: | ||
Resources: | ||
S3BucketMyBucket: | ||
Type: AWS::S3::Bucket | ||
Properties: | ||
BucketName: bucketname-${self:provider.stage} | ||
CorsConfiguration: | ||
CorsRules: | ||
- AllowedHeaders: | ||
- "*" | ||
AllowedMethods: | ||
- GET | ||
- POST | ||
- PUT | ||
AllowedOrigins: | ||
- "*" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Docker insecure registry | ||
|
||
[Test an insecure registry](https://docs.docker.com/registry/insecure/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Docker.qcow2 disk space issue on Mac | ||
|
||
I found `Docker.qcow2` uses 28G on my mac. I solve this issue using the commands below. | ||
|
||
```script | ||
docker rm $(docker ps -a -q) | ||
docker rmi $(docker images -q) | ||
docker volume rm $(docker volume ls |awk '{print $2}') | ||
rm -rf ~/Library/Containers/com.docker.docker/Data/* | ||
``` | ||
|
||
Reference: [https://github.com/docker/for-mac/issues/371](https://github.com/docker/for-mac/issues/371) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Manage different docker versions | ||
|
||
When you try to manage different docker container using docker-machine, it is impossible to manage them on one machine as those docker demons may have different docker versions. One solution is to use one docker container to manage one docker version containers. | ||
|
||
1. Get a docker container from docker hub | ||
|
||
`docker run --name mysites -it nootfly/ubuntu_docker` | ||
|
||
2. Install specific version docker:[Reference](https://docs.docker.com/engine/installation/linux/ubuntulinux/) | ||
|
||
`sudo apt-get install docker-engine=1.12.0-0~xenial` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Move docker-machine config to another machine | ||
|
||
1. Move `~/.docker/machine` directory to another machine's the same directory | ||
|
||
2. Update all machine's `config.json` files under `~/.docker/machine/machines/`, the purpose is to update ssh key and cert path. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# docker commands | ||
|
||
* run a ubuntu image | ||
|
||
`docker run -i -t ubuntu /bin/bash` | ||
|
||
* go into a running container | ||
|
||
`docker exec -i -t containerName /bin/bash` | ||
|
||
* resolve "The default lines below are for a sh/bash shell, you can specify the shell you're using, with the --shell flag." error to use this command | ||
|
||
`eval $(docker-machine env docker-sandbox --shell bash)` | ||
|
||
* create a volume | ||
|
||
`docker run --name mysites -v /Users/noot/docker/data:/data -it nootfly/docker1.1.2` | ||
|
||
* commit a container | ||
|
||
`docker commit 1ff9c95fdc30 nootfly/docker1.1.2` | ||
|
||
* docker-machine configures at the start of each shell session | ||
|
||
`eval $(docker-machine env docker-sandbox)` | ||
|
||
* docker saves an image to a tar | ||
|
||
`docker save -o ~/container1.tar container1` | ||
|
||
* docker recovery an image from a tar | ||
|
||
`docker load -i /root/container1.tar` | ||
|
||
* rename docker container | ||
|
||
`docker rename CONTAINER NEW_NAME` | ||
|
||
* copy files from the container to the host | ||
|
||
`docker cp <containerId>:/file/path/within/container /host/path/target` | ||
|
||
* [Removing Docker containers and images](https://zaiste.net/posts/removing_docker_containers/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# docker-compose node link mongo | ||
|
||
1. Create a `Dockerfile` | ||
|
||
``` | ||
FROM node:6.9.4-alpine | ||
ADD . /usr/src/app | ||
WORKDIR /usr/src/app | ||
RUN npm install | ||
CMD ["npm", "start"] | ||
``` | ||
2. Create `docker-compose.yaml`, and pay attention to the service names which should not include `_`. | ||
|
||
``` | ||
version: '2.1' | ||
services: | ||
mongodbservice: | ||
container_name: mongo | ||
image: mongo | ||
ports: | ||
- "27017:27017" | ||
volumes: | ||
- ./db:/data/db | ||
web: | ||
container_name: web | ||
build: . | ||
depends_on: | ||
- mongodbservice | ||
volumes: | ||
- ./:/usr/src/app | ||
links: | ||
- mongodbservice | ||
ports: | ||
- "3000:3000" | ||
``` | ||
3. In code, use the correct mongodb URL | ||
|
||
`let mongodb = mongojs('mongodb://mongodbservice:27017/Test', ['test']);` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Docker nginx log configuration | ||
|
||
If you use ```nginx``` docker offical image, the nginx logs point to ```stderr``` and ```stdout```. You need to keep logs into different files, otherwise the logs won't be saved. For example: | ||
|
||
``` | ||
http { | ||
access_log /var/log/nginx/access1.log; | ||
error_log /var/log/nginx/error1.log; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# sudo docker | ||
|
||
how to remove sudo | ||
|
||
http://askubuntu.com/questions/477551/how-can-i-use-docker-without-sudo |
Oops, something went wrong.