Skip to content

Instantly share code, notes, and snippets.

View guibranco's full-sized avatar
🎯
Focusing

Guilherme Branco Stracini guibranco

🎯
Focusing
View GitHub Profile
@guibranco
guibranco / updateIssuesToTriggerAction.js
Last active January 5, 2023 21:11
Update all opened issues from a repository to trigger a GH action to run
const ghToken = pm.globals.get("GH_PAT");
const organization = pm.collectionVariables.get("org");
const repository = pm.collectionVariables.get("repository");
const headerAuthorization = `Authorization: Bearer ${ghToken}`;
const repositoryUrl = `https://api.github.com/repos/${organization}/${repository}`;
pm.sendRequest({
url: repositoryUrl,
method: 'GET',
@guibranco
guibranco / createLabelsViaPostman.js
Last active March 28, 2023 17:39
Create labels on specific repository using Postman tests tab
const ghToken = pm.globals.get("GH_PAT"); // environment variable with GitHub PAT (Personal Access Token) with repo:write.
const organization = pm.collectionVariables.get("org"); // environment variable with GitHub username/organization name.
const repository = pm.collectionVariables.get("repository"); // environment variable with GitHub repository name.
// ⬆️💡 The variables above you can paste directly in the script, if you don't want to use environment variables in Postman
// No need to change below this line ⬇️⛔
const authorizationHeader = `Authorization: Bearer ${ghToken}`;
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^tabelas/atribuicoes-tabelas/details/2/(\d{1,4})(/?(.*?))?/?$ ./index.php?id=$1
@guibranco
guibranco / melhorSoma.php
Created December 16, 2021 11:53
Soma de valores mais proximos de um valor final - PHP Brasil - Alan Cisneiro - https://www.facebook.com/groups/phpbr/posts/4765496826840537/
<?php
$nfs = array(100,600,300,400);
$max = 1000;
$minDist = null;
$minDistI = null;
$maxI = pow(2,sizeof($nfs));
for($i=0;$i<$maxI;$i++) {
@guibranco
guibranco / generateBankSlipBarCode.cs
Last active September 17, 2023 05:53
Generates the barcode of a bank slip (pt-br: Boleto bancário) from typeful line (linha digitável)
/// <summary>
/// Calculates the bar code.
/// </summary>
private string CalculateBarCode(string typefulLine)
{
var line = Regex.Replace(typefulLine, "[^0-9]", "");
if (line.Length < 47)
{
line = line + new string('0', 47 - line.Length);
const seconds = 30;
const lsKey = "acesso-anterior";
if (localStorage.getItem(lsKey) === null)
setTimeout(showElements, seconds * 1000);
else
showElements();
function showElements() {
<?php
//código que eu não vi no print...
$historicoDeOperacoes = [];
switch($operacao){
case "saque":
$_SESSION["saldo"] -= $valor;
@guibranco
guibranco / diasDaSemana.js
Last active April 24, 2021 00:38
Exibe quantos dias da semana tem entre duas datas - Facebook - NodeJS Brasil - https://www.facebook.com/groups/1407602962733165/permalink/2136557383171049
var startDate = new Date(2021, 3, 1);
var endDate = new Date(2021, 4, 1);
var diffTime = Math.abs(endDate - startDate);
var diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
var totalWeeks = Math.round(diffDays / 7);
var remainingDays = diffDays % 7;
//se quiser considerar o dia final também, descomente a linha abaixo:
@guibranco
guibranco / Dockerfile
Last active July 17, 2025 06:55
Docker file for PHP 7.4 with Apache, MySQLi extension, GD2 and Apache mod_rewrite enabled
FROM php:7.4-apache
RUN apt-get update
RUN apt-get install --yes --force-yes cron g++ gettext libicu-dev openssl libc-client-dev libkrb5-dev libxml2-dev libfreetype6-dev libgd-dev libmcrypt-dev bzip2 libbz2-dev libtidy-dev libcurl4-openssl-dev libz-dev libmemcached-dev libxslt-dev
RUN a2enmod rewrite
RUN docker-php-ext-install mysqli
RUN docker-php-ext-enable mysqli
@guibranco
guibranco / docker-compose.yml
Created March 31, 2021 10:51
ELK cluster with 3 ES instances and 1 Kibana
version: '3.4'
services:
es01:
image: docker.elastic.co/elasticsearch/elasticsearch:7.12.0
container_name: es01
environment:
- node.name=es01
- cluster.name=es-docker-cluster
- discovery.seed_hosts=es02,es03