Skip to content

Instantly share code, notes, and snippets.

View tonyblaze27's full-sized avatar
:octocat:
Dealing with life...

Tony Videnov tonyblaze27

:octocat:
Dealing with life...
  • HardCode Digital
  • Sofia, Bulgaria
View GitHub Profile
@tonyblaze27
tonyblaze27 / gist:ea9e18b748ee57b0278df247e391c73c
Created October 4, 2019 13:01 — forked from arjunvenkat/gist:1115bc41bf395a162084
Seeding a Rails database with a CSV file

How to seed a Rails database with a CSV file

1. Setup

First, Create a folder inside of lib called seeds

Put your CSV file example.csv into the lib/seeds folder. In the example below, the file is called real_estate_transactions.csv

Make sure you've created a resource with the appropriate columns to match your seed data. The names don't have to match up.

@tonyblaze27
tonyblaze27 / easy_rails_deployment_with_capistrano.md
Created May 22, 2019 11:15
Easy Rails deployment with Capistrano

Goals of this tutorial:

  • deploy a new Rails app with capistrano
  • make it fast (total process takes less than 5 minutes)
  • make it simple (no unecessary config)
  • manual ssh to the server not required

Rails application stack:

  • nginx
  • unicorn
  • postgresql
require 'csv'
require 'nokogiri'
xml = File.read('hello.xml')
doc = Nokogiri::XML(xml)
all_the_things = []
doc.xpath('//file').each do |file|
title = file.xpath("./title").first.text
  1. Add gem 'rails_12factor' to your Gemfile. This will add error logging and the ability for your app to serve static assets.
  2. bundle
  3. Run RAILS_ENV=production rake db:create db:migrate db:seed
  4. Run rake secret and copy the output
  5. From the command line: export SECRET_KEY_BASE=output-of-rake-secret
  6. To precompile your assets, run rake assets:precompile. This will create a folder public/assets that contains all of your assets.
  7. Run RAILS_ENV=production rails s and you should see your app.

Remember to clobber your assets (rake assets:clobber) and re-precompile (rake assets:precompile) if you make changes.

@tonyblaze27
tonyblaze27 / media-query.css
Created October 18, 2018 10:01 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS