Blog posts categorized as Reply
Menambahkan array baru pada object array
Artikel ini merupakan jawaban saya terhadap salah satu pertanyaan pada situs Kotakode.com, sebuah forum dan komunitas para developer di Indonesia. Lihat pertanyaan asli Pertanyaan Saya punya list data berdasarkan tahun, dimana list data tersebut dicek apakah list data tersebut setiap tahun ada datanya atau tidak… jika list data tersebut tidak ada data.nya, maka tambahkan object baru… ini codingannya saya : $data = [ [ 'hak' => '12', 'tambahan' => '6', 'sisa' => '12', 'tahun' => '2019' ], [ 'hak' => '12', 'tambahan' => '6', 'sisa' => '12', 'tahun' => '2021' ] ]; $tahun = [ '2019', '2020', '2021' ]; for($i=0;$i<count($tahun);$i++){ $tahun == $tahun[$i]; $filterData = array_filter($data, function($entry) { global $tahun; return $entry['tahun'] == $tahun; } ); $newdata = [ 'hak' => '12', 'tambahan' => '0', 'sisa' => '0', 'tahun' => $tahun ]; if(count($filterData)==0){ $data = array_push($newdata); } } return $data; Hasil yang diinginkan seperti ini: [ { hak: '12', tambahan: '6', sisa: '12', tahun: '2019' }, { hak: '12', tambahan: '0', sisa: '0', tahun: '2020' }, { hak: '12', tambahan: '6', sisa: '12', tahun: '2021' } ] Tetapi setelah saya jalankan codinganya, muncul error seperti ini : array_filter() expects parameter 1 to be array, null given Jawaban Halo, kalau saya lihat kamu salah menggunakan array_push(): $data = array_push($newdata); cara yang benar untuk memakainya adalah array_push($data, $newdata); karena fungsi array_push() akan mengembalikan return value berupa jumlah isi di dalam array yang sudah dimerge, bukan array yang sudah digabungkan tersebut. Makanya muncul error itu.
Re: Falling in love with writing code
I've walked this path for over 7 years, from just learning to create a simple website, then discovered Node.js, C, PHP, Python, Java (Android), Dart/Flutter and now Swift and still wanted to learn either Rust, Golang, or C#... But sure there's ups and downs too, like when you're up for a deadline and still have to finish all those bugs. At the end, I treated myself as my own code and software, because I've been thinking about this all day long. And for my entire life. There's still a long way to go to "teach" computers to do the same thing like me, I mean, being able to do what I thought as a software. That's why, be patient.
Re: Building a tool for tech bloggers to write, schedule and publish posts on all major platforms
I currently rely on WordPress and its RSS/Atom integration, which is still good for forwarding content from my personal blog site at reinhart1010.id to others like DEV.to and Hashnode through a mechanism namely "Publish (on your) Own Site, Syndicate Elsewhere" (POSSE). The good news is that I can just write new posts from my site, then selectively forward them into other blogging sites through automated export/import from the generated RSS/Atom feeds. But there are some challenges, though. First, not all of my blog posts on my site might be relevant to, let's say, DEV.to audiences. So I need to filter posts by two steps: Manually tagging from my WordPress site that might be relevant, and that's why I used specific tags like #feed-en-tech to be whitelisted in the generated, curated RSS feed at reinhart1010.id/tag/feed-en-tech/feed. Choosing the right tags to be published on DEV.to. DEV.to posts are currently limited to 4 tags, and some of them (like #showdev) have their respective content guidelines. Taking my post about how bad virtual expos are, I decided to republish to DEV.to under a different topic: User Experience, since #ux on DEV.to seems to be more active than others like "Virtual Reality". Another next problem is that it's difficult to get "likes" from viewers on your WordPress site, unless if they have their respective personal blog sites. WordPress have implemented pingbacks since way back then, and modern alternatives like ActivityPub and Webmentions are (intentionally) unsupported on major blog platforms today like LinkedIn and Medium. The solution is either: Republish my posts on other platforms, or Encourage readers to use federated social platforms (e.g. Mastodon), or Encourage readers to have their blog sites which supports sending pingbacks/webmentions Of course, the last 2 options are not viable for those already comfortable with existing sites, like this DEV.to. That's why I decided to selectively repost to other sites. Speaking of your idea, I really recommend to implement these two features: Assigning different tags/categories for publishing into different platforms, An integrated counter (think about a WordPress plugin/widget) to show the current total number of views, likes, and comments. I think this closely follow your idea about analytics.
Q&A: Sebutkan contoh dari application layer dalam OSI Model yang anda gunakan dalam kehidupan sehari-hari!
Sebenarnya, hampir semua aplikasi yang kita pakai hari-hari ini merupakan bagian dari application layer, setidaknya menurut OSI model. Anda sering menggunakan aplikasi pesan instan, dan aplikasi-aplikasi tersebut sering menggunakan protokol HTTP(S) untuk mengecek dan mengirimkan pesan-pesan baru. Adapun aplikasi email yang menggunakan HTTPS untuk melakukan autentikasi OAuth2 (biasanya untuk Yahoo! Mail, Gmail, Office 365, dan Outlook.com), menggunakan IMAP atau POP untuk menerima pesan, serta SMTP untuk mengirim surat baru. Jika kedua aplikasi ini masuk ke dalam application layer yang dimaksud, apalagi aplikasi video conference yang menggunakan protokol-protokol lainnya seperti QUIC (misal: di dalam aplikasi Google Duo) dan WebRTC, aplikasi ojek online yang ujung-ujungnya bergantung terhadap HTTPS, serta aplikasi SMS yang menggunakan salah satu jenis protokol Point-to-Point yang diadopsi untuk jaringan GSM dan CDMA. Dan ternyata, sebuah aplikasi media sosial yang menggunakan HTTPS dan RTMP pun juga tergolong ke dalam application layer, karena menurut definisi OSI sendiri application layer merupakan lapis terdekat jaringan komputer terhadap para end-user.
Q&A: Apa itu SMTP? dan bagaimana cara protokol SMTP bekerja?
SMTP (Simple Mail Transfer Protocol) merupakan sebuah protokol yang ditujukan untuk mengirim surat elektronik (email). Namun, protokol ini hanya ditujukan untuk mengirim pesan sesama client/perangkat pengirim dan server email saja; untuk melihat daftar email yang diterima sebuah client/perangkat perlu untuk menggunakan protokol POP (Post Office Protocol), IMAP (Internet Mail Access Protocol), atau mengakses situs HTTP/HTTPS yang dimiliki/dioperasikan oleh server email tersebut. Sebelum sang client (alias User-Agent/UA) dapat mengirim surat melalui SMTP, client tersebut harus menghubungi dan mengecek apakah server email asal (sender Mail Transfer Agent/MTA) aktif dan bersedia untuk mengirim email. Jika server/MTA tersebut membalas permintaan sang client/UA dengan status "220 Ready for Mail", maka client tersebut sudah dipastikan dapat mengirim email selama permintaan-permintaan client berikutnya tidak terganggu akibat masalah dalam jaringan yang menghubungkan sang client/UA dengan server/MTA. Kemudian, client tersebut akan mengirimkan perintah EHLO kepada server email pengirim. Dalam kasus ini saya menggunakan perintah EHLO daripada HELO untuk menggunakan fitur-fitur yang ada di dalam protokol Extended SMTP, termasuk fitur autentikasi yang sering digunakan dalam banyak aplikasi dan layanan email saat ini. Jika server tersebut meminta sang client untuk menyebutkan data credentials (misal: alamat email dan password, atau token OAuth2) di dalam respons 250 dari server (misal: "250 AUTH LOGIN PLAIN DIGEST-MD5"), maka sang client akan mengirimkan data-data yang diminta dan server tersebut akan memverifikasinya. Oke, anggap saja bahwa proses autentikasi tersebut telah usai. Client tersebut akan mulai untuk memasukkan data-data berikut (secara berurutan): 1. Alamat pengirim email, menggunakan perintah MAIL FROM 2. Alamat penerima email, menggunakan perintah RCPT TO 3. Isi pesannya, baik head (misal: metadata) dan body, menggunakan perintah DATA Jika pesan tersebut sudah siap dikirim dari server, maka sang server akan memberikan kode status 250 kepada sang client. Server pengirim tersebut akan menjadwalkan pengiriman surat tersebut kepada server penerima (kecuali sang client memutuskan untuk mengirim perintah RSET sebelum surat tersebut dikirim dari server), dan jika server dan/atau alamat penerima tersebut tidak ditemukan, maka server pengirim tersebut berhak untuk memberitahu sang client bahwa pengiriman surat tersebut gagal, biasanya melalui email khusus dari program "mailer daemon" yang dijalankan oleh server pengirim tersebut. Protokol SMTP juga dapat digunakan untuk memverifikasi jika alamat yang dituju ada, dengan menggunakan perintah VRFY, dan mengecek apakah koneksi server tersebut masih aktif dengan menggunakan perintah NOOP. Terakhir, jika client tersebut ingin memutuskan hubungan terhadap server pengirim, maka client tersebut dapat mengirimkan perintah QUIT untuk melakukannya. Referensi https://www.samlogic.net/articles/smtp-commands-reference.htm https://www.ionos.com/digitalguide/e-mail/technical-matters/smtp-auth/
Q&A: Jelaskan fungsi dan cara kerja ARP dan ICMP
ARP (Address Resolution Protocol) ARP merupakan sebuah protokol link-layer yang berfungsi untuk mencari alamat fisik (bagian) perangkat komputer yang terhubung dengan sebuah jaringan (seperti Network Interface Card dan Wireless NIC) berupa alamat MAC berdasarkan alamat IP yang disetel atau diterima perangkat tersebut (misal: melalui DHCP). Dalam protokol IPv6 protokol ini digantikan dengan Neighbor Discovery Protocol (NDP). Namun, hal ini tidak berarti bahwa ARP hanya dapat digunakan di dalam jaringan protokol IPv4 saja. Pencarian alamat MAC melalui ARP ini dapat dilakukan dengan mengirim sebuah paket request kepada broadcast address global 255.255.255.255 atau broadcast address jaringan tersebut. Jika ada sebuah perangkat yang memang memiliki alamat IP yang dicari, maka perangkat tersebut akan mengirimkan paket reply yang berisi informasi alamat MAC yang dicari. Perangkat-perangkat komputer juga sering meng-cache hasil pencarian alamat MAC melalui ARP ini untuk beberapa waktu, sehingga mereka dapat menghemat waktu yang diperlukan untuk mencari alamat MAC kembali saat mengirim paket dengan alamat IP yang sama dengan paket-paket sebelumnya. ICMP (Internet Control Message Protocol) ICMP berfungsi sebagai protokol pendukung jaringan komputer yang berfungsi untuk mengirim informasi operasional atau kendala pada jaringan-jaringan Internet. Meskipun nama ICMP sendiri berasal dari kata Internet, ICMP ini masih dapat digunakan di dalam jaringan lokal (LAN) tanpa adanya hubungan ke WAN atau Internet. Beberapa contoh informasi yang dikirimkan melalui ICMP adalah pesan-pesan error yang sering kita temukan seperti Destination host unreachable, Destination port unreachable, Destination network unknown, dan bahkan PING (Echo reply). Karena itu, protokol ini sering digunakan di dalam program ping, traceroute, dan program-program diagnostik jaringan lainnya untuk mengecek kendala-kendala dalam sebuah jaringan komputer. Seluruh paket informasi yang diberikan melalui ICMP dilakukan secara sukarela. Jika misalnya perangkat A berhasil mengirim data ke perangkat B melalui router C, router tersebut tidak harus mengirim pesan ICMP kepada perangkat A yang mengirimnya. Bahkan, ICMP sendiri tidak memerlukan koneksi TCP/IP atau UDP untuk mengirim informasi tersebut, sehingga protokol ini masuk ke dalam kategori Internet-layer dalam daftar protokol yang sering digunakan untuk berkomunikasi di dalam Internet.
Q&A: Apa yang anda ketahui mengenai Intranet dan Extranet serta berikan contohnya!
Intranet Intranet merupakan sebuah jaringan komputer yang hanya dikhususkan untuk kepentingan internal, misalnya untuk kepentingan pribadi, organisasi, atau perusahaan, sehingga akses dari dan terhadap jaringan tersebut dibatasi dengan alasan-alasan keamanan. Berikut ini adalah contoh kasus nyata di mana Intranet dapat digunakan dalam kehidupan sehari-hari. Saya memiliki sebuah perangkat Raspberry Pi yang terhubung dengan sebuah printer dan jaringan Wi-Fi, di mana perangkat tersebut dapat memungkinkan saya untuk mencetak dokumen langsung dari laptop dan ponsel saya tanpa menghubungkannya ke dalam printer tersebut (melalui CUPS, Bonjour/Avahi, SMB, dan AirPrint). Saya tidak mau orang lain yang berada di luar jaringan Wi-Fi saya dapat mengaksesnya dan menggunakannya, karena hal tersebut dapat memboroskan penggunaan kertas HVS, tinta printer, serta listrik di rumah saya. Karena itu, saya memutuskan untuk mengatur Firewall untuk memblokir akses masuk dari perangkat komputer yang berada di luar jaringan Wi-Fi saya terhadap perangkat Raspberry Pi tersebut. Karena itu perangkat Raspberry Pi dan perangkat lainnya yang terhubung secara langsung dengan Wi-Fi saya masuk di dalam sebuah jaringan Intranet. Kemudian, Anda secara tidak sadar juga menggunakan Intranet saat Anda hendak melakukan screen sharing ke sebuah Smart TV berbasis Apple AirPlay dan Google Chromecast. Koneksi screen sharing berbasis Miracast tidak tergolong sebagai koneksi Intranet karena Miracast menggunakan koneksi Wi-Fi Direct yang bersifat Personal Area Network / PAN. Anda pastinya tidak mau jika seseorang dari jarigan luar melakukan koneksi screen sharing tanpa seizin Anda. Karena itu, perangkat router Anda secara otomatis memblokir akses ke LAN dari WAN, sehingga Smart TV Anda secara otomatis berada di dalam Intranet milik Anda. Extranet Sedangkan, Extranet merupakan sebuah jaringan komputer yang secara khusus dirancang agar dapat diakses oleh pengguna di luar jaringan tersebut (misal: WAN) dengan batasan dan syarat tertentu. Sebuah perangkat Extranet dapat dipasang di dalam jaringan Intranet yang sudah ada untuk membuka akses bagi sebagian pengguna WAN/Internet untuk mengunjungi dan menggunakan sistem/aplikasi dan informasi di dalamnya. Jarigan Extranet saat ini sudah sering digunakan di dalam remote working khususnya dalam masa pandemi seperti ini, di mana banyak perusahaan memasang perangkat server VPN (Virtual Private Network) yang dapat memudahkan para pekerja untuk mengakses informasi yang berada di Intranet perusahaan tanpa harus berada di dalam kantor. Perangkat server VPN inilah yang berfungsi membuka akses Intranet menjadi Extranet bagi perusahaan tersebut. Selain itu, Anda sebagai Binusian mungkin sudah mengenal beberapa situs intranet yang hanya dapat diakses di dalam perangkat-perangkat komputer yang terpasang di dalam sistem jaringan komputer di dalam kampus-kampus BINUS. Meskipun bukan merupakan server VPN, situs ini masih dapat dikategorikan sebagai salah satu jaringan Extranet karena mahasiswa Binus lainnya masih dapat mengakses sistem tersebut tanpa harus menggunakan salah satu perangkat komputer di dalam lingkungan kampus.
Q&A: What are the pros and cons of Android and iOS that most people are not aware of?
Android If you think that Google invented Android, you are absolutely wrong. Andy Rubin, an ex-Apple employee, founded Android, Inc. and Android as an open source OS before Google purchased and acquired Android. Advantages of Android Open source, anyone can take the source code of some AOSP (Android Open Source Projects) Applications and Components. That's why BlackBerry 10 and Jolla devices can also run Android Apps, and Android manufacturers are allowed to customize the UI/OS such as Xiaomi's MiUI, Samsung's TouchWiz, HTC Sense UI etc. Runs on many devices, since it's allowed to be ported for other phones/devices. Owned by Google, which means that there are many Google-integrated features in Android (such as Contacts backup, Gmail, Google Drive, etc.) Customization. This is one of the biggest factors of the switch from iOS/others to Android. You can choose many different types of Launchers/Home Screens, Keyboards (Even though this can be customized since iOS 8), Status bar, and more. Variants. Manufacturers can easily integrate Android with some new features on the phone, such as fingerprint and eye scanner. There are also some Android variants, one of them is CyanogenMod. App installation and updates. Most Google Apps in Android can be updated without updating the OS. Android users just simply update it in Google Play Store (or others). Many apps can also be installed/updated without Google Play Store, by just installing the app in .APK format. This is useful for enterprises to create company-specific apps for Android. External storage support. This is another factor of the switch to Android. iPhones does not have support for memory cards (Micro SD cards), and the only way to connect with PC/Mac is through iTunes (And iTunes is not available in Linux distributions). Some manufacturers may have their own app to connect their Android devices to computers, such as Kies3 by Samsung. First setup and updates. Android may not need any software (such as iTunes) to setup your phone and delivering updates. iOS setup must require iTunes. Android updates will also not deleting your apps and your data, so it's easier to update than iOS. Price. Prices of Android phones are vary, depending on your needs. Many of them are cheaper than iPhones and iPads, while some of them have features what iOS devices (iDevices) does not have. Disadvantages of Android Google Play Services. This is a Google's trick: As I mention earlier, Android is open source, but it's limited to AOSP apps. Google Play apps and Services are not open source. Manufacturers must comply with Google's standard (and pay to Google) to allow Google Play Services and Apps to be bundled with their Android builds. Google Play Services is also important to many Google APIs on Android, and this is the reason why apps with Google Maps API and other Google APIs may fail in BlackBerry 10 and Sailfish OS. Different screen sizes and resolutions can cause problems with app development. This can take time to developers to develop an Android App. Bloatware. Many Android Apps are bloatwares, including unnecessary Google Apps. Manufacturers may include "Exclusive" apps that you may not use. And, there are many Google Apps that you also may not use. Bloatwares can take up many of device memory. Fortunately, many of them can be disabled through Settings. Update lifecycle. This depends of the manufacturers' decision. Android One phones receive updates for several years, Nexus phones are often to be updated quickly and used to test the beta versions of Android. Samsung's high-end devices received updates about a year after Google's official release, while old and low-end Android devices may not receive updates at all. This is because some manufacturers are modifying and porting the new versions of Android for their devices, and that's a long process. Different versions. Since updates are released slowly, there are many different Android versions of all Android devices around the world. Currently, Android 4.x is more used than Lollipop (5.x), Marshmallow (6.x) and Android N (7.x). This may cause difficulties with developers to create apps and fix bugs. Compatibility with older versions of Android. Currently, Google Apps supports from Android Jellybean to Android N. Meanwhile, Google is also developing a compatibility layer for some features (such as Material Design for KitKat and below). Developers must choose which Android will be supported, since lower versions means less APIs and functions, as well as some things that are deprecated today. Security. Some bugs on Linux kernel in Android phones may open backdoors to security flaw. Furthermore, there are some malicious Android apps that can threat the OS itself. iOS If you think that iOS is the first smartphone OS, that’s another mistake. Before iOS, there are some smartphone/PDA OS before it, such as BlackBerry, Palm WebOS, Windows Mobile and even Apple’s Newton OS for their Newton Messagepad PDAs. Please note that iOS is originally a trademark of Cisco Systems, Inc. not Apple, Inc. Advantages of iOS Just works. If you don't care about customization, and random process of setting up your phone, iOS may be perfect for you. If you notice, there are far less steps for you to set up an email account, calendar, even installing Apps from the App Store can be done in a tap. In Google Play, users are asked to understand the App permissions (for non-Marshmallow devices). Software lifecycle. In iOS, it's far easier for iPhones to update (rather than Android devices, unless you are using latest Android phones). This also benefit for developers so they can integrate new iOS features easily. App size. Most of apps whose have both iOS and Android versions are different in memory size. In fact, iOS apps are “lighter” than Android apps. This happens due to diverse Android phones that are need to be supported, with new Material Design libraries for Android as well. Continuity. If you previously owned other Apple products (such as a Macbook), a new feature in iOS, MacOS (OS X), WatchOS and Apple tvOS, which allows you share content from an Apple device to another Apple device, including photos, clipboards, notes and more. Again,this is a new feature and requires latest version of those Apple OSes I mentioned above. User Interface. Even though Android's Material Design is good, iOS keep the UI as simple as possible. The aim of iOS to create a mobile OS which “Just works”. Security. By restricting other third-party content on iOS, iOS is more secure than Android. Even though there was some bugs in iOS, Apple fix those bugs on later versions. Disadvantages of iOS Apple ID. Most of iOS apps may require Apple ID for services such as Continuity, Apple Pay, Apple Watch integration, App Store, Game Center and even the iTunes. If you already have the Apple ID you won’t worry about this Restrictions. Unlike Android, iOS wants to monopoly your activities by their services. For example, you cannot install an iOS app just by download and install the packages like what Android does. Then, some of iOS apps are default for specific tasks, such as Safari for browsing and iTunes/Apple Music for playing music, even though Jailbreak is available for iOS. Meanwhile, this can improve the security of iOS as iOS apps are regulated in the App Store guidelines, and constantly reviewed by Apple. iTunes dependency. Every time you are updating to the latest iOS version, there’s always one more step: connect with iTunes for your computer. In Android, the updating process is straightforward and does not delete any of your previously installed updates. Price. iOS, alongside with other Apple OSes, are closed source. This means that to enjoy iOS you must have either the iPhone, iPad, or even the iPod Touch. In some countries, those devices are expensive due to taxes applied in their government. The iOS-capable devices are “the same”. This statement is even used in new Android marketing campaign, “Be together, not the same”. Unless a custom case is applied for iPhones, someone may incidentally steal your iPhone because it looks the same with each other. Storage. iPhones, iPod Touch and iPads are limited in storage. There are no external storage, weird iCloud problems, and other web storage apps available (such as Dropbox and Google Drive). Meanwhile, this should not be a problem because based on my experience, a 8GB iPod Touch (4th Generation, iOS 4) can be filled with almost 50 apps and Jailbreak, and less photos.
Q&A: Which were the first browsers that claimed to have at least partial HTML5 support?
Since most of the HTML5 components are come from previous versions (such as from basic HTML to HTML 4.01), HTML4-capable browsers still can support it. Since the HTML5 is released in 2012–2014, there were few browsers who claimed to have HTML5 support. According to Which Browsers Support HTML5? Chrome 10 had the highest score in The HTML5 test - How well does your browser support HTML5?, which is 301 out of 400 (now 300, since the maximum score increases to 555) should have more HTML5 compatibility. Firefox 4.0 has 249 out of 400 (now 215 out of 555). Opera 11.10 comes the next, with score 212 out of 555. Safari 5.1 scored 224 out of 555. The last browser to have good HTML5 support is Internet Explorer 10. It scores 265 out of 555. You can find the data in Which Browsers Support HTML5?, including for tablet and mobile OSes, as well as others such as game consoles, Kindle and smart TVs.