Skip to content

Instantly share code, notes, and snippets.

@leesmith
leesmith / api_controller.rb
Created August 14, 2020 20:08 — forked from eliotsykes/api_controller.rb
Token Authentication in Rails API Controller and Request Spec
# File: app/controllers/api/api_controller.rb
class Api::ApiController < ActionController::Base
# Consider subclassing ActionController::API instead of Base, see
# http://api.rubyonrails.org/classes/ActionController/API.html
protect_from_forgery with: :null_session
before_action :authenticate
def self.disable_turbolinks_cookies
skip_before_action :set_request_method_cookie
@leesmith
leesmith / deploy.log
Last active November 20, 2021 22:58
Heroku Rails 6 issue
git push heroku tailwind:master
Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Delta compression using up to 12 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (5/5), 395 bytes | 395.00 KiB/s, done.
Total 5 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
@leesmith
leesmith / deploy.sh
Created October 9, 2019 17:15
Sync Nuxtjs dist folder to S3 and invalidate Cloudfront distribution
#!/usr/bin/env bash
#
# Sync generated site to S3 and invalidate Cloudfront distribution
if [ ! -f .env ]; then
echo "# Project environment variables...do not commit this file." >> .env
echo "AWS_CF_DIST_ID=" >> .env
echo "AWS_S3_URI=" >> .env
echo "Please add the necessary values to the .env file."
else
@leesmith
leesmith / postgres-commands.txt
Created August 12, 2019 14:45
Postgres dump & restore
pg_dump --format=c --blobs --verbose --clean --file=some_db_name.dump some_db_name
pg_restore --verbose --no-acl --no-owner --dbname=some_db_name some_db_name.dump
@leesmith
leesmith / coinbase-clone.html
Created January 21, 2019 19:16
Tailwind CSS examples
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<title>Coinbase</title>
<link href="https://cdn.jsdelivr.net/npm/tailwindcss/dist/tailwind.min.css" rel="stylesheet">
</head>
<body>
<div class="font-sans bg-grey-lighter flex flex-col min-h-screen w-full">
<div>
@leesmith
leesmith / index.html
Created October 23, 2018 17:24
CSS maintenance server
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Maintenance Page</title>
<style>
html{font-size:18px}
body{font-family:'IBM Plex Sans',sans-serif;line-height:1.6;font-size:1em;padding:0 20px}
#wrapper{width:100%;height:350px;margin:0 auto;position:absolute;top:50%;left:50%;margin-top:-175px;margin-left:-50%}
@leesmith
leesmith / great-work.md
Last active September 5, 2021 03:11
Great Work

What separates the fleeting thrill of a “great idea” from the enduring rewards of great work?

These five facts:

  1. Great work is work that helps people. It’s not made great by accolades or praise from your peers… but by the experience of the people who actually use it. That’s work you can be proud of.
  2. Great work can be done by anyone. You don’t need to be “An Expert.” If you take the time to find out what people truly need, your work can help people now, and so you can do great work now.
  3. Great work is shipped work. Work that lives only in your brain or your hard drive can’t be great work. If you want your work to help people, you’ve got to get it into their hot little hands.
  4. Great work is work you can keep doing. If your work can’t sustain itself (aka with money and time off), you can’t keep doing it, which means you can’t keep helping people, and neither can your work. Great work takes care of you, so you can take care of it.
  5. Great work is never done. There can be nothing pe
@leesmith
leesmith / postgres-dump-all-and-restore.txt
Created August 25, 2017 12:30
Postgres dump cluster and restore
$ pg_dumpall > pg_all.sql
$ psql -U lsmith -f pg_all.sql postgres
@leesmith
leesmith / repo-cleanup.md
Last active November 21, 2016 22:42
Git commands for keeping a tidy local repo

Prune remotes

git remote prune origin

Delete branches

Locally:

@leesmith
leesmith / upgrade.md
Last active June 2, 2016 04:29
Upgrade Postgres via Homebrew