Skip to content

Instantly share code, notes, and snippets.

@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: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:b8d561a61411ab80a0ad
Last active April 10, 2019 09:35
Get configuration for all "rails-app" OpsWorks Layer
require 'aws-sdk-opsworks'
client = Aws::OpsWorks::Client.new(region: 'us-east-1')
stacks = client.describe_stacks.stacks
layers = stacks.map { |stack| client.describe_layers(stack_id: stack.stack_id).layers }.compact
rails_app_layers = layers.detect { |layer| layer.shortname == 'rails-app' }
rails_app_layers.each do |layer|
stack = stacks.detect { |stack| stack.stack_id == layer.stack_id }
@fmasuhr
fmasuhr / gist:e4b281b1860dda147ac3
Last active April 10, 2019 09:36
Get Node.js configuration for OpsWorks stacks
require 'aws-sdk-opsworks'
client = Aws::OpsWorks::Client.new(region: 'us-east-1')
stacks = client.describe_stacks.stacks
stacks.each do |stack|
custom_json = JSON.parse(stack.custom_json)
next unless custom_json['nodejs']
puts <<-END_OF_STRING
@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: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: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: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]