Skip to content

Instantly share code, notes, and snippets.

View almokhtarbr's full-sized avatar
👋

almokhtar almokhtarbr

👋
  • 09:00 (UTC -04:00)
View GitHub Profile
@almokhtarbr
almokhtarbr / debug_rails.md
Created February 23, 2022 09:26 — forked from philsmy/debug_rails.md
Debugging Ruby on Rails Cheatsheet
@almokhtarbr
almokhtarbr / txt
Created February 7, 2022 11:32 — forked from leaguecodeuk/txt
Unknown username "whoopsie" in message bus configuration file
Unknown username "whoopsie" in message bus configuration file (Crouton)
For some time I had this notification "Unknown username 'whoopsie' in message bus configuration file" coming up when I started my Ubuntu-server on my Chromebook via crouton. It seemed not to do anything wrong but hey, I hate to see error messages popping up on the screen and not knowing what it really means.
In my search I've learned that the user 'whoopsie' is being used for the error reporting daemon in Ubuntu.
System Description:
Toshiba Chromebook 2:
Intel® Celeron® Processor N2840
Intel® HD Graphics
4GB DDR3 1600MHz
@almokhtarbr
almokhtarbr / main.rb
Created February 4, 2022 11:43 — forked from amirrajan/main.rb
DragonRuby Game Toolkit - Shadows (https://amirrajan.itch.io/shadows)
class Game
attr_gtk
def tick
defaults
input
calc
render
end
@almokhtarbr
almokhtarbr / how-to-copy-aws-rds-to-local.md
Created February 3, 2022 21:02 — forked from syafiqfaiz/how-to-copy-aws-rds-to-local.md
How to copy production database on AWS RDS(postgresql) to local development database.
  1. Change your database RDS instance security group to allow your machine to access it.
    • Add your ip to the security group to acces the instance via Postgres.
  2. Make a copy of the database using pg_dump
    • $ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
    • you will be asked for postgressql password.
    • a dump file(.sql) will be created
  3. Restore that dump file to your local database.
    • but you might need to drop the database and create it first
    • $ psql -U <postgresql username> -d <database name> -f <dump file that you want to restore>
  • the database is restored
@almokhtarbr
almokhtarbr / rails7_before_after.md
Created December 26, 2021 01:22 — forked from zakariaf/rails7_before_after.md
New Rails 7 features, Before and After

Add ComparisonValidator

Before Rails 7

class Event < ApplicationRecord
  validates :start_date, presence: true
  validates :end_date, presence: true

  validate :end_date_is_after_start_date
@almokhtarbr
almokhtarbr / stonks-on-rails-3-rufus-vs-whenever.md
Created May 13, 2021 21:02 — forked from wakproductions/stonks-on-rails-3-rufus-vs-whenever.md
Rufus vs Whenever Ruby Schedulers - Stonks on Rails #3
# docker-compose.yml
version: '3'

services:
  web:
    build: ./
    command: 'rails server -b 0.0.0.0 -p 3000'
    ports:
      - 4000:3000
@almokhtarbr
almokhtarbr / tutorial.md
Created May 8, 2021 17:31 — forked from thibaudgg/tutorial.md
Rails Authentication from Scratch - Step by Step

Rails Authentication from Scratch - Step by Step

Prerequisites

  • Clone the Cloud9 thibaudgg/rails-weblog workspace. Go to https://c9.io/new/clone and then choose the "MAS-RAD / Ruby on Rails" team, click on the "Clone workspace" tab, then choose the "thibaudgg/rails-weblog" workspace.
  • Seed the database, this will create some posts and comments (see db/seeds.rb):
rails db:seed
require 'rails_helper'
RSpec.describe TodosController, :type => :controller do
describe "GET #index" do
#describe "POST #create" do
#describe "GET #show" do
#describe "PATCH #update" do (or PUT #update)
#describe "DELETE #destroy" do
#describe "GET #new" do
@almokhtarbr
almokhtarbr / rspec_model_testing_template.rb
Created February 27, 2021 11:55 — forked from SabretWoW/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
// index.html
<div id="chat">
<ul id="message">
<li v-for="message in messages" :key="message.id">{{ message }}</li>
</ul>
<form @submit="send">
<input type="text" v-model="message">
<button>Send</button>
</form>