Skip to content

Instantly share code, notes, and snippets.

Avatar

Rico Sta. Cruz rstacruz

View GitHub Profile
@rstacruz
rstacruz / settings.js
Last active Jul 28, 2020
My VSCode settings
View settings.js
{
// --------------------------------------------------------------------------------
// Font settings
// --------------------------------------------------------------------------------
// Fonts
"editor.fontFamily": "Victor Mono, Iosevka, monospace", // 15/18 or 16/18
"editor.fontWeight": "600",
"editor.letterSpacing": 0,
"editor.lineHeight": 17,
View 0 Cloudflare worker redirect example.md

CloudFlare worker example

Sample CloudFlare worker that does redirects and rewrites.

View Docker on ArchWSL.md

Running Docker in ArchWSL

Problem: Running Docker on [ArchWSL] doesn't work by default. ArchWSL doesn't allow systemd services.

docker info
# ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

sudo systemctl start docker
# System has not been booted with systemd as init system (PID 1). Can't operate.
View Opinion: Ruby's pessimistic operator.md

Opinion: Ruby's pessimistic operator

Today I realised that Ruby's >= is more useful than ~>.

Rubygems’s pessimistic operator ~>, also known as “twiddle-wakka”, allows developers to specify flexible gem version ranges.

This... Is equivalent to...
gem 'i18n', '~> 2.3.5' gem 'i18n', ‘>= 2.3.5’, '< 2.4.0'
gem 'i18n', '~> 2.3' gem 'i18n', ‘>= 2.3.0’, ‘< 3’
View Reasons to avoid using ID's.md
View Updating gems with Bundler.md

Updating gems with Bundler

Bundler recommends using bundle update to update Rails. It also accepts --conservative to try not to update shared dependencies.

bundle update [--conservative] rails

This method can often produce unexpected results. Even with the conservative flag, it may try to update gems that you may not need updated. In some cases, bundler might even give some errors.

View Using multiple Ruby versions with Appraisal.md

Using multiple Ruby versions with Appraisal

[Appraisal] is often used for testing multiple versions of a Ruby gem's dependencies at once. When authoring a gem that requires compatibility with Rails 4 and 5, appraisal is often used to make this easier:

# Appraisals
appraisal 'rails-4' do
  gem 'rails', '~> 4'
end
View Using rem units in CSS.md

Using rem units in CSS

One pattern I've noticed lately is using rem as a unit of distance in CSS. This seems like a pretty good idea.

.box {
  height: 1.5rem;
  padding: 1rem;
}
@rstacruz
rstacruz / README.md
Last active Apr 4, 2020
Setting up Jest with ESM
View README.md

Setting up Jest with ESM

Here are some different ways on how to set up Jest to support ESM. This applies for Jest v25, Node v13, and Babel v7.

Using Babel

Add babel-jest.

You can’t perform that action at this time.