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 / Puppet-Spec-Rakefile
Last active August 29, 2015 14:08
Rakefile for running spec tests for puppet modules
require 'rake'
require 'rspec/core/rake_task'
require 'yaml'
namespace :spec do
desc 'Run unit tests'
task :unit do
FileList["modules/*/Rakefile"].each do |project|
dir = project.pathmap("%d")
sh "cd #{dir}; rake spec:unit"
@jitran
jitran / fluentd_kubernetes_dynamic_config.yaml
Last active July 25, 2018 09:51
Dynamic FluentD Configuration for Kubernetes cluster logs using kubernetes_metadata, rewrite_tag_filter, and forest plugins
apiVersion: v1
data:
fluentd.conf: |
# Capture the kubernetes pod container logs
<source>
@type tail
format json
path /var/log/containers/*.log
pos_file /var/log/kubernetes.pos
time_format %Y-%m-%dT%H:%M:%S
@jitran
jitran / setup_python36_rhel6.sh
Created May 15, 2018 05:14
Run Python 3.6 in RHEL6
#!/bin/bash
if grep -q -i "release 6" /etc/redhat-release 2> /dev/null
then
sudo yum -y install scl-utils
sudo yum -y install --enablerepo=rhui-ap-southeast-2-rhel-server-rhscl rh-python36
PYTHON36=$(scl enable rh-python36 "bash -c 'which python'")
export PATH=$(dirname $PYTHON36):$PATH
fi
#! /usr/bin/env python
""" slack_delete.py
Removes files uploaded to Slack
Usage:
virtualenv slack
source slack/bin/activate
pip install requests
@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'})
@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 / 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 / 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 / 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 / README.md
Created March 26, 2024 07:25
Probot Exercise