Monday, December 24, 2018

How to use Custom CSS/Javascript in Android WebView


By default you cannot get custom CSS/Javascript loaded into Android Webview. We should override the onPageFinished method to be able to add custom CSS/javascript to Android Webview.





This example is using Kotlin, you may search something else if you're using native Java code or Flutter.





The best approach to use Custom CSS/Javascript is by creating the style node containing CSS and a script node containing the javascript for your sites.





var node = document.createElement('style');

node.type = 'text/css';
node.innerHTML = 'MY_CSS_STYLE';

document.head.appendChild(node);




and





var node = document.createElement('script');

node.type = 'text/javascript';
node.innerHTML = 'MY_JS_SCRIPT';

document.body.appendChild(node);




and override the onPageFinished method:





override fun onPageFinished(view: WebView, url: String) {
val code = """javascript:(function() {

var node = document.createElement('style');

node.type = 'text/css';
node.innerHTML = 'body {
color: white;
background-color: black;
}';

document.head.appendChild(node);

})()""".trimIndent()

loadUrl(code)
}





Sunday, December 23, 2018

How to Create Flask Server with Raspberry Pi


On this very basic tutorial, we gonna create a simple Flask Server with Raspberry Pi. Flask is python microframework which allows you to create a web based applications.





This time, we'll install Flask and using NGINX as the default webserver, altough the similar way can be reproduced using Apache.





Prepare your SD Card and burn the latest Raspbian Image onto the SD card using the tool like 'Etcher' or 'dd' command in Linux/MacOS.





Power on you raspberry pi, and take a moment, be sure your Raspberry Pi is connected to Internet, through Wi-Fi or LAN. Then update the repository and packages on Raspberry Pi with this command:





sudo apt-get update




Install the required software, like NGINX, pip3 (python installer) and uWSGI (micro-WSGI):





sudo apt-get install nginx
sudo apt-get install python3-pip
sudo pip3 install uwsgi




To install Flask Microframework, use the pip command:





sudo pip3 install flask




Create Flask App and Nginx Configuration





In your home directory, create new directory for flask app example, called 'flask'. Create new file, called 'testSite1.py' with nano containing this example script:





from flask import Flask
app = Flask(__name__)

@app.route("/")
def index():
return "<html><body><h1>Test site running under Flask</h1></body></html>"

if __name__ == "__main__":
app.run(host='0.0.0.0',debug=True)




then, test your script with uwsgi:





uwsgi --socket 0.0.0.0:8000 --protocol=http -w testSite1:app




you should read this page: Test site running under Flask





Next step, configure uwsgi init file in uwsgi.ini in your flask directory:





[uwsgi]chdir = /home/pi/flasktest
module = testSite1:app

master = true
processes = 1
threads = 2

uid = www-data
gid = www-data

socket = /tmp/flasktest.sock
chmod-socket = 664
vacuum = true

die-on-term = true




Create Autostart uWSGI by create new in /etc/systemd/system, called uwsgi.service





[Unit]
Description=uWSGI Service
After=network.target

[Service]
User=www-data
Group=www-data
WorkingDirectory=/home/pi/flask/
ExecStart=/usr/local/bin/uwsgi --ini /home/pi/flask/uwsgi.ini

[Install]
WantedBy=multi-user.target




reload the daemon using sudo systemctl daemon-reload and then start the uwsgi service with systemctl:





sudo systemctl start uwsgi.service




configure NGINX to use uWSGI by editing the default site configuration in /etc/nginx/sites-available/default





Delete all content on those file, and replace with this script:





server {
listen 80;
server_name localhost;

location / { try_files $uri @app; }
location @app {
include uwsgi_params;
uwsgi_pass unix:/tmp/flasktest.sock;
}
}




Restart NGINX with sudo systemctl restart nginx command.





Test and look your browser.


Friday, December 21, 2018

How to Create FTP Server with Raspberry Pi


