Skip to content

Instantly share code, notes, and snippets.

View byjg's full-sized avatar

Joao M byjg

View GitHub Profile
@byjg
byjg / 1. Docker.md
Created September 3, 2022 02:19
Code applied in the EasyHAProxy screencasts

EasyHAProxy Docker

Terminal 1

docker network create easyhaproxy

docker run -d \
      --name easy-haproxy \
      --rm \
@byjg
byjg / Example using git "rebase" in the work branch.md
Last active February 2, 2022 15:59
If you want a single commit you don't need to rebase your development branch. Just add your commit, and then merge squeezing the branch into a single commit.

Prepare the test environment

# Create the git repository
mkdir test2
cd test2
git init

# Add some files
echo "Content" > file1.txt
@byjg
byjg / 01-setup-redis-replication.sh
Last active February 26, 2023 15:20
Redis Replication with Docker
docker network create test
cat << EOF > master.conf
bind 0.0.0.0
appendonly yes
appendfilename "appendonly.aof"
EOF
docker run -it --rm -v $PWD/master.conf:/etc/master.conf --name master --network test -d redis:6.2 redis-server /etc/master.conf
@byjg
byjg / buildah.md
Last active December 8, 2020 06:01

containers/buildah#1901

docker run --security-opt seccomp=unconfined \
    --security-opt apparmor=unconfined \
    -it --rm alpine:edge sh

apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing buildah
@byjg
byjg / all-branches.sh
Created April 16, 2020 01:39
Get a formatted list with all branches and last commit for each branch
git branch -a | grep remotes | xargs -l | cut -d"/" -f3 | xargs -l git checkout
git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset); %(color:red)%(objectname:short)%(color:reset); %(contents:subject); %(authorname); (%(color:green)%(committerdate:relative)%(color:reset))'
<?php
echo toKebabStyle("TestingConversion");
function toKebabStyle($input) {
$result = preg_replace_callback(
'/([a-z])([A-Z])/',
function ($match) use ($input) {
return $match[1] . "-" . $match[2];
},
@byjg
byjg / MyTable.php
Created November 17, 2019 12:55
ByJG Micro Orm with Snake Case
<?php
class MyTable
{
protected $field_id;
protected $field_value;
/**
* MyTable constructor.
* @param $field_value
@byjg
byjg / docker-composer-wordpress.yml
Last active November 1, 2019 02:59
Docker Compose Wordpress (Docker Swarm)
version: '3.2'
services:
wordpress:
image: wordpress:4.8-php7.1
environment:
- WORDPRESS_DB_HOST=mysql-container
- WORDPRESS_DB_USER=user
- WORDPRESS_DB_PASSWORD=password
- WORDPRESS_DB_NAME=wordpress
volumes:
#!/usr/bin/env python
""" Print all of the clone-urls for a GitHub organization.
It requires the pygithub3 module, which you can install like this:
$ sudo yum -y install python-virtualenv
$ mkdir scratch
$ cd scratch
$ virtualenv my-virtualenv
$ source my-virtualenv/bin/activate
Sub SMS()
Dim Result As String
Result = EnviarSMS("21", "999999999", "Mensagem", "Usuario", "Senha")
MsgBox Result
End Sub
Function RequestURL(Method As String, Dict As Variant) As String
Dim QueryString As String
Dim Key As Variant