Skip to content

Instantly share code, notes, and snippets.

Adam Cuppy acuppy

Block or report user

Report or block acuppy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View permanent_zoom_and_ringcentral_server_remover.sh
# 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.)
View monkey-patching.rb
class A
def foo
:bar
end
end
a = A.new
puts a.foo # => :bar
@acuppy
acuppy / rake_logger_example.rb
Created Jul 26, 2016
An example of how to tap into Rake and run a log line prior to every Rake Task run.
View rake_logger_example.rb
# 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
View data-migrations-arborist-step1.rb
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!
View data-migrations-split-fullname.rake
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!
View data-migrations-temp-model-association.rb
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
View data-migrations-temp-model.rb
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
View data-migrations.rb
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
View keybase.md

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:

View delegate-event.rb
class Sampson < Character
def when(event, &block)
@events[event] ||= []
@events[event] << block
end
def bite_thumb
call_event :bite_thumb
end
You can’t perform that action at this time.