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
require 'nio' | |
selector = NIO::Selector.new | |
# 1234番ポートでTCPを待ち受ける | |
server = TCPServer.new('localhost', 1234) | |
# 標準出力を取得する。常にwriteが可能な口がほしいだけ | |
stdout = $stdout | |
# セレクタに登録。 |
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
# frozen_string_literal: true | |
require 'fiber' | |
# Manage packet. | |
class Packets | |
def initialize | |
@packets = [] | |
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
# frozen_string_literal: true | |
require 'fiber' | |
# Manage packet. | |
class Packets | |
def initialize | |
@packets = [] | |
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
# frozen_string_literal: true | |
require 'concurrent' | |
require 'benchmark' | |
def api_a_call | |
sleep 2 | |
'answer_from_api_a' | |
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
# frozen_string_literal: true | |
require 'concurrent' | |
require 'benchmark' | |
def api_a_call | |
sleep 2 | |
'answer_from_api_a' | |
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
class ExcelsController < ApplicationController | |
def show | |
end | |
def create | |
file = params[:file] | |
# ファイルを開く | |
workbook = RubyXL::Parser.parse file.path | |
# 編集する | |
workbook[0].add_cell 0, 0, 'changed' |
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
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]; |
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 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]; | |
} | |
} |
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 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; |
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 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; |