Skip to content

Instantly share code, notes, and snippets.

View ta1kt0me's full-sized avatar
🐢
slow

ta1kt0me

🐢
slow
View GitHub Profile
@ta1kt0me
ta1kt0me / query_constraints_test.rb
Last active February 26, 2024 10:49
query_constraintsによる複合キーの関連付けの動作確認
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "rails", "7.1.3.2"
@ta1kt0me
ta1kt0me / simple_state_manager.rb
Created November 15, 2020 16:01
SimpleStateManager for PORO
module SimpleStateManager
class InvalidTransitionError < StandardError; end
def self.included(klass)
klass.extend(ClassMethods)
attr_accessor :state
klass.class_eval do
original_method = instance_method(:initialize)
@ta1kt0me
ta1kt0me / run_length_compress.rb
Created July 31, 2020 13:11
Run Length 圧縮
require 'minitest/autorun'
class CompressString
def initialize(text)
@text = text
end
def text
@text
end
@ta1kt0me
ta1kt0me / rails_sql_injection.rb
Created July 14, 2020 12:18
RailsでSQL Injectionを実行するsample script
# https://rails-sqli.org/ を参考に ActiveRecord を利用した SQL Injection のサンプルを試す
# 試した環境は Rails 5.2.4
# delete_allやdestroy_allでは引数を渡せない状況になったりもしているので全てのサンプルを試すことはできなかった。
#
# db/seeds.rb
# (1..100).each do |i|
# Task.create(name: "task_#{i}")
# end
#
# db:seed を実行した後に以下のスクリプトを実行する
@ta1kt0me
ta1kt0me / Dockerfile
Last active April 8, 2024 19:32
ansible on docker-compose
FROM python:3.8.3-alpine3.11
RUN apk add --no-cache gcc=9.2.0-r4 musl-dev=1.1.24-r2 libffi-dev=3.2.1-r6 openssl-dev=1.1.1g-r0 openssh-client=8.1_p1-r0
RUN mkdir /app
WORKDIR /app
COPY requirements.txt /app/
RUN pip install -r requirements.txt
@ta1kt0me
ta1kt0me / keybase.md
Created January 6, 2020 13:36
hello keybase.io

Keybase proof

I hereby claim:

  • I am ta1kt0me on github.
  • I am ta1kt0me (https://keybase.io/ta1kt0me) on keybase.
  • I have a public key ASDX5EMGrQ283yL5_ZGyrL2fbMKuEEqn0vcZ2HlQT1IyQAo

To claim this, I am signing this object:

@ta1kt0me
ta1kt0me / ssh2essh.rb
Created October 30, 2019 22:30
converts ssh_config to essh config.lua
ssh_config = File.read(ENV.fetch('HOME') + "/.ssh/config")
group = {}
host = []
ssh_config.each_line do |line|
line.strip!
if line.start_with?(/Host |host /)
unless host.empty?
values = host[1..-1].map { |str| [str.strip.split(" ", 2)].to_h }.inject(&:merge)
@ta1kt0me
ta1kt0me / unhighlignter.js
Last active July 25, 2019 09:26 — forked from sinsoku/unhighlignter.js
WIP Pull Request Unhighlignter for GitHub が使えなくなったので、 Tampermonkey の UserScript で再実装した
// ==UserScript==
// @name WIP Pull Request Unhighlignter
// @author sinsoku
// @version 0.4.1
// @match https://github.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
@ta1kt0me
ta1kt0me / generate_britta_dsl_from_xml.rb
Created January 15, 2019 12:57
Genarate gmail-britta DSL from mailFilter.xml for gmail, not perfect
require 'nokogiri'
require 'byebug'
f = File.open("./mailFilters.xml")
doc = Nokogiri::XML(f)
body = []
doc.xpath('//xmlns:entry').each do |entry|
body << "filter {\n"
@ta1kt0me
ta1kt0me / Gemfile
Created January 3, 2019 11:03
put cloudwatch logs
# frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem "aws-sdk-cloudwatchlogs"