When you judge another, you do not define them, you define yourself – Wayne Dyer

Beautifully Zen

Lets face it, judging others is a natural human trait.   I try my hardest not to make assumptions about others, I really do,  but sometimes despite my best efforts I will find myself exploring feelings of negativity towards someone else or even making judgements about them.  On the flip side, I sometimes find myself on the receiving end of such perceptions and thoughts.

One thing I strongly believe is this,  every person we encounter in our lives, be it for a short or long period of time, has actually been sent our way to teach us something.   Even if we find this person challenging or so far away from how we view ourselves, they potentially may have arrived to teach us something valuable. One of the worlds most renowned Buddhist teachers Pema Chodron once said   “If we learn to open our hearts, anyone, including the people who…

View original post 1,005 more words

Advertisements

Bake a model for users table

Setup Database Connection

Edit config/app.php

Selection_018.png

Bake Model


root@b75c5d942521:/var/www# ./bin/cake bake model
Choose a model to bake from the following:
- Users
root@b75c5d942521:/var/www# ./bin/cake bake model Users
One moment while associations are detected.

Baking table class for Users...

Creating file /var/www/src/Model/Table/UsersTable.php
Wrote `/var/www/src/Model/Table/UsersTable.php`
Deleted `/var/www/src/Model/Table/empty`

Baking entity class for User...

Creating file /var/www/src/Model/Entity/User.php
Wrote `/var/www/src/Model/Entity/User.php`
Deleted `/var/www/src/Model/Entity/empty`

Baking test fixture for Users...

Creating file /var/www/tests/Fixture/UsersFixture.php
Wrote `/var/www/tests/Fixture/UsersFixture.php`
Deleted `/var/www/tests/Fixture/empty`
Bake is detecting possible fixtures...

Baking test case for App\Model\Table\UsersTable ...

Creating file /var/www/tests/TestCase/Model/Table/UsersTableTest.php
Wrote `/var/www/tests/TestCase/Model/Table/UsersTableTest.php`
root@b75c5d942521:/var/www#

Selection_019.png

source: https://book.cakephp.org/3.0/en/orm/database-basics.html#configuration

Test The model Using Console (REPL)

Selection_020.png

Insert new data

use Cake\ORM\TableRegistry;

$articlesTable = TableRegistry::get('Articles');
$article = $articlesTable->newEntity();

$article->title = 'A New Article';
$article->body = 'This is the body of the article';

if ($articlesTable->save($article)) {
    // The $article entity contains the id now
    $id = $article->id;
}

CakePHP 3.6.12 Migration (Phinx)

Phinx

Phinx is a standalone command line tool for managing database Migrations. The official Migrations plugin for CakePHP is based on this tool.

Composer Install Phinx (Mine is in the Docker Container)


root@b75c5d942521:/var/www# composer require robmorgan/phinx
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Using version ^0.10.6 for robmorgan/phinx
./composer.json has been updated
1/1: http://packagist.org/p/provider-latest$1c25e7d4b2021ab02c5f787753a04479e835647834fff24e816493dcb3b64a52.json
Finished: success: 1, skipped: 0, failure: 0, total: 1
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Writing lock file
Generating autoload files
> Cake\Composer\Installer\PluginInstaller::postAutoloadDump
root@b75c5d942521:/var/www# vendor/bin/phinx init
Phinx by CakePHP - https://phinx.org. 0.10.6

created /var/www/phinx.yml
root@b75c5d942521:/var/www# 

Phinx Init


root@b75c5d942521:/var/www# vendor/bin/phinx init
Phinx by CakePHP - https://phinx.org. 0.10.6

created /var/www/phinx.yml

www#

Setup Phinx’s  DB Connection


environment

. . .

  development:
    adapter: pgsql
    host: localhost
    name: cake1_db
    user: postgres
    pass: postgres
    port: 5432
    charset: utf8

. . .

Test Phinx’s DB Connection


root@b75c5d942521:/var/www# ./vendor/bin/phinx migrate -e development
Phinx by CakePHP - https://phinx.org. 0.10.6

