Showing posts with label display. Show all posts
Showing posts with label display. Show all posts
Thursday, July 13, 2017
Display File Content with Colors and Line Number Alternative to cat Ubuntu
Display File Content with Colors and Line Number Alternative to cat Ubuntu
Sometimes you may want to quickly display the contents of a file directly on the command line with the `cat` command. And sometimes the contents of that file is the source code of a program.
If you want to display the source code markup with colors and line numbers, then this trick is what you are looking for.
What you need to do first is install Pygments, a python syntax highlighter.
sudo apt-get install python-pygments python3-pygments
After installing pygments, you can now view source code with colored markups. just run the ff:
pygmentize testfile.rb
Now for the line numbers, you will have to pipe the `nl` command
pygmentize testfile.rb | nl --body-numbering=a
The option
--body-numberingmeans it will accept a style for line numbering and it is any of the ff:
a - number all lines
t - number only nonempty lines
n - number no lines
I used a so that everything will be numbered including empty lines.
We can actually add nl options in bash alias so that we do not have to type it everytime.
alias nl=nl --body-number=a
While at it, lets also shorten the pygmentize command.
alias ccat=pygmentize
Now the source code syntax will be highlighted everytime we ran this command:
ccat testfile.rb | nl

Monday, July 10, 2017
Display Driver Uninstaller Download 16 1 0 1
Display Driver Uninstaller Download 16 1 0 1
Display Driver Uninstaller Download
Display Driver Uninstaller Download. Display Driver Uninstaller, or DDU, is a driver utility programs that allows you to remove all traces of NVIDIA, AMD, and INTEL display and audio drivers from Windows. Display Driver Uninstaller is a driver removal utility that can help.
Display Driver Uninstaller. Display Driver Uninstaller, or DDU, is a driver utility programs that allows you to remove all traces of NVIDIA, AMD .
Systems with AMD APUs do not need to go through the driver uninstall process prior to updating the graphics driver. To update the graphics driver on AMD APU .
Display Driver Uninstaller is a free display driver removal utility for Windows that can completely uninstall and remove AMD, INTEL, NVIDIA .
Display Driver Uninstaller Download auf Freeware.de. Grafiktreiber restlos entfernen. Jetzt kostenlos downloaden!
If youre looking for a clean uninstall of your graphics drivers for whatever reason, Display Driver Uninstaller could be your knight in shining .
Display Driver Uninstaller (DDU) / Cleaner made for Display Drivers. Display Driver Uninstaller is a driver removal utility that can help you .
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.
Monday, May 15, 2017
Display All The Text Files From A Directory Using C
Display All The Text Files From A Directory Using C
DESCRIPTION:
- This program get the directory path from the user and display all the text files available in the directory.
- We should add dirent.h header file to accomplish this program.
PROGRAM:
#include <string.h>
#include <dirent.h>
#include <string.h>
const char *only_txt (const char *);
int main (int argc, char *argv[])
{
DIR *directory;
struct dirent *file;
directory = opendir (argv[1]);
int directory_length = strlen(argv[1]);
if (directory != NULL){
while (file = readdir (directory)){
if( !strcmp((only_txt (file->d_name)), ".txt") )
puts (file->d_name);
}
(void) closedir (directory);
}
else
perror ("Not able to open the directory ");
return 0;
}
/**load only .txt file**/
#include <dirent.h>
#include <string.h>
const char *only_txt (const char *);
int main (int argc, char *argv[])
{
DIR *directory;
struct dirent *file;
directory = opendir (argv[1]);
int directory_length = strlen(argv[1]);
if (directory != NULL){
while (file = readdir (directory)){
if( !strcmp((only_txt (file->d_name)), ".txt") )
puts (file->d_name);
}
(void) closedir (directory);
}
else
perror ("Not able to open the directory ");
return 0;
}
/**load only .txt file**/
const char *only_txt (const char *filespec)
{
char *file = strrchr (filespec, .);
if (file == NULL)
file = "";
return file;
}
COMPILE:
gcc -o out scan.c
RUN:
- Pass the directory name with the path as argument to the program
./out /home/sujin/directory
test.txt
README.txt
file.txt
CONCLUSION:
Changing ".txt" to any type file extension, you can customize this program for file type you like.
Friday, May 12, 2017
Display Driver Uninstaller 17 0 3 0
Display Driver Uninstaller 17 0 3 0

