Skip to content

Instantly share code, notes, and snippets.

@kangmasjuqi
kangmasjuqi / Bird.php
Last active May 2, 2021 04:35
PHP OOP with Singleton
<?php
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);
interface Bird{
public function layEgg($egg_name);
}
@kangmasjuqi
kangmasjuqi / bidding
Created February 26, 2021 03:31
bidding
<?php
# Bidding
#
# Tujuan dari bidding ini adalah untuk mencari harga terendah yang ditawarkan oleh setiap partner sebagai pemenang project.
# Terdapat 2 items yang dibuka untuk bidding di bawah ini.
# Setiap item mempunyai harga maximum yang boleh diajukan oleh peserta bidding.
# Peserta bidding dapat memasukkan harga penawaran selama bidding masih aktif yaitu di antara waktu "start" dan "end".
# #####################################################
# Expected result sample:
# # item-a - 1000 - 70000
@kangmasjuqi
kangmasjuqi / sync_datetime_on_linux.txt
Created January 25, 2021 03:22
sync-datetime-from-internet
sudo date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"
ref : https://askubuntu.com/questions/81293/what-is-the-command-to-update-time-and-date-from-internet
@kangmasjuqi
kangmasjuqi / gist:ef188beb00adcd1f3346fd69be1a8202
Created December 2, 2020 08:16
MULTIPLE PAIR OF PUBKEY AND PRIVATEKEY FOR MULTIPLE ACCOUNTS
MULTIPLE PAIR OF PUBKEY AND PRIVATEKEY FOR MULTIPLE ACCOUNTS
STEPS :
- generate multiple pair of private and public key
ssh-keygen -t rsa -C "[email protected]"
ssh-keygen -t rsa -C "[email protected]"
=> enter unique name for these prompt "Enter file in which to save the key (/home/user_name/.ssh/id_rsa):"
- create config file on ~/.ssh folder containing below configuration
@kangmasjuqi
kangmasjuqi / mysql_root_password_changes_on_centos7.txt
Created June 10, 2020 13:39
Change/Reset MySQL Root password on Centos 7
https://stackoverflow.com/questions/33510184/change-mysql-root-password-on-centos7/34207996#34207996
1. Stop mysql:
systemctl stop mysqld
2. Set the mySQL environment option
systemctl set-environment MYSQLD_OPTS="--skip-grant-tables"
3. Start mysql usig the options you just set
systemctl start mysqld
@kangmasjuqi
kangmasjuqi / regex_check_valid_file_url
Last active April 8, 2020 03:12
Javascript Regex - check valid file URL
REGEX :
/(www\.|https?:\/\/)([a-z0-9_\-\.])+([a-z])+\/([a-z0-9_\-\.\/])*([a-z0-9_-])+\.(aif|aiff|bmp|cr2|crdow|db|doc|docx|ds_st|exr|flv|jpeg|jpg|m2ts|m4a|m4v|mkv|mov|mp3|mp4|mpeg|mpg|mxf|pdf|png|psd|rar|rtf|tga|tif|tiff|vid|wav|webm|wma|wmv|xlsx|xml|zip)/gmi
LINK :
https://regex101.com/r/NjaPbb/1
TEST CASES :
@kangmasjuqi
kangmasjuqi / deployedCommits.sh
Last active June 4, 2020 06:59
deployedCommits is designed to fetch commits in each releases folder for https://deployer.org/
# deployedCommits for https://deployer.org/
# created by marjuqi, nov 2019
# 1. this script is designed to fetch commits in each releases folder.
# the final output will be stored in file deployedCommits.log
# 2. in the beginning of the setup, just create a dump latestCommitID.log file:
# cd /var/www/sites/PROJECT_NAME/ && echo 123456789 > latestCommitID.log
# go to the currect version of the codes
projectFolder=/var/www/sites/PROJECT_NAME/
cd $projectFolder'current/'
@kangmasjuqi
kangmasjuqi / longest sql queries #3.txt
Created September 2, 2019 14:10
longest sql queries #3
### the longest sql queries I've ever made in 2016
### QUERY 3
select nmlokasi, anggaran_pagu, anggaran_realisasi,
((anggaran_realisasi/anggaran_pagu)*100) as anggaran_percentage,
table_dzohir.dzohir_target, table_dzohir.dzohir_realisasi, table_dzohir.dzohir_percentage
from
lokasis
left join
(
@kangmasjuqi
kangmasjuqi / longest sql queries #2.txt
Last active August 1, 2024 12:35
longest sql queries #2
### the longest sql queries I've ever made in 2016
### QUERY 2
select table_keuangan.*, dzohir_target,dzohir_realisasi,dzohir_percentage,dzohir_satkeg
from
(
select __is_kegiatan.description as nmitem, table_data.*,
((anggaran_realisasi/anggaran_pagu)*100) as anggaran_percentage
from __is_kegiatan
join (
@kangmasjuqi
kangmasjuqi / longest sql queries #1.txt
Created September 2, 2019 14:09
longest sql queries #1
### the longest sql queries I've ever made in 2016
### QUERY 1
select __is_kegiatan.description as nmitem, table_data.*
from __is_kegiatan
join
(
select table_percentage.kdgiat, table_percentage.kdoutput, table_percentage.kdsoutput,
((percentage_kdsoutput_by_kdoutput*lembaga_keuangan_jumlah_perkdoutput)/100) as jumlah_pagu,
((percentage_kdsoutput_by_kdoutput*lembaga_keuangan_realisasi_perkdoutput)/100) as jumlah_realisasi