Skip to content

Instantly share code, notes, and snippets.

View ttanimichi's full-sized avatar

Tsukuru Tanimichi ttanimichi

View GitHub Profile
@ttanimichi
ttanimichi / main.dart
Created January 28, 2024 09:22
oval-charm-0735
void main() {
var list = [1, 2, 3];
print(list.reversed);
print(list.reversed.runtimeType);
print(list);
}
error_highlight
hash_instance_methods = %w(
<
<=
==
===
>
>=
[]
[]=
assoc
# Current.time = Time.current
# Current.user = User.find(42)
# MyAPIClient.new.analyze
class MyAPIClient
URL = 'http://api.example.com'
def analyze
response = Faraday.post(URL, body_hash.to_json, headers)
JSON.parse(response.body)
Hash.class_eval do
if respond_to? :deep_camelize_keys
fail "deep_camelize_keys is already defined"
else
def deep_camelize_keys(first_letter = :upper)
deep_transform_keys { |key| key.to_s.camelize(first_letter) }
end
end
end
@ttanimichi
ttanimichi / routes.txt
Last active April 22, 2017 12:01
Mastodon のルーティング
/mastodon # bin/rails routes
Prefix Verb URI Pattern Controller#Action
sidekiq /sidekiq Sidekiq::Web
pghero /pghero PgHero::Engine
GET /oauth/authorize/:code(.:format) oauth/authorizations#show
oauth_authorization GET /oauth/authorize(.:format) oauth/authorizations#new
DELETE /oauth/authorize(.:format) oauth/authorizations#destroy
POST /oauth/authorize(.:format) oauth/authorizations#create
oauth_token POST /oauth/token(.:format) doorkeeper/tokens#create
oauth_revoke POST /oauth/revoke(
@ttanimichi
ttanimichi / client.js
Created September 1, 2016 11:27
socket.io の Event をメタプロでクラスに流すサンプルコード
class ClientEvents {
static connect() {
logger.info({ event: 'connect' });
}
static reconnect_error(error) {
logger.info({ event: 'reconnect_error', error: error });
}
}
@ttanimichi
ttanimichi / cached_records.rb
Created July 11, 2016 02:48
AR::Base のテーブルをキャッシュするサンプルコード
class ApplicationRecord
def self.all
s = Struct.new(:code, :v)
[s.new(42, "hoge"), s.new(43, "fuga")]
end
end
ApplicationRecord.singleton_class.class_eval do
def CachedRecords(key: :id)
Module.new do
require 'sshkit'
require 'sshkit/dsl'
include SSHKit::DSL
on 'freeza@freeza.aiming-inc.biz' do
puts capture(:ls, '-l')
end
# total 12
@ttanimichi
ttanimichi / Gemfile
Last active March 15, 2016 11:33
共通基盤システムの Gemfile
source 'https://rubygems.org'
gem 'rails', '~> 4.2.0'
gem 'rails-i18n'
gem 'mysql2'
gem 'fluent-logger'
gem 'rack-oauth2'
gem 'twitter'
gem 'koala', '~> 1.11'
gem 'airbrake', '~> 4.1'