Skip to content

Instantly share code, notes, and snippets.

View mul14's full-sized avatar
:octocat:
Preparing for big things...

Mulia Nasution mul14

:octocat:
Preparing for big things...
View GitHub Profile
@mul14
mul14 / README.md
Last active November 4, 2024 06:03
How to set MySQL timezone with timezone name?

Check current MySQL timezone:

SELECT @@global.time_zone, @@session.time_zone;

The value might be SYSTEM, UTC, or your current MySQL timezone.

If you want to change the default MySQL timezone to something else (e.g Asia/Jakarta), run this query:

SET GLOBAL time_zone = 'Asia/Jakarta';
@mul14
mul14 / mysql_create_new_user.sql
Created May 15, 2022 13:46
MySQL: Create new user with native password
CREATE USER 'username'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
ALTER USER 'username'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost';
FLUSH PRIVILEGES;
-- Reference: https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql
@mul14
mul14 / docker-compose.yml
Last active June 4, 2022 18:55
Docker compose for PHP 7.2, MySQL 5.7, Adminer
version: '3.8'
services:
nginx:
image: nginx:1.21
ports:
- "8000:80"
volumes:
- .:/var/www/html
- ./site.conf:/etc/nginx/conf.d/default.conf
@mul14
mul14 / switch_to_mysql_native_password.md
Created January 18, 2022 10:33 — forked from rohsyl/switch_to_mysql_native_password.md
MariaDB switch to mysql_native_password

Switch to mysql_native_password plugin

By default MariaDB use the unix_socket plugin to authenticate users.

But it's easier to use mysql_native_password for dev (and only for dev because it's way less secure).

Get root access

sudo su
@mul14
mul14 / README.md
Created March 24, 2021 04:17 — forked from danbst/README.md
[Linux] [Firefox] Open link in browser, which is in current workspace

I use separate Firefox profiles for work and personal stuff. To distinguish those I place them on different workspaces.

  • Workspace 0: firefox --no-remote -P MyJob
  • Workspace 1: firefox --no-remote -P default

I have also company Slack on Workspace 0. Which usually contains links to some work stuff.

The problem

@mul14
mul14 / 99-install-facetime-camera.sh
Created November 21, 2020 07:02 — forked from ukn/99-install-facetime-camera.sh
Install the kernal module required for the facetimehd camera to work on Linux
#!/bin/bash
set -e
export CONFIG_MODULE_SIG=n
export CONFIG_MODULE_SIG_ALL=n
# For current kernel
export KERNELRELEASE=$(cat /proc/version | awk '{print $3}')
temp_dir=$(mktemp -d)
echo "Installing FacetimeHD camera for $KERNELRELEASE"
@mul14
mul14 / create_new_user.sql
Last active November 16, 2020 12:26
MySQL/MariaDB mysql_native_password
CREATE USER 'mul14'@'localhost' IDENTIFIED BY 'secret_password';
GRANT ALL PRIVILEGES ON *.* TO 'mul14'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
@mul14
mul14 / graphql_query.js
Last active November 21, 2020 09:34
Simple GraphQL Client for web browser
function graphql_query(endpoint, query, variables = {}, token = null) {
return new Promise((resolve, reject) => {
const headers = {
'Content-Type': 'application/json',
}
if (token) {
headers['Authorization'] = `Bearer ${token}`
}
@mul14
mul14 / ApproachingFibonacci.js
Last active March 1, 2024 01:12
Someone give me some coding test on CoderByte. Here are the questions and my answers.
/*
Have the function
ArithGeo(arr)
take the array of numbers stored in
arr
and return the string
"Arithmetic"
if the sequence follows an arithmetic pattern or return
"Geometric"
if it follows a geometric pattern. If the sequence doesn't follow either pattern return
@mul14
mul14 / demo.sh
Last active June 4, 2022 18:55
I very often create new folder to demonstrate or experiment. Run mkdir, cd, git init, etc; each time when I need is painful. So, I create this simple bash script.
#!/bin/bash
demo () {
project_name=""
if [ $# -eq 0 ]; then
project_name=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 6 | head -n 1)
else
if [[ ( $1 == "--help") || $1 == "-h" ]]; then
cat << EOF