Skip to content

Instantly share code, notes, and snippets.

View paulodutra's full-sized avatar

Paulo Dutra paulodutra

View GitHub Profile
@paulodutra
paulodutra / laminas-api-tools-database
Created December 8, 2022 15:23
The dabase using the test laminas-api-tools. Link to repository: https://github.com/paulodutra/laminas-api-tools
First create the sqlite file: touch test.sqlite
Access the database file using the sqlite: sqlite3 test.sqlite
Listing of the tables: .tables
Creating the table of users: create table users(id int, name varchar(255), email varchar(255));
@paulodutra
paulodutra / composer-with-official-image-php.dockerfile
Created December 8, 2022 15:20
You can use this dockerfile for install composer and php together using only official images docker.
FROM composer as composer
FROM php:VERSION
COPY --from=composer /usr/bin/composer /usr/bin/composer
<?php
class Sql {
public $conn;
public function __construct(){
return $this->conn = mysqli_connect("127.0.0.1","root","","hcode_shop");
FROM php:5.6-apache
#Instala as libs de desenvolvimento
RUN apt update && apt install -y \
libaio1 \
vim \
unzip \
curl \
wget \
build-essential \
version: '3'
services:
db:
build:
context: ./
dockerfile: mysql.dockerfile
container_name: db-laravel
restart: always
tty: true
ports:
FROM mysql:5.7
RUN usermod -u 1000 mysql
FROM nginx:1.19.1-alpine
RUN apk add bash
RUN rm /etc/nginx/conf.d/default.conf
COPY ./docker/nginx.conf /etc/nginx/conf.d/default.conf
FROM php:7.4.8-fpm-alpine3.12
RUN apk add --no-cache shadow bash mysql-client
RUN docker-php-ext-install pdo pdo_mysql
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
WORKDIR /var/www
@paulodutra
paulodutra / rename-files.js
Created November 22, 2021 16:05
rename files in path specific node
const fs = require('fs').promises;
const fsSync = require('fs');
const path = require('path');
const REGEX_REPLACE =/([\u0300-\u036f]|[^0-9a-zA-Z])/g;
/**
* PATH: Constante a ser definida onde possui os arquivos.
*/
const PATH = 'path-to-files';
/**
@paulodutra
paulodutra / fibonacci.js
Last active November 4, 2021 18:34
Calculate fibonnaci
function fibonacci(number){
let term = number;
let penultimate = 0, last = 1;
let result = 0;
if (term <= 2) {
result = term - 1;
} else {
for( let i = 3; i<= term; i++){
result = last + penultimate;
penultimate = last;