Skip to content

Instantly share code, notes, and snippets.

@LNA
LNA / a_new_branch_workflow.md
Last active September 27, 2021 15:28
New Branch WorkFlow

git fetch origin && git checkout -b name-of-new-feature-branch origin/release

or

git fetch origin && git checkout -b release origin/release

Check out someone elses branch:

git fetch origin && git checkout name-of-branch

#Example pulled from my dotfiles
# git
alias g="git"
alias gs="git status"
alias gl="git l"
alias gcm="git commit -m"
alias ga="git add"
alias gd="git diff"
alias ga.="git add -A"
alias gco="git checkout"
//Using let
//the let keyword scopes to the nearest block, not function
// it prevents variable declarations from being moved to the top of the scope. This is called hoisting.
// loadingMessage and flashMessage are trapped in their braces, and can't be accessed outside of them.
<script src="./load-profiles.js">
<script>
loadProfiles(["Prince", "MJ", "James Brown"]);
</script>
get to next tab: gt or GT
@LNA
LNA / test.rb
Created January 26, 2014 18:53
Multiplying A Range of Numbers Via Nested Iterations
def test
test_numbers = []
(5).downto(1).each do |number|
(number ..5).each do |range_of_numbers|
product = number * range_of_numbers
test_numbers << product
end
end
test_numbers
@LNA
LNA / euler_4.rb
Last active January 4, 2016 14:49
Project Euler Problem 4: Find the largest palindrome made from the product of two 3-digit numbers.
def palindrome
palindromes = []
(999).downto(100).each do |number|
(number ..999).each do |range_of_numbers|
product = number * range_of_numbers
if product.to_s == product.to_s.reverse
palindromes << product
end
end
@LNA
LNA / association_change.rb
Last active January 2, 2016 03:48
Association Change.
#First Pass:
module AR
class Guest < ActiveRecord::Base
has_and_belongs_to_many :drinks
end
end
module AR
class Drink < ActiveRecord::Base
@LNA
LNA / refactoring_ar.rb
Last active January 1, 2016 06:59
Refactoring code smells. Refactoring an Active Record Relationship Model
module AR
class Guest < ActiveRecord::Base
has_many :orders, class_name: "Orders"
has_many :drinks, through: :orders, class_name: "Orders"
def drinks
drinks_array = []
AR::Orders.all.each do |relationship|
if relationship.guest_id == self.id
drinks_array << relationship.drink
end