using config file ./phinx.yml
using config parser yaml
using migration paths
using seed paths
using environment development
using adapter pgsql
using database cake1_db

All Done. Took 0.1185s

Create Migration File

root@b75c5d942521:/var/www# ./vendor/bin/phinx create CreateTableUser
Phinx by CakePHP - https://phinx.org. 0.10.6

Upps…

You probably used curly braces to define migration path in your Phinx configuration file, but no directories have been matched using this pattern
. You need to create a migration directory manually.

Selection_014.png

run ` mkdir -p db/migrations ` to create migration directory manually and solve the error.

Re-run Create Command


root@b75c5d942521:/var/www# ./vendor/bin/phinx create CreateTableUser
Phinx by CakePHP - https://phinx.org. 0.10.6

using config file ./phinx.yml
using config parser yaml
using migration paths
- /var/www/db/migrations
using seed paths
using migration base class Phinx\Migration\AbstractMigration
using default template
created db/migrations/20181002121753_create_table_user.php
root@b75c5d942521:/var/www# 

Selection_013.png

 

Edit 20181002121753_create_table_user.php

Selection_015.png

Selection_016.png
Changecreated_at and updated_at wirhcreated and modified so When a new entity is saved the created and modified fields will be set to the current time.

Selection_017.png

 

Find more about Phinx Here.

CakePhp 3.6 Installation on Ubuntu 18

My Laptop Environment


╭─yusuf@yusuf-berkarya ~/htdocs/mycake1
╰─➤ php -v
PHP 7.2.10-0ubuntu0.18.04.1 (cli) (built: Sep 13 2018 13:45:02) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.10-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies

╭─yusuf@yusuf-berkarya ~/htdocs/mycake1
╰─➤ lsb_release --a
LSB Version: core-9.20170808ubuntu1-noarch:security-9.20170808ubuntu1-noarch
Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic

CakePHP 3.6 Instalation


╭─yusuf@yusuf-berkarya ~/htdocs
╰─➤ composer create-project --prefer-dist cakephp/app mycake1 127 ↵
Installing cakephp/app (3.6.5)
- Installing cakephp/app (3.6.5): Loading from cache
Created project in mycake1
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- cakephp/cakephp 3.6.9 requires ext-intl * -> the requested PHP extension intl is missing from your system.
- cakephp/cakephp 3.6.8 requires ext-intl * -> the requested PHP extension intl is missing from your system.
- cakephp/cakephp 3.6.7 requires ext-intl * -> the requested PHP extension intl is missing from your system.
- cakephp/cakephp 3.6.6 requires ext-intl * -> the requested PHP extension intl is missing from your system.
- cakephp/cakephp 3.6.5 requires ext-intl * -> the requested PHP extension intl is missing from your system.

Fix Error

PHP Fatal error: You must enable the intl extension to use CakePHP.
in /home/yusuf/htdocs/mycake1/config/requirements.php on line 31


╭─yusuf@yusuf-berkarya ~/htdocs/mycake1
╰─➤ sudo apt-get install php7.2-intl

Re-run Install


╭─yusuf@yusuf-berkarya ~/htdocs/mycake1
╰─➤ composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 47 installs, 0 updates, 0 removals
- Installing cakephp/plugin-installer (1.1.0): Downloading (100%)
- Installing psr/http-message (1.0.1): Downloading (100%)
- Installing zendframework/zend-diactoros (1.8.6): Downloading (100%)
- Installing psr/log (1.0.2): Downloading (100%)
- Installing aura/intl (3.0.0): Downloading (100%)
- Installing cakephp/chronos (1.2.2): Downloading (100%)
- Installing cakephp/cakephp (3.6.12): Downloading (100%)
- Installing symfony/polyfill-ctype (v1.9.0): Downloading (100%)
- Installing symfony/yaml (v4.1.5): Downloading (100%)
- Installing symfony/polyfill-mbstring (v1.9.0): Downloading (100%)
- Installing symfony/console (v4.1.5): Downloading (100%)
- Installing symfony/filesystem (v4.1.5): Downloading (100%)
- Installing symfony/config (v4.1.5): Downloading (100%)

