Skip to content

Instantly share code, notes, and snippets.

[2] pry(main)> State.delete_all
SQL (329.0ms) DELETE FROM "states"
=> 3181
[3] pry(main)> require 'csv'
=> true
[4] pry(main)> CSV.foreach(Rails.root.join("#{Rails.root}/db/seeds/states.csv"), encoding:'iso-8859-1:utf-8', headers: true) do |row|
[4] pry(main)* country = Country.find_by_uuid(row[1])
[4] pry(main)* if country.present? && country.name != row[2]
[4] pry(main)* State.create! do |state|
[4] pry(main)* state.name = row[2]
@jleo3
jleo3 / gist:9618554
Created March 18, 2014 11:49
aws_ec2_setup.rake
set :domain, "aws_ezg"
set :ssh_flags, %w[-t -t]
namespace :aws do
remote_task :setup_ec2 do
run "sudo yum update -y"
run "sudo yum groupinstall -y 'Development Tools'"
run "sudo yum install -y zlib-devel"
run "curl -L https://get.rvm.io | bash -s stable"
run "rvm pkg install -y openssl"

##Pull Requests We try to write high quality code on this team. Here are some guidelines:

  • Before submitting any pull request, make sure you can run all tests with rake and that all tests pass.
  • Any new code you write should have a high amount of test coverage - preferably 100% but not less than 85%.
  • I use Code Climate (codeclimate.com) to review pull requests. Any new classes or modules you submit should be graded an A or B on Code Climate.
  • Some classes on this project do not have an A or a B in Code Climate. In that case, it should not get worse as a result of your change.

##Git policy ###No Commits to Master

  • Every commit must be made on a feature branch. The feature branch can be sent to GitHub and Travis on a push. The git workflow is as follows:
@jleo3
jleo3 / gist:e1fad70192063b7160e6
Last active August 29, 2015 14:01
BEWD git setup

###Log in and Fork

  1. Log into your GitHub account
  2. Navigate to https://github.com/ga-students/BEWD_NYC_10
  3. Click on the "Fork" button

###Git Ready

  1. git config --global user.email "your@email.com"
  2. create a directory called "dev" under home directory

###Clone

@jleo3
jleo3 / gist:0993986fe06c0b0868ad
Created May 5, 2014 23:26
windows with virtual box
#!/bin/bash
set -e
lowercase(){
echo "$1" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"
}
install_mac_tools() {
# Do we have to install mac tools?
  1. Log into github.com
  2. Navigate to https://github.com/ga-students/bewd_10_nyc_homework
  3. Fork this repo
  4. cd into your development directory (wherever you keep BEWD_NYC_10)
  5. git clone https://github.com/GITHUB_USER_NAME/bewd_10_nyc_homework
  6. cd into your new bewd_10_nyc_homework directory and ls. You should see a folder with your name on it.
  7. cd into the directory with your name on it.
  8. mv your quiz file into this directory
  9. git add your quiz file
  10. git commit and git push this file
class Teddit
def add_story
puts "Please enter a News story:"
story = get_input
puts "Please give it a category:"
category = get_input
upvotes = calculate_upvotes(story, category)
puts "New story added! #{story}, Category: #{category.capitalize}, Current Upvotes: #{upvotes}"
end
- list.each { |i| Subsector.create({title: i['Name'], icb_code: i['Code']}) if i['Type'] == 'Subsector'}
+ list.each { |i| i['Type'].constantize.create({title: i['Name'], icb_code: i['Code']}) }
class Newspaper
attr_accessor :stories
def initialize
@stories = []
end
def self.generate_random_story
"This random event happened on day #{rand(28)} of this month."
end