Skip to content

Instantly share code, notes, and snippets.

View Panioglo's full-sized avatar

Panioglo Sergiu Panioglo

  • Galati, Romania
View GitHub Profile
@Panioglo
Panioglo / how-to-copy-aws-rds-to-local.md
Created January 14, 2022 09:39 — 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
@Panioglo
Panioglo / db_migration.md
Last active March 4, 2020 14:00 — forked from Chocksy/db_migration.md
Wordpress DB migration (via queries)

DB migration WP

  • export the wp_posts, wp_postmeta tables from the old DB.
  • import the exported data into 2 new tables wp_old_posts, wp_old_postmeta into the new DB.
  • change collation on the table from utf8mb4_unicode_ci to utf8mb4_unicode_520_ci
  • add to the current/new table a column old_id (to store the id of the row in the old table. In our case wp_posts)
  • make a similar query to this:
INSERT INTO wp_posts (old_id, post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_content_filtered, post_parent, guid, menu_order, post_type, post_mime_type, comment_count) 
SELECT * FROM wp_old_posts;
@Panioglo
Panioglo / installing_rmagick_ubuntu_16.04.txt
Created March 5, 2019 07:41 — forked from ryderstorm/installing_rmagick_ubuntu_16.04.txt
Installing rmagick gem on Ubuntu 16.04
# the instructions from here: https://stackoverflow.com/questions/3704919/installing-rmagick-on-ubuntu/31089915#31089915
# worked, but only after I added in line 8
sudo apt-get purge graphicsmagick graphicsmagick-dbg imagemagick-common imagemagick imagemagick-6.q16 libmagickcore-6-headers libmagickwand-dev graphicsmagick-libmagick-dev-compat
sudo apt-get autoremove
sudo apt-get install imagemagick libmagickwand-dev
sudo ln -s /usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16/Magick-config /usr/bin/Magick-config
export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig
gem install rmagick
@Panioglo
Panioglo / dynamic-critical-path-css.md
Created May 22, 2018 13:24 — forked from taranda/dynamic-critical-path-css.md
Dynamically Add Critical CSS to Your Rails App

Dynamically Add Critical CSS to Your Rails App

Optimizing the delivery of CSS is one way to improve user experience, load speed and SEO of your web app. This involves determining the "critical path CSS" and embeding it into the html of your page. The rest of the CSS for the site is loaded asynchronously so it does not block the rendering of your "above the fold" content. This Gist will show you how to dynamically generate critical path CSS for your Rails app.

In this example we will use the mudbugmedia/critical-path-css gem.

Prerequisites

You will need to set up caching and Active Job in your Rails app. I recommend using a thread-safe background job manager like resque.

@Panioglo
Panioglo / precompile_assets.rb
Created March 26, 2018 11:30 — forked from Chocksy/precompile_assets.rb
Precompile js files in rails
# use this file in the rails app root directory and run it with
# ruby precompile_assets.rb to see if there is any error in your
# js file assets by using Uglifier. This would save you from running
# rake assets:precompile and using production as env var.
require './config/environment'
JS_PATH = 'app/assets/javascripts/**/*.js'.freeze
Dir[JS_PATH].each do |file_name|
puts "\n#{file_name}"
puts Uglifier.compile(File.read(file_name))
@Panioglo
Panioglo / details.md
Created March 26, 2018 11:29
Atom Editor make linter-rubocop work.

In order for atom.io to work and use the linter-rubocop on all projects, you need to install rubocop in your global rvm gemset. This can be done by running sudo gem install rubocop in a folder where you don't have a gemset set for rvm.

After doing the above you can just use the following command to make rubocop work in any project:

rvm use 2.2.1@global rubocop do --config /Users/username/development/.rubocop.yml
@Panioglo
Panioglo / git.migrate
Created March 26, 2018 11:26 — forked from niksumeiko/git.migrate
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.
@Panioglo
Panioglo / .1details.md
Created March 26, 2018 11:22 — forked from Chocksy/.1details.md
Gemfile local that will allow for special gems only on local env

Differences between team gemfile and your preferences

The solution for the above problem is to have a different gemfile that you run your rails app against. It can be easily done by adding some terminal aliases to use a different gemfile file. I made that in the current configuration and it works well.