Skip to content

Instantly share code, notes, and snippets.

View awongh's full-sized avatar
🍕
Snacking on pizza. Coding.

Akira Wong awongh

🍕
Snacking on pizza. Coding.
View GitHub Profile
@awongh
awongh / settings.json
Last active April 10, 2021 07:49
VSCode Settings
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"editor.minimap.enabled": false,
"editor.tabSize": 2,
"editor.wordWrap": "on",
"eslint.format.enable": true,
"eslint.lintTask.enable": true,
"eslint.migration.2_x": "off"
@awongh
awongh / postgres-cheatsheet.md
Created November 16, 2020 07:08 — 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)
@awongh
awongh / gist:394d41f845f7f81f3b27a5cd36dccbd9
Last active November 3, 2020 13:27 — forked from victorsollozzo/gist:4134793
recursively find all files in a directory with given extension in node.js
import path from 'path';
import { readdirSync, statSync } from 'fs';
function recFindByExt(base,ext,files,result)
{
files = files || readdirSync(base)
result = result || []
files.forEach(
function (file) {
["✌","😂","😝","😁","😱","👉","🙌","🍻","🔥","🌈","☀","🎈","🌹","💄","🎀","⚽","🎾","🏁","😡","👿","🐻","🐶","🐬","🐟","🍀","👀","🚗","🍎","💝","💙","👌","❤","😍","😉","😓","😳","💪","💩","🍸","🔑","💖","🌟","🎉","🌺","🎶","👠","🏈","⚾","🏆","👽","💀","🐵","🐮","🐩","🐎","💣","👃","👂","🍓","💘","💜","👊","💋","😘","😜","😵","🙏","👋","🚽","💃","💎","🚀","🌙","🎁","⛄","🌊","⛵","🏀","🎱","💰","👶","👸","🐰","🐷","🐍","🐫","🔫","👄","🚲","🍉","💛","💚"]
{
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"eslint.codeAction.showDocumentation": {
"enable": true
},
"eslint.format.enable": true,
"eslint.lintTask.enable": true,
"eslint.migration.2_x": "off"
var opts = {
retries: 10,
factor: 2,
minTimeout: 1 * 1000,
maxTimeout: Infinity,
};
TRUNCATE TABLE songs CASCADE;
TRUNCATE TABLE artists CASCADE;
ALTER SEQUENCE songs_id_seq RESTART WITH 1;
ALTER SEQUENCE artists_id_seq RESTART WITH 1;
INSERT INTO artists (name, photo_url, nationality) VALUES ('Weird Al Yankovich', 'http://i.huffpost.com/gen/1952378/images/o-WEIRD-AL-facebook.jpg', 'American');
INSERT INTO songs (title, album, preview_url, artist_id) VALUES ('White & Nerdy (Parody of "Ridin"")', 'Straight Outta Lynwood', 'http://a1748.phobos.apple.com/us/r1000/062/Music/ce/3d/70/mzm.hmiurdzp.aac.p.m4a', 1);
INSERT INTO songs (title, album, preview_url, artist_id) VALUES ('Ebay (Parody of "I Want It That Way" By the Backstreet Boys)', 'Poodle Hat', 'http://a920.phobos.apple.com/us/r1000/160/Music5/v4/17/ef/0b/17ef0bd4-2428-71ac-f1c4-2abf7eff7d9e/mzaf_5868025817010222762.plus.aac.p.m4a', 1);
INSERT INTO songs (title, album, preview_url, artist_id) VALUES ('Canadian Idiot (Parody of "American Idiot" By Green Day)', 'Straight Outta Lynwood', 'http://a699.phobos.apple.com/us/r1000/079/Music/a9/
@awongh
awongh / postgresql_configuration_on_ubuntu_for_rails.md
Created January 22, 2016 12:49 — forked from p1nox/postgresql_configuration_on_ubuntu_for_rails.md
PostgreSQL configuration without password on Ubuntu for Rails

Abstract

You could have postgre installed on localhost with password (or without user or password seted after instalation) but if we are developing we really don't need password, so configuring postgre server without password for all your rails project is usefull.

Install Postgre packages

  • postgresql
  • postgresql-client
  • libpq-dev

User Auth Rails app: What we're adding:

  • User model
rails g model user username:string password_hash:string
  • user_id foreign key in tables (user has many cars)

generate a migration

rails generate migration addUserId
## User Auth Rails app: What we're adding:
- User model
```bash
rails g model user username:string password_hash:string
```
- user_id foreign key in tables (user has many cars)
generate a migration
```bash
rails generate migration addUserId