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 / index.html
Last active October 5, 2018 16:19
here is some code or testing.
<table style="width: 100%; height: 304px;">
<tbody>
<tr style="height: 21px;">
<th style="width: 50%; height: 21px;">Token Name</th>
<th style="width: 50%; height: 21px;">Value</th>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px;">Proposal Title</td>
<td style="width: 50%; height: 21px;"><span allowstyling="true" data-name="proposal_title" data-type="string"
data-variable-content="inline" data-source="" data-raw-value="Cy Kosis" class="inline-variable mceNonEditable"
@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|
@brand-it
brand-it / install_steam_starbound.sh
Last active May 8, 2016 00:11
Install Steam and starbound
#!/bin/bash --login
read -p "Enter Username: " username
read -s -p "Enter Password: " password
sudo apt-get update
sudo apt-get install lib32gcc1
sudo apt-get install libpng12-0
adduser steam
start on runlevel [2345]
stop on runlevel [!2345]