Skip to content

Instantly share code, notes, and snippets.

class MainActivity extends Activity {
// mEntries in this case is just an ArrayList store
private ArrayList<String> mEntries;
// ...
// Fetch method
private void fetch(RequestQueue requestQueue) {
JsonArrayRequest request = new JsonArrayRequest("http://example.com/feed.json",
new Response.Listener<JSONArray>() {
@victory1908
victory1908 / DividerItemDecoration.java
Created April 22, 2016 13:42 — forked from zokipirlo/DividerItemDecoration.java
DividerItemDecoration. RecyclerView.ItemDecoration simple implementation
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;
package us.kostenko.architecturecomponentstmdb.details.viewmodel.netres
import retrofit2.Response
import timber.log.Timber
import java.util.regex.Pattern
/**
* Common class used by API responses.
* @param <T> the type of the response object
</T> */
@victory1908
victory1908 / wait-for-it.sh
Created June 3, 2019 17:52
wait-for-it.sh #docker #alpine
#!/bin/sh
# original script: https://github.com/eficode/wait-for/blob/master/wait-for
TIMEOUT=15
QUIET=0
echoerr() {
if [ "$QUIET" -ne 1 ]; then printf "%s\n" "$*" 1>&2; fi
}
@victory1908
victory1908 / Dockerfile
Last active June 4, 2019 03:45
docker node-alpine #docker
FROM node:alpine
WORKDIR /usr/src/app
COPY package*.json ./
RUN apk update && apk upgrade && apk --no-cache --virtual build-dependencies add python make g++ \
&& npm install -g prisma && npm install \
&& apk del build-dependencies
@victory1908
victory1908 / docker node dockerfile
Created June 4, 2019 13:36
docker node #docker
I took one of my current projects and basically ran your Dockerfile...and got a 1.1 GB docker save tar file. It compresses well, but a 345 MB gzipped tar file still isn't what you're after. "Use an Alpine base image" is somewhat helpful, but not a silver bullet; switching it to be FROM node:8-alpine reduces it to a 514 MB uncompressed tar file.
If you don't already have a .dockerignore file, then your entire existing node_modules directory will get copied into the image. (In particular, the COPY . . step will copy your entire working tree in, overwriting the installed modules from the previous step.) It can just contain the single line
node_modules
The Alpine base image, plus not emitting a duplicate node_modules tree, gets me down to 382 MB uncompressed.
Notice in your example that your npm install step includes all of the development dependencies as well as the runtime dependencies. That can be a significant cost. If your application doesn't need any precompilation (it is plain JavaScript that Node can r