Skip to content

Instantly share code, notes, and snippets.

View featherart's full-sized avatar
🎯
Focusing

Feather featherart

🎯
Focusing
View GitHub Profile
@featherart
featherart / gist:e092df4a973108fa5598f9743b4198d4
Last active August 31, 2020 18:22
generate a new todo context
# generate a new context Todos with a database table Items. This table will have fields
# description:string
# priority:string
# is_done:boolean
mix phx.gen.live Todos Item items description:string priority:string is_done:boolean
# scaffold the todos UI app
npx create-react-app todos-ui
# move into the newly created directory
cd todos-ui
# install all dependencies
yarn
# create a new todo item
curl -H "Content-Type: application/json" -X POST -d '{"item":{"description":"learn elixir", "priority":1, "is_complete": false }}' http://localhost:4000/api/items
# list items
curl -H "Content-Type: application/json" -X GET http://localhost:4000/api/items
# in dev.ex, under
config :todos_api ...
debug_errors: false,
...
# generate context & controller for a JSON resource
# this will create a migration that when run will create a table for items
# this table has a description, a priority level and a flag for whether the task is complete
mix phx.gen.json TodoItem Item items description:string priority:integer is_complete:boolean
# to run the migration we will use ecto again
mix ecto.migrate
# run all tests
mix test
# fire up the server
# by default the server will be listening on http://localhost:4000
mix phx.server
@featherart
featherart / gist:dee7af017b84f4733329176535f46c64
Last active February 5, 2020 05:39
Create a new JSON Phoenix API
# generate a new app in a directory called todos-json-api
# namespaced under ToDosApi, & no html or webpack will scaffolded
mix phx.new todos-json-api --app todos_api --module ToDosApi --no-html --no-webpack
# go into newly created directory
cd todos-json-api
# create the database
mix ecto.create
# To install postgres
brew update
brew install postgres
# To create new user (necessary step before you can create a database):
createuser -d postgres
# To start up postgres:
brew services start postgresql
@featherart
featherart / gist:6734826
Last active January 9, 2019 16:56
Week one: !Quiz This isn't a chance to "fail a test", it's a way of letting us all (including you) know what you know.
# ,o888888o. 8 8888 88 8 8888 8888888888',8888'
# . 8888 `88. 8 8888 88 8 8888 ,8',8888'
# ,8 8888 `8b 8 8888 88 8 8888 ,8',8888'
# 88 8888 `8b 8 8888 88 8 8888 ,8',8888'
# 88 8888 88 8 8888 88 8 8888 ,8',8888'
# 88 8888 `8. 88 8 8888 88 8 8888 ,8',8888'
# 88 8888 `8,8P 8 8888 88 8 8888 ,8',8888'
# `8 8888 ;8P ` 8888 ,8P 8 8888 ,8',8888'
# ` 8888 ,88'8. 8888 ,d8P 8 8888 ,8',8888'
@featherart
featherart / second_week.html
Last active January 9, 2019 16:55
Week 2 quiz in JavaScript
<html>
<head>
<title>!Quiz - Week 2</title>
</head>
<body>
<center>
<h1>Puppies - wait, is that a puppy?! </h1>
<img id="daPuppies" src="puppies.jpg" width="300" height="auto" />
<h3> don't forget to open your Chrome console </h3>
<button onclick="alert('function needed!');">Bigger Puppies</button>