This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String ucapkan(String zikir) { | |
var lafal = ''; | |
switch (zikir.toLowerCase()) { | |
case 'tasbih': | |
lafal = 'Subhanallah'; | |
break; | |
case 'tahmid': | |
lafal = 'Alhamdulillah'; | |
break; | |
case 'takbir': |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Mixins adalah cara agar kode dapat digunakan berulang-ulang | |
// pada hirarki kelas lebih dari satu. | |
// Kelas berikut berfungsi sebagai mixin: | |
class Piloted { | |
int astronauts = 1; | |
void descriveCrew(){ | |
print('Number of astronauts: $astronauts'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Dart tidak memiliki katakunci interface. | |
// Sebagai gantinya semua kelas adalah sebuah interface secara tersirat. | |
// Oleh karenanya, Anda dapat mengimplementasikan sembarang kelas. | |
class MockSpaceship implements Spacecraft{ | |
// ... | |
} | |
// Anda dapat menkreasikan sebuah kelas abstrak yang nantinya akan diperpanjang (atau diimplemetasikan) oleh kelas yang konkrit. | |
// Kelas abstrak dapat mengandung metode-metode yang abstrak (dengan badan yang kosong). | |
abstract class Describable{ | |
void describe(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Hindari neraka panggilnanti dan buat kode anda jadi lebih mudah dibaca | |
// dengan menggunakan async dan await | |
const oneSecond = Duration(seconds:1); | |
// ... | |
Future<void> printWithDelay(String message) async{ | |
await Future.delayed(oneSecond); | |
print(message); | |
} | |
// metode di atas sama dengan berikut | |
Future<void> printWithDelay(String message){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Exceptions | |
// Untuk membangkitkan sebuah eksepsi, gunakan throw: | |
if(astonauts == 0){ | |
throw StateError('No astronauts.'); | |
} | |
// Untuk menangkap sebuah eksepsi, gunakan sebuah pernyataan try dengan on atau | |
// catch (atau keduanya) | |
try{ | |
for(var object in flybyObjects){ | |
var description = await File('$object.txt').readAsString(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Hello World | |
// Setiap aplikasi mempunyai fungsi main(). | |
// Untuk menampilkan teks ke konsol, | |
// Anda dapat menggunakan fungsi level-teratas print() | |
void main(){ | |
print('Hello, World!'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Peubah-peubah | |
// Bahkan di dalam kode Dart yang bersifat tipe-aman | |
// Banyak peubah-peubah tidak memerlukan tipe yang tersurat, | |
// Terima-kasih pada penalaran tipe. | |
var name = 'Voyager I'; | |
var year = 1977; | |
var antennaDiameter = 3.7; | |
var flybyObjects = ['Jupiter','Saturn','Uranus','Neptune']; | |
var image = { | |
'tags':['saturn'], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main(){ | |
var anuMu="hihihi"; | |
print(terbalik(anuMu)); | |
} | |
String terbalik(anu){ | |
return anu.split('').reversed.join();} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Docker aliases | |
alias di='sudo docker images' | |
alias dps='sudo docker ps -a' | |
# useful Docker functions | |
dock-run() { sudo docker run -i -t --privileged $@ ;} | |
dock-exec() { sudo docker exec -i -t $@ /bin/bash ;} | |
dock-log() { sudo docker logs --tail=all -f $@ ;} | |
dock-port() { sudo docker port $@ ;} | |
dock-vol() { sudo docker inspect --format '{{ .Volumes }}' $@ ;} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM php:8.0-fpm | |
RUN apt-get update && apt-get install -y \ | |
libfreetype6-dev \ | |
libjpeg-dev \ | |
libpng-dev \ | |
libwebp-dev \ | |
--no-install-recommends \ | |
&& docker-php-ext-configure gd --with-freetype --with-jpeg \ | |
&& docker-php-ext-install pdo_mysql -j$(nproc) gd |
OlderNewer