Skip to content

Instantly share code, notes, and snippets.

View ola-dola's full-sized avatar
🛠️
pushin' x

Ola ola-dola

🛠️
pushin' x
View GitHub Profile
@ola-dola
ola-dola / rails-pg-ubuntu.md
Created August 11, 2023 16:34
notes from setting up Rails to use postgres on Ubuntu 22.04
# place this after nvm initialization!
autoload -U add-zsh-hook
load-nvmrc() {
local nvmrc_path
nvmrc_path="$(nvm_find_nvmrc)"
if [ -n "$nvmrc_path" ]; then
local nvmrc_node_version
nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
@ola-dola
ola-dola / next-config-for-image-export.js
Last active June 20, 2022 14:35
Workaround for next/image if the site is to be statically exported
module.exports = {
// https://github.com/vercel/next.js/issues/21079
// https://stackoverflow.com/a/69258517
images: {
loader: "imgix",
path: "",
},
};
@ola-dola
ola-dola / nextjs-warn-before-route-change.md
Last active May 11, 2022 17:24
Ask for user confirmation before changing route in next js.
@ola-dola
ola-dola / vscode-nodejs-debugger-hot-reload.md
Last active February 6, 2022 21:22
Restarting debug sessions automatically when source is edited using nodemon (without global install)
  • Add a script to start app with nodemon in inspect mode: "server": "nodemon --inspect server.js"
  • Add the following config to vscode's launch.json:
{
  "name": "Attach to node",
  "type": "node",
  "request": "attach",
  "restart": true,
 "port": 9229
@ola-dola
ola-dola / sample-sql-queries
Created July 13, 2021 19:01
Example SQL queries for common tasks. Run query in browser: https://www.w3schools.com/Sql/tryit.asp?filename=trysql_select_top
SELECT * FROM Customers
WHERE city like "M%"; // cities that start with M.
select * FROM Customers
where city like "B%" AND customerId >= 10;
select * FROM Customers
where city like "B%" OR customerId >= 10;
select * FROM Customers

css

CSS makes my head hurt most times. But sometimes, it hurts for long enough(like today,11/8/2020), I start to grok some of its interesting powers. This will be a living document I update on days like this.

  • You can target a grandchild or great-grandchildren with &>tag(child)>tag(grandchild)...>tag(nth-great-grandchild).

  • TIL about dl tag(Description List). It's like a a ul, but for key-value pairs, or data relating to that.

  • Flexbox: just-cont: flex-start, on an item: margin-left: auto. Splits the into two far ends starting at the item. Good for navs, esp.

  • If there's horizontal scroll bar and you can't figure out which element is causing it: Devtools -> new style rule(+ sign to the top right corner on chrome) -> * { outline: 1px solid red }. Easily shows.

What is the difference between knex migrate:rollback and knex migrate:down?

When you run knex migrations to add/modify table(s) with knex(using knex migrate:latest), it runs as a batch if there's more than one file in the migrations directory, and more than one uncompleted migration files.

migrate:rollback rollback(undo) the last batch job(--all flag to rollback all batches)

migrate:down rollback the last migration(a single file) in the last batch.

For example, if we have abc.js, def.js and ghi.js uncompleted migration files in the migrations directory. knex migrate:latest runs all 3 in a single batch. migrate:rollback undo the last batch job(all 3 files) while