Skip to content

Instantly share code, notes, and snippets.

# Check server process is using jemalloc
# ref. [Japanese] https://tech.studyplus.co.jp/entry/2019/09/09/094140
class AppController < ActionController::Base
def show
r = `strings /proc/#{Process.pid}/maps | grep jemalloc`
render plain: "<h1>#{ENV['LD_PRELOAD'].presence || 'empty'}</h1><pre>#{r}</pre>"
end
end
@tlopo
tlopo / self_signed_cert.rb
Created November 24, 2022 12:07 — forked from nickyp/self_signed_cert.rb
create a self-signed certificate using ruby-openssl
We couldn’t find that file to show.
@tlopo
tlopo / default.conf
Created December 15, 2020 14:13 — forked from flox1an/default.conf
nginx config that uses the oauth2-proxy (via auth_request) to authenticate against gitlab and then proxies all requests to a backend service while setting the auth headers X-User and X-Email
server {
listen 80;
server_name localhost;
location /oauth2/ {
proxy_pass http://oauth-proxy:4180;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Auth-Request-Redirect $request_uri;
@tlopo
tlopo / Decode-Base64.md
Created December 12, 2020 13:15 — forked from mmaha/Decode-Base64.md
Decode SAML Assertion in Base64

Perl

perl -MMIME::Base64 -ne 'print decode_base64($_)' ./saml_input.txt | xmllint --format - | source-highlight  -s xml -f esc

Ruby

cat ./saml_input.txt | ruby -r Base64 -ne 'puts Base64.decode64($_)' | xmllint --format - | source-highlight  -s xml -f esc
@tlopo
tlopo / build.sh
Created November 27, 2020 21:36 — forked from sheeley/build.sh
Terraform API Gateway Lambda setup
#! /usr/bin/env bash
GOOS=linux GOARCH=amd64 go build -o main main.go
zip main.zip main

Every piece of technology in China has its own mirror.

To pull images:

docker pull dockerhub.azk8s.cn/tlopo/troubleshoot # This seems to require authentication now
docker pull hub-mirror.c.163.com/library/java:8
docker pull docker.mirrors.ustc.edu.cn/library/java:8

Alpine apk mirrors:

@tlopo
tlopo / Dockerfile
Created February 24, 2020 10:17 — forked from andrewodri/Dockerfile
Connect Fargate instance to SSM Session Manager
FROM debian:10-slim
RUN apt-get update -y && \
apt-get install -y awscli curl gnupg && \
apt-key adv --fetch-keys "https://nginx.org/keys/nginx_signing.key" && \
echo "deb http://nginx.org/packages/debian buster nginx" > /etc/apt/sources.list.d/nginx.list
RUN curl --silent --show-error --location --output /tmp/amazon-ssm-agent.deb "https://s3.us-east-1.amazonaws.com/amazon-ssm-us-east-1/latest/debian_amd64/amazon-ssm-agent.deb" && \
dpkg -i /tmp/amazon-ssm-agent.deb
package http

import (
	"bytes"
	"errors"
	"fmt"
	log "github.com/sirupsen/logrus"
	"io"
	"io/ioutil"
@tlopo
tlopo / _aws_golang_examples.md
Created November 5, 2019 17:51 — forked from eferro/_aws_golang_examples.md
golang aws: examples

AWS Golang SDK examples

@tlopo
tlopo / Selenium Cheat Sheet.md
Created July 30, 2019 21:12 — forked from kenrett/Selenium Cheat Sheet.md
Selenium Cheat Sheet - Ruby

#Getting Started

##Webpage:

<html>
<head>
    <title>Testing with Ruby and Selenium WebDriver</title>
</head>
 
<body bgcolor="antiquewhite">