Display Driver Uninstaller | 1.3 MB
Display Driver Uninstaller adalah sebuah software gratis yang digunakan untuk menghapus driver grafis dari PC. Display Driver Uninstaller sudah mendukung berbagai macam tipe driver grafis dari AMD, Nvidia dan juga Intel. Display Driver Uninstaller bisa bekerja dengan optimal saat menghapus driver dari komputer.
Terkadang menghapus driver grafis lewat Control Panel masih menyebabkan masalah karena ada file / folder / registry yang masih tertinggal, sehingga saat akan meng-update driver ke versi terbaru terjadi error, nah Display Driver Uninstaller ini bertujuan untuk mencegah hal tersebut karena mampu bekerja secara maksimal saat penghapusan driver grafis di komputer miliki kalian.
Homepage : http://www.wagnardmobile.com/
DOWNLOAD DISINI
NO ADFLY, NO PASSWORD !
Sunday, May 7, 2017
Display amount of free and used memory in the system In Ubuntu
Display amount of free and used memory in the system In Ubuntu
By using free you can display amount of free and used memory in the system.
Free displays the total amount of free and used physical and swap memory in the system, as well as the buffers used by the kernel. The shared memory
column should be ignored; it is obsolete.
Example:
free -m
Will display something like this:
total used free shared buffers cached
Mem: 244 240 3 0 15 82
-/+ buffers/cache: 143 101
Swap: 715 107 608
Usage:
free [-b | -k | -m | -g] [-o] [-s delay ] [-t] [-V]
Options:
The -b switch displays the amount of memory in bytes; the -k switch
(set by default)
displays it in kilobytes; the -m switch displays it in megabytes;
the -g switch displays it in gigabytes.
The -t switch displays a line containing the totals.
The -o switch disables the display of a "buffer adjusted" line. If the
-o option is not
specified, free subtracts buffer memory from the used memory and
adds it to the free memory reported.
The -s switch activates continuous polling delay seconds apart. You may
actually specify
any floating point number for delay, usleep(3) is used for
microsecond resolution delay times.
The -V displays version information.
Tuesday, April 18, 2017
Display All The Files From A Directory Using C
Display All The Files From A Directory Using C
DESCRIPTION:
- This program get the directory path from the user and display all the filed from the directory.
- We should add dirent.h header file to accomplish this program.
PROGRAM:
#include <stdio.h>
#include <string.h>
#include <dirent.h>
int main (int argc, char *argv[])
{
DIR *directory;
struct dirent *file;
directory = opendir (argv[1]);
int directory_length = strlen(argv[1]);
if (directory != NULL){
while (file = readdir (directory))
printf("FILE : %s ",file->d_name);
(void) closedir (directory);
}
else
perror ("Not able to open the directory ");
return 0;
}
COMPILE
gcc -o out scan.c
RUN:
- Pass the directory name with the path as argument to the program
./out /home/sujin/directory
FILE : favicon.ico
FILE : README.txt
FILE : monkey.jpg
FILE : index.html
Thursday, April 13, 2017
Display PDF using PdfRenderer
Display PDF using PdfRenderer

The class android.graphics.pdf.PdfRenderer enables rendering a PDF document. This example show how to:
MainActivity.java
package com.blogspot.android_er.androidpdf;
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.File;
import java.io.IOException;
public class MainActivity extends AppCompatActivity {
String targetPdf = "/sdcard/MagPi54.pdf";
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 {
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(0);
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();
fileDescriptor.close();
}
}
layout/activity_main.xml, add a ImageView to display the PDF:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android_id="@+id/activity_main"
android_layout_width="match_parent"
android_layout_height="match_parent"
android_paddingBottom="@dimen/activity_vertical_margin"
android_paddingLeft="@dimen/activity_horizontal_margin"
android_paddingRight="@dimen/activity_horizontal_margin"
android_paddingTop="@dimen/activity_vertical_margin"
android_orientation="vertical"
tools_context="com.blogspot.android_er.androidpdf.MainActivity">
<TextView
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_layout_margin="20dp"
android_layout_gravity="center_horizontal"
android_autoLink="web"
android_text="http://android-er.blogspot.com/"
android_textStyle="bold"/>
<ImageView
android_id="@+id/pdfview"
android_layout_width="match_parent"
android_layout_height="match_parent" />
</LinearLayout>
uses-permission of "android.permission.READ_EXTERNAL_STORAGE" is needed in AndroidManifest.xml to read file from sdcard.
<?xml version="1.0" encoding="utf-8"?>
<manifest
package="com.blogspot.android_er.androidpdf">
<application
android_allowBackup="true"
android_icon="@mipmap/ic_launcher"
android_label="@string/app_name"
android_supportsRtl="true"
android_theme="@style/AppTheme">
<activity android_name=".MainActivity">
<intent-filter>
<action android_name="android.intent.action.MAIN" />
<category android_name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android_name="android.permission.READ_EXTERNAL_STORAGE"/>
</manifest>
Next:
- Display PDF in assets folder (inside APK)
Related:
- Create PDF using PdfDocument
Labels:
display,
pdf,
pdfrenderer,
using
Subscribe to:
Posts (Atom)