Prepare app.php


╭─yusuf@yusuf-berkarya ~/htdocs/mycake1
╰─➤ ./bin/cake
Could not load configuration file: /home/yusuf/htdocs/mycake1/config/app.php
╭─yusuf@yusuf-berkarya ~/htdocs/mycake1
╰─➤ vim config/app.default.php
╭─yusuf@yusuf-berkarya ~/htdocs/mycake1
╰─➤ cp config/app.default.php config/app.php
╭─yusuf@yusuf-berkarya ~/htdocs/mycake1
╰─➤ ./bin/cake
No command provided. Choose one of the available commands.

Current Paths:

* app: src
* root: /home/yusuf/htdocs/mycake1
* core: /home/yusuf/htdocs/mycake1/vendor/cakephp/cakephp

Available Commands:

- bake
- benchmark
- cache
- compile
- completion
- console
- whitespace
- help
- i18n

Development Server


╭─yusuf@yusuf-berkarya ~/htdocs/mycake1
╰─➤ bin/cake server

Welcome to CakePHP v3.6.12 Console
---------------------------------------------------------------
App : src
Path: /home/yusuf/htdocs/mycake1/src/
DocumentRoot: /home/yusuf/htdocs/mycake1/webroot
Ini Path:
---------------------------------------------------------------
built-in server is running in http://localhost:8765/
You can exit with `CTRL-C`

Visit Web

http://localhost:8765/

Selection_012.png

Installing Lando from source on Ubuntu 18 Ubuntu 18.04.1 LTS

Clone the Lando source

git clone https://github.com/lando/lando.git

Install its dependencies

cd lando && yarn

Optionally set up a symlink

sudo mkdir -p /usr/local/bin

sudo ln -s /absolute/path/to/above/repo/bin/lando.js /usr/local/bin/lando.dev

Run lando

lando.dev

Final result

Selection_011.png
Lando

Source: https://docs.devwithlando.io/installation/installing.html#from-source

Catatan Belajar Functional programming dengan ES6

Dalam catatan ini merangkum hasil belajar saya saat menonton video presentasi dari Jeremy Fairbank, berikut video yang saya lihat di Youtube:

 

Apakah Functional Programming itu?

Selection_070.png

 

Mengapa Menggunakan Functional Programming ?

Selection_071.png

 

Basic Building Block

Selection_072.png

 

Empat Prinsip Functional Programming (04:31)

  1. Predictable (Pure and Declarative)
  2. Safe (Immutable State)
  3. Transparent (First Class State)
  4. Modular (Function as building blocks)

*Pembahasan lebih lanjut setelah Pengenalan Syntax ES6

 

Pengenalan Syntax ES6

 

Variable binding

Penggunaan var, let dan const

var a = 1
let b = 2
const c = 3

a = 99
b = 99
c = 99 // Akan Error disini karena c adalah constant binding

Perbedaan let dan var

var x = 0

if (x==0) {
  var a = 'kucing'
  let b = 'sapi'
}

document.write(a);
document.write(b); // Error, b tidak bisa diakses diluar block code if diatas

Lambdas / Anonymous Function

const a = (x, y) => x+y

document.write( a(2,2) ) // 4

// Fungsi diatas sama dengan

const b = function (x, y) {
  return x+y
}

document.write( b(2,2) ) // 4

Perbedaan Function Declaration dan Expressions

// Declaration

document.write(foo())

function foo() {
return "foo"
}

// Expression

document.write(bar())
var bar = () => "bar"

Ellipsis Operator

function foo(...x) {
  console.log(x)
}

foo("a", "b", "c")

Destructuring

The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables.

[a, b, c, d] = [10, 20, 30];

console.log(a);
// expected output: 10

console.log(b);
// expected output: 20

console.log(d);
// expected output: undefined

Destructuring dengan Ellipsis Operator

[a, b, ...rest] = [10, 20, 30, 40, 50];

console.log(rest);
// expected output: [30,40,50]

Sebagai Function Parameters

const thex = ([a,b,c]) => c // hasilnya: cccc

console.log(thex(["aaa", "bbbb", "cccc"]))

Default parameter values

const greeting = (name="yusuf", greet="hallo") => greet + ", " + name + "!"

document.write(greeting())

document.write(greeting("Jony", "Hi"))

Object.assign()

The Object.assign() method only copies enumerable and own properties from a source object to a target object. It uses [[Get]] on the source and [[Set]] on the target, so it will invoke getters and setters.

var karyawan = {ktp: "12345", nama: "Jhony"}

karyawan = Object.assign(karyawan, {alamat: "Jakarte"}, {hobi: "makan"})

console.log(karyawan) //output: {ktp: "12345", nama: "Jhony", alamat: "Jakarte", hobi: "makan"}

Perhatikan Mutasi yang terjadi pada variable karyawan

var karyawan = {ktp: "12345", nama: "Jhony"}

var karyawan2 = Object.assign(karyawan, {alamat: "Jakarte"}, {hobi: "makan"})

console.log(karyawan)
console.log(karyawan2)

//output logs diatas:
//(index):34 {ktp: "12345", nama: "Jhony", alamat: "Jakarte", hobi: "makan"}
//(index):35 {ktp: "12345", nama: "Jhony", alamat: "Jakarte", hobi: "makan"}

 

Lebih Detain Tentang 4 Prinsip Functional Programming

 

Predictable (Pure and Declarative)

What if Pixabay
Predictable (Pure and Declarative)

In computer programming, a pure function is a function that has the following properties:

  1. Its return value depends only on its parameters and not on any internal or external state (such as local static variablesnon-local variables or inputs from I/O devices).
  2. Its evaluation has no side effect (such as mutation of local static variables or non-local variables, or performing I/O operations).

Thus a pure function is a computational analogue of a mathematical function.

Contoh sederhana tentang Function yang tidak Pure (impure)

var x = 10

// Mengakibatkan side effect tak terduga dari nilai x (global state)
// Hasil dari fungsi tidak dapat ditebak
// 10x dipanggil bisa jadi 10 hasil berbeda
function add(y)  {
  return x + y // nilai x bisa saja sudah berubah oleh sesuatu hal
}

Contoh Pure Function

Selection_075.png
‘name’- nya diambil dari parameter bukan akses langsung variable diluar fungsi
Fungsi matematika
f(x,y) = x+y
Fungsi Javascript ES5
var add = function (x, y) {
  return x+1
}
Fungsi Javascript ES6
(x, y) => x+1 // Lihat mirip banget sama matematika kan?

Contoh Function yang tidak Pure (impure)

Selection_074.png
Fungsi merubah variable diluar fungsi begitu saja

impure_thoughts_by_fanfarekid-d9kas2w

Recursive

Contoh menghitung faktorial !n dengan rekursif

Selection_095.png

Dengan recursive

const factorial = n => {
  if (n<2) {
    return 1;
  }

  let result = n * factorial(n-1) // recursive
  
  //document.write( n + ' * factorial(' + (n-1) + ') = ' , result, '<br />')
  
  return result
}

document.write(factorial(4))

Tanpa recursive

const factorial = n => {
  let result = 1

  while(n > 1) {
    result *= n
    n--
  }

  return result
}

document.write(factorial(4))

 

Safe (Immutable State)

db9141f801bf5cf7061155ef398ec2f2

Create state, don’t mutate it!

Mutasi yang kita hindari

var a = {name: "kokom"}
var b = a

document.write(a.name) // masih kokom
b.name = 'munaroh'
document.write(a.name) // a jadi munaroh
Penjelasan kode diatas

“Variables that are assigned a non-primitive value are given a reference to that value. That reference points to the object’s location in memory. The variables don’t actually contain the value.” — @farm_fresh_js https://codeburst.io/explaining-value-vs-reference-in-javascript-647a975e12a0

 

Object.freeze()

The Object.freeze() method freezes an object: that is, prevents new properties from being added to it; prevents existing properties from being removed; and prevents existing properties, or their enumerability, configurability, or writability, from being changed, it also prevents the prototype from being changed. The method returns the passed object.

