Skip to content

Instantly share code, notes, and snippets.

View buncis's full-sized avatar
❤️
(づ。◕‿‿◕。)づ

buncis buncis

❤️
(づ。◕‿‿◕。)づ
View GitHub Profile
@buncis
buncis / server_setup.md
Last active April 26, 2023 12:15
Ruby on Rails Deployment steps

INSTALL basic Requirements

Pertama Install Node

curl -sL https://deb.nodesource.com/setup_lts.x | sudo -E bash -

Kedua Install Yarn

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -

echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

Ketiga Install Redis

sudo add-apt-repository ppa:chris-lea/redis-server

Install packages

@buncis
buncis / default
Last active January 11, 2023 14:00
default nginx
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
# https://wiki.debian.org/Nginx/DirectoryStructure
#
# In most cases, administrators will remove this file from sites-enabled/ and
# leave it as reference inside of sites-available where it will continue to be
# updated by the nginx packaging team.
@buncis
buncis / authentication_with_bcrypt_in_rails_4.md
Created December 15, 2021 17:30 — forked from thebucknerlife/authentication_with_bcrypt_in_rails_4.md
Simple Authentication in Rail 4 Using Bcrypt

#Simple Authentication with Bcrypt

This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.

The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).

You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault

##Steps

require 'cgi'
require 'active_support'
def verify_and_decrypt_session_cookie(cookie, secret_key_base = Rails.application.secret_key_base)
config = Rails.application.config
cookie = CGI::unescape(cookie)
salt = config.action_dispatch.authenticated_encrypted_cookie_salt
encrypted_cookie_cipher = config.action_dispatch.encrypted_cookie_cipher || 'aes-256-gcm'
# serializer = ActiveSupport::MessageEncryptor::NullSerializer # use this line if you don't know your serializer
serializer = ActionDispatch::Cookies::JsonSerializer
@buncis
buncis / _stepper_form.html.erb
Last active October 10, 2021 05:11
add bs-stepper to rails
<div class="mb-5 p-4 bg-white shadow-sm">
<h3>Non linear stepper</h3>
<div id="stepper" class="bs-stepper">
<div class="bs-stepper-header" role="tablist">
<div class="step" data-target="#test-nl-1">
<button type="button" class="step-trigger" role="tab" id="steppertrigger1" aria-controls="test-nl-1">
<span class="bs-stepper-circle">
<span class="fas fa-user" aria-hidden="true"></span>
</span>
<span class="bs-stepper-label">Name</span>
@buncis
buncis / add admin-lte 3.1 to rails 6
Last active September 16, 2021 11:45
add admin-lte 3.1 to rails 6
yarn add admin-lte
{
"files.autoSave": "off",
"window.titleBarStyle": "custom",
"window.menuBarVisibility": "classic",
"[dart]": {
"editor.formatOnSave": true,
"editor.formatOnType": true,
"editor.rulers": [
80
],
@buncis
buncis / add bootstrap 4.6 to rails 6
Last active March 2, 2021 15:16
add bootstrap 4.6 to rails 6
yarn add bootstrap jquery popper.js
@buncis
buncis / api_controller.rb
Created January 19, 2021 09:56 — forked from dnlserrano/api_controller.rb
Custom Authentication Controllers
class ApiController < ApplicationController
# define which model will act as token authenticatable
acts_as_token_authentication_handler_for Login
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :null_session
respond_to :json
skip_before_filter :verify_authenticity_token, if: :json_request?
@buncis
buncis / .terminal config
Last active August 6, 2021 11:33
terminal config
title