Pages

Showing posts with label inside. Show all posts
Showing posts with label inside. Show all posts

Wednesday, June 21, 2017

Dev Inside A Docker Container With SSHFS

Dev Inside A Docker Container With SSHFS


Many of you may have already discovered Docker, but have been put off using it due to the prospect of it killing your development cycle because you are rebuilding the container after every change.



We are going to address this by mounting the files directly within the container with SSHFS. This will allow us to make changes in our IDE or text editor, and see them take place immediately inside the container, removing the need to keep rebuilding.

Prerequisites

This tutorial assumes you already have a built container (or a way to build one) and a "project" consisting of a codebase, such as a website. It also assumes that your codebase is on a Linux host that you want to share from. I will be using an Ubuntu 14.04 container, but the theory should also apply to other Linux OS types.

If you are a Windows user, you could use Samba to sync to a linux host, and then use that one for this tutorial
    Start your container with the
    --privileged
    flag added to the
    run
    command. I dont know what options/switches you already have, but you just need to add this one to the list.
    Enter the running container. For this I use lxc-attach, but there is also a fantastic tool called docker-enter on github that you can use, which means you dont have to be running LXC for the container engine.
    Run
    apt-get install sshfs -y
    from inside the container.
    Create a folder where you wish to mount your codebase. This may want to replace any existing code that was imported into the container when it was built, in which case remove everything from inside that folder.
    Run the following command:
    sshfs -o allow_other $USER@$IP_OF_CODE_HOST:/full/path/to/codebase /path/to/mount
    The allow_other part is to allow other users within the container, such as www-data to be able to access the files
    Thats it! Any changes you make to your codebase are immediately changed in the docker container. This allows you to use docker as an easy/quick way to get a development environment up (like Vagrant)!
Read more »

Friday, June 9, 2017

Display PDF in assets folder inside APK

Display PDF in assets folder inside APK


The example "Display PDF using PdfRenderer" show how to display PDF stored in sdcard, this example show how to display PDF stored in assets inside APK.


First, you have to create assets folder and copy your PDF into it.


Then you have to edit aaptOptions in build.gradle (Module: app), not to compass "pdf" file.


aaptOptions {
noCompress "pdf"
}


Layout file, refer to the example "Create PDF using PdfDocument".

MainActivity.java
package com.blogspot.android_er.androidpdf;

import android.content.res.AssetFileDescriptor;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.pdf.PdfRenderer;
import android.os.Bundle;
import android.os.ParcelFileDescriptor;
import android.support.v7.app.AppCompatActivity;
import android.widget.ImageView;
import android.widget.Toast;

import java.io.IOException;

public class MainActivity extends AppCompatActivity {

ImageView pdfView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

pdfView = (ImageView)findViewById(R.id.pdfview);

try {
openPDF();
} catch (IOException e) {
e.printStackTrace();
Toast.makeText(this,
"Something Wrong: " + e.toString(),
Toast.LENGTH_LONG).show();
}
}

private void openPDF() throws IOException {

//open file in assets

AssetManager assetManager = getAssets();
AssetFileDescriptor assetFileDescriptor =
assetManager.openFd("test.pdf");
ParcelFileDescriptor fileDescriptor =
assetFileDescriptor.getParcelFileDescriptor();

//open file from sdcard
/*
String targetPdf = "/sdcard/test.pdf";
File file = new File(targetPdf);

ParcelFileDescriptor fileDescriptor = null;
fileDescriptor = ParcelFileDescriptor.open(
file, ParcelFileDescriptor.MODE_READ_ONLY);
*/

//min. API Level 21
PdfRenderer pdfRenderer = null;
pdfRenderer = new PdfRenderer(fileDescriptor);

final int pageCount = pdfRenderer.getPageCount();
Toast.makeText(this,
"pageCount = " + pageCount,
Toast.LENGTH_LONG).show();

//Display page 0
PdfRenderer.Page rendererPage = pdfRenderer.openPage(1);
int rendererPageWidth = rendererPage.getWidth();
int rendererPageHeight = rendererPage.getHeight();
Bitmap bitmap = Bitmap.createBitmap(
rendererPageWidth,
rendererPageHeight,
Bitmap.Config.ARGB_8888);
rendererPage.render(bitmap, null, null,
PdfRenderer.Page.RENDER_MODE_FOR_DISPLAY);

pdfView.setImageBitmap(bitmap);
rendererPage.close();

pdfRenderer.close();

assetFileDescriptor.close();
}

}




Remark:If you reported with the error "java.io.IOException: not create document. Error:", read next post.

Read more »

Tuesday, June 6, 2017

Developer Inside Playdead Berikan Sinyal Game Terbaru Mereka

Developer Inside Playdead Berikan Sinyal Game Terbaru Mereka


Hari ini Playdead, developer dibalik Limbo dan Inside memberikan sinyal proyek game mereka selanjutnya. Melalui Twitter resminya, mereka menyatakan bahwa mereka sedang mengerjakan �petualangan selanjutnya� lengkap dengan sebuah screenshot.

advertisement Gaming Guide: PC Awet Low Budget untuk eSports
Playdead tidak memberikan detil lebih lanjut tentang game baru yang sedang mereka kerjakan. Namun jika dilihat dari screenshot yang mereka berikan kami yakin mereka tidak akan membuat game sejenis Limbodan sepertinya studio ini akan membuat game dengan gaya yang baru dibanding game yang pernah mereka buat sebelumnya.
Source: Playdead Twitter, Dualshockers
Read more »