Skip to content

Instantly share code, notes, and snippets.

@fmasuhr
fmasuhr / gist:5789c787a8cc6b20ca85
Last active August 29, 2015 14:27
Review Github pull requests assigned to authenticated user
require 'octokit'
TITLE = 'example title'
LABEL = 'ready to merge'
COMMENT = '+B'
client = Octokit::Client.new(access_token: ENV['GITHUB_ACCESS_TOKEN'])
pulls = client.list_issues.select { |issue|
issue.pull_request &&
@fmasuhr
fmasuhr / gist:d898c2b0dedc43cbfebb
Last active August 31, 2015 18:26
Create Github pull request
require 'octokit'
def client
Octokit::Client.new(access_token: ENV['GITHUB_ACCESS_TOKEN'])
end
def create_pull_request(repo, head, options = {})
ref = client.ref(repo, "heads/#{head}")
commit = client.commit(repo, ref.object.sha)
title = options[:title] || commit.commit.message
@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)] }
@fmasuhr
fmasuhr / gist:c216a24f15f613c82445
Last active November 19, 2015 11:27
Automated bundle update process and creation of pull request
require 'bundler/cli'
require 'git'
require 'octokit'
BRANCH_NAME = 'gem-updates'
COMMIT_MESSAGE = 'Update gems'
# 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: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:5557856
Last active December 17, 2015 05:29
Clean up memory with shell on Mac OS X. On OS X Mavericks you must prefix the command with sudo
sudo purge
@fmasuhr
fmasuhr / gist:5620438
Created May 21, 2013 14:55
Prevent Mac from going to sleep e.g. for an hour
caffeinate -t 3600
@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:6581808
Last active March 1, 2016 10:35
Store the passphrase for your default key in the Keychain. This will prevent you from entering this every time after a system restart.
# SSH key on OS X
ssh-add -K
@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