Skip to content

Instantly share code, notes, and snippets.

View rahenrique's full-sized avatar
🐺

Rafael Henrique rahenrique

🐺
View GitHub Profile

Estimation

This document is an attempt to pin down all the things you don't think about when quoting for a project, and hopefully provide a starting point for some kind of framework to make quoting, working and delivering small-medium jobs more predictable and less stressful.

Contents

@lucasmezencio
lucasmezencio / SLUG.md
Last active March 7, 2025 16:32
Creating URL slugs properly in PHP (including transliteration for UTF-8)

Creating URL slugs properly in PHP (including transliteration for UTF-8)

The point to use a slug (semantic URL) besides of improve the SEO of your articles is to prevent that the user, at the creation of for example an article, it uses special characters that aren't allowed in a URL, appropiate the usage etc. What target usage means, is context dependent.

In this article, you'll learn how to slugify a string in PHP properly, including (or not) support (conversion) for cyrilic and special latin characters.

Slugify in PHP

The following function exposes a simple way to convert text into a valid slug:

@h4
h4 / env.py
Last active January 18, 2025 08:07
Setup alembic to work properly with PostgreSQL schemas
from __future__ import with_statement
from alembic import context
from sqlalchemy import engine_from_config, pool
from logging.config import fileConfig
from models import Base
config = context.config
fileConfig(config.config_file_name)
@thoriqmacto
thoriqmacto / update_url.sql
Last active May 28, 2018 12:32
[sql] Update Specific URL Inside wp_posts Table
UPDATE wp_posts SET `post_content` = REPLACE (`post_content`, 'src="http://www.your-site.com"', 'src="https://www.your-site.com"');
UPDATE wp_2_posts SET `post_content` = REPLACE (`post_content`, 'src="http://www.your-site.com"', 'src="https://www.your-site.com"');
UPDATE wp_posts SET `guid` = REPLACE (`guid`, 'http://www.your-site.com', 'https://www.your-site.com') WHERE post_type = 'attachment';
UPDATE wp_2_posts SET `guid` = REPLACE (`guid`, 'http://www.your-site.com', 'https://www.your-site.com') WHERE post_type = 'attachment';
@davidalves1
davidalves1 / formatar_cnpj_cpf.md
Last active March 3, 2025 12:27
Função para formatar CNPJ e CPF, disponível em PHP e JS

PHP

function formatCnpjCpf($value)
{
  $CPF_LENGTH = 11;
  $cnpj_cpf = preg_replace("/\D/", '', $value);
  
  if (strlen($cnpj_cpf) === $CPF_LENGTH) {
    return preg_replace("/(\d{3})(\d{3})(\d{3})(\d{2})/", "\$1.\$2.\$3-\$4", $cnpj_cpf);
  } 
@noelboss
noelboss / git-deployment.md
Last active March 2, 2025 15:09
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your local GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like deepl.io to act upon a Web-Hook that's triggered that service.

@lapointexavier
lapointexavier / read_vcrpy_binary_body.py
Last active November 24, 2023 12:55
Snippet to read a vcr cassette binary body
import json
import gzip
import base64
import StringIO
from vcr.serialize import deserialize
from vcr.serializers import yamlserializer
path = '../cassettes/api-InstagramAPITestCase-test_media.yml'
@im4aLL
im4aLL / php-event-listener-example.php
Last active August 18, 2024 18:18
PHP event listener simple example
<?php
// Used in https://github.com/im4aLL/roolith-event
class Event {
private static $events = [];
public static function listen($name, $callback) {
self::$events[$name][] = $callback;
}
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@ecdundar
ecdundar / copymysql.sh
Last active September 12, 2024 16:18
Copy MySQL Database One Server (Remote) To Another (Local) Server
#!/bin/bash
# copymysql.sh
# GENERATED WITH USING ARTUR BODERA'S SCRIPT
# Source script at: https://gist.github.com/2215200
MYSQLDUMP="/usr/bin/mysqldump"
MYSQL="/usr/bin/mysql"