Skip to content

Instantly share code, notes, and snippets.

View fatadz's full-sized avatar

fahmi fatadz

  • Bandung, Tasikmalaya
  • 22:39 (UTC +07:00)
View GitHub Profile
@fatadz
fatadz / palindrome.php
Created May 12, 2019 06:37
Check Palindrome Word
<?php
class Palindrome
{
public static function isPalindrome($word)
{
if($word && is_string($word)){
$word = strtolower($word);
$wordReverse = strrev($word);
$isPalindrome = $word==$wordReverse ? true : false;
@fatadz
fatadz / be_sql1.sql
Created May 12, 2019 06:46
BE_SQL #1
select count(1) from students where firstName='John';
@fatadz
fatadz / be_sql2.sql
Created May 12, 2019 09:22
BE_SQL #2
select name from employees
where id not in (select managerId from employees where managerId is not null)
<?php
class Pipeline
{
public static function make_pipeline()
{
$funcs = func_get_args();
return function($arg) use ($funcs)
{
foreach($funcs as $function) {
if(!isset($value))
<!DOCTYPE html>
<html>
<head>
<title>Crop Image Before Upload</title>
<script src="https://code.jquery.com/jquery-3.6.3.min.js" integrity="sha256-pvPw+upLPUjgMXY0G+8O0xUf+/Im1MZjXxxgOcBQBXU=" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
@fatadz
fatadz / postgresql-export-import.sh
Created February 15, 2023 01:31
Export or dump PostgreSQL table structure and data, then import it
#dump 1 table
pg_dump -v --table=table_name --data-only --column-inserts -h 127.0.0.1 -U postgres_user postgres_db > ~/dump.sql
#structure and dump all tables
pg_dump -v -h 127.0.0.1 -U postgres_user postgres_db > ~/postgres-db.sql
#import
psql -h 127.0.0.1 -U postgres_user postgres_db < ~/postgres-db.sql
@fatadz
fatadz / mysql-export-import.sh
Created February 15, 2023 01:33
Export or dump MySQL table structure and data, then import it
#export
mysqldump --set-gtid-purged=OFF -h host_source -u username -p db_name > ~/dump.sql;
#import
mysql -h host_destination -u username -p db_name < ~/dump.sql
@fatadz
fatadz / qrcode.html
Created July 15, 2023 07:22
Generate QR Code in html with javascript
<!DOCTYPE html>
<html>
<body>
<div id="qrcode"></div>
<script src="https://cdn.rawgit.com/davidshimjs/qrcodejs/gh-pages/qrcode.min.js"></script>
<script>
// Get the reference to the HTML element where the QR code will be displayed
const qrcodeContainer = document.getElementById('qrcode');
// Generate the QR code
@fatadz
fatadz / scroll-x.html
Created July 15, 2023 07:27
Horizontally scrollable content
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.wrapper{
max-height: 120px;
@fatadz
fatadz / html input validation.js
Last active September 30, 2023 08:45
To check if multiple input fields are empty using vanilla JavaScript
// Get all the input fields
var inputs = document.querySelectorAll('input');
// Set a flag to track if any input fields are empty
var emptyFields = false;
// Loop through the input fields
for (var i = 0; i < inputs.length; i++) {
// Check if the current input field is empty
if (inputs[i].value === '') {