Skip to content

Instantly share code, notes, and snippets.

View bengsiswantoh's full-sized avatar

Bengsiswanto Hendrawan bengsiswantoh

View GitHub Profile
class ArticlesController < ApplicationController
before_action :require_login, only: :new
SECRET = "yoursecretword"
def index
payload = { data: 'test' }
token = JWT.encode payload, SECRET, "HS256"
@bengsiswantoh
bengsiswantoh / .babelrc
Created December 10, 2021 05:04
next js in cpanel
{"presets": ["next/babel"]}
const fs = require('fs');
const archiver = require('archiver');
const { exec } = require('child_process');
require('dotenv').config();
const SMB_USER = process.env.SMB_USER;
const SMB_PASSWORD = process.env.SMB_PASSWORD;
const SMB_SERVER = process.env.SMB_SERVER;
const SMB_DIR = process.env.SMB_DIR;
const fs = require("fs")
const path = require("path")
const getAllFiles = function(dirPath, arrayOfFiles) {
files = fs.readdirSync(dirPath)
arrayOfFiles = arrayOfFiles || []
files.forEach(function(file) {
if (fs.statSync(dirPath + "/" + file).isDirectory()) {
@bengsiswantoh
bengsiswantoh / aws-upload-directory
Last active October 22, 2020 06:52
upload directory to aws
https://docs.aws.amazon.com/cli/latest/reference/s3/cp.html
aws s3 cp {local_dir} s3://{remote_dir} --recursive
require 'net/ldap'
require 'devise/strategies/authenticatable'
module Devise
module Strategies
class LdapAuthenticatable < Authenticatable
def authenticate!
if params[:user]
ldap = Net::LDAP.new
ldap.host = CONFIG[Rails.env]["ldap_host"]
@bengsiswantoh
bengsiswantoh / .htaccess
Created January 9, 2019 01:53
single page application .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
</IfModule>