Skip to content

Instantly share code, notes, and snippets.

View uyab's full-sized avatar
👽
Write code for humans

Bayu Hendra Winata uyab

👽
Write code for humans
View GitHub Profile
@uyab
uyab / Different file for each log level in Laravel
Last active August 31, 2015 04:46
Memisah log aplikasi Laravel
...
$app->configureMonologUsing(function($monolog) use ($app){
$bubble = false;
foreach($monolog->getLevels() as $name => $level) {
$name = strtolower($name);
$monolog->pushHandler(new \Monolog\Handler\StreamHandler($app->storagePath() . "/logs/{$name}.log", $level, $bubble));
}
});
@uyab
uyab / error-log.txt
Created February 8, 2016 04:44
Kernel Panic
Anonymous UUID: ADCA482E-30A8-76EB-F023-232DB1954601
Mon Feb 8 11:38:43 2016
*** Panic Report ***
panic(cpu 0 caller 0xffffff80031cc23a): Kernel trap at 0xffffff91f0d8fa6c, type 6=invalid opcode, registers:
CR0: 0x000000008001003b, CR2: 0x000070000083fba8, CR3: 0x00000002a8a620f5, CR4: 0x00000000001626e0
RAX: 0x0000000000000000, RBX: 0xffffff91ed511000, RCX: 0x0000000000000000, RDX: 0xffffff91f0e90380
RSP: 0xffffff91ed9139f0, RBP: 0xffffff91ed913a10, RSI: 0xffffff91ed511000, RDI: 0x000000000e4f6000
R8: 0xffffff91f0da6cf0, R9: 0xffffff91ed913a10, R10: 0xffffff91ed913b08, R11: 0x0000000000000206
@uyab
uyab / home.md
Last active November 7, 2016 22:38
There is no place like 127.0.0.1
@uyab
uyab / app.php
Created December 1, 2016 10:32
Memisah log aplikasi Laravel berdasar level dan process name (web atau cli)
// bootstrap/app.php
$app->configureMonologUsing(function ($monolog) use ($app) {
$bubble = false;
foreach ($monolog->getLevels() as $name => $level) {
$name = strtolower($name);
$filename = $app->storagePath()."/logs/{$name}-".php_sapi_name().".log";
$monolog->pushHandler(new \Monolog\Handler\RotatingFileHandler($filename, 0, $level, $bubble, 0666));
}
@uyab
uyab / ganjil-genap.php
Created March 17, 2017 06:24
Print bilangan ganjil genap
<?php
$ganjil = $genap = [];
foreach (range(1, 100) as $angka) {
if ($angka % 2 == 0) {
$genap[] = $angka;
} else {
$ganjil[] = $angka;
}
}
@uyab
uyab / prima.php
Created March 17, 2017 06:45
Print Bilangan Prima
<?php
function isPrime($number) {
if($number <= 1) {
return false;
}
foreach(range(2, $number) as $i) {
if($number % $i == 0) {
@uyab
uyab / fizzbuzz.php
Created March 17, 2017 07:05
FizzBuzz memakai PHP
<?php
foreach (range(1, 100) as $i) {
$msg = '';
if($i % 3 == 0) {
$msg .= 'Fizz';
}
if($i % 5 == 0) {
$msg .= 'Buzz';
}
@uyab
uyab / fibonacci.php
Created March 17, 2017 07:15
Deret Fibonacci
<?php
// 0,1,1,2,3,5,8,13
$fib = [];
foreach (range(0, 100) as $i) {
if ($i == 0) {
$fib[$i] = 0;
} elseif ($i == 1) {
@uyab
uyab / just-in-time-sort.php
Last active November 27, 2020 07:43
Algoritma sorting dadakan
<?php
$numbers = [10, 9, 13, 100, 0, -10, 23, 2, 4, 17, 1000];
echo 'Original data: '.implode(',', $numbers);
echo '<br>';
echo 'After sort: ';
echo implode(',', bubbleSort($numbers));
function bubbleSort($data)
{
@uyab
uyab / routes.md
Last active August 29, 2017 00:34
RESTful Controllers

Soal Restful Controllers

Ngomik.com adalah sebuah platform untuk mempublikasikan komik bagi komunitas. Anda diminta untuk membuat sebuah website sederhana, versi minimalis dari ngomik.com, dengan fungsional seperti berikut:

  • Guest bisa melakukan registrasi menjadi Member
    • Guest harus mengaktivasi akunnya lewat link yang dikirim via email
  • Member bisa login
  • Member bisa mengedit profilnya sendiri
  • Member bisa menghapus akunnya sendiri