Skip to content

Instantly share code, notes, and snippets.

View byjg's full-sized avatar

Joao M byjg

View GitHub Profile
@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
<?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 / 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))'
@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
<!-- Start Audima Widget Injection -->
<div id="audimaWidget"></div>
<script src="//audio.audima.co/audima-widget.js"></script>
<!-- End Audima Widget Injection -->
<!-- Audima CSS Customization -->
<style>
#audimaWidget .audima-panel {
/* Insira aqui a customização exemplo:
background-color: silver;
@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 / 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 / 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 / NoVNC_Paste.js
Last active November 24, 2023 05:46
How to Paste code to NoVNC.
// This will open up a prompt for text to send to a console session on digital ocean
// Useful for long passwords
(function () {
window.sendString = function (str) {
f(str.split(""));
function f(t) {
var character = t.shift();
var i=[];
var code = character.charCodeAt();
var needs_shift = character.match(/[A-Z!@#$%^&*()_+{}:\"<>?~|]/);