Skip to content

Instantly share code, notes, and snippets.

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 Sep 29, 2022
Blog post TailwindCSS style
View blog-posts.html
<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
Refactor nested IF statements in Ruby
View nested_if_statements.rb
# 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 Apr 4, 2021 — forked from yshmarov/0 AWS Cloud9
Ruby on Rails 6: Learn 25+ gems and build a Startup MVP 2020
View 0 AWS Cloud9
# 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 Dec 14, 2020 — forked from mrmartineau/stimulus.md
Stimulus cheatsheet
View stimulus.md
@AhmedNadar
AhmedNadar / index.md
Created Feb 13, 2018 — forked from rstacruz/index.md
Rails models cheatsheet
View index.md

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

View 1railsgirlsla_part1_tutorial.md
@AhmedNadar
AhmedNadar / application_controller.rb
Last active Dec 17, 2020
How to redirect to a 404 in Rails?
View application_controller.rb
# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
def not_found
raise ActionController::RoutingError.new('Not Found')
rescue
render_404
end
View rails_column_types.md

####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 Dec 26, 2016 — forked from poc7667/gemfile_template.rb
gemfile gems cheat sheet tools
View gemfile_template.rb
#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 Dec 26, 2016 — forked from kyletcarlson/42-things.md
42 Sweet, sweet things Rails (and Ruby) can do. Wonderful reference.
View 42-things.md