Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View donrestarone's full-sized avatar
🤖
Building products

Don Restarone donrestarone

🤖
Building products
View GitHub Profile
@donrestarone
donrestarone / babel.config.js
Created December 23, 2020 23:29
babel configuration for React (used in a Phoenix application)
module.exports = function (api) {
api.cache(true);
const presets = [
'@babel/preset-env',
'@babel/preset-react',
]
const plugins = [
]
@donrestarone
donrestarone / home_view.ex
Created December 23, 2020 23:21
view function to avoid missing view error in phoenix
defmodule WorkshopWeb.HomeView do
use WorkshopWeb, :view
end
@donrestarone
donrestarone / home_controller.ex
Created December 23, 2020 23:16
phoenix controller file
defmodule WorkshopWeb.HomeController do
use WorkshopWeb, :controller
def index(conn, _params) do
render(
conn,
"index.html",
props: Jason.encode!(%{foo: "bar"})
)
end
@donrestarone
donrestarone / router.ex
Created December 23, 2020 23:15
phoenix route file
defmodule WorkshopWeb.Router do
use WorkshopWeb, :router
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_live_flash
plug :put_root_layout, {WorkshopWeb.LayoutView, :root}
plug :protect_from_forgery
plug :put_secure_browser_headers
@donrestarone
donrestarone / docker.md
Last active December 15, 2020 02:19
docker cheatsheet

docker cheatsheet

viewing available/running containers

docker ps shows running containers, amd docker container ls lists available containers

docker ps
docker container ls

viewing available images

@donrestarone
donrestarone / sshconfig.sh
Created November 21, 2020 14:48
setting up SSH via .ssh/config
# make sure to move your .pem file for SSH auth to ~/.ssh & chmod 0400 the file
chmod 0400 your-server-identity.pem
# open ~/.ssh/config with your favorite text editer and drop in the following plumbing (replace the IP/host of your server and username and point to the correct pem file)
Host my-server
HostName 54.157.228.255
User your-user-name
IdentityFile ~/.ssh/your-server-identity.pem
IdentitiesOnly yes
@donrestarone
donrestarone / postgres-ec2.sh
Last active November 21, 2020 14:06
standalone postgres server in ec2
sudo apt-get update -y && sudo apt-get upgrade -y
sudo apt install postgresql -y
sudo su postgres
psql -U postgres -c "CREATE ROLE ubuntu;"
psql -U postgres -c "ALTER ROLE ubuntu WITH LOGIN;"
psql -U postgres -c "ALTER USER ubuntu CREATEDB;"
psql -U postgres -c "ALTER USER ubuntu WITH PASSWORD 'ubuntu';"
exit
@donrestarone
donrestarone / ec2-rails-only.sh
Last active October 23, 2020 10:59
barebones rails install for ec2
#to run curl link_to_this_raw_gist | sudo bash
sudo apt-get update -y && sudo apt-get upgrade -y
sudo apt install curl -y
sudo apt-get install tmux -y
sudo apt install nodejs -y && sudo apt install npm -y
sudo apt-get install htop build-essential zlib1g-dev openssl libreadline6-dev git-core zlib1g libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf automake libtool bison libgecode-dev -y && sudo apt-get install libpq-dev -y
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc && echo 'eval "$(rbenv init -)"' >> ~/.bashrc
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv && git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
@donrestarone
donrestarone / heroku-db-dump-restore.md
Last active November 14, 2020 13:54
pulling a db dump from heroku and restoring your local database with it

first grab the latest.dump from heroku

heroku pg:backups:capture
heroku pg:backups:download

then make sure that you have a database user with a password setup

sudo su postgres
CREATE ROLE test;
@donrestarone
donrestarone / hacky-nginx.md
Created October 14, 2020 11:58
hacky nginx configuration

This hacky configuration is not right. You should always use a unix socket as its more secure and performant. This is setup assuming that there is a server listening on port 3000

RAILS_ENV=production rails db:create
RAILS_ENV=production rails db:migrate
RAILS_ENV=production rails assets:precompile
RAILS_ENV=production rails s
upstream app {