Skip to content

Instantly share code, notes, and snippets.

@todd-demone
todd-demone / systemFont.css
Created November 2, 2017 12:32
System Fonts
html {
font-family: -apple-system, BlinkMacSystemFont,
"Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell",
"Fira Sans", "Droid Sans", "Helvetica Neue",
sans-serif;
}
@todd-demone
todd-demone / boxSizing.css
Created November 2, 2017 12:33
box-sizing: border-box
/* apply a natural box layout model to all elements, but allowing components to change */
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}
@todd-demone
todd-demone / doubleAngleQuote.txt
Created November 2, 2017 14:04
Double angle quote »
Here are the keyboard shortcuts to use in OS X:
Double Left Angle Quote («) – ALT \ (hold the ALT key and press the backward slash key)
Double Right Angle Quote (») – ALT SHIFT \ (hold the ALT and SHIFT keys, then press the backward slash key)
@todd-demone
todd-demone / postgres-cheatsheet.md
Created January 12, 2022 20:06 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)

#Simple Authentication with Bcrypt

This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.

The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).

You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault

##Steps

Rails naming conventions

General Ruby conventions

Class names are CamelCase.

Methods and variables are snake_case.

Methods with a ? suffix will return a boolean.

Signing VirtualBox Kernel Modules

These are the steps I followed enable VirtualBox on my laptop without disabling UEFI Secure Boot. They're nearly identical to the process described on [Øyvind Stegard's blog][blog], save for a few key details. The images here are borrowed from the [Systemtap UEFI Secure Boot Wiki][systemtap].

  1. Install the VirtualBox package (this might be different for your platform).
    src='https://download.virtualbox.org/virtualbox/rpm/fedora/virtualbox.repo'

ORM mapping between OOP and relational database

Object-Oriented Programming Relational Database
Class Table
Instance of class (object) Row
Name of instance property (e.g., 'username') Column

Sequelize operators and their SQL equivalents

Sequelize .Op operator SQL Operator
[Op.eq] =
[Op.and] AND
[Op.or] OR
[Op.not] NOT
[Op.like] LIKE
[Op.in] IN
@todd-demone
todd-demone / sequelize-install.sh
Last active April 25, 2022 15:21
Sequelize Installation
npm init -y # Run this command if the project is new and you don't have a package.json
npm install sequelize
npm install sqlite3 # This command will differ depending on what RBDMS you use