These are the very basics of reading and writing to CSV files in Ruby. For more details and other available options consider checking out the full documentation: here
Consider a given csv file scientists.csv
with the following content:
id | name | age | cured | |
---|---|---|---|---|
1 | Joe | 27 | false | |
2 | Nick | 25 | false | |
3 | Robbie | 18 | true | |
4 | Romain | 26 | false | |
5 | Romain | 26 | false |
require_relative 'cookbook' # You need to create this file! | |
require_relative 'controller' # You need to create this file! | |
require_relative 'router' | |
require_relative 'search' | |
require_relative 'recipe' | |
require_relative 'view' | |
csv_file = File.join(__dir__, 'recipes.csv') | |
cookbook = Cookbook.new(csv_file) | |
controller = Controller.new(cookbook) |
require_relative 'cookbook' # You need to create this file! | |
require_relative 'controller' # You need to create this file! | |
require_relative 'router' | |
csv_file = File.join(__dir__, 'recipes.csv') | |
cookbook = Cookbook.new(csv_file) | |
controller = Controller.new(cookbook) | |
router = Router.new(controller) |
<button id="clickme">Click me</button> | |
<p id="output"></p> | |
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script> | |
<script> | |
// Write your JavaScript here | |
$("#clickme").on("click", () => { | |
var personsName = prompt("What is your name"); |
// Exercise 1: Concatinate two strings | |
var firstName = "Alan"; | |
var lastName = "Turing"; | |
console.log(firstName + " " + lastName) | |
// Exercise 2: Filter names starting with "B" | |
// What's the problem with this code? We're repeating our code |
{ | |
"terminal.integrated.cursorBlinking": true, | |
"terminal.integrated.fontSize": 12, | |
"editor.cursorStyle": "block", | |
"editor.renderWhitespace": "all", | |
"editor.roundedSelection": false, | |
"editor.minimap.enabled": false, | |
// "editor.fontFamily": "'DejaVu Sans Mono'", | |
"editor.fontSize": 15, |
class Threater | |
def self.run(iterations = 1_000_000) | |
last_person_got_seat = 0.0 | |
total_runs = 0.0 | |
iterations.times do |i| | |
if i % 1000 == 0 | |
print("\rNº of iterations: #{i.to_s.ljust(iterations.to_s.length)}") | |
end | |
last_person_got_seat += 1 if new.last_person_got_seat |
for project_dir in */; do | |
cd "$project_dir" | |
git checkout master | |
git checkout -- . | |
git pull | |
bundle install | |
yarn install | |
rails db:drop db:create db:migrate db:seed | |
cd .. | |
done |
These are the very basics of reading and writing to CSV files in Ruby. For more details and other available options consider checking out the full documentation: here
Consider a given csv file scientists.csv
with the following content:
#!/bin/sh | |
mkdir $1 && cd $1 | |
yarn init | |
yarn add webpack webpack-dev-server \ | |
babel-core babel-preset-es2015 \ | |
babel-loader sass-loader css-loader style-loader \ | |
extract-text-webpack-plugin \ | |
node-sass --dev |