Cara untuk menghindari mutasi pada object dengan Object.freeze

const object1 = {
  property1: 42
};

const object2 = Object.freeze(object1);

object2.property1 = 33;
// Throws an error in strict mode

console.log(object2.property1);
// expected output: 42

 

Ingat pemahaman yang baik tentang Destructuring sangat diperlukan untuk mamahami kode dibawah ini.

Don’t / Jangan

Selection_076.png
constructor dan moveBy merubah global state x dan y, dalam Functional Programming itu bad practise

Do / Lakukan ini

Selection_077.png

Penjelasan gambar diatas:

  1. Fungsi createPoint mengembalikan Object [x, y] yang immutable dari param x, y yang diberikan.
  2. Fungsi point berisi immutable [x, y] di assign ke Fungsi movePointBy untuk di tambahkan parameter baru dx, dy yang diinputkan juga ke Fungsi  movePointBy.
  3. Fungsi movePointBy mengembalikan immutable object baru hasil dari [dx+x, dy+y].

 

Transparent (First Class State)

 

Modular (Function as building blocks)

 

Selesai…

 

Sumber lainnya

Publishing React Native App on Expo

Github

Expo adalah aplikasi “React Native” yang berisi SDK Expo. SDK Expo itu sendiri adalah kumpulan dari library2 native dan juga library2 JS yang berfungsi menyediakan akses kode kita ke fungsi bawaan sistem milik perangkat/device (seperti kamera, kontak, penyimpanan lokal, dan perangkat keras lainnya). dengan itu berarti kita tidak perlu lagi menggunakan Xcode atau Android Studio, atau dengan kata lain tidak perlu lagi menulis program dengan kode native sesuai platform yang diinginkan, dan itu juga berarti membuat proyek yang dikerjakan dengan React Native menjadi lebih portabel karena dapat berjalan di lingkungan manapun/apapun yang berisi SDK Expo.

Create your own Expo account

Selection_039.png
Expo registration form

Selection_040.png

Install and Run Expo XDE

XDE stands for Expo Development Environment. It is a standalone desktop app that includes all dependencies you’ll need to get started.
Download the latest version of XDE for macOSWindows (64-bit), or Linux.
On Linux, open with chmod a+x xde*.AppImage and ./xde*.AppImage.
Selection_042.png

 

Selection_043.png
User login

Open Your project on Expo XDE

Selection_044.png
Select wanted project to publish
Selection_041.png
Available thru global internet access
Selection_045.png
Local network only

 

Publish Your project on Expo

Selection_046.png

Selection_047.png
Publishing
Selection_048.png
Building

Application Published

Selection_049.png

You will get sms to your mobile phone regarding this publishing activity

photo_2018-07-29_16-14-48

 

Open Published App on The Android Expo Client

photo_2018-07-29_16-14-46

 

Final Result

photo_2018-07-29_16-14-44.jpg

 

 

 

Running React Native App on Genymotion Emulator

Build and Run React Native App on Genymotion Emulator

 

Download genymotion-2.12.2-linux_x64.bin

1.download

Execute genymotion-2.12.2-linux_x64.bin

2.jadikan-x-dan-execute

GENYMOTION is Starting up… ups,missing Virtual Box (Install Virtual-box here)

3.ups-install-dulu-virtual-box

GENYMOTION Welcome Screen

4.geny-motion-welcome-screen

Login to your GENYMOTION account

5.Login-ke-akun-kamu

GENYMOTION User Agreement

6.terima-egreement

Setup Android SDK Path on GENYMOTION

7.set-android-sdk8.sdk-path-set-selesai9.masuk-pertama-kali

Create First GENYMOTION Virtual Device

10.ditawari-bikin-virtual-device-oleh-GenyMotion12.installing-downloading-Virtual-device13.deploying14.installed

Start GENYMOTION Virtual Device

15.installed-Virtual-device16.starting17.booting18.running-virtual-device

Ups.. yarn start error

could not install *smartsocket* listener: Address already in use ADB server didn’t ACK

19.run-ract-error

Fix Error Above

20.fix-ADB-error21.react-building-js-bundle22.running-app

Done…

Cara mengecek tagihan Kartu Kredit Bank BCA Secara Online

Bila anda masuk ke halaman ini maka besar kemungkinan anda mengalami kasus seperti saya dimana tagihan kartu kredit tidak pernah dikirim kerumah oleh BCA dan tagihan juga tidak pernah dikirim ke Email padahal fitur tagihan via email sudah berkali-kali diaktifkan bahkan sudah berkirim email ke Customer service BCA, tapi tidak ada kemajuan, tagihan tak kunjung masuk ke Email maupun ke rumah via POS.

Bila anda mengalami hal yang sama terkait Tagihan Kartu kredit BCA yang tidak dikirim kerumah juga ke Email oleh BCA maka mengecek sendiri tagihan anda secara online adalah pilihan terakhir karena bila harus via telp akan banyak pulsa dan biaya terbuang.

  1. Masuk ke halaman eform klikbca https://eform.klikbca.com/fasilitasonlinecc/
  2. Lengkpi informasi kartu di formSelection_001.png
  3. Masuk kehalaman E-Statement

    Selection_003.png
    Hei, anda mau mengaktivasi PIN Kartu Kredit BCA anda juga bisa dari halaman ini
  4. Pilih bulan yang dinginkanSelection_004.pngSelection_005.png

Untuk kasus saya tidak ada tagihan di bulan yang saya pilih.

Gratis Tarik Tunai di ATM bank manapun dengan Debit BTPN Jenius

Kali ini saya akan berbagi pengalaman kedua saya bertransaksi dengan BTPN Jenius, bila kemarin saya melakukan pembayaran kartu kredit CIMB Niaga Syariah gratis dengan akun BTPN Jenius di HP Android android saya (dan terbukti Gratis) maka kali ini saya akan menceritakan pengalaman saya saat mencoba menarik tunai uang dari ATM BCA dengan kartu Debit BTPN Jenius yang baru saja saya miliki (kartu dikirim sekitar 1 minggu setalah varifikasi akun ke kantor saya).

Saldo saya Sebelumnya adalah :

Rp. 1.280.000

Tarik tunai via ATM BCA:

Rp. 100.000

tarik-tunai-btpn-jenius.jpg

Sisa saldo:

Rp. 1.180.000

Terbukti Tarik Tunai dan Juga bayar Kartu Kredit dengan BTPN Jenius adalah benar benar gratis (25x pertama tiap awal bulan).

Untuk detail apa saja yang gratis dan bagai kondisinya cek tabel berikut ini:

Tipe Transaksi Biaya
Transfer Online via Aplikasi
25x transaksi pertama setiap bulan Gratis
Transaksi berikutnya ke Bank Lain Rp3.000/trx
Transfer dengan metode SKN Rp3.000/trx
Transfer dengan metode RTGS Rp20.000/trx
Ke nomor HP & Email Rp3.000/trx
Transfer Via ATM (dengan m-Card dan x-Card)
Jaringan Prima/Bersama Rp6.500/trx
Tarik Tunai
Akumulasi 25x transaksi pertama menggunakan m-Card (kartu utama) and x-Card (kartu tambahan) di jaringan ATM Prima/Bersama setiap bulan Gratis
ATM BTPN Gratis
Transaksi berikutnya di jaringan Prima/Bersama Rp7.500/trx
Jaringan Visa Rp25.000/trx
Cek Saldo (m-Card & x-Card)
Via aplikasi Gratis
ATM BTPN Gratis
Jaringan Prima/Bersama Rp4.000/trx
Jaringan Visa Rp5.000/trx
Transaksi Gagal
Debit melalui EDC di jaringan Prima Rp2.000/trx
Jaringan Visa Rp5.000/trx
Berkas & Ganti Kartu
Print Dokumen Rp50.000 (maks/hari)
Buat Kartu Baru Free (1 kartu/tahun, Rp25.000 setelahnya)

Sumber: WEB Resmi BTPN Jenius

 

Membayar kartu kredit apapun gratis dengan Applikasi Mobile Android Bank BTPN Jenius: Link