Skip to content

Instantly share code, notes, and snippets.

View AhmedNadar's full-sized avatar
🌎
Ready to work remote with you 😀 💻 🤝 👏🏼

Ahmed Nadar AhmedNadar

🌎
Ready to work remote with you 😀 💻 🤝 👏🏼
View GitHub Profile
@AhmedNadar
AhmedNadar / blog-posts.html
Created September 29, 2022 04:18
Blog post TailwindCSS style
<div class="px-4 py-16 mx-auto sm:max-w-xl md:max-w-full lg:max-w-screen-xl md:px-24 lg:px-8 lg:py-20">
<div class="grid gap-8 lg:grid-cols-3 sm:max-w-sm sm:mx-auto lg:max-w-full">
<div class="flex">
<div class="pt-1 mr-6 text-center">
<div class="px-2 pb-1 mb-1 border-b border-gray-400">
<p class="text-sm text-blue-500">Jul</p>
</div>
<div class="px-2"><p class="text-lg font-bold">18</p></div>
</div>
<div>
@AhmedNadar
AhmedNadar / nested_if_statements.rb
Last active May 4, 2021 18:01
Refactor nested IF statements in Ruby
# Before refactor
def set_company
if current_user
if current_user.company_id.present?
if current_user.companies.include?(current_user.company)
current_account = current_user.company
set_current_tenant(current_account)
else
set_current_tenant(nil)
end
@AhmedNadar
AhmedNadar / 0 AWS Cloud9
Created April 4, 2021 01:45 — forked from yshmarov/0 AWS Cloud9
Ruby on Rails 6: Learn 25+ gems and build a Startup MVP 2020
# All AWS C9 envments
https://eu-central-1.console.aws.amazon.com/cloud9/home?region=us-east-1
# Instance management
https://console.aws.amazon.com/ec2/home?region=eu-central-1#Instances:sort=instanceId
# Create AWS C9 environment
https://eu-central-1.console.aws.amazon.com/cloud9/home/create
Setting - set tabs to 2
@AhmedNadar
AhmedNadar / stimulus.md
Created December 14, 2020 09:00 — forked from mrmartineau/stimulus.md
Stimulus cheatsheet
@AhmedNadar
AhmedNadar / index.md
Created February 13, 2018 21:23 — forked from rstacruz/index.md
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@AhmedNadar
AhmedNadar / application_controller.rb
Last active November 30, 2023 00:43
How to redirect to a 404 in Rails?
# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
def not_found
raise ActionController::RoutingError.new('Not Found')
rescue
render_404
end
@AhmedNadar
AhmedNadar / rails_column_types.md
Last active January 13, 2017 18:02
Rails column types

####String: Limited to 255 characters (depending on DBMS) Use for short text fields (names, emails, etc) ####Text: Unlimited length (depending on DBMS) Use for comments, blog posts, etc. General rule of thumb: if it's captured via textarea, use Text. For input using textfields, use string. ####Integer: Whole numbers ####Float: Decimal numbers stored with floating point precision

@AhmedNadar
AhmedNadar / gemfile_template.rb
Created December 26, 2016 21:10 — forked from poc7667/gemfile_template.rb
gemfile gems cheat sheet tools
#How to Use rails _4.0.0_ new $1 -m app_tmpl.rb -T --skip-bundle
# rails (4.0.0, 3.2.13, 3.2.12)
require 'ap'
require 'awesome_print'
app_name=@app_name
remove_file "README.rdoc"
create_file "README.md", "TODO"
create_file ".ruby-version"
@AhmedNadar
AhmedNadar / 42-things.md
Created December 26, 2016 08:51 — forked from SabretWoW/42-things.md
42 Sweet, sweet things Rails (and Ruby) can do. Wonderful reference.