Skip to content

Instantly share code, notes, and snippets.

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

Aslam Aslam97

🏠
Working from home
  • Bandung, Jawa Barat, Indonesia
  • 13:38 (UTC +07:00)
  • X @__asuramus
View GitHub Profile
@Aslam97
Aslam97 / interview.md
Created June 24, 2024 06:09
interview
function creditCardCheck(num) {
  var computed = makeComputed()
  var i = (num + '').length
  var start = false // why false? since double every the second index but start from right
  var sum = 0

  // start from right
  while (i--) {
    n = Number(num[i])
@Aslam97
Aslam97 / READM.md
Created June 20, 2024 06:03
bitenow
bitenow.1.mp4
@Aslam97
Aslam97 / is_top.js
Created June 15, 2024 05:06
Is on top scroll react shadow
const [isTop, setIsTop] = useState(true)
useEffect(() => {
const handleScroll = () => {
setIsTop(window.scrollY < 100)
}
window.addEventListener('scroll', handleScroll)
return () => {
@Aslam97
Aslam97 / is_scrolling.js
Last active June 15, 2024 05:05
Check whether is scrolling to bot or top - React
const [currentPosition, setCurrentPosition] = useState(0)
const [isScrollingToBottom, setIsScrollingToBottom] = useState(false)
useEffect(() => {
const handleScroll = () => {
const { scrollTop } = document.documentElement
const isScrollingDown = scrollTop > currentPosition
setIsScrollingToBottom(isScrollingDown)
setCurrentPosition(scrollTop)
@Aslam97
Aslam97 / react-table-laravel-pagination.md
Created March 28, 2024 12:53
Laravel @TanStack table using shadcn

api response

{
    "data": [
        ...
    ],
    "links": {
        "first": "https://example.com/pagination?page=1",
        "last": "https://example.com/pagination?page=10",

kode ini harus di enchance. agar tidak terjadi case seperti ini lagi pada margin import tambahan

    grade_mapping = {
        "Mega Store": "mega",
        "Basic Store": "basic",
        "Super Store": "super",
    }
@Aslam97
Aslam97 / lunar_page_component.md
Created October 10, 2022 11:19
Create Lunar Page and Component

This follow the lunar structure code.

First create folder call Pages and Components inside App\Http\Livewire it will become something like this.

App\Http\Livewire\Components App\Http\Livewire\Pages

Moving on. we will create new Page call Foo

  1. Create livewire component call FooIndex inside Pages
@Aslam97
Aslam97 / mix_to_vite.md
Last active August 15, 2024 07:26
Guide on migrating from Mix to Vite
@Aslam97
Aslam97 / quill_image_upload_to_server_aws_s2.js
Last active January 21, 2024 07:30
Quill upload image to server aws s3
// Check whether quill content is empty
function isQuillEmpty(quill) {
if ((quill.getContents()['ops'] || []).length !== 1) {
return false
}
return quill.getText().trim().length === 0
}
// Delta to HTML
@Aslam97
Aslam97 / generate-referral-code.php
Created April 25, 2021 20:49
Generate referral code
<?php
use Illuminate\Support\Str;
function generateReferralCode($str) {
// get random number min & max 4 digit
$randomNumber = rand(1000, 9999);
// get the first 4 character and trim whitespace
$strName = trim(substr($str, 0, 4));
// get str length