Skip to content

Instantly share code, notes, and snippets.

View nilsandrey's full-sized avatar
🏠

Nils nilsandrey

🏠
View GitHub Profile
@nilsandrey
nilsandrey / index.html
Created April 4, 2021 22:25
Scriptless HTML Menu
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="initial-scale=1.0" />
<title>Document</title>
<link href="style.css" rel="stylesheet">
</head>
<body>
<input type="checkbox" id="menu-toggle" />
<!-- Line by line explanation: https://www.matuzo.at/blog/html-boilerplate/ -->
<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<title>Unique page title - My Site</title>
<script type="module">
@media
(prefers-reduced-motion: no-preference) {
:focus {
transition: outline-offset .25s ease;
outline-offset: 5px;
}
}
@nilsandrey
nilsandrey / docker-fixports.ps1
Last active May 4, 2021 12:45
Workaround for Unable to bind ports: Docker-for-Windows & Hyper-V. https://github.com/docker/for-win/issues/3171
# 1. Disable hyper-v (which will required a couple of restarts)
dism.exe /Online /Disable-Feature:Microsoft-Hyper-V
# 2. When you finish all the required restarts, reserve the port you want so hyper-v doesn't reserve it back
# Notice: Include the port number is failing to you...50051 on sample...
netsh int ipv4 add excludedportrange protocol=tcp startport=50051 numberofports=1
# 3. Re-Enable hyper-V (which will require a couple of restart)
dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All

Cheat Sheets are greate but they are not a substitute for learning the framework and reading the documentation as we most certainly have not covered every potential example here. Please refer to the Rails Command Line Docs for more information.

Command Line Generator Info

Reference

You can get all of this information on the command line.

rails generate with no generator name will output a list of all available generators and some information about global options. rails generate GENERATOR --help will list the options that can be passed to the specified generator.

@nilsandrey
nilsandrey / instructions.md
Created May 5, 2021 05:03 — forked from matthewjberger/instructions.md
Install a nerd font on ubuntu

1.) Download a Nerd Font

2.) Unzip and copy to ~/.fonts

3.) Run the command fc-cache -fv to manually rebuild the font cache

{
path: 'refresh' // See `AppComponent.watchForRefresh()`
},
// ...
this._router.events
.pipe(filter(e => e instanceof NavigationEnd))
.subscribe((e: NavigationEnd) => {
const current = e.urlAfterRedirects.substr(1);
@nilsandrey
nilsandrey / omniAuth.rb
Created June 1, 2021 12:47
OmniAuth initializer configuration to enable all environments browse to your Auth0Controller::failure route
OmniAuth.configure do |config|
# Always use /auth/failure in any environment
config.failure_raise_out_environments = []
end
# Define cache store
# config.cache_store = :mem_cache_store
if ENV["REDIS_URL"].present?
config.cache_store = :redis_cache_store, { url: ENV["REDIS_URL"] }
else
config.cache_store = :file_store, "tmp/cache"
end
@nilsandrey
nilsandrey / object_to_hash.rb
Last active September 20, 2021 15:30
Ruby convert Object to Hash (and read hash to attributes in case of AR objects)
module ObjectExtension
# For any object...
def to_hash
hash = {}
instance_variables.each {|var| hash[var.to_s.delete("@")] = instance_variable_get(var) }
hash
end
##
# Update all attributes with values from a hash. Only update existing attributes.