Skip to content

Commit

Permalink
rollback
Browse files Browse the repository at this point in the history
  • Loading branch information
Noot committed Apr 6, 2018
1 parent b75da24 commit f61c092
Show file tree
Hide file tree
Showing 166 changed files with 2,540 additions and 1,225 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
_site
.sass-cache
.jekyll-metadata
.DS_Store
24 changes: 0 additions & 24 deletions 404.html

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
---
layout: post
title: "Alway show an Intent chooser"
date: 2017-02-15 8:37:00 +1000
categories: android
tags: android
---

# Alway show an `Intent` chooser

If you want to alway show a chooser dialog, you can create `Intent` using `createChooser()`

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
---
layout: post
title: "Use Dagger 2 for dependency injection"
date: 2017-09-8 8:37:00 +1000
categories: android
tags: android
---
# Use Dagger 2 for dependency injection

This quote is from Google
>Dependency injection frameworks can simplify the code you write and provide an adaptive environment that's useful for testing and other configuration changes.
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions Android/enable-emulator-keyboard.md
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)
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
---
layout: post
title: "Gradle damon error"
date: 2017-09-7 8:37:00 +1000
categories: android
tags: android
---
# Gradle damon error

You can solve the below issue by adding `org.gradle.jvmargs=-Xmx1024m` in `gradle.properties` file.

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions Cloud/aws-ec2-disk-full.md
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)
18 changes: 18 additions & 0 deletions Cloud/aws-lambda-read-config-file.md
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)
7 changes: 7 additions & 0 deletions Cloud/aws-policy-generator.md
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)

12 changes: 12 additions & 0 deletions Cloud/serverless-commands.md
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`

28 changes: 28 additions & 0 deletions Cloud/serverless-function-6-seconds-timeout.md
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)
25 changes: 25 additions & 0 deletions Cloud/serverless-s3-exits-error.md
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:
- "*"
```
3 changes: 3 additions & 0 deletions Docker/Docker-insecure-registry.md
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/)
12 changes: 12 additions & 0 deletions Docker/Docker.qcow2-disk-space-issue-on-Mac.md
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)
11 changes: 11 additions & 0 deletions Docker/Manage-different-docker-versions.md
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`
5 changes: 5 additions & 0 deletions Docker/Move-docker-machine-config.md
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.
43 changes: 43 additions & 0 deletions Docker/docker-commands.md
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/)
38 changes: 38 additions & 0 deletions Docker/docker-compose-node-link-mongo.md
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']);`
10 changes: 10 additions & 0 deletions Docker/nginx-log-conf.md
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;
}
```
5 changes: 5 additions & 0 deletions Docker/sudo-docker.md
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
32 changes: 0 additions & 32 deletions Gemfile

This file was deleted.

Loading

0 comments on commit f61c092

Please sign in to comment.