Skip to content

Instantly share code, notes, and snippets.

@jchuerva
jchuerva / setting-up-sinatra-with-active-record.md
Created November 6, 2019 15:40
Setting up Sinatra with Active Record

Setting up Sinatra Project

create an empty project and add a Gemfile

cd ~/Desktop
mkdir project-name
cd project-name
touch Gemfile
@jchuerva
jchuerva / rails_naming_conventions.md
Created November 8, 2019 16:47
Rails naming conventions

Rails naming conventions

General Ruby conventions

Class names are CamelCase.

Methods and variables are snake_case.

Methods with a ? suffix will return a boolean.

@jchuerva
jchuerva / rubocop-style.adoc
Last active November 8, 2019 17:00
Rubocop Style

The Ruby Style Guide

@jchuerva
jchuerva / .rubocop.yml
Created November 27, 2019 15:25
Rubocop config file
Rails:
Enabled: true
# Commonly used screens these days easily fit more than 80 characters.
Metrics/LineLength:
Max: 120
# Too short methods lead to extraction of single-use methods, which can make
# the code easier to read (by naming things), but can also clutter the class
Metrics/MethodLength:
@jchuerva
jchuerva / obsidian-web-clipper.js
Created August 21, 2022 11:00 — forked from kepano/obsidian-web-clipper.js
Obsidian Web Clipper Bookmarklet to save articles and pages from the web (for Safari, Chrome, Firefox, and mobile browsers)
javascript: Promise.all([import('https://unpkg.com/turndown@6.0.0?module'), import('https://unpkg.com/@tehshrike/readability@0.2.0'), ]).then(async ([{
default: Turndown
}, {
default: Readability
}]) => {
/* Optional vault name */
const vault = "";
/* Optional folder name such as "Clippings/" */
@jchuerva
jchuerva / ReadMe.md
Created June 4, 2023 12:21 — forked from rbnpi/ReadMe.md
Beethoven Moonlight Sonata played by Sonic Pi. Uses Sonatina Symphonic Orchestra samples. See readme for availablilty. Video at https://youtu.be/8rdJ9wxGw5Y

The Sonic Pi file moonlightSonata-RF.rb which plays Beethoven's Moonlight Sonata 1st Movement requires the use of the Grand Piano samples from the Sonatina Symphonic Orchestra produced by Matthias Westlund.

Unfortunately this is no longer available from his website https://sso.mattiaswestlund.net/ However there is an alternative available at https://github.com/peastman/sso from where you can download the library. It is coverd by a https://creativecommons.org/licenses/sampling+/1.0/ Download and expand on your Desktop, or other suitable location and then set the link in the program at line 9 appropraitely for your installation.

The file should be run using the run_file "/path/to/file/location" command as it is too long to run from a Sonic Pi buffer.

An alternative version using the built in piano synth in Sonic Pi is included for comparison.

@jchuerva
jchuerva / CONDTIONALS
Created June 4, 2023 12:21 — forked from alptugan/CONDTIONALS
Sonic Pi Cheat Sheet
So, let’s flip a coin: if it’s heads, play a drum, if it’s tails, play a cymbal. Easy. We can emulate a coin flip with our one_in function (introduced in the section on randomness) specifying a probability of 1 in 2: one_in(2). We can then use the result of this to decide between two pieces of code, the code to play the drum and the code to play the cymbal:
loop do
if one_in(2)
sample :drum_heavy_kick
else
sample :drum_cymbal_closed
end