Skip to content

Instantly share code, notes, and snippets.

View brand-it's full-sized avatar

Brandt Lareau brand-it

View GitHub Profile
@brand-it
brand-it / gem_installer.rb
Created October 1, 2018 15:21
I have had it come up some times where I need a isolated gem installer using ruby. Found this is a nice way to handle that problem. Used it in https://github.com/newdark/faker-alfred-workflow
require 'fileutils'
require 'rubygems'
require 'rubygems/gem_runner'
require 'rubygems/exceptions'
require File.expand_path('./logger', __dir__).to_s
ENV['GEM_HOME'] = File.expand_path('gems', __dir__).to_s
FileUtils.mkdir_p(ENV['GEM_HOME'])
ENV['GEM_PATH'] = "#{ENV['GEM_HOME']}:/var/lib/ruby/gems/1.8"
Gem.clear_paths
s3 = S3Util.new
s3.bucket.objects.each do |object|
if s3.bucket.object(object.key).server_side_encryption
puts "Skipping #{object.key}"
next
end
puts "Encrypting #{object.key}"
s3.turn_on_encryption(object.key)
end
@brand-it
brand-it / loopers_script.rb
Last active August 24, 2018 20:34
This is a converter for Paperclip to from old url Patters to a new one. This can be helpful if you have to change maybe the bucket name or just change the path in which they are stored.
require 'paperclip_pattern_processor'
processor = PaperclipPatternProcessor.new
Page.find_each do |page|
urls = page.body.scan(/"(https?:\/\/[\S]+s3.amazonaws.com[\S]+?)"/).flatten.uniq
urls.each do |url|
page.body.gsub!(url, processor.upgrade_url(url))
end
page.save!
end
@brand-it
brand-it / ugh certs suck
Last active June 26, 2018 22:19
This is a fix for chrome as it turns out that chrome decided to be different
openssl req -newkey rsa:2048 -x509 -nodes -keyout localhost.key -new -out localhost.crt -subj /CN=\*.tb.local.vhost -reqexts SAN -extensions SAN -days 3650 -config <(cat /System/Library/OpenSSL/openssl.cnf <(printf '[SAN]\nsubjectAltName=DNS:*.tb.local.vhost'))
class TestsController < ApplicationController
before_action :set_test, only: [:show, :edit, :update, :destroy]
# GET /tests
# GET /tests.json
def index
@tests = Test.all
end
# GET /tests/1
{
// If not specified searches for 'rubocop' executable available on PATH (default and recommended)
// "ruby.rubocop.executePath": "/Users/newdark/.rbenv/shims/",
// You can use specific path
// "ruby.rubocop.executePath": "/Users/you/.rbenv/shims/"
// "ruby.rubocop.executePath": "/Users/you/.rvm/gems/ruby-2.3.2/bin/"
// "ruby.rubocop.executePath": "D:/bin/Ruby22-x64/bin/"
// If not specified, it assumes a null value by default.
#!/usr/bin/env ruby
require 'benchmark'
require 'net/http'
require 'optparse'
options = { total_execute_time: 300, uri: 'https://gitlab.com' }
OptionParser.new do |opts|
opts.banner = "Usage: curl_gitlab [options]"
opts.on('-t', '--total-execute-time SECONDS', 'How long you would like to run this command for') do |t|
start on runlevel [2345]
stop on runlevel [!2345]
@font-face {
font-family: 'Glyphicons Halflings';
src: url(if($bootstrap-sass-asset-helper, twbs-font-path('#{$icon-font-path}#{$icon-font-name}.eot'), '#{$icon-font-path}#{$icon-font-name}.eot'));
src: url(if($bootstrap-sass-asset-helper, twbs-font-path('#{$icon-font-path}#{$icon-font-name}.eot?#iefix'), '#{$icon-font-path}#{$icon-font-name}.eot?#iefix')) format('embedded-opentype'),
url(if($bootstrap-sass-asset-helper, twbs-font-path('#{$icon-font-path}#{$icon-font-name}.woff2'), '#{$icon-font-path}#{$icon-font-name}.woff2')) format('woff2'),
url(if($bootstrap-sass-asset-helper, twbs-font-path('#{$icon-font-path}#{$icon-font-name}.woff'), '#{$icon-font-path}#{$icon-font-name}.woff')) format('woff'),
url(if($bootstrap-sass-asset-helper, twbs-font-path('#{$icon-font-path}#{$icon-font-name}.ttf'), '#{$icon-font-path}#{$icon-font-name}.ttf')) format('truetype'),
url(if($bootstrap-sass-asset-helper, twbs-font-path('#{$icon-font-path}#{$icon-font-name}.svg##{$icon-font-svg-id}'),
#!/bin/bash
read -p "Enter Username: " username
~/steamcmd/steamcmd.sh +login $username +force_install_dir ~/starbound +app_update 211820 +quit