- 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
''' This script uses ytmusicapi and pytube together to download your playlists, history or 'liked' songs as | |
high-quality audio-only streams from Youtube Music, which are protected by a "signatureCipher" obfuscation scheme. | |
To use it, first install [ytmusicapi] and [pytube] using pip, then follow the instructions for creating the auth | |
file from the response in an authenticated session to a watch-page request as found in your browser's dev-tools. | |
The downloaded files are placed in ~/Music, named with the artist and track metadata, and will be skipped instead | |
of downloaded again next time it is run, based on the videoIds of the downloaded songs. | |
Merry Xmas - V. |
I was building up a small library of css snippets, and mixing and matching via copy-paste was getting tiresome.
So, I knocked myself up a little solution using https://sass-lang.com/
To use this solution, you need to follow the instructions on the website to install the SASS command line utility.
For my purposes, I created a subfolder in my Obsidian vault called ./.themes
where my obsidian.scss
file lives.
I also created a subfolder for mixins (./.themes/mixins
) containing small snippets like "Andy Matuschak" mode and collapsing sidebars (and my preferred custom colours for my Base2Tone theme)
const apiUrl = "http://api.quotable.io/random?tags="; | |
async function start() { | |
var quote; | |
var cite; | |
const response = await fetch(apiUrl); | |
const data = await response.json(); | |
if (response.ok) { | |
// Update DOM elements |
#!/bin/bash | |
# create a slideshow from images, with nice blending | |
# using MLT or ffmpeg | |
# adapted from https://superuser.com/a/834035 | |
# | |
# beware of the ffmpeg command, it eats memory quickly | |
# USAGE | |
# 1 pass images as arguments |
require "active_record" | |
namespace :db do | |
db_config = YAML::load(File.open('config/database.yml')) | |
db_config_admin = db_config.merge({'database' => 'postgres', 'schema_search_path' => 'public'}) | |
desc "Create the database" | |
task :create do | |
ActiveRecord::Base.establish_connection(db_config_admin) |
I am passionate about Ruby, but its execution time compared to other languages is extremely high, especially when we want to use more complex algorithms. In general, data structures in interpreted languages become incredibly slow compared to compiled languages. Some algorithms such as ´n-body´ and ´fannkuch-redux´ can be up to 30 times slower in Ruby than Go. This is one of the reasons I was interested in embedding Go code in a Ruby environment.
For those who do not know how shared libraries operate, they work in a similar way as DLLs in Windows. However, they have a native code with a direct interface to the C compiler.
Note Windows uses the DLL system, and in this case, this does not necessarily have to be in native code.
One example is DLLs written in C#, which runs on a virtual machine. Because I do not use windows, I ended up not testing if it is poss
# SCS | |
BenchmarkSCSMemstore-8 200000 9573 ns/op 3643 B/op 49 allocs/op | |
BenchmarkSCSCookies-8 100000 23220 ns/op 7516 B/op 83 allocs/op | |
BenchmarkSCSRedis-8 30000 45783 ns/op 4459 B/op 76 allocs/op | |
BenchmarkSCSMySQL-8 300 5782698 ns/op 4382 B/op 73 allocs/op | |
BenchmarkSCSPostgres-8 500 3715685 ns/op 5585 B/op 96 allocs/op | |
# Gorilla |
<template> | |
<div></div> | |
</template> | |
<script> | |
import Trix from 'trix'; | |
export default { | |
props: ['value'], |
package main | |
import ( | |
"bufio" | |
"fmt" | |
"os" | |
"time" | |
) | |
const numWorkers = 3 |