Skip to content

Instantly share code, notes, and snippets.

View cameronbarker's full-sized avatar
👀
Best Status Ever

Cameron Barker cameronbarker

👀
Best Status Ever
View GitHub Profile
@cameronbarker
cameronbarker / utility_method_benchmark.rb
Last active December 8, 2022 00:44
Class vs. Method Self.Method vs Method Class << Self Method vs Method Extend Self
require 'benchmark/ips'
# gem install benchmark-ips -v 2.7.2
class TestClass
def echo(value)
value
end
end
module TestModule
@cameronbarker
cameronbarker / delete_node_modules.rb
Created March 17, 2021 14:48
Delete node modules from a folder system
require 'fileutils'
path = '' # Add folder where all projects live
skip_folder = %w[] # Add any folders you'd like to skip
Dir.chdir(path)
folders = Dir.glob('*').select {|f| File.directory? f}
parsed_folders = folders - skip_folder
parsed_folders.each do |folder|
@cameronbarker
cameronbarker / find_big_files.sh
Created January 2, 2019 01:58
Find all files over 1gb aka 1_000m
sudo find / -xdev -type f -size +1000M
# Taken from https://github.com/nicknisi/dotfiles
# heavily inspired by the wonderful pure theme
# https://github.com/sindresorhus/pure
# needed to get things like current git branch
autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git # You can add hg too if needed: `git hg`
zstyle ':vcs_info:git*' use-simple true
zstyle ':vcs_info:git*' max-exports 2
zstyle ':vcs_info:git*' formats ' %b' 'x%R'
@cameronbarker
cameronbarker / rails_db_tasks.rb
Created June 6, 2018 13:51
Some helpful heroku database tasks
require "uri"
namespace :db do
desc "reset but from the migrations not the schema"
task restart: :environment do
Rake::Task["db:drop"].invoke
Rake::Task["db:create"].invoke
Rake::Task["db:migrate"].invoke
Rake::Task["db:seed"].invoke
end
task clear: :environment do
arr_of_arrs = CSV.read("/Users/cameronbarker/Desktop/reading.csv")
["Timestamp",
"Full name of Ninja",
"Original Address",
"Address",
"City",
"State",
"Zip Code",
"Country",
"Country Code",
@cameronbarker
cameronbarker / bitly_unique_id.rb
Created October 6, 2015 17:09
Bitly like unique id
unique_id = (('a'..'z').to_a + ('A'..'Z').to_a + (0..9).to_a).sample(7).join("")
{
"levels": [
[
{
"letter": "P",
"word": "Post",
"win": "false"
},
{
"letter": "O",
require "curb"
require "json"
=begin
This snippet will allow a user to like the latest 100 images on a hashtag or on their feed.
Instagram internally limits to 100 likes/hour.
To run copy code to a file named instagram_like.rb
In your terminal move to where that code is and run 'ruby instagram_like.rb'
Trouble Shoot:

Originally published in June 2008

When hiring Ruby on Rails programmers, knowing the right questions to ask during an interview was a real challenge for me at first. In 30 minutes or less, it's difficult to get a solid read on a candidate's skill set without looking at code they've previously written. And in the corporate/enterprise world, I often don't have access to their previous work.

To ensure we hired competent ruby developers at my last job, I created a list of 15 ruby questions -- a ruby measuring stick if you will -- to select the cream of the crop that walked through our doors.

What to expect

Candidates will typically give you a range of responses based on their experience and personality. So it's up to you to decide the correctness of their answer.