# stage all modified files being tracked
git add -u
# Taken from http://robots.thoughtbot.com/post/33706558963/migrating-data-from-an-upgraded-postgres | |
# | |
# Note: these steps assume installation with Homebrew. | |
# Initialize a new database, adding a .new suffix to the directory that Homebrew recommends. | |
initdb /usr/local/var/postgres.new -E utf8 | |
# Run the upgrade script, providing the correct paths for the various flags. |
A brief description of your project, including its purpose and goals.
-- show running queries (pre 9.2) | |
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
FROM pg_stat_activity | |
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
ORDER BY query_start desc; | |
-- show running queries (9.2) | |
SELECT pid, age(clock_timestamp(), query_start), usename, query | |
FROM pg_stat_activity | |
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
Disclaimer: I'm not the original author of this sheet, but can't recall where I found it. If you know the author, please let me know so I give the attribution.
Note: Since this seems to be helpful to some people, I formatted it to improve readability of the original. Also, note that this is from 2016, many things may have changed, and I don't use macOS anymore, so I probably can't help in case of questions, but maybe someone else can.
After writing up the presentation for MacSysAdmin in Sweden, I decided to go ahead and throw these into a quick cheat sheet for anyone who’d like to have them all in one place. Good luck out there, and stay salty.
Get an ip address for en0:
Sequelize is a powerful library in Javascript that makes it easy to manage a SQL database. Sequelize can layer over different protocols, but here we'll use PostgreSQL. At its core, Sequelize is an Object-Relational Mapper – meaning that it maps an object syntax onto our database schemas. Sequelize uses Node.JS and Javascript's object syntax to accomplish its mapping.
Under the hood, Sequelize used with PostgreSQL is several layers removed from our actual database:
- First, we write our Sequelize, using Javascript objects to mimic the structure of our database tables.
- Sequelize creates a SQL string and passes it to a lower-level library called
pg
(PostgreSQL). pg
connects to your PostgreSQL database and queries it or transforms its data.pg
passes the data back to Sequelize, which parses and returns that data as a Javascript object.
'use strict'; | |
// simple express server | |
var express = require('express'); | |
var app = express(); | |
var router = express.Router(); | |
app.use(express.static('public')); | |
app.get('/', function(req, res) { | |
res.sendfile('./public/index.html'); |