Difference between rake db:migrate db:reset and db:schema:load

db:migrate runs (single) migrations that have not run yet. db:create creates the database db:drop deletes the database db:schema:load creates tables and columns within the existing database following schema.rb. This will delete existing data. db:setup does db:create, db:schema:load, db:seed db:reset does db:drop, db:setup db:migrate:reset does db:drop, db:create, db:migrate Typically, you would use db:migrate after having made … Read more

Execute a command line binary with Node.js

For even newer version of Node.js (v8.1.4), the events and calls are similar or identical to older versions, but it’s encouraged to use the standard newer language features. Examples: For buffered, non-stream formatted output (you get it all at once), use child_process.exec: const { exec } = require(‘child_process’); exec(‘cat *.js bad_file | wc -l’, (err, … Read more

How to generate a random string in Ruby

(0…8).map { (65 + rand(26)).chr }.join I spend too much time golfing. (0…50).map { (‘a’..’z’).to_a[rand(26)] }.join And a last one that’s even more confusing, but more flexible and wastes fewer cycles: o = [(‘a’..’z’), (‘A’..’Z’)].map(&:to_a).flatten string = (0…50).map { o[rand(o.length)] }.join If you want to generate some random text then use the following: 50.times.map { … Read more

Multi-Line Comments in Ruby?

#!/usr/bin/env ruby =begin Every body mentioned this way to have multiline comments. The =begin and =end must be at the beginning of the line or it will be a syntax error. =end puts “Hello world!” <<-DOC Also, you could create a docstring. which… DOC puts “Hello world!” “..is kinda ugly and creates a String instance, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)