Skip to content

Instantly share code, notes, and snippets.

View acuppy's full-sized avatar

Adam Cuppy acuppy

View GitHub Profile
# To prevent the vulnerable server from running on your machine
# (this does not impact Zoom functionality), run these two lines in your Terminal.
pkill "ZoomOpener"; rm -rf ~/.zoomus; touch ~/.zoomus && chmod 000 ~/.zoomus;
pkill "RingCentralOpener"; rm -rf ~/.ringcentralopener; touch ~/.ringcentralopener && chmod 000 ~/.ringcentralopener;
# (You may need to run these lines for each user on your machine.)
class A
def foo
:bar
end
end
a = A.new
puts a.foo # => :bar
@acuppy
acuppy / rake_logger_example.rb
Created July 26, 2016 01:04
An example of how to tap into Rake and run a log line prior to every Rake Task run.
# lib/rake/logging.rb
require 'rake'
module Rake
module Logging
def invoke_task *args
puts "Running: #{parse_task_string args.first}" # ...or do whatever
super
end
class AddFirstNameAndLastNameToUsers < Arborist::Migration
model :User
data do
model.find_each do |user|
first_name, last_name = user.full_name.split ' '
user.first_name = first_name
user.last_name = last_name
user.save!
namespace :data do
desc "Split the user's fullname into first and last names"
task :split_fullname => :environment do
User.reset_column_information
User.find_each do |user|
first_name, last_name = user.full_name.split ''
user.first_name = first_name
user.last_name = last_name
user.save!
class AddCategoriesToPosts < ActiveRecord::Migration
# Fill the void
class ::Category < ActiveRecord::Base
end unless defined? ::Category
def change
Post.find_each do |p|
p.categories.create
end
class AddAdminToUsers < ActiveRecord::Migration
# Fill the void
class User < ActiveRecord::Base
end unless defined? ::User
def change
add_column :users, :admin, :boolean, default: false
# convert existing users to admin
class AddAdminToUsers < ActiveRecord::Migration
def change
add_column :users, :admin, :boolean, default: false
# convert existing users to admin
User.reset_column_information
User.find_each do |u|
u.update admin: true
end
end

Keybase proof

I hereby claim:

  • I am acuppy on github.
  • I am acuppy (https://keybase.io/acuppy) on keybase.
  • I have a public key whose fingerprint is 8C8F EEEC D29D 5152 15A8 2619 46FF 4859 12E8 82B8

To claim this, I am signing this object:

class Sampson < Character
def when(event, &block)
@events[event] ||= []
@events[event] << block
end
def bite_thumb
call_event :bite_thumb
end