Skip to content

Instantly share code, notes, and snippets.

View komagata's full-sized avatar

Masaki Komagata komagata

View GitHub Profile
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'optparse'
ARGV.each do |file_from_arg|
file = File.read(file_from_arg)
print file.count("\n").to_s.rjust(8)
word = File.open(file_from_arg).read.split(/\s+/).count
print word.to_s.rjust(8)
@komagata
komagata / rails.yml
Last active June 25, 2022 03:45
Fjord rubocop configuration.
require:
- rubocop-rails
AllCops:
Exclude:
- '**/templates/**/*'
- '**/vendor/**/*'
- 'app/views/**/*'
- 'config/**/*'
- 'node_modules/**/*'
@komagata
komagata / comment.vue
Created November 23, 2018 08:20
comments component
<template lang="pug">
.review-comments
.narrow-container
h2.review-comments__title コメント
transition-group(name="fade" tag="div" class="review-comments__items")
comment(v-for="(comment, index) in comments"
v-bind:key="comment.id"
v-bind:comment="comment"
v-bind:userId="reviewUserId"
v-on:delete="deleteComment")
@komagata
komagata / app.rb
Last active August 19, 2019 08:55
Memoアプリ
require "sinatra"
require_relative "memo"
Memo.data_dir = "memos"
get "/" do
@memos = Memo.all
erb :index, layout: :layout
end
@komagata
komagata / Mole.cs
Last active December 20, 2017 06:40
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Mole : MonoBehaviour {
public GameObject prefab;
GameObject instance;
void Start () {
this.instance = Instantiate (prefab) as GameObject;
@komagata
komagata / gist:8abbe8c8395b0b689f3cc4a97ff9a4ac
Created November 6, 2017 07:24 — forked from machida/html_practice.html
HTMLの練習(このレシピにマークアップをしてみましょう)
カレーのレシピ
誰でもできる、美味しいカレーの作り方です。旦那も息子もこのカレーが大好物。
ポイントは玉ねぎと人参はミキサーで細かくしてしまうところ。逆にコクのある美味しいカレーになります。
レシピの作者
山田サチ子さん
材料 ( 8皿分 )
@komagata
komagata / delegation.js
Created September 23, 2017 11:33
Event delegation
const ul = document.querySelector("ul");
ul.addEventListener("click", (event) => {
if (event.target.tagName === "LI") {
console.log("FOO↑↑↑");
}
});
@komagata
komagata / dynamicEvent.js
Last active September 22, 2017 11:12
jQueryを使わず、動的にイベントリスナを追加する。
let elements = document.getElementsByTagName("div");
Array.from(elements, (element) => {
if (element.classList.contains(".foo")) {
element.addEventListener("click", () => {
console.log("FOO!");
})
}
});
@komagata
komagata / http-with-cache.go
Created July 28, 2016 09:50
go-cache利用アプリ。
package main
import (
"database/sql"
_ "github.com/go-sql-driver/mysql"
"github.com/patrickmn/go-cache"
"html/template"
"net/http"
"strconv"
"time"
@komagata
komagata / http.go
Created July 28, 2016 09:50
毎回MySQLにアクセスするアプリ。
package main
import (
"database/sql"
_ "github.com/go-sql-driver/mysql"
"html/template"
"net/http"
)
func viewHandler(w http.ResponseWriter, r *http.Request) {