Skip to content

Instantly share code, notes, and snippets.

View didikz's full-sized avatar
🏠
Working from home

Didik Tri Susanto didikz

🏠
Working from home
View GitHub Profile
@didikz
didikz / friday.php
Created July 15, 2025 04:39
Displaying Friday
<?php
// Set timezone (you can adjust this to your timezone)
date_default_timezone_set('UTC');
// Get current date
$currentDate = new DateTime();
// Calculate end date (6 months from now)
$endDate = clone $currentDate;
$endDate->modify('+6 months');
@didikz
didikz / main.go
Last active May 4, 2025 12:38
Golang Middlewares
// you need to create the module first by running
// go mod init <yourpackage>
package main
import (
"context"
"encoding/json"
"errors"
"log"
"net/http"
@didikz
didikz / test.php
Created October 7, 2020 01:54
Sample test using pest php
<?php
use App\Domain\User\User;
use function Tests\actingAs;
use App\Domain\Product\Product;
use App\TestFactory\UserFactory;
use App\Domain\Merchant\Merchant;
use Illuminate\Http\UploadedFile;
use App\TestFactory\MerchantFactory;
@didikz
didikz / compose-components.blade.php
Created March 24, 2020 03:51
example of component implementation in laravel blade
@extends('layouts.app')
@section('content')
<div class="max-w-4xl mx-auto py-6">
<div class="bg-white shadow overflow-hidden sm:rounded-lg">
<div class="px-4 py-5 border-b border-gray-200 sm:px-6">
<h3 class="text-lg leading-6 font-medium text-gray-900">
Applicant Information
</h3>
<p class="mt-1 max-w-2xl text-sm leading-5 text-gray-500">
@didikz
didikz / app.blade.php
Created March 21, 2020 18:46
Basic layout app for laravel tailwind UI
<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
@didikz
didikz / composer.json
Created March 15, 2020 13:21
composer.json with git hook setup
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
@didikz
didikz / gcs-laravel-upload.php
Created October 23, 2019 17:42
snippet upload image to Google Cloud Storage using laravel & intervention
<?php
public function store(Request $request)
{
try {
$watermark = storage_path('app'.DIRECTORY_SEPARATOR.'watermark.png');
$thumbnailName = 'thumb_'.sha1(date('Y-m-d H:i:s').uniqid()).'.png';
$originName = 'img_'.sha1(date('Y-m-d H:i:s').uniqid()).'.png';
$thumbnailUrl = storage_path('app'.DIRECTORY_SEPARATOR.'public'.DIRECTORY_SEPARATOR.'imagerepositories'.DIRECTORY_SEPARATOR.$thumbnailName);
<html>
<body>
<form>
IP Server
<input type="text" id="ip" name="ip" maxlength="50" size="50">
Port Server
<input type="text" id="port" name="port" maxlength="50" size="50">
<br/>
<?php
class SomeClass {
public function dashboard(Request $request)
{
$user = $this->userSummary();
$merchant = $this->merchantSummary();
<?php
class SomeClass {
public function dashboard(Request $request)
{
$userTotal = User::where('type', 'customer)->count();
$userToday = User::where('type', 'customer')->whereDate('created_at', date('Y-m-d))->count();
$userActive = User::where('type', 'customer)->where('is_active', true)->count();
$userSuspended = User::where('type', 'customer')->where('is_active', false)->count();