Skip to content

Instantly share code, notes, and snippets.

View cyberfly's full-sized avatar

Muhammad Fathur Rahman cyberfly

View GitHub Profile
@cyberfly
cyberfly / test.html
Last active December 19, 2023 09:11
Add validation to hx-trigger. If validate false, hx-post is not trigger `hx-trigger="submit[!isFieldEmpty('#seed_keyword')]`
<form
id="keyword_suggestions_form"
hx-post="/api/v1/keywords"
hx-target="#keywords_container"
hx-indicator="#loader_container"
hx-on:htmx:before-request="emptyDiv('#keywords_container')"
hx-trigger="submit[!isFieldEmpty('#seed_keyword')], submitKeywordSearch from:body"
>
<button type="submit">Search</button>
</form>
<?php
namespace App\Libraries;
class Lookup {
// constant for MAP NEGERI ID
// const MAP_JOHOR = "001";
// const MAP_KEDAH = "002";
public function store()
{
$rules = [
'title' => 'required',
'description' => 'required',
];
if (! $this->validate($rules)) {
return redirect()->back()->withInput();
}
<script type="module">
let data = {!! $keywords !!};
$('#example tbody').on('click', 'button', function () {
var data = table.row($(this).parents('tr')).data();
$("#keyword").val(data.keyword);
$("#keyword").focus();
});
@cyberfly
cyberfly / Layout.js
Last active September 14, 2022 07:50
const Layout = ({ children }) => {
useEffect(() => {
// set version
window.APP_VERSION = process.env.NEXT_PUBLIC_APP_VERSION;
}, []);
}
export default Layout;
@cyberfly
cyberfly / command.txt
Last active September 6, 2022 03:09
Now you can preview served project at http://localhost:8090
Host devserve
User akid
HostName 12.120.104.101
Port 41083
ForwardAgent yes
LocalForward 8090 localhost:8000
@cyberfly
cyberfly / .env
Last active September 1, 2022 02:05
NEXT_PUBLIC_HELPSCOUT_BEACON_ID=9dc0a553-237e-5678-1234-09977d96ddf8
import React, { useState, useEffect } from "react";
import Modal from "react-modal";
import { getModalStyle } from "helpers/common_helper";
export default function Home() {
const [modalIsOpen, setIsOpen] = useState(false);
// modal methods
function openModal() {
const nextConfig = {
trailingSlash: true,
images: {
loader: "akamai",
path: "",
},
};
module.exports = nextConfig;
cp -a /source/. /dest/