Skip to content

Instantly share code, notes, and snippets.

View elithecho's full-sized avatar

Elijah elithecho

  • Singapore
View GitHub Profile
@elithecho
elithecho / Dockerfile
Created October 31, 2023 23:03
Render Dockerfile deployment
# syntax = docker/dockerfile:1.2
FROM timbru31/ruby-node:3.2-slim
ENV RAILS_LOG_TO_STDOUT=true
RUN --mount=type=secret,id=_env,dst=/etc/secrets/.env cat /etc/secrets/.env
RUN corepack enable && \
corepack prepare yarn@stable --activate
@elithecho
elithecho / docker-compose.yml
Created August 7, 2022 02:19
Docker compose setup
services:
app:
build:
context: ./
dockerfile: Dockerfile.dev
container_name: mapp_container
ports:
- 3000:3000
volumes:
- ./:/app
@elithecho
elithecho / bool_at.rb
Created June 29, 2021 02:39
Bool At Rails Lazy bugger
module BoolAt
extend ActiveSupport::Concern
class_methods do
# Defines a bool_at DSL
# allows setting true false on a virtual attribute
# and maps to attr_at
def bool_at(*attrs)
attrs.each do |attr|
at_attribute = "#{attr}_at"
@elithecho
elithecho / Dockerfile
Last active November 26, 2021 16:23
Simple local docker development
services:
app:
tty: true
stdin_open: true
build: .
container_name: app_container
ports:
- "3000:3000"
user: "${UID}:${GID}"
volumes:

Keybase proof

I hereby claim:

  • I am choonggg on github.
  • I am choonggg (https://keybase.io/choonggg) on keybase.
  • I have a public key ASDQc845gwoZnZIUnDLGQCMCn2LKBYtP4RmrGFMHBEMaSAo

To claim this, I am signing this object:

@elithecho
elithecho / profiles_controller.rb
Created January 29, 2019 11:33
Slim model with Form object
class ProfilesController < ApplicationController
def new
@form = ProfileForm.new(current_user)
end
def create
@form = ProfileForm.new(current_user, form_params)
# Now your form can act like a model
if @form.save
@elithecho
elithecho / base_form.rb
Last active January 29, 2019 10:39
BaseForm
class BaseForm
include ActiveModel::Model
include ActiveModel::Validations
def initialize(params={})
super(params)
end
end
@elithecho
elithecho / profile_form.rb
Last active January 29, 2019 10:40
Profile Form explained
class ProfileForm
# Make ProfileForm acts like a model
include ActiveModel::Model
include ActiveModel::Validations
attr_accessor :user, :profile
# This is shorthand for
# def user_attributes=(attribute)
# user.attributes = attributes
@elithecho
elithecho / base_form.rb
Created January 29, 2019 10:27
Form Objects - Refactoring Rails the Clean Way
class BaseForm
include ActiveModel::Model
include ActiveModel::Validations
def initialize(params={})
super(params)
end
end
@elithecho
elithecho / http-base.js
Last active November 1, 2017 16:52
Vue templates
// Creates a new axios instance for config
import axios from 'axios'
const instance = axios.create({
baseURL: 'http://localhost:3000',
timeout: 1000,
})
export default instance