Skip to content

Instantly share code, notes, and snippets.

@rutcreate
rutcreate / perf.py
Created June 4, 2024 05:27
Measure the elapsed time of a block of code using Python
import time
class Watcher:
"""
Measure the elapsed time of a block of code
Usage:
1. with statement:
@rutcreate
rutcreate / deploy.sh
Created March 25, 2024 02:34
Deploy script
#/bin/bash
branch_name=''
force_export=false
usage() {
echo "Usage: $0 <prod|uat> [OPTIONS]"
echo "Options:"
echo " -h, --help Display this help message"
echo " -f, --force Force export (even no new commit)"
@rutcreate
rutcreate / README.md
Created February 7, 2024 03:35
Setup Oracle Database on Apple Silicon Chip (Docker)
@rutcreate
rutcreate / README.md
Last active November 11, 2024 08:50
Install Python 3.10.x on Ubuntu 20.04

Prerequisite

sudo apt update
sudo apt install software-properties-common -y

Add custom APT repository

@rutcreate
rutcreate / README.md
Last active August 26, 2024 11:57
Install psycopg2 on Ubuntu 20.04

Install packages

sudo apt install build-essensial libpq-dev postgresql postgresql-contrib python3-venv python3-dev

Test

Create virtual env

@rutcreate
rutcreate / README.md
Last active November 12, 2024 04:26
Install Oracle InstantClient and SQL*Plus from source on Ubuntu 20.04

Download InstantClient

mkdir -p /opt/oracle
cd /opt/oracle
wget https://download.oracle.com/otn_software/linux/instantclient/218000/instantclient-basic-linux.x64-21.8.0.0.0dbru.zip
unzip instantclient-basic-linux.x64-21.8.0.0.0dbru.zip

Download SQLPlus

@rutcreate
rutcreate / README.md
Created October 4, 2022 12:17
Cloudflare SSL for WordPress

Prerequisite

  • http://yourdomain.com is accessible. (Make sure protocol is http)
  • Update Cloudflare DNS see topic Minimum DNS settings

Minimum DNS settings

Type Value Proxied Status
A 0.0.0.0 Proxied
@rutcreate
rutcreate / README.md
Last active October 1, 2022 18:34
Ubuntu for WordPress setup

Update package list

sudo apt update

Add new user

sudo adduser newuser
@rutcreate
rutcreate / .psysh
Created June 14, 2022 09:00
Laravel Debug Query in Tinker
<?php
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
use Illuminate\Support\Facades\DB;
function generate_color_console() {
/** Reference: https://symfony.com/doc/current/console/coloring.html */
$output = new ConsoleOutput();
@rutcreate
rutcreate / generate-nginx-locations.js
Last active April 28, 2022 06:29
Generate NGINX locations for Nextjs pages
const fs = require('fs')
const path = require('path')
const nextConfig = require('../next.config')
// Create pages directory.
// NOTE: if you have different location, please change.
const pageDir = path.join(__dirname, '../src/pages')
// Determine trailing slash configuration.
const isTrailingSlash = nextConfig.trailingSlash === undefined