Skip to content

Instantly share code, notes, and snippets.

View frullah's full-sized avatar
🎯
Focusing

Fajarullah frullah

🎯
Focusing
View GitHub Profile
@frullah
frullah / docs.md
Created March 11, 2021 16:23
Laravel to rails

Parameters

  • Laravel: $request->parameter

  • Rails:

    jika menggunakan tag form biasa params.permit(:nama_parameter)

@frullah
frullah / script.sh
Created March 12, 2021 13:28
rails engine RSpec installation
#!/bin/bash
mv spec/dummy/spec/{rails_helper,spec_helper}.rb spec/
@frullah
frullah / install.sh
Last active March 14, 2021 17:02
install datatables in rails webpacker 6
#!/bin/sh
yarn add \
imports-loader \
jquery \
datatables.net \
datatables.net-bs4 \
datatables.net-responsive \
datatables.net-responsive-bs4
@frullah
frullah / guide.md
Last active March 23, 2021 04:07
how to use webpacker 6 in rails engine
  1. install rails webpacker 6
  2. add 'runtime' to javascript_pack_tag in dummy views, without that the entire javascript will not be executed
  3. [optional] set app source to the engine app packs
@frullah
frullah / run_ruby.sh
Last active June 15, 2021 16:29
auto reload code using inotifywait
#!/bin/bash
files_to_watch=$@
file_to_run=$1
inotifywait -e close_write $files_to_watch -m | while read file _event; do bundle exec ruby $file_to_run; done
@frullah
frullah / gist:5cd0517ddfb51633d492d8729326360f
Created June 25, 2021 17:32
zsh fresh installation with starship
sudo apt update
sudo apt install git zsh
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
sh -c "$(curl -fsSL https://starship.rs/install.sh)"
@frullah
frullah / setup.sh
Last active June 25, 2021 18:40
oh my zsh syntax plugins
#!/bin/zsh
# install auto suggestions
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# install syntax highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
echo "source ${(q-)PWD}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
sed -z --regexp-extended 's/(plugins=\(.*)\)/\1\tzsh-autosuggestions\n\tzs-syntax-highlighting\n)/g' ~/.zshrc
@frullah
frullah / scaffold-docs.md
Last active July 19, 2021 13:04
Rails scaffold helpers docs

Rails Scaffold

Template

if you use erb, template files should be in lib/templates/erb/scaffold

if you use slim, template files should be in lib/templates/slim/scaffold

the template file will evaluate erb tag, if you don't want to evaluate it, use double % (<%% ... %%>)

@frullah
frullah / dynamic_form_controller.js
Last active September 16, 2021 09:14
Stimulus JS dynamic form
import { Controller } from 'stimulus'
// used for changing form fields dynamically based on what user want in one page
export default class extends Controller {
static values = { targetContainerId: String, templateId: String }
async connect() {
// store array of DocumentFragment by id
this.templates = {}
// store container elements by id

change resource name in sidebar

define method plural_name that returns String

Hide resource in sidebar

set self.visible_on_sidebar = true in Resource