Raspberry Pi revolutionised electronics and computer hobby nearly 6 years. Too many creative project has been created with this tiny computer. On this simple tutorial, we'll create a simple FTP server with Raspberry Pi.





This tutorial as intended to Raspberry Pi 3 Model B user, but it also practicable to other version of Raspberry Pi with some modification.





You will need:





  • a Raspberry Pi 3 Model B or other version,
  • a SD Card with the latest Raspbian/ARMbian images or other Debian-based distribution for Raspberry Pi
  • Power supply
  • Keyboard or monitor or LCD




Install FTP Server





You must set your IP Address as static IP. To know your ip address, use command like 'ifconfig'. You also need to enable and start SSH Server for more easy to use in the future.





Install vsftpd using this command:





sudo apt-get update
sudo apt-get install vsftpd




Configure FTP Server





the default FTP server is located in /etc/vsftpd.conf.





Configure and tweak your ftp server by modifying some of those parameters. My suggesstion is enable this parameters, remove the # symbol on every lines that match following parameters:





anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
chroot_local_user=YES




then add some lines to the end of file:





user_sub_token=$USER
local_root=/home/$USER/ftp




Save and exit (in Nano you can use Ctrl + O and Ctrl + X





Last but not least, you can create the user FTP directory:





mkdir /home/pi/ftp
mkdir /home/pi/ftp/files
chmod a-w /home/pi/ftp




You can create new user account by using adduser command and create their FTP directory like the above commands.





Done.


Monday, November 19, 2018

Cara Auto Backup Repo Git dengan Gitlab

Pernah berpikir ataupun khawatir, repositori git di Github atau Bitbucket yang kita gunakan hilang tak berbekas karena gangguan sistem dari Github/Bitbucket atau vendor lainnya? Pernah terbesit untuk membackup repositori itu secara berkala?

Pada tutorial kali ini kita akan memanfaatkan fasilitas Repository Mirroring yang dimiliki oleh Gitlab. Silakan install Gitlab dulu jika belum punya.

Secara umum, mirroring repo yang bisa dilakukan oleh Gitlab itu ada dua:


  • Push: melakukan push repo di Gitlab ke platform lain

  • Pull: melakukan pull repo dari platform lain ke Gitlab



Untuk keperluan tutorial kali ini, tampaknya kita akan menggunakan mode Pull saja. Pastikeun Gitlab yang dipakai sudah versi 8.2 atau lebih baru.

Thursday, November 1, 2018

How to Install WSO2 API Manager in Docker Container

WSO2 API Manager is an open source approach to addressing any spectrum of the API lifecycle, monetization and policy enforcement.



WSO2 API Manager features:


  • Design APIs and gather developers' feedback before implementing (API First Design). Design can be done from the publishing interface or via importing an existing Swagger 2.0 definition

  • Deploy a prototyped API, provide early access to APIs, and get early feedback

  • Mock API implementation using JavaScript

  • Supports publishing SOAP, REST, JSON, and XML style services as APIs

  • Pre-loaded sample APIs for a hassle-free first experience



Build the WSO2 API Manager Images



Create a Dockerfile and write this sample script:

Monday, October 29, 2018

Cara Membatasi Akses API Berdasar IP Address dengan NodeJS

Meneruskan tutorial NodeJS kemarin, kali ini kita akan menambahkan fitur untuk membatasi akses ke API yang kita buat dengan pembatasan IP Address. API yang akan kita buat hanya bisa diakses dari IP Address tertentu saja.

Langsung saja install package express-ipfilter dari NPM. dengan perintah npm install express-ipfilter

Kemudian, masukkan ke aplikasi dengan membuat variabel baru

[sourcecode language="javascript"]const ipfilter = require("express-ipfilter").IpFilter[/sourcecode]

Tuesday, August 28, 2018

Cara Mudah Deploy Sistem Informasi ke Server dengan Git Hook!

Masih banyak yang bingung dengan cara upload software yang dikembangkan dalam repositori Git ke server, apakah menggunakan metode upload file via FTP seperti biasa, atau via cron untuk pull repo tiap waktu yang ditentukan. Pada tutorial kali ini, kita akan menggunakan metode paling mudah yaitu Git Hook.

Apa itu Git Hook?



Git Hook secara sederhana adalah fasilitas bawaan dari Git yang bisa diisi dengan script yang akan dijalankan sebelum atau setelah suatu proses di Git berjalan. Misal, sebelum commit file, lakukan script A, atau setelah di push, lakukan script B.

Syaratnya, server biasanya sudah terinstall Git dan kita punya akses SSH.

Monday, August 27, 2018

Cara Install Ubuntu Server di Orange Pi i96

Pada tutorial kali ini kita akan menginstall ubuntu server di Orange Pi i96. Apa itu Orange Pi i96? simak penjelasannya berikut.



Orange Pi i96 adalah single board computer (SBC) yang diproduksi oleh Shenzen Xunlong Software, co.ltd. Ukurannya sangat kecil, 60 mm x 30 mm. Sudah dibekali dengan prosesor ARM Cortex A5 32 bit dan RAM 256 MB.

Tuesday, June 5, 2018

How to Automount a Virtualbox Shared Folder at Startup



To always mount a Virtual Box "shared folder" on booting an Ubuntu guest we have two options. It is up to personal preference which option works best in our setting.

1. Mount with fstab


To mount a shared folder using the vboxsf filesystem provided with Guest Additions we first need to make sure prerequisites are met. Then we may put the following line in our etc/fstab file:

<name_of_share>   /path/to/mountpoint   vboxsf   <options>  0   0

Replace name_of_share and /path/to/mountpoint with your individual setup (the directory for the mountpoint has to be created first). See the manpage for mount <options>. One possibility is to mount with defaults, or to give specific mount options (e.g. rw, suid, exec, auto, users).

Thursday, April 5, 2018

Haha, Lubuntu Menyerah, Akhirnya Pake Calamares Installer Seperti Distro Lain

Diakui atau tidak tim Lubuntu dan beberapa anak turunan Ubuntu lainnya sudah menyerah melakukan maintenance terhadap aplikasi Installer distro linux yang mereka pakai, tepatnya, mereka warisi dari Ubuntu.

Dalam informasi terbaru dari perkembangan project Lubuntu di lubuntu.me,  tim pengembang Lubuntu mempersiapkan diri untuk menangguhkan Installer Default Ubuntu yang mereka pakai dan menggantinya dengan Calamares Installer, sebuah project Installer distro linux yang universal yang sudah digunakan oleh banyak distro lainnya di luar Ubuntu.

Apakah menyerahnya tim Lubuntu melakukan maintenance ini diikuti oleh saudara kandung mereka anak turunan Ubuntu? ternyata iya, yang nyerah melakukan maintenance Installer Ubuntu di distro mereka itu tidak hanya Lubuntu, tapi juga KDE Neon dan Kubuntu. Haha...

Thursday, March 15, 2018

Ada Upgrade Raspberry Pi 3, Kini lebih cepat dan Bisa Wifi 5GHz

Memperingati Pi Day, tanggal 14 Maret Kemarin, Raspberry Pi Foundation mengumumkan versi upgrade dari Raspberry Pi 3 Model B. Kini hadir dengan nama Raspberry Pi 3 Model B+. Apa saja yang diupgrade pada versi terbaru tersebut?


  • Yang pertama, dari sektor kecepatan Prosesor. Kini Raspberry Pi sudah memapai prosesor Quad-core ARM Cortext-A53 64 bit dengan kecepatan 1.4 GHz. Sudah lebih cepat dari versi sebelumnya.

  • Yang kedua, Wireless LAN (Wifi) yang kini mendukung Dual-band 802.11ac dan frekuensi wifi 5 GHz. Selain itu, Bluetooth juga diupgrade ke versi 4.2.

  • Yang ketiga, Raspberry Pi sudah mendukung PoE (Power over Ethernet) tapi dengan HAT atau asesoris yang terpisah. Sehingga jika dibutuhkan, Raspberry Pi sudah bisa dinyalakan via kabel LAN.

  • Yang keempat, kemampuan untuk booting dari jaringan PXE dan booting dari USB Flashdisk. Tidak perlu lagi utak-atik aneh-aneh, sekarang Raspberry Pi sudah seperti PC/Laptop kebanyakan yang bisa booting dari USB Flashdisk.



Lebih lengkapnya, simak video berikut aja:



Tenang, harga dari Raspberry Pi 3 Model B+ ini masih tetap 35 dollar. Belum jelas, adakah supplier atau toko online yang sudah jual versi terbaru ini.

Tuesday, February 6, 2018

Cara Mengetahui Delay Penerbangan!

Mengalami delay penerbangan oleh maskapai apapun adalah sebuah kejengkelan yang luar biasa, apalagi jika delay tersebut tidak ada kaitannya dengan cuaca buruk atau bencana alam. Nah, sebagai orang cerdas yang memakai gawai cerdas (smartphone) berikut adalah beberapa aplikasi yang membantu anda mengetahui delay penerbangan yang terjadi.

Google Flights



Dari namanya saja sudah jelas ya gan, Google Flights ini memang aplikasi dari Google yang urusannya terkait dengan dunia penerbangan. Sehingga sangat recomended buat kalian yang ingin tracking, notifikasi penerbangan dll. Jika menggunakan android, versi mini dari Google Flights ini  secara tidak sengaja sudah sampeyan nikmati lewat layanan Gmail dan Google Calendar.

Untuk menginstall Google Flights, silakan kunjungi Google Play Store dan search Google Flights.

Wednesday, January 17, 2018

Kebijakan Youtube Ganti, Kini Channel Dibawah 1000 Subscriber Ketar-ketir!

Youtube kembali membuat kejutan dengan mengirim surat elektronik (surel) ke semua partner Youtube (channel yang daftar Adsense Youtube) terkait perubahan kebijakan syarat menjadi Youtube Partner Program (YPP).

Dalam email cukup panjang tersebut, Youtube memberikan pemberitahuan 30 hari sebelum jatuh tempo bahwa channel youtube dengan subcriber kurang dari 1000 orang dan tidak memiliki lebih dari 4000 jam penayangan di Youtube dalam 12 bulan terakhir akan didepak dari partner Youtube. Implikasi terbesarnya, seluruh tool Monetize akan di disable. Kecuali dalam 30 hari channel tersebut bisa mencapai milestone kaya kuwi. abot son.

Baca-baca pengumuman resmi mereka di blog official Youtube, bikin sejumlah partner Youtube bertanya-tanya besar. Apa bisa mereka mengajukan kembali jadi partner Youtube (monetize ulang) jika sudah mencapai 1000 subscriber dan 4000 jam penayangan? Entahlah.

Friday, January 12, 2018

Cara Membuat Website Banyak Dikunjungi

Bisa dibilang, salah satu pekerjaan berat pengelolaan website adalah membuat sebuah website ramai dikunjungi, banyak pembaca yang mengunjungi ulang website dan mempromosikan website ke koleganya.

Nah, berikut adalah tips untuk membuat website banyak dikunjungi orang.

Sunday, January 7, 2018

Mengenal Orange Pi R1

Apa sih Orange Pi R1? board apalagi ini? Apa bedanya dengan saudara Orange Pi lainnya, atau bedanya dengan Raspberry Pi apa sih? Semoga tulisan ini bisa menjawab pertanyaan diatas.

Orange Pi R1 adalah seri dari board Orange Pi yang memiliki 2 Port Ethernet, sehingga banyak digunakan sebagai Router/Firewall. Bentuknya mirip dengan Orange Pi Zero, hanya berbeda di jumlah port Ethernet yang berjumlah 2 buah.

Seperti ini tampak atas dari Orange Pi R1: