Skip to content

Instantly share code, notes, and snippets.

@kadekjayak
kadekjayak / Dockerfile
Created November 24, 2022 05:10
NextJS standalone mode on Docker
FROM node:16-alpine
ARG NEXT_PUBLIC_API_URL
WORKDIR /usr/src/app
COPY . /usr/src/app
RUN yarn add sharp
RUN yarn install
RUN yarn build
@kadekjayak
kadekjayak / auth.sh
Last active July 13, 2020 13:21
openvpn auth scripts using rest api
#!/bin/bash
user_id=`php /etc/openvpn/server/script/auth.php $username $password`
## Check user
[ "$user_id" != '' ] && echo "user : $username" && echo 'authentication ok.' && exit 0 || echo "authentication failed. $username"; exit 1
@kadekjayak
kadekjayak / auth.php
Created July 13, 2020 13:10
openvpn auth scripts using rest api
<?php
/**
* Define Login URL
*/
$api_url = 'https://your-website/api/v1/login';
/**
* Header Add your own Header for Logging
*/
@kadekjayak
kadekjayak / backup.sh
Created June 21, 2019 16:17
Backup File & DB to AWS
#!/bin/sh
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
S3_BUCKET=
SITE_NAME=kadekjayak.web.id
WEB_ROOT=/var/www/html
# Database Config
MYSQL_USER=kadekjayak
MYSQL_HOST=127.0.0.1
@kadekjayak
kadekjayak / install-wordpress
Created December 15, 2018 14:47
Install Wordpress using WP CLI
wp core download
wp core config --dbhost=localhost --dbname=homestead --dbuser=homestead --dbpass=secret
wp core install --url=awesomesite.com --title="Awesome Site" --admin_name=admin --admin_password=admin --admin_email=admin@admin
@kadekjayak
kadekjayak / run.sh
Created October 8, 2018 14:54
This script is used to import certificate to Amazon
# Amazon Certificate Manager
# Import certificate from aws cli
# tested on Let's encrypt certificate :)
#
# amazon cloudfront support maximum 2048 bit cert,
# if more than that it wont displayed on list...
#
# Region must be set to us-east-1 (Virginia) if you want to use it on CloudFront
aws configure set aws_access_key_id <ACCESS_KEY>
@kadekjayak
kadekjayak / composer.json
Last active August 16, 2017 05:45
composer.json with gitlab private repo
"repositories": [
// From Private GITLAB REPO
{
"type": "git",
"url": "https://gitlab.com/kadekjayak/repository.git",
"options": {
"http": {
"header": [
"API-TOKEN: adfasdfasdfsdf"
@kadekjayak
kadekjayak / round.php
Created July 22, 2017 11:24
Rounding number down
<?php
/**
* Rounding number down into nearest thousand or hunderd
* a simple Round can achieve on some cases
*/
function ika_round($number)
{
$digitLength = ( strlen( $number ) - 1 );
$factor = str_pad('1', $digitLength, '0');
$result = $number / (int)$factor;