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 / generate_token.py
Created September 23, 2023 20:56
Generates a JWT for a GitHub application based on PEM file and APP ID.
#!/usr/bin/env python3
import jwt
import time
import sys
# Get PEM file path
if len(sys.argv) > 1:
pem = sys.argv[1]
else:
pem = input("Enter path of private PEM file: ")
@guibranco
guibranco / build-bump-version.yml
Last active September 17, 2023 20:25
A GitHub action to build (debug) .NET framework project with some comments/reports on the Pull Request
name: Build & Bump Version
on:
push:
branches:
- '*'
- '*/*'
- '**'
- '!main'
paths-ignore:
@guibranco
guibranco / dependabot.yml
Last active September 17, 2023 06:06
Sample dependabot.yml file to update Docker, GitHub-actions, NPM and Nuget outdated versions. Assign, request review and labeling the PR
version: 2
updates:
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 50
assignees:
- "guibranco"
@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);
@guibranco
guibranco / clone.ps1
Last active August 2, 2023 16:36
Clone all repositories from an organization in Azure DevOps
$organization = "AZURE_DEVOPS_ORGANIZATION"
$personalAccessToken = "AZURE_DEVOPS_PAT"
$base64AuthInfo = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($personalAccessToken)"))
$headers = @{Authorization=("Basic {0}" -f $base64AuthInfo)}
Write-Host "Cloning all repositories from organization: " $organization
$projectsUrl = "https://dev.azure.com/" + [uri]::EscapeDataString($organization) + "/_apis/projects?api-version=7.0"
$result = Invoke-RestMethod -Uri $projectsUrl -Method Get -Headers $headers
@guibranco
guibranco / createIssueViaPostman.js
Created January 29, 2023 16:57
Create an issue on each user/org repository that is not a fork and has issues enabled
//Request the user/org repositories, and add this script to tests tab of the request
//Repositories of a specific user: https://api.github.com/users/{{username}}/repos
//Repositories of a specific org: https://api.github.com/orgs/{{org}}/repos
const ghToken = pm.globals.get("GH_PAT");
const authorizationHeader = `Authorization: Bearer ${ghToken}`;
const issueTitle = "Issue title";
const issueBody = "Issue body";
@guibranco
guibranco / cloneRepositories.bash
Created February 21, 2023 12:57
Clone all repositories of an organization
#!/bin/bash
ORG_NAME="<<ORG>>"
ACCESS_TOKEN="<<GH_PAT>>"
TOTAL_PAGES=10;
eval `ssh-agent -s`
ssh-add ~/.ssh/*_rsa
for((PAGE=1;PAGE<=TOTAL_PAGES;PAGE++)); do
@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}`;
@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',
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