Skip to content

Instantly share code, notes, and snippets.

View ytnk531's full-sized avatar

Yudai Tanaka ytnk531

View GitHub Profile
require 'nio'
selector = NIO::Selector.new
# 1234番ポートでTCPを待ち受ける
server = TCPServer.new('localhost', 1234)
# 標準出力を取得する。常にwriteが可能な口がほしいだけ
stdout = $stdout
# セレクタに登録。
# frozen_string_literal: true
require 'fiber'
# Manage packet.
class Packets
def initialize
@packets = []
end
@ytnk531
ytnk531 / network.rb
Last active September 24, 2019 17:57
# frozen_string_literal: true
require 'fiber'
# Manage packet.
class Packets
def initialize
@packets = []
end
# frozen_string_literal: true
require 'concurrent'
require 'benchmark'
def api_a_call
sleep 2
'answer_from_api_a'
end
# frozen_string_literal: true
require 'concurrent'
require 'benchmark'
def api_a_call
sleep 2
'answer_from_api_a'
end
class ExcelsController < ApplicationController
def show
end
def create
file = params[:file]
# ファイルを開く
workbook = RubyXL::Parser.parse file.path
# 編集する
workbook[0].add_cell 0, 0, 'changed'
public class ArrayManupilation {
static long arrayManipulation(int n, int[][] queries) {
long[] arr = new long[n+1];
int a, b, k;
for (int [] query : queries) {
a = query[0];
b = query[1];
k = query[2];
import java.util.Arrays;
public class ArrayManupilation {
static long arrayManipulation(int n, int[][] queries) {
long[] arr = new long[n+1];
for (int[] query : queries) {
for(int i = query[0];i <= query[1]; i++) {
arr[i] += query[2];
}
}
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import java.util.List;
@ytnk531
ytnk531 / MockTest.java
Last active August 11, 2018 02:58
Runnerを使う
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import java.util.List;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.when;