Skip to content

Instantly share code, notes, and snippets.

@webuilder240
webuilder240 / Vue2Island.js
Last active January 8, 2024 12:37
tiny island Architecture Codes (not SSR
import Vue from 'vue';
class Vue2Island extends HTMLElement {
constructor() {
super();
this.vueInstance = null;
}
connectedCallback() {
this.name = this.dataset.name
@webuilder240
webuilder240 / 1_queuing_condition.rb
Last active April 18, 2023 13:13
1は条件分岐をキューイングする際、Jobクラス内部のどちらででも行うようにしています。2はJobクラスでのみ処理条件を書くようにしています。
# user.rb
class User < ApplicationRecord
after_create_commit do
if is_admin?
AdminUserCreateLoggingJob.perform_later(self.id)
end
end
end
# ConditionをJobクラスに含めない
// https://twitter.com/justin999_/status/1293738518989029379?s=21
//
// 1万個のarrayを高速で作る方法を考えよ。
// Swiftでいうなら、[[Int]]。
// なお、それぞれのarrayの中身はランダム、長さは7である
// [
// [1, 3, 9, 0, 1, 2, 4],
// [1, 9, 0, 7, 9 ,1, 2],
// ....(1万個)
// ]
@webuilder240
webuilder240 / designdoc.md
Last active January 11, 2022 04:05 — forked from daijinload/designdoc.md
Googleのデザインドックのマークダウンサンプルらしい
@webuilder240
webuilder240 / app.rb
Created August 28, 2021 03:52
EventEmitterをRubyで再実装
require "./emitter.rb"
Emitter.once("hello") do |param|
puts "Hello World #{param}"
end
Emitter.emit("hello", "param")
Emitter.emit("hello", "param2")
@webuilder240
webuilder240 / 01_index.html.erb
Last active August 25, 2021 15:00
MPAでページネーションをまたいでのチェックボックスの内容を保持するコードの比較(Vue, Stimulus)
<p id="notice"><%= notice %></p>
<h1>Users</h1>
<div data-controller="hello" data-hello-check-ids-value="[]">
<table>
<thead>
<tr>
<th>
<input type="checkbox" data-action="hello#toggleCheckAllDisplayUsers">
class Message
attr_reader :id, :text
def initialize(id, text)
@id = id
@text = text
end
def self.find(messages, search_id)
# 2回目以降はインスタンス生成をしたくない。
@webuilder240
webuilder240 / codable.swift
Created January 18, 2021 14:39
Codableの練習。
import UIKit
import Foundation
var str = "Hello, playground"
struct Author: Codable {
var id: Int?
var name: String
var nickname: String?
}
@webuilder240
webuilder240 / Gemfile
Created July 20, 2020 14:11 — forked from dhh/Gemfile
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
class MtParser
attr_reader :mt_records, :file_path, :is_parseing_body
def self.import
parser = new("#{Rails.root}/app/models/webuilder240.hatenablog.com.export.txt")
parser.parse
records = parser.mt_records
ActiveRecord::Base.transaction do
records.each do |mt_record|