Skip to content

Instantly share code, notes, and snippets.

View tmokmss's full-sized avatar

Masashi Tomooka tmokmss

View GitHub Profile
@tmokmss
tmokmss / EchoTest.cs
Last active April 28, 2018 09:01
A successful WebSocket server and client set
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System;
public class EchoTest : MonoBehaviour {
WebSocket w;
int myid = -1;
public Text output;
@tmokmss
tmokmss / 1. main.gs
Last active May 26, 2018 14:25
GASによる永続化方法
function main() {
var count_before = loadCount();
var count_today = getCountToday();
var count_sum = count_before + count_today;
Logger.log(count_sum);
saveCount(count_sum);
}
function getCountToday() {
@tmokmss
tmokmss / result.md
Last active June 12, 2018 12:58
the difference of processing speed with various "push back" method

Result

All the results are shown in second.

benchmark A

Debug

num push_back resize reserve emplace_back reserve alt resize alt
0 0 0 0 0 0 0
2000000 1.39 0.422 0.984 1.312 0.953 0.406
4000000 2.813 0.843 1.985 2.734 1.906 0.797
@tmokmss
tmokmss / stackdriver_logger.rb
Last active November 9, 2019 16:36
stackdriver logger patch for usability
require "google/cloud/logging"
class StackdriverLogger < Google::Cloud::Logging::Logger
module EntryRefinement
refine Google::Cloud::Logging::Entry do
attr_accessor :http_request
end
end
using EntryRefinement
@tmokmss
tmokmss / fargate-stack.ts
Created January 20, 2021 01:39
Fargate with ECS CDK Definition
import * as cdk from '@aws-cdk/core';
import * as ecs from '@aws-cdk/aws-ecs';
import * as efs from '@aws-cdk/aws-efs';
import * as ec2 from '@aws-cdk/aws-ec2';
export class FargateStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const vpc = new ec2.Vpc(this, 'vpc');
@tmokmss
tmokmss / main.tf
Created July 21, 2021 09:07
Terraform that enables AWS Config
resource "aws_s3_bucket" "aws_config_bucket" {
bucket_prefix = "aws-config-"
server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
}
@tmokmss
tmokmss / init_workspace.sh
Created March 2, 2022 05:20
Create AWS resources for Terraform S3 backend
#!/bin/bash
# A shell script to create AWS resources for Terraform S3 backend
STACK_NAME=TerraformStateStack-6nc8asv # add random suffix to prevent from colliding with any existing stacks
TEMPLATE_PATH="$(dirname "$0")/workspace_cfn.yaml"
aws cloudformation deploy --stack-name $STACK_NAME --template-file $TEMPLATE_PATH --no-cli-pager
aws cloudformation describe-stacks --stack-name $STACK_NAME --query "Stacks[0].Outputs" --no-cli-pager
@tmokmss
tmokmss / job.ts
Created March 30, 2022 14:18
A standalone construct for DataBrew Job
import { Construct } from 'constructs';
import { aws_databrew as databrew } from 'aws-cdk-lib';
import { IBucket } from 'aws-cdk-lib/aws-s3';
import { IRole } from 'aws-cdk-lib/aws-iam';
export interface JobProps {
readonly name: string;
readonly inputBucket: IBucket;
readonly inputKey: string;
readonly outputBucket: IBucket;
@tmokmss
tmokmss / index.js
Last active May 12, 2022 00:42
Survey form powered by Lambda function URL
const https = require('https')
exports.handler = async (event) => {
console.log(event)
const req = event.requestContext.http;
const sourceIp = req.sourceIp;
// can perform IP address restriction here
// e.g. if (sourceIp != "11.4.51.4") throw new Error()
@tmokmss
tmokmss / ISUCON_SOLO.md
Last active September 4, 2023 01:03
ソロISUCON 道標

準備

  • リポジトリの作成 (app, infra)
  • リポジトリをローカルに pull
  • AWSアカウントにログイン
  • ターミナルのウィンドウ配置

ソロISUCON 道標

具体的なコマンドはこちらに: https://github.com/tmokmss/isucon12q-infra

  1. 環境のセットアップ