Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View igorcosta's full-sized avatar
:octocat:

Igor Costa igorcosta

:octocat:
View GitHub Profile
@igorcosta
igorcosta / README.md
Last active April 17, 2024 13:56
Get a list of all programming languages used by the repositories in a GitHub Organisation

get_org_languages.py 🚀

Python script to get all the programming languages in a GitHub organization and return a total number of repos using the programming language.

Hard requirements: 🐍

  • Make sure you know Python 3.0 or older.
  • Make sure you have a GitHub Personal Access Token with the read:org and repo:status permissions. 🔐
  • Install the Python dependencies:
@igorcosta
igorcosta / cpf_cnpj_validator
Created June 26, 2014 19:13
Regex para validar CPF e CNPJ
Para CPF
/^\d{3}\.\d{3}\.\d{3}\-\d{2}$/
Para CNPJ
/^\d{2}\.\d{3}\.\d{3}\/\d{4}\-\d{2}$/
Para ambos ao mesmo tempo
@igorcosta
igorcosta / gitlab_to_ghec_playbook.md
Last active November 23, 2023 05:46
Gitlab to GHEC Migration playbook

GitLab to GitHub Enterprise Cloud (GHEC) migration playbook

This playbook is a step-by-step guide to assist you with migration from GitLab to GitHub.com Enterprise Cloud GHEC.

Steps & Tasks Description
Step One Let's get ready for the migration. This step gives you an overview of what is required to start the migration process
Step Two Creating the artefact to be imported on GitHub requires special access to the Enterprise Cloud Import tool. This step will help you understand what is required to get access to the tool.
Step Three With the file ready to be imported, this step will guide you on how to connect and upload the file to your GitHub Enterprise Cloud instance.
@igorcosta
igorcosta / open-to-control.md
Last active September 21, 2023 02:28
How to maintain two repositories internal/private and one open-source

📖 Managing dual repositories on GitHub

Managing multiple repositories that serve distinct but interconnected purposes can be a challenging task 😓. This scenario is common when an organization wishes to contribute to an open-source project 🌐 while also maintaining an internal space for private collaboration 🔒.

The challenge here lies in keeping these repositories in sync 🔄 without manual intervention, ensuring that changes made to one repository 📁 are accurately reflected in the other 📁.

In this step-by-step tutorial 📃, we'll walk through a use case where a customer wants to contribute to an open-source project 💻 and, at the same time, collaborate internally within their organization 🏢.

We will:

  1. Changing the ownership of the existing repository. [Follow this steps](https://docs.github.com/en/enterprise-cloud@latest/account-and-profile/setting-up-and-managing-your-personal-account-on-gi
@igorcosta
igorcosta / windows-on-mac.md
Created April 13, 2023 04:50 — forked from mislav/windows-on-mac.md
Install Windows 11 in a virtual machine on macOS with an M1 CPU

Based on https://docs.getutm.app/guides/windows/

  1. Get UTM for Mac - the App Store version is offered merely as a way to support the developers, since it's paid, but has the same features as the free build;
  2. Obtain scripts that bootstrap an arm64 Windows 11 22H2 (I've chosen Windows Home edition and not Pro);
  3. brew install aria2 cabextract wimlib cdrtools minacle/chntpw/chntpw;
  4. cd into the directory extracted in step 1 and bash uup_download_macos.sh - this will produce an ISO;
  5. In the UTM app, create a new “Virtualize” machine and mount the ISO file from the previous step;
  6. Check “Install drivers and SPICE tools”;
  7. Boot the VM and go through the Windows installer;
  8. Boot the installed OS and finish the SPICE tools installer that should pop up by itself, then reboot the OS;
@igorcosta
igorcosta / migrate-repos.sh
Created February 22, 2023 00:25
A handy script to shift GitHub repos from one place to another
#!/bin/bash
# Make sure you change this script chmod to executable
# Set your GitHub username and access token
USERNAME={REPLACE_ME}
ACCESS_TOKEN={REPLACE_ME}
# Set the path to the directory where you want to store your repositories
LOCAL_REPO_DIR=/path/to/your/local/repo/directory
@igorcosta
igorcosta / README.md
Created August 17, 2022 04:29 — forked from osy/README.md
Local caching for GitHub Actions self hosted runner using Squid Proxy

One of the biggest issues with using a self hosted GitHub runner is that actions that require downloading large amounts of data will bottleneck at the network. [actions/cache][1] does not support locally caching objects and artifacts stored on GitHub's servers will require a lot of bandwidth to fetch on every job. We can, however, set up a content proxy using [Squid][2] with SSL bumping to locally cache requests from jobs.

Patching Squid

A major challenge is that [actions/cache][1] uses Azure storage APIs which makes HTTP range requests. While Squid supports range requests, it is not good at caching them. There is an option, range_offset_limit none which, according to the [documentation][3]:

A size of 'none' causes Squid to always fetch the object from the beginning so it may cache the result. (2.0 style)

However, after extensive debugging, I discovered that the feature does not work if the client closes the connection. When range_offset_limit is set, Squid will make a full request to the server,

@igorcosta
igorcosta / file_to_sftp.py
Created February 14, 2018 22:07
SFTP with Python using paramiko
#!/usr/bin/env python
import sys
import time
import paramiko
## How to use it?
##
## You have to install a dependecy called paramiko, which is a ssh protocol implementation that helps you to connect to sftp.
## pip install paramiko
## Commands in your terminal:
@igorcosta
igorcosta / dispatch_input.md
Created December 20, 2021 03:02
Public workflow_dispatch_hard_limit

Limitations in our products

Because the customer uses infrastructure as a code (IaC) into their pipelines using AWS CloudFormattion, they were used to the YAML format and the advanced features from the AWS schema and functionalities available, Actions YAML was simple to use and teach, however, introduced last year the workflow_dispatch allows customers to create workflows that are manually trigger with the option of input parameters. Our product supports only a limit of 10 inputs and throws an error, not allowing customer with multi-cloud environment setup more control for those manually trigger workflows.

We introduced a few options for the customer with the goal of continue maintaining the developer experience, interoperability, compliance and security and the ability to use the product in a multi-cloud environment.

Using commit message in JSON format

@igorcosta
igorcosta / elastic_cheat_sheet.md
Created January 6, 2017 00:42 — forked from quantizor/elastic_cheat_sheet.md
Elastic Cheat Sheet