Skip to content

Instantly share code, notes, and snippets.

View reke592's full-sized avatar

Erric Rapsing reke592

  • Bulacan, Philippines
View GitHub Profile
@reke592
reke592 / Dockerfile
Created May 16, 2024 05:04
mysql docker with tcmalloc
FROM mysql:8.0.15
RUN echo "deb http://archive.debian.org/debian stretch main" > /etc/apt/sources.list && \
apt-get update && \
apt-get install -y libgoogle-perftools-dev
# ENV LD_PRELOAD=/usr/lib/libtcmalloc.so.4
@reke592
reke592 / rotatelogs.bat
Last active February 10, 2024 08:29
nginx windows and log rotation
@echo Off
REM requirements:
REM This Nginx build for windows, available at http://nginx-win.ecsds.eu/download/
REM this build has fixed issues related to the 1024 worker_connection limit.
REM rar.exe - for archive, replace this if you don't want rar.exe
REM Current installation directory of nginx
pushd c:\nginx
REM Log folder name
@reke592
reke592 / troubleshooting.md
Created June 12, 2023 04:37
troubleshooting

MySql Display lock status

SELECT thread_id, object_name, lock_type, lock_mode, lock_data, index_name, lock_status FROM performance_schema.data_locks;

SSL Check public and private key if match

openssl x509 -noout -modulus -in certificate.crt | openssl md5
openssl rsa -noout -modulus -in private.key | openssl md5
openssl req -noout -modulus -in request.csr | openssl md5
@reke592
reke592 / nginx-tuning.md
Created June 2, 2023 09:00 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@reke592
reke592 / ModalPrompt.dart
Created November 7, 2021 14:17
Sample common modal prompt for flutter
import 'package:flutter/material.dart';
import 'package:animations/animations.dart';
import 'package:sample/widgets/app_loading_indicator.dart';
import 'package:pointer_interceptor/pointer_interceptor.dart';
class ModalPrompt {
static Future<R?> showProcessing<R>({
required context,
required String message,
required Future<R> Function() process,
@reke592
reke592 / Debouncer.dart
Created November 7, 2021 14:11
Sample debouncer in dart for flutter
import 'dart:async';
class Debouncer {
final Duration duration;
Timer? debouncer;
/// cancel previous action if recur within debounce duration
Debouncer({
this.duration = const Duration(milliseconds: 200)
});
@reke592
reke592 / sample-dropdown-option-test.js
Created November 7, 2021 13:58
Sample dropdown option test case using supertest
const request = require('supertest');
const { app } = require('../server');
describe('Form input options', () => {
it('GET /option/regions --> array public list regions', () => {
return request(app)
.get('/option/regions')
.expect('Content-Type', /json/)
.expect(200)
@reke592
reke592 / rarlogs.bat
Created November 7, 2021 13:29
sample apache log rotation batch file for windows
@echo off
REM this file is being called by apache via pipe in rotatelogs.exe
REM adjustments to be made in apache httpd.conf (search for log_config_module)
REM to rotate the logs every midnight
REM CustomLog "|bin/rotatelogs.exe -p c:/<path to this dir>/rarlogs.bat -l c:/<path to client>/logs/access-%Y-%m-%d.log 86400" common
REM rotate when reached 100Mb limit
REM CustomLog "|bin/rotatelogs.exe -p c:/<path to this dir>/rarlogs.bat -l c:/<path to client>/logs/access-%Y-%m-%d-%H_%M.log 100M" common
REM %1 new .log, %2 old .log
set compress=1
@reke592
reke592 / encryption.js
Last active November 7, 2021 13:20
Sample data encryption in nodejs
/** Sample usage:
*
* let _encrypt, _decrypt, _createIV;
*
* repo.useEncryption = async (encryption) => {
* if (!toString.call(_encrypt).match(/Function/)
* && !toString.call(_decrypt).match(/Function/)) {
* let config = encryption.configure([
* 'first_name',
* 'last_name',
@reke592
reke592 / web-notes.txt
Last active June 11, 2023 09:36
web notes
-- Disclaimer: not a standard rule. just a collection of ideas/experience while doing a fullstack development task --
identify the configurations that can affect the application restart, put those dynamic configuration in database. (eg. email config).
create server.js (exports app and start function), and index.js (imports start function), so we can use the server.app for unit testing with supertest.
identify the common functions and store them inside `commons` folder.
create commons/errors to contain all the possible application errors we can throw, include the http status code.
[frontend]
eg. /commons
'-- debouncer.dart
'-- errors.dart