Skip to content

Instantly share code, notes, and snippets.

function timeLeft($future) // $original should be the future date and time in unix format
{
date_default_timezone_set('Asia/Jakarta');
// Common time periods as an array of arrays
$periods = array(
array(60 * 60 * 24 * 365 , 'Y'),
array(60 * 60 * 24 * 30 , 'M'),
array(60 * 60 * 24 * 7, 'W'),
array(60 * 60 * 24 , 'D'),
array(60 * 60 , 'H'),
<?php
function kekata($x) {
$x = abs($x);
$angka = array("", "satu", "dua", "tiga", "empat", "lima",
"enam", "tujuh", "delapan", "sembilan", "sepuluh", "sebelas");
$temp = "";
if ($x <12) {
$temp = " ". $angka[$x];
} else if ($x <20) {
$temp = kekata($x - 10). " belas";
@madindo
madindo / gist:95e9c7bacd744d27a31760dd0cc31683
Last active November 17, 2022 07:05
Basic Roles permission using spatie permission
app()[\Spatie\Permission\PermissionRegistrar::class]->forgetCachedPermissions();
//MISC
$miscPermission = Permission::create(['name' => 'N/A']);
//USER MODEL
$userPermission1 = Permission::create(['name' => 'create: user']);
$userPermission2 = Permission::create(['name' => 'read: user']);
$userPermission3 = Permission::create(['name' => 'update: user']);
$userPermission4 = Permission::create(['name' => 'delete: user']);
@madindo
madindo / phone_country.php
Created September 29, 2022 01:40
Laravel 8 with breeze - login using phone number
$path = storage_path() . "/json/phone_country.json";
$phone_country = json_decode(file_get_contents($path), true);
$phone = '';
foreach ($phone_country as $country) {
$pos = strpos($this->email, $country['dial_code']);
if ($pos !== false) {
$phone = str_replace($country['dial_code'],'', $this->email);
}
}
@madindo
madindo / passwordValidation.php
Created January 28, 2022 10:51 — forked from Michael-Brooks/passwordValidation.php
Laravel Password validation Regex (Contain at least one uppercase/lowercase letters and one number)
<?php
/*
* Place this with the rest of your rules.
* Doesn't need to be in an array as there are no pipes.
* Password is required with a minimum of 6 characters
* Should have at least 1 lowercase AND 1 uppercase AND 1 number
*/
$rules = [
'password' => 'required|min:6|regex:/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).+$/'
];
h1 {
display: block;
font-size: 2em;
margin-top: 0.67em;
margin-bottom: 0.67em;
margin-left: 0;
margin-right: 0;
font-weight: bold;
}
h2 {
@madindo
madindo / install-wp.sh
Created December 9, 2020 00:34 — forked from BFTrick/install-wp.sh
Download & Install WordPress via Curl
curl -O https://wordpress.org/latest.zip
unzip latest.zip
mv wordpress site
rm latest.zip
<link rel='manifest' href='/manifest.json'>
<script>
// Check compatibility for the browser we're running this in
if ("serviceWorker" in navigator) {
if (navigator.serviceWorker.controller) {
console.log("[PWA Builder] active service worker found, no need to register");
} else {
// Register the service worker
navigator.serviceWorker
protected function mapAmpRoutes()
{
Route::group([
'middleware' => 'web',
'namespace' => $this->namespace,
'prefix' => 'amp',
], function ($router) {
require base_path('routes/amp.php');
});
}
package com.madindo.fotofilio;
import android.content.Intent;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
private static int SPLASH_TIME_OUT = 4000;