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 / docker-compose.yml
Last active November 29, 2022 07:19
simple docker-compose file for dockerizing the restarone website
version: '3'
networks:
development:
test:
volumes:
db_data:
gem_cache:
shared_data:
services:
restarone_redis:
@donrestarone
donrestarone / Dockerfile.dev
Created December 27, 2020 15:51
simple dockerfile for setting up the dependencies for a rails application
FROM ruby:2.6.6-alpine
ENV APP_PATH /var/app
ENV BUNDLE_VERSION 2.1.4
ENV BUNDLE_PATH /usr/local/bundle/gems
ENV TMP_PATH /tmp/
ENV RAILS_LOG_TO_STDOUT true
ENV RAILS_PORT 3000
# copy entrypoint scripts and grant execution permissions
@donrestarone
donrestarone / _tweet.html.erb
Created December 25, 2020 15:20
turbo frame partial rails 6
<%= turbo_frame_tag dom_id(tweet) do %>
<div class="card m-4">
<div class="card-body">
<%= tweet.content %>
</div>
<div class="card-footer bg-transparent border-success">
<%= link_to 'Show', tweet, class: 'btn btn-sm btn-primary text-white' %>
<%= link_to 'Edit', edit_tweet_path(tweet), class: 'btn btn-sm btn-warning text-white', remote: true %>
<%= link_to 'Destroy', tweet, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-sm btn-danger text-white' %>
</div>
@donrestarone
donrestarone / index.html.erb
Created December 25, 2020 15:19
turbo stream with rails 6
<p id="notice"><%= notice %></p>
<h1>Tweets</h1>
<table>
<thead>
<tr>
<th colspan="3"></th>
</tr>
</thead>
@donrestarone
donrestarone / tweet.rb
Created December 25, 2020 15:18
hotwire demo rails 6
class Tweet < ApplicationRecord
has_rich_text :content
after_create_commit {broadcast_prepend_to "tweets"}
after_update_commit {broadcast_replace_to "tweets"}
after_destroy_commit {broadcast_remove_to "tweets"}
end
@donrestarone
donrestarone / index.css
Created December 23, 2020 23:57
css fix for react-zoom-pan-pinch rendering invisible pan area
/* fix not rendering on chrome/safari */
.react-transform-component {
width: unset !important;
height: unset !important;
}
.react-transform-element {
width: unset !important;
height: unset !important;
}
@donrestarone
donrestarone / todolist.js
Created December 23, 2020 23:50
a function for dynamically generating dummy data for react-grid-layout
let faker = require('faker');
export const todoList = () => {
let columnCount = 12
let maxBlocksPerColumn = 12
let layout = []
let i = 0
const cardWidth = 3
const cardHeight = 8
const inlineYaxis = 1
@donrestarone
donrestarone / app.js
Created December 23, 2020 23:47
react component demo'ing react-grid-layout and pan pinch zoom
import React, {useEffect} from 'react'
import './index.css';
import { TransformWrapper, TransformComponent } from "react-zoom-pan-pinch";
import {todoList} from './constants/todo'
import {useState} from 'react'
import 'react-grid-layout/css/styles.css'
import 'react-resizable/css/styles.css'
import GridLayout from 'react-grid-layout';
function App(props) {
@donrestarone
donrestarone / index.js
Created December 23, 2020 23:40
React entrypoint for Phoenix
import { define } from 'remount'
import App from './App'
define({ 'x-application': App })
@donrestarone
donrestarone / webpack.config.js
Created December 23, 2020 23:31
webpack configuration for React (in a Phoenix application)
const path = require('path');
const glob = require('glob');
const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = (env, options) => {
const devMode = options.mode !== 'production';