Skip to content

Instantly share code, notes, and snippets.

View jitran's full-sized avatar
🏀
https://gist.github.com/jitran

Ji Tran jitran

🏀
https://gist.github.com/jitran
View GitHub Profile
@jitran
jitran / README.md
Created October 18, 2024 06:45
Copilot Extension Demo: Blackbeard
@jitran
jitran / README.md
Created April 5, 2024 02:46
GitHub App - Installation Access Token

Install the gh-token extension

gh extension install Link-/gh-token

Retrieve the installation access token for your GitHub App

APP_ID=<APP ID>
PRIVATE_KEY=<PATH TO PRIVATE KEY>
INSTALLATION_ID=$(gh token installations --app-id $APP_ID --key $PRIVATE_KEY | jq '.[] | .id')
@jitran
jitran / user.mjs
Created April 5, 2024 02:29
User statistics
import { Octokit } from "octokit";
import dotenv from "dotenv";
dotenv.config();
const octokit = new Octokit({
auth: process.env.GITHUB_TOKEN,
});
const username = process.argv[2]
@jitran
jitran / README.md
Created March 26, 2024 07:25
Probot Exercise
@jitran
jitran / README.md
Last active March 27, 2024 01:25
Octokit with Codespaces debug and run exercise

Octokit with Codespaces debug and run exercise

  1. Go to https://github.com/robandpdx/octokit-js-demo > Code > Create codespace..

  2. Give it a few minutes to set up.

  3. Rename env.orig to .env and populate with your PAT and org name.

  4. Add breakpoints in script.js.

@jitran
jitran / Answer.md
Last active March 26, 2024 06:54
API: Ruby List Repo Exercise
View Answer
require "octokit"

octokit = Octokit::Client.new(access_token: ENV["GITHUB_TOKEN"])

Octokit.auto_paginate = true
@jitran
jitran / Answer.md
Last active March 26, 2024 06:44
API: JavaScript List Repo Exercise
View Answer
import { Octokit } from "octokit";
import dotenv from "dotenv";

dotenv.config();

const octokit = new Octokit({ 
@jitran
jitran / git_commit_sizes.sh
Last active February 27, 2024 05:51
Calculates the size of each commit in the current branch
#!/usr/bin/env bash -e
for commit in $(git log --format="%H"); do
size=0
blobs=0
IFS=$'\n'
for line in $(git log -1 --raw --no-merges --no-renames --no-abbrev --full-index --raw --pretty=oneline $commit | tail -n +2); do
id=$(echo $line | cut -d' ' -f4)
blob_size=$(git cat-file -s $id 2>/dev/null || echo 0)
(( size += blob_size ))
@jitran
jitran / app.py
Last active September 18, 2022 00:09
AWS CDK Python - Overriding the resource logical IDs
#!/usr/bin/env python3
from aws_cdk import core
from my_python_sample.my_python_sample_stack import MyPythonSampleStack
app = core.App()
MyPythonSampleStack(app, 'my-python-sample', env={'region': 'ap-southeast-2'})
#! /usr/bin/env python
""" slack_delete.py
Removes files uploaded to Slack
Usage:
virtualenv slack
source slack/bin/activate
pip install requests