Skip to content

Instantly share code, notes, and snippets.

View kimihito's full-sized avatar
🏠
Working from home

kimihito kimihito

🏠
Working from home
View GitHub Profile
# create myapp_web/plugs/htmx.ex
defmodule MyAppWeb.Plugs.Htmx do
import Plug.Conn
import Phoenix.Controller, only: [put_root_layout: 2, put_layout: 2, root_layout: 1, layout: 1]
@behaviour Plug
@impl true
def init(opts), do: opts
Mix.install([{:playwright, "~> 1.18.0-alpha.1"}])
Playwright.CLI.install_deps()
Playwright.CLI.install()
browser = Playwright.launch()
page = browser |> Playwright.Browser.new_page()
page |> Playwright.Page.goto("https://google.com")
@kimihito
kimihito / ecosystem.config.js
Created January 11, 2023 07:02
Remix.run pm2
module.exports = {
apps: [
{
name: "remix-pm2-test",
exec_mode: "cluster",
instances: "max",
cwd: "./",
script: "./node_modules/.bin/remix-serve",
args: "build",
watch: ["./"], // または true
@kimihito
kimihito / main.tf
Created May 30, 2021 07:35
Use Terraform for deploying Digital Ocean App platform
terraform {
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
version = "~> 2.0"
}
}
}
# Set the variable value in *.tfvars file
@kimihito
kimihito / Dockerfile.prod
Last active December 24, 2022 19:00
Using Fullstaq Ruby on Heroku
# base dockerfile from https://github.com/evilmartians/terraforming-rails/blob/567566348a6a9893e10b9f857f1e5e58ba581b41/examples/dockerdev/.dockerdev/Dockerfile
# See explanation below
ARG RUBY_VERSION
FROM quay.io/evl.ms/fullstaq-ruby:$RUBY_VERSION-jemalloc-buster-slim as builder
ARG PG_MAJOR
ARG NODE_MAJOR
ARG BUNDLER_VERSION
@kimihito
kimihito / index.go
Created April 28, 2020 21:19
Running labstack/echo on Zeit now (Vercel) Serverless function
// set api/index.go
package handler
import (
"net/http"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
@kimihito
kimihito / active_storage.rake
Created November 25, 2019 06:58
setup for Active Storage direct upload ( Google Cloud Storage )
# lib/tasks/active_storage.rake
require 'google/cloud/storage'
namespace :active_storage do
desc 'create bucket'
task :create_bucket, [:bucket_name, :domain] => :environment do |task, args|
storage.create_bucket(args.bucket_name, location: 'us-east1') do |b|
b.cors.add_rule ["http://#{args.domain}", "https://#{args.domain}"],
'*',
= image_tag '', class: 'avatar width-full height-full', data: { controller: 'avatar', 'avatar-seed': user.name }
@kimihito
kimihito / track_decorator.rb
Created April 22, 2019 13:07
Use autolink twitter-text gem
module TrackDecorator
include Twitter::TwitterText::Autolink
include Rails.application.routes.url_helpers
def body
# https://github.com/twitter/twitter-text/blob/752b9476d5ed00c2ec60d0a6bb3b34bd5b19bcf9/rb/spec/autolinking_spec.rb#L687-L689
html = auto_link_hashtags(raw_body, { :hashtag_url_block => lambda { |url| project_path(self.project) } , hashtag_class: 'Label Label--gray'})
raw html
end
end
@kimihito
kimihito / application.html.haml
Last active April 22, 2019 05:19
twemoji + Stimulus.js
!!!
%html
%head
%meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
%title Idone.today
= csrf_meta_tags
= csp_meta_tag
= stylesheet_pack_tag 'application', media: 'all', 'data-turbolinks-track': 'reload'
= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload'
%body.bg-gray{ data: { controller: 'emoji-parser'} }