This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def main | |
count = 0 | |
uniq_list = [] | |
f = open('write', 'w') | |
open_each_ss('parsed_mobamasu_kai') do |row| | |
array = row.strip.split(' ') | |
array.uniq.each do |word| | |
if !uniq_list.include?(word) | |
uniq_list << word | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dir::foreach('db/migrate/.') do |file| | |
next if file == '.' || file == '..' | |
state = 0 | |
table = '' | |
table_name = '' | |
open("db\/migrate\/#{file}") do |f| | |
file_name = file.match(/.+_create_(\w+)\.rb/)[1] | |
wf = open("db\/schemas\/#{file_name}\.rb", 'w') | |
f.each do |line| | |
if line.include?('create_table') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Customer < ApplicationRecord | |
has_many :orders, dependent: :destroy | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OpenURI.open_uri('ファイルのURL') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 性・名・電話番号でのAND検索 | |
User.search('田中 太郎 08012345678') | |
# メールアドレスに"gmail"が含まれており、登録が2015年あるいは2016年 | |
User.search('email: gmail AND (created_at:2015 OR created_at:2016)') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user = User.find(5) | |
SampleJob.perform_later(user) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ '<' => [-1], '>' => [1], '<=' => [-1, 0], '>= ' => [1, 0]}.each do |ope, v| | |
[TrueClass, FalseClass].each do |klass| | |
klass.class_eval("def #{ope}(num); self ? value #{ope} num : false;end") | |
end | |
[Integer, Float].each do |klass| | |
klass.class_eval do | |
define_method(ope) do |n| | |
return false unless v.include? (self <=> n) | |
TrueClass.class_eval("def value; #{n};end") | |
true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git clone https://github.com/EastResident/locusts | |
cd locusts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import uuid | |
from datetime import datetime | |
from locust import HttpLocust, TaskSet, task | |
class MetricsTaskSet(TaskSet): | |
@task | |
def index(self): | |
self.client.get("/index") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from locust import HttpLocust, TaskSet | |
def login(l): | |
l.client.post("/login", {"username":"ellen_key", "password":"education"}) | |
def logout(l): | |
l.client.post("/logout", {"username":"ellen_key", "password":"education"}) | |
def index(l): | |
l.client.get("/") |
OlderNewer