Skip to content

Instantly share code, notes, and snippets.

@vafrcor
vafrcor / Base64DataUri.php
Last active June 2, 2024 06:43
Laravel Validator Extension for Image Data URI
<?php
namespace App\Helper\ValidatorExtensions;
use Illuminate\Support\Facades\Validator;
/**
* Validator Extension registration on Laravel AppServiceProvider.php:
* => Validator::extend('is_base64_image_data', 'App\Helper\ValidatorExtensions\Base64DataUri@validate');
* => Validator::replacer('is_base64_image_data', 'App\Helper\ValidatorExtensions\Base64DataUri@replacer');
* Usage on Controller:
@vafrcor
vafrcor / docker-compose-db-mssql.yml
Created December 28, 2020 08:19
Docker Compose For MSSQL
version: '3.1'
# reference:
# - docker mssql notes: https://docs.docker.com/storage/volumes/
# - setup mssql docker linux named volumes: https://dbafromthecold.com/2019/03/21/using-docker-named-volumes-to-persist-databases-in-sql-server/
# - run docker mssql: https://medium.com/@reverentgeek/sql-server-running-on-a-mac-3efafda48861
services:
mssql-db:
image: mcr.microsoft.com/mssql/server:latest
@vafrcor
vafrcor / Python-Multiply-Factor-Round.py
Created December 3, 2020 00:34
Rounding by Multiply Factor in python
def round_multiply_by_factor(factor: float = 0, input_value: float = 0 ) -> float:
fix = False
x= input_value
y= 1.0
while fix == False:
if x <= (y * factor):
x= y * factor
fix = True
y+=1
return x
@vafrcor
vafrcor / node-configstore-loader.js
Last active April 12, 2020 07:42
NodeJS Config Loader using configstore module
const dotenv = require('dotenv');
dotenv.config();
const fs = require('fs');
const approot = require('app-root-path');
const _ = require('lodash');
const ConfigStore = require('configstore');
const app_name = process.env.APP_NAME || 'app_config';
const config_path = process.env.APP_CONFIG_PATH || approot + '/config';
const readdir_mode = process.env.APP_CONFIG_READDIR_MODE || 'recursive';
@vafrcor
vafrcor / node-interactive-menu.js
Created April 11, 2020 05:21
NodeJS Interactive Menu Example
const moment = require('moment');
const _ = require('lodash');
const urlencode = require('urlencode');
const approot = require('app-root-path');
const readline = require('readline');
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
@vafrcor
vafrcor / sequelize-migrator.js
Last active December 5, 2020 18:20
Node Sequelize Migrator Programmatically
const execSync = require('child_process').execSync;
const _ = require('lodash');
const asyncjs = require('async');
const sequelizeCliExec = (command) => {
let commands=[
'db:drop',
'db:create',
'db:migrate',
'db:migrate:undo:all',
'use strict';
//# check required modules
var module_exists = require('module-exists');
var required_modules=['js-rijndael', 'base64-js', 'lodash'];
var valid_requirement=required_modules.length;
var not_exist_module=[];
required_modules.forEach(function(em){
if(module_exists(em) === false){
valid_requirement--;
<?php
/*
|--------------------------------------------------------------------------
| Detect The Application Environment
|--------------------------------------------------------------------------
|
| Laravel takes a dead simple approach to your application environments
| so you can just specify a machine name for the host that matches a
| given environment, then we will automatically detect it for you.