Skip to content

Instantly share code, notes, and snippets.

View typewriter's full-sized avatar

typewriter / takuya typewriter

View GitHub Profile
@typewriter
typewriter / add.asm
Created June 13, 2021 13:27
x86 Linux Assembly
; NASM x86
global _start
_start:
mov eax, 2
mov edx, 1
add edx, eax ; 3
add edx, '0' ; '3'
mov [sum], edx
@typewriter
typewriter / Dockerfile
Created May 21, 2021 12:49
GCP Cloud Run と AWS App Runner のスケーリングの様子をみる
FROM golang:latest as builder
WORKDIR /opt/server
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -o app main.go
FROM alpine:latest
EXPOSE 8080
COPY --from=builder /opt/server/app /opt/server/app
CMD ["/opt/server/app"]
@typewriter
typewriter / load_mem.rb
Created February 25, 2021 13:50
Ruby Memory Compaction Test
#!/usr/bin/env ruby
COMPACTION = !!ENV['COMPACTION']
def gc
GC.start
sleep 1
GC.compact if COMPACTION
sleep 1 if COMPACTION
end
@typewriter
typewriter / docker-compose.yml
Last active March 4, 2024 19:23
Zero downtime deployment reproduction using traefik
version: "3"
services:
traefik:
image: "traefik:v2.2"
ports:
- "80:80"
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
@typewriter
typewriter / metrics-to-slack.js
Last active May 31, 2020 08:46
Notify CloudWatch Metrics to Slack
var AWS = require('aws-sdk');
var cloudwatch = new AWS.CloudWatch();
exports.handler = function (event, context) {
alarmMetricStatistics("http", event, context);
alarmMetricStatistics("app", event, context);
}
function alarmMetricStatistics(namespace, event, context) {
console.log(`check namespace: ${namespace}`);
@typewriter
typewriter / sse_client_windows.rb
Created December 4, 2017 14:12
Server Sent Events (SSE) Client with Ruby
# Server Sent Events (SSE) Windows Client sample
# (but cannot install/load em-eventsource)
require 'win32ole'
require 'em-eventsource'
# Windows Script Host :(
shell = WIN32OLE.new('Shell.Application')
wsh = WIN32OLE.new('Wscript.Shell')
@typewriter
typewriter / sse_server.rb
Created November 23, 2017 13:12
Server Sent Events (SSE) Server with Ruby
# Server Sent Events (SSE) Server sample
# refs. https://gist.github.com/rkh/1476463
require 'sinatra'
require 'thin'
set :bind, '0.0.0.0'
set :port, 8080
connections = []