Skip to content

Instantly share code, notes, and snippets.

View achmiral's full-sized avatar
🏠
WFH

Miral Achmed achmiral

🏠
WFH
View GitHub Profile
@lazaronixon
lazaronixon / _form.html.erb
Last active June 6, 2025 19:24
Dropzone.js + Stimulus + Active Storage + CSS Zero (2025)
<%= form_with(model: billboard) do |form| %>
<%= tag.div class: "dropzone", data: { controller: "dropzone", dropzone_param_name_value: "billboard[images][]", dropzone_url_value: rails_direct_uploads_url, dropzone_accepted_files_value: "image/*", dropzone_max_files_value: 3, dropzone_max_filesize_value: 0.300 } do %>
<div class="dz-default dz-message flex flex-col items-center">
<%= image_tag "upload.svg", size: 28, class: "colorize-black", aria: { hidden: true } %>
<h5 class="font-semibold mbs-4">Drop files here or click to upload.</h5>
<p class="text-sm text-subtle">Upload up to 10 files.</p>
</div>
<% end %>
<div class="inline-flex items-center mbs-2 mie-1">
@rawaludin
rawaludin / stack.md
Last active September 21, 2019 02:10

Dependency Stack

The following table is a list of the major dependencies we use along with their purpose and links to supplemental documentation.

Dependency Purpose Docs
NextJS Official Docs
Another Name Parser Break up a concatenated name into pieces Official Docs
CASL Restricting access to features based on permissions Official Docs
@okitavera
okitavera / dzen2-wttr.sh
Last active February 19, 2021 10:08
wttr.in example with dzen2 and polybar module
#!/usr/bin/env bash
# width of window
W=250
# City
C=Malang
prin_weather() {
printf '\n\n %s Now \n\n' $C
curl -s "wttr.in/$C?0QT"
printf '\n'
@SunDi3yansyah
SunDi3yansyah / README.md
Last active November 29, 2018 17:51
Find Gems on Repository with Scraping

Find Gems on Repository with Scraping

Get Gems from Local

~/ruby via 💎 v2.5.3 
➜ gem list --no-versions

then put in array gems.rb

@SunDi3yansyah
SunDi3yansyah / README.md
Last active November 9, 2018 16:26
List of valid respond formats for exception handles in Rails

List of valid respond formats for exception handles in Rails

:text, :css, :ics, :csv, :vcf, :png, :jpeg, :gif, :bmp, :tiff, :svg, :mpeg, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :pdf, :zip, :gzip, :web_console_v2

Bonus

:html, :json, :js
@SunDi3yansyah
SunDi3yansyah / Tracking-Error.md
Last active November 9, 2018 16:34
Tracking Error in Ruby

Tracking Error

Free:

  • sentry
  • bugsnag
  • errbit

Not Free:

  • rollbar
  • airbrake
@SunDi3yansyah
SunDi3yansyah / group_by.rb
Created August 13, 2018 01:14
Rails group by beginning_of
Model.all.group_by { |value| value.created_at.beginning_of_week }
Model.all.group_by { |value| value.created_at.beginning_of_month }
Model.all.group_by { |value| value.created_at.beginning_of_year }
@SunDi3yansyah
SunDi3yansyah / 00.md
Created August 3, 2018 21:37 — forked from maxivak/00.md
Sending emails with ActionMailer and Sidekiq

Sending emails with ActionMailer and Sidekiq

Send email asynchroniously using Sidekiq.

ActionMailer

Create your mailer us usual:

class Api::RegionsController < ApplicationController
def provinces
prompt = [
{
id: "",
name: core_model_lang("province")
}
]
@provinces = prompt + Province.all
render json: @provinces.to_json(only: [:id, :name])
@SunDi3yansyah
SunDi3yansyah / rails-singular-or-plural.md
Last active July 24, 2018 03:53
Rails Conventions - Singular or Plural?
Name Singular/Plural Use
Controller Plural rails g controller Users index show
Helper Plural rails g helper Users
Mailer Singular rails g mailer UserMailer
Migration Plural rails g migration AddEmailToUsers email:string
Model Singular rails g model User name:string
Observer Singular rails g observer User
Resource Plural* resources :users, :only => [:index, :show]
Scaffold Singular rails g scaffold User name:string