Skip to content

Instantly share code, notes, and snippets.

View fajarwz's full-sized avatar
👨‍💻
Working from anywhere

Fajar Windhu Zulfikar fajarwz

👨‍💻
Working from anywhere
View GitHub Profile
@fajarwz
fajarwz / app.js
Created May 26, 2020 03:37
entry point nya di app.js
import "../manifest";
// import '../node_modules/materialize-css/dist/css/materialize.min.css';
import "./nav";
import "./register-sw";
import home from "./home";
import "./article";
import "./db";
document.addEventListener("DOMContentLoaded", home);
@fajarwz
fajarwz / .env
Created December 14, 2020 04:18
Setting timezone di laravel (bisa untuk memperbaiki waktu created_at, updated_at)
// dan begini lah penampakan variabel timezone di .env
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
APP_TIMEZONE="Asia/Jakarta"
// ketika sc dibuka di komputer lain tinggal setting di .env jika timezone disetting menggunakan .env
@fajarwz
fajarwz / web.php
Created December 14, 2020 04:26
Cara routing di Laravel 8
// routes/web.php
// 1. Menulis Alamat Controller ketika Pendefinisian
// Contohnya:
Route::get('/user',[App\Http\Controllers\User\UserController::class, 'index']);
// 2. Menggunakan use
// Contohnya:
@fajarwz
fajarwz / index.html
Last active January 30, 2021 16:54
CSS for floatable item
<div class="header">
<h3>Example of floatable</h3>
</div>
<div class="card floatable">
<h4>
Hover me!
@fajarwz
fajarwz / app.js
Created June 25, 2021 13:21
Reverse String using JS
function reverseString(str) {
return str.split('').reverse().join('');
}
console.log(reverseString('ya ndak tau'));
@fajarwz
fajarwz / app.php
Created June 25, 2021 14:07
Factorial using PHP (recursive)
<?php
function factorial($n) {
return ($n == 1 ? $n : $n * factorial($n - 1));
}
echo factorial(6);
@fajarwz
fajarwz / app.php
Created June 25, 2021 14:36
Search for 3 numbers that summable to zero using PHP
<?php
function threeSummableToZero($arr) {
for($i = 0; $i < count($arr); $i++) {
for($j = 0; $j < count($arr); $j++) {
for($k = 0; $k < count($arr); $k++) {
if($i == $j || $j == $k || $i == $k) continue;
if($arr[$i] + $arr[$j] + $arr[$k] == 0) return "[".$arr[$i].", ".$arr[$j].", ".$arr[$k]."]";
@fajarwz
fajarwz / app.php
Created June 25, 2021 15:01
Palindrome checker using PHP
<?php
function isPalindrome($string) {
for($i = 0, $j = strlen($string) - 1; $i < strlen($string) / 2; $i++, $j--) {
if($string[$i] != $string[$j]) {
return 'false';
}
@fajarwz
fajarwz / app.php
Created June 25, 2021 15:12
Fizz Buzz using PHP
<?php
function fizzBuzz($total) {
for($i = 1; $i <= $total; $i++) {
if($i % 3 == 0 && $i % 5 == 0) {
$result .= "Fizz Buzz\n";
}
elseif($i % 3 == 0) {
@fajarwz
fajarwz / app.php
Created June 25, 2021 17:10
Get Prime Numbers using PHP
<?php
function getPrimeNumbers($total) {
// 1 is impossible to be the prime number. 2 is the first prime number.
// the law is prime number cannot be divided by other prime number.
// so our logic here is to try to divide the number that we want to check
// with prime number that is previously identified.
$result = [2];
for($i = 2; $i <= $total; $i++) {