Skip to content

Instantly share code, notes, and snippets.

View almokhtarbr's full-sized avatar
👋

almokhtar almokhtarbr

👋
  • 09:38 (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
Magical Authentication with Sorcery
Gems
Ruby on Rails
March 16, 2015
Share
Magician Hat
@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

add this to docker-composefile after build line

stdin_open: true
tty: true

to be like this

services:
  app:
 build:
# create a migration to enable uuid# This will generate a new migration file with
# timestamp_enable_uuid_extension.rbrails g migration EnableUuidExtension# In migration file add following line to enable pgcryptoclass EnableUuidExtension < ActiveRecord::Migration[6.0]
def change
enable_extension 'pgcrypto'
end
end
# Create migration for tasks tablerails g migration CreateTasksclass CreateTasks < ActiveRecord::Migration[6.0]
def change
@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
brew install postgresql
# Add te path
export PATH=$PATH:/usr/local/opt/postgresql@13/bin
create database almokhtar;
brew install postgis
initdb /usr/local/var/postgresql\@13/
rm -r /usr/local/var/postgresql\@13/
createdb postgis_test
Stash current changes
git > Stash > Stash (Include Untracked)
Create stash as patch
git stash show "stash@{0}" -p > changes.patch
Apply patch
git apply changes.patch