This file contains hidden or 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 'net/http' | |
require 'socket' | |
# to run on Ubuntu/Debian with sudo access | |
def with_unresponsive_dns | |
fake_dns_ip = "127.0.0.1" | |
th = Thread.new do | |
server = UDPSocket.new | |
server.bind(fake_dns_ip, 53) | |
server.recvfrom(16) |
This file contains hidden or 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 'net/http' | |
require 'socket' | |
def with_unresponsive_dns | |
fake_dns_ip = "127.0.0.1" | |
th = Thread.new do | |
server = UDPSocket.new | |
server.bind(fake_dns_ip, 53) | |
server.recvfrom(16) | |
sleep | |
end |
This file contains hidden or 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
int deserialize_String_vector(struct iarchive *in, const char *tag, struct String_vector *v) | |
{ | |
int rc = 0; | |
int32_t i; | |
rc = in->start_vector(in, tag, &v->count); | |
v->data = calloc(v->count, sizeof(*v->data)); | |
for(i=0;i<v->count;i++) { | |
rc = rc ? rc : in->deserialize_String(in, "value", &v->data[i]); | |
} | |
rc = in->end_vector(in, tag); |
This file contains hidden or 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 Deadline | |
def self.current=(value) | |
ActiveRecord::Base.deadline = value | |
end | |
def initialize(duration_seconds) | |
@deadline = now + duration_seconds.to_i | |
end | |
def extend_deadline(duration_seconds) |
This file contains hidden or 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 'benchmark/ips' | |
require 'securerandom' | |
str = "#{SecureRandom.alphanumeric(1000)} SUBSTR" | |
Benchmark.ips do |x| | |
x.config(:time => 5, :warmup => 2) | |
x.report("=~") do |t| | |
100.times do |
This file contains hidden or 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 "bundler/inline" | |
gemfile(true) do | |
source "https://rubygems.org" | |
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
gem "rails", github: "rails/rails" |
This file contains hidden or 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
#!/bin/bash | |
# The script to run actual benchmark | |
set -e -x | |
IMAGE=redmine:latest | |
CHECKPOINT_NAME=checkpoint-redmine | |
GCS_BUCKET=kirs-criu |
This file contains hidden or 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
apt update | |
apt upgrade | |
apt install build-essential | |
apt install pkg-config | |
apt install libnet-dev python-yaml libaio-dev | |
apt install libprotobuf-dev libprotobuf-c0-dev protobuf-c-compiler protobuf-compiler python-protobuf libnl-3-dev libcap-dev python-future | |
# criu install | |
curl -O -sSL http://download.openvz.org/criu/criu-3.10.tar.bz2 | |
tar xjf criu-3.10.tar.bz2 |
This file contains hidden or 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 'bundler/inline' | |
gemfile do | |
source 'https://rubygems.org' | |
gem "aws-sdk", "~> 3.0" | |
end | |
require 'aws-sdk' | |
ec2 = Aws::EC2::Resource.new(region: 'us-east-1') |
This file contains hidden or 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 'bundler/inline' | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'google-api-client', '~> 0.11' | |
end | |
require 'google/apis/compute_v1' | |
Google::Apis.logger = Logger.new(STDERR) | |
Google::Apis.logger.level = Logger::INFO |