Skip to content

Instantly share code, notes, and snippets.

@fmasuhr
fmasuhr / gist:8c3ae9932fac6db7afa1e9cd74435773
Created April 8, 2020 12:19
Git Interactive Rebase a fork

Sync a fork of a repository to keep it up-to-date with the upstream repository.

Inspired by the GitHub documentation

Fetch latest changes of the upstream repository.

git fetch upstream

Checkout the branch you want to sync the upstream into (Usually master).

@fmasuhr
fmasuhr / gist:585b97bad2a0b8c483f6857211122b13
Created June 6, 2019 15:11
Copy whole folder from AWS S3
aws s3 cp s3://<bucket>/<path>/ . --recursive --profile <profile>
@fmasuhr
fmasuhr / gist:a5ec1031d344330a5bdb94dd31aa99fc
Last active May 16, 2019 10:49
Listing teams of an organizations including their ID. This is using `jq` to map the result for better readability.
curl -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/orgs/<organization>/teams | jq '[.[] | {name: .name, id: .id}]'
@fmasuhr
fmasuhr / gist:3ee4dd414d90765090188978e6bc7655
Last active July 18, 2018 09:40
Move Travis CI required_status_checks to new Github Application integration
require 'json'
require 'octokit'
require 'restclient'
ORGANIZATION = 'lessonnine'.freeze
ACCEPT_HEADER = 'application/vnd.github.luke-cage-preview+json'.freeze
Octokit.auto_paginate = true
client = Octokit::Client.new(access_token: ENV['GITHUB_ACCESS_TOKEN'])
@fmasuhr
fmasuhr / gist:da68ee59a2141f5b058d940de2ecc301
Created June 26, 2018 14:00
Vagrant up error: NFS is reporting that your exports file is invalid

When running vagrant up you might encounter the following error:

==> default: Exporting NFS shared folders...
NFS is reporting that your exports file is invalid. Vagrant does
this check before making any changes to the file. Please correct
the issues below and execute "vagrant reload":

exports:39: path contains non-directory or non-existent components: <any local path>
exports:39: no usable directories in export entry
@fmasuhr
fmasuhr / gist:4fd661b884f157590613
Last active June 27, 2022 03:25
Associate a Vagrant project directory with an existing VirtualBox VM
  1. Run the following command and copy the ID of your VM
VBoxManage list vms
=> "virtualMachine" {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
  1. Go to the Vagrant project configuration folder
@fmasuhr
fmasuhr / gist:6fbea3cea32e62ba74db
Created February 29, 2016 16:31
Update all git repositories in a specified path
require 'git'
root_path = ARGV[0]
raise 'Specify root path as first parameter e.g. \'/Users/myname\'' unless root_path
# Find all folders wich are git repositories
Dir[File.join(root_path, '*/.git')].each do |git_path|
path = git_path.gsub('.git', '')
git = Git.open(path)
@fmasuhr
fmasuhr / gist:8b7dee8a706f3d431b22
Created December 14, 2015 22:49
Create GitHub Pull Request for local changes
require 'bundler/cli'
require 'git'
require 'octokit'
BRANCH_NAME = 'branch'
COMMIT_MESSAGE = 'Commit Message'
# ASSIGNEE = 'pengwynn' # update to assing pull request
git = Git.open(Dir.pwd)
github = Octokit::Client.new(access_token: ENV['GITHUB_ACCESS_TOKEN'])
@fmasuhr
fmasuhr / gist:a3863994252175bf2fcc
Last active August 2, 2018 11:54
Add own labels to GitHub repository
require 'octokit'
LABELS = [{ name: 'almost ready to merge', color: 'bfe5bf' },
{ name: 'dependency missing', color: 'fbca04' },
{ name: 'do not merge', color: 'e11d21' },
{ name: 'ready to merge', color: '0e8a16' },
{ name: 'refactoring expected', color: 'fbca04' },
{ name: 'work in progress', color: 'fbca04' }]
repository = ARGV[0]
@fmasuhr
fmasuhr / gist:dd91202e8015690906f8
Created October 15, 2015 13:13
Create missing spec files for a ruby gem
require 'active_support/all'
require 'fileutils'
require 'pathname'
root = Pathname.pwd
code_folder = root.join('lib')
spec_folder = root.join('spec')
code = Dir[code_folder.join('**/*.rb')].map { |file| file[(code_folder.to_s.length+1)..-('.rb'.length+1)] }
specs = Dir[spec_folder.join('**/*_spec.rb')].map { |file| file[(spec_folder.to_s.length+1)..-('_spec.rb'.length+1)] }