Skip to content

Instantly share code, notes, and snippets.

View usutani's full-sized avatar

Yasuhiro Usutani usutani

  • Kobe, Hyogo, Japan
View GitHub Profile
@usutani
usutani / ch9_trip.rb
Last active June 14, 2020 06:48
オブジェクト指向設計実践ガイド 9章 ダックタイプをテストする
# frozen_string_literal: true
class Trip
def prepare(preparers)
# ...
preparers.each do |preparer|
preparer.prepare_trip(foo: self)
end
@usutani
usutani / ch6_bicyle.rb
Created June 13, 2020 01:46
オブジェクト指向設計実践ガイド 6章 キーワード引数版
# frozen_string_literal: true
class Bicycle
attr_reader :size, :chain, :tire_size
def initialize(**kwargs)
@size = kwargs[:size]
@chain = kwargs[:chain] || default_chain
@tire_size = kwargs[:tire_size] || default_tire_size
post_initialize(**kwargs)
<!DOCTYPE html>
<html lang="en">
<head>
<title>Tailwind CSS Modal</title>
<link href="https://cdn.jsdelivr.net/npm/tailwindcss/dist/tailwind.min.css" rel="stylesheet">
</head>
<body>
<div class="flex flex-col">
<div class="bg-blue-500 m-3 py-20 px-4">text</div>
@usutani
usutani / application.js
Last active January 17, 2021 04:43
Tailwind CSSの習作: Rails scaffold.scssの移植
// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.
require("@rails/ujs").start()
require("turbolinks").start()
require("@rails/activestorage").start()
require("channels")
require("./application.scss")
@usutani
usutani / note_serve_rails_prod_alone.md
Created May 21, 2020 04:32
覚書: Rails単体production環境での動作確認

環境

macOS 10.15.4 Ruby 2.7.1 Rails 6.0.3.1 Yarn 1.22.4 Node 13.12.0

確認用アプリの作成

rails new app_name cd app_name

@usutani
usutani / terminate.cs
Created January 6, 2019 06:47 — forked from jvshahid/terminate.cs
C# terminating a child process (as opposed to killing, i.e. sigkill vs. sigint on linux)
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace TestCtrlEvent
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Mail server for receiving",
"Parameters" : {
"MailServerDomain" : {
"Type" : "String",
"Default" : "mail.example.com",
"Description" : "mail server domain"
},
@usutani
usutani / Factorial.playground
Last active August 29, 2015 14:10
Factorial.playground
func factorial(n : Int) -> Int {
if (n > 0) {
return n * factorial(n - 1)
} else {
return 1
}
}
factorial(20)
git config --global color.ui auto
git config --global core.editor vim
git config --global alias.st status
git config --global alias.br branch
git config --global alias.co checkout
git config --global alias.ci commit
git config --global alias.l 'log --color --graph --pretty=oneline --decorate --date=short --abbrev-commit --branches'
git config --global alias.ds 'diff --stat'

Docker 虎の巻

何故Dockerを使うべきか

Why Should I Care (For Developers)

"Dockerが面白いのはシンプルな環境に隔離性と再現性をもたらしてくれることだ.ランタイムの環境を一度作れば、パッケージにして別のマシンでも再利用することできる.さらに,すべてはホスト内の隔離された環境で行われる(VMのように).最も素晴らしい点は,シンプルかつ高速であることだ."