Skip to content

Instantly share code, notes, and snippets.

opan / pgmetrics.json
Created Feb 25, 2020
Sample output from pgmetrics tools in JSON format
View pgmetrics.json
"meta": {
"version": "1.7",
"at": 1582601656,
"collected_dbs": [
"local": true
"start_time": 1582527353,
opan / Vagrantfile-etcd.rb
Last active Aug 21, 2019
Vagrantfile for setup Vault and ETCD
View Vagrantfile-etcd.rb
# -*- mode: ruby -*-
# vi: set ft=ruby :
$install_go = <<-SCRIPT
sudo apt-get update -y
sudo tar -xvf go1.12.7.linux-amd64.tar.gz
sudo mv go /usr/local
cd ~
opan / postgresql-slave-volume
Created May 13, 2019
Setup postgreSQL slave volumn
View postgresql-slave-volume
# Check whether EBS volume already attached
# Check EBS volume filesystem
sudo file -s /dev/xvdf
# If type of filesystem still 'data' it means no filesystem yet, we have to create it
sudo mkfs -t ext4 /dev/xvdf
opan / create-read-only-access.sql
Created May 13, 2019 — forked from ekarisky/create-read-only-access.sql
How to create read only user in PostgreSQL
View create-read-only-access.sql
-- Create a group with read-only access
CREATE ROLE readonly;
-- Grant access on public sheme to existing tables
GRANT USAGE ON SCHEMA public TO readonly;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readonly; -- grant access to future tables
-- Grant access to specific database, repeat code below for each database
GRANT CONNECT ON DATABASE db_name to readonly;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO readonly; -- grant access to future tables
opan /
Created Mar 26, 2018 — forked from PurpleBooth/
A template to make good

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.


opan / palindrome_prime_number_lazy.rb
Last active Feb 19, 2017
Generate palindromic prime numbers using Enum#lazy method
View palindrome_prime_number_lazy.rb
n = gets.to_i
# Get infinity list of number
# Use Enum#lazy method
# Find prime number
.select { |i| (2..Math.sqrt(i)).none? { |a| (i % a).zero? }}
# Limit infinity list of number by 200
# Find palindrome prime number
opan / ROT13 Algorithm in Ruby
Last active Feb 3, 2017
Solving ROT13 Algorithm logic in Ruby
View ROT13 Algorithm in Ruby
#!/usr/bin/env ruby
str = "Jul qvq gur puvpxra pebff gur ebnq?"
def rot13(secret_messages)
upcase_alphabet = ("A".."Z").to_a
downcase_alphabet = ("a".."z").to_a
upcase_rot13 = []
upcase_length = upcase_alphabet.length
downcase_length = downcase_alphabet.length
View regex-japanese.txt
Regex for matching ALL Japanese common & uncommon Kanji (4e00 – 9fcf) ~ The Big Kahuna!
Regex for matching Hirgana or Katakana
Regex for matching Non-Hirgana or Non-Katakana
Regex for matching Hirgana or Katakana or basic punctuation (、。’)


cribbed from

Templates to remind you of the options and formatting for the different types of objects you might want to document using YARD.


# Namespace for classes and modules that handle serving documentation over HTTP
opan / rspec test model and controller examples
Created Jan 18, 2016
rspec test model and controller examples. Opan Mustopah
View rspec test model and controller examples
# start model test
require "spec_helper"
module Mesin
describe User do
before do
@customer = create(:role, :customer)
@super_admin = create(:role, :super_admin)