- You MUST NOT try and generate a Rails app from scratch on your own by generating each file. For a NEW app you MUST use
rails new
first to generate all of the boilerplate files necessary. - Create an app in the current directory with
rails new .
- Use Tailwind CSS for styling. Use
--css tailwind
as an option on therails new
call to do this automatically. - Use Ruby 3.2+ and Rails 8.0+ practices.
- Use the default Minitest approach for testing, do not use RSpec.
- Default to using SQLite in development.
rails new
will do this automatically but take care if you write any custom SQL that it is SQLite compatible. - An app can be built with a devcontainer such as
rails new myapp --devcontainer
but only do this if requested directly. - Rails apps have a lot of directories to consider, such as app, config, db, etc.
- Adhere to MVC conventions: singular model names (e.g., Product) map to plural tables (products); controllers are plural.
- Guard against incapable browsers accessing controllers with `allo
ruby '2.7.1' | |
gem 'rails', github: 'rails/rails' | |
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data | |
# Action Text | |
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra' | |
gem 'okra', github: 'basecamp/okra' | |
# Drivers |
The following instructions describe a set of processes allowing you to run Django database migrations against a production database without having to bring the web service down.
Note that in the below instructions, migrations are all run manually at explicit points, and are not an automatic part of the deployment process.
- Make the model or column addition in your code.
A quick guide on how to read/write/modify ID3 metadata tags for audio / media files using ffmpeg
.
FFmpeg has a free-form command line option that allows the user to specify key-value-pairs for encoding metadata. Let's take a look.
To list all global metadata tags for a media file, just set an input but no output file.
// Для ренджей в раст реализован IntoIter, а итератор коллекционируется в вектор функцией collect: | |
let arr: Vec<u8> = (0..200).into_iter().collect(); | |
//причем итераторы в раст ленивые, т.е. (0..200).into_iter() ≡ xrange(200), | |
//а (0..200).into_iter().collect() ≡ list(xrange(200)). | |
//Если ты имел ввиду list comprehensions из python, то было что-то такое на базе макросов, но нестрого говоря это лишь сахар над map и filter. | |
//Питоновский пример: | |
//M = [x**2 for x in range(10) if x % 2 == 0] | |
//будет выглядеть так: | |
let m: Vec<u8> = (0..10).into_iter().filter(|x| x % 2 == 0).map(|x| x * x).collect(); |
# habraproxy.py — это простейший http-прокси-сервер, запускаемый локально (порт на ваше | |
# усмотрение), который показывает содержимое страниц Хабра. С одним исключением: после | |
# каждого слова из шести букв должен стоять значок «™». Примерно так: | |
# | |
# http://habrahabr.ru/company/yandex/blog/258673/ | |
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
# Сейчас на фоне уязвимости Logjam все в индустрии в очередной раз обсуждают проблемы и | |
# особенности TLS. Я хочу воспользоваться этой возможностью, чтобы поговорить об одной из | |
# них, а именно — о настройке ciphersiutes. | |
# |
# https://www.erlang-solutions.com/downloads/download-erlang-otp | |
# wget http://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb | |
# sudo dpkg -i erlang-solutions_1.0_all.deb | |
deb http://packages.erlang-solutions.com/ubuntu trusty contrib | |
deb http://packages.erlang-solutions.com/ubuntu saucy contrib | |
deb http://packages.erlang-solutions.com/ubuntu precise contrib | |
wget http://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc | |
sudo apt-key add erlang_solutions.asc |
This page is no longer maintained, go to https://help.vivaldi.com/article/html5-proprietary-media-on-linux/ for help
// Reference: http://lea.verou.me/2011/10/easily-keep-gh-pages-in-sync-with-master/ | |
$ git add . | |
$ git status // to see what changes are going to be commited | |
$ git commit -m 'Some descriptive commit message' | |
$ git push origin master | |
$ git checkout gh-pages // go to the gh-pages branch | |
$ git rebase master // bring gh-pages up to date with master | |
$ git push origin gh-pages // commit the changes |
class Person | |
def initialize(attributes) | |
attributes.each do |attribute_name, attribute_value| | |
##### Method one ##### | |
# Works just great, but uses something scary like eval | |
# self.class.class_eval {attr_accessor attribute_name} | |
# self.instance_variable_set("@#{attribute_name}", attribute_value) | |
##### Method two ##### | |
# Manually creates methods for both getter and setter and then |