Skip to content

Instantly share code, notes, and snippets.

View lakuapik's full-sized avatar

David Adi Nugroho lakuapik

View GitHub Profile
@lakuapik
lakuapik / .env.example
Last active March 13, 2023 11:55
Laravel Sail example config using alpine:edge image with PHP 8
# file: /laravel-project/.env.example
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
APP_SERVICE=laravel.test
APP_PORT=8000
@lakuapik
lakuapik / laravel-mysql-57-json-array-to-rows.php
Last active April 23, 2020 08:44
Laravel MySQL 5.7 implementation of json array as rows
<?php
\Illuminate\Support\Facades\Schema::create('z_user', function ($table) {
$table->uuid('user_id');
$table->json('skills');
});
\Illuminate\Support\Facades\DB::table('z_user')->insert([
['user_id' => \Illuminate\Support\Str::uuid(), 'skills' => '["coding", "baseball", "soccer"]'],
['user_id' => \Illuminate\Support\Str::uuid(), 'skills' => '["coding", "public-speaking"]'],
@lakuapik
lakuapik / stats.php
Created August 31, 2019 05:08
Get uptime, memory usage, cpu usage and disk usage on GNU/Linux server using PHP
<?php
header('Content-Type: application/json');
function get_uptime()
{
$str = @file_get_contents('/proc/uptime');
$num = floatval($str);
$secs = (int) fmod($num, 60); $num = intdiv($num, 60);
$mins = $num % 60; $num = intdiv($num, 60);
@lakuapik
lakuapik / statlog.sh
Created April 2, 2019 07:31
Stat Log Linux
#!/bin/bash
# DateTime
now=`date +"%Y/%m/%d %H:%M:%S"`
# Memory Total
mem_total=`grep 'MemTotal' /proc/meminfo | awk '{print $2}'`
mem_total=$(expr $mem_total / 1024) #KB to MB
# Memory Used
@lakuapik
lakuapik / dim
Created July 12, 2018 23:02
Ubuntu GNU/Linux screen dimmer command line bash script
#!/bin/bash
# copy this file to /usr/local/bin/
# usage: dim 0.5 -> 0.5 is the brightness
screen=($(xrandr -q | grep -w 'connected'))
xrandr --output $screen --brightness $1
@lakuapik
lakuapik / tugas-1-teknologi-web.html
Last active October 5, 2017 03:00
Tugas 1 : Teknologi Web
<!DOCTYPE html>
<html>
<head>
<title>Lorem 101</title>
</head>
<style type="text/css">
body {text-align: center;}
.red {color: red;}
.green {color: green;}
.brown {color: brown;}
@lakuapik
lakuapik / ganjilgenap.py
Created April 17, 2017 10:37
Python: Membedakan Angka Ganjil dan Genap
#!/usr/bin/env python3
'''
17 Apr 2017 JKT DHE
davidadi216@gmail.com
skrip python untuk membedakan angka ganjil dan genap
Penggunaan: python ganjilgenap.py [angka]
-> python3 ganjilgenap.py 9