Skip to content

Instantly share code, notes, and snippets.

View mmyoji's full-sized avatar
🙃

mmyoji mmyoji

🙃
View GitHub Profile
@mmyoji
mmyoji / hyphenize.ts
Last active July 5, 2023 12:23
Replace camelCaseString with dashed-string
/**
* @example
* ```ts
* hyphenize("someCamelCaseString");
* //=> "some-camel-case-string"
*
* hyphenize("ABigHouse");
* //=> "a-big-house"
* ```
*/
@mmyoji
mmyoji / variable_test.yaml
Last active March 15, 2019 21:57
Testing YAML variables
ja:
activerecord:
models:
admin_user: 管理ユーザー
attributes:
default: &default
nickname: ニックネーム
email: メールアドレス
bio: BIO
@mmyoji
mmyoji / pre-commit
Last active June 17, 2022 01:44
pre-commit
#!/bin/sh
# http://qiita.com/yuku_t/items/ad072418290a2b01a35a
# A: Added
# M: Modified
files=$(git diff --cached --name-only --diff-filter=AM | grep '\.rb$')
if [ -n "$files" ]; then
bundle exec rubocop --force-exclusion ${files}
# For docker:
@mmyoji
mmyoji / action_view_render_method_from_anywhere.md
Last active March 15, 2019 22:38
Calls render method directly in Rails
@mmyoji
mmyoji / dynamo_scan_paging_with_ruby_sdk.md
Last active May 15, 2024 05:33
DynamoDB Scan paging w/ Ruby SDK
@mmyoji
mmyoji / strToHTML.ts
Last active September 1, 2021 09:41
Parse HTML string to raw DOM
/**
* @example
* document.getElementById("messages").append(
* strToHTML('<div class="message">foo</div>')
* );
*/
function strToHtml(rawStr: string) {
var parser = new DOMParser();
var html = parser.parseFromString(rawStr, 'text/html');
return html.body.children[0];
@mmyoji
mmyoji / gem_deprecate.rb
Created May 31, 2018 07:31
Usage of Gem::Deprecate.deprecate
class Test
extend Gem::Deprecate
# DEPRECATED
def foo
puts "foo"
end
def bar
puts "bar"
@mmyoji
mmyoji / dev-team-should-be.md
Last active June 17, 2022 01:42
Dev team should be
  • Using GitHub, GitLab or similar de facto git hosting/collaborating services
  • Many public chat messages, a few private ones
  • Preferring remote/asynchronous communication to synchronous one
  • Well-tested and -documented applications
  • No routine meetings: discuss whenever necessary
  • Higher priority for code review with respecting team mates' motivation
  • Make code/projects public as mush as possible rather than trying hard to write "tech blog"
  • CI/CD
  • linter/formatter: not discuss code styles or preferences during code review
@mmyoji
mmyoji / bundler-inline.rb
Created July 11, 2018 06:36
bundler/inline usage
# frozen_string_literal: true
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "virtus"
end
@mmyoji
mmyoji / datediff.ts
Last active July 27, 2021 01:19
Get Date diff (sec, min, hours) like moment.diff with Vanilla JS
const SECONDS = 1000;
const MINUTES = SECONDS * 60;
const HOURS = MINUTES * 60;
interface Result {
hours: number;
minutes: number;
seconds: number;
}