Skip to content

Instantly share code, notes, and snippets.

@julianrubisch
julianrubisch / deploy_script.sh
Created March 26, 2021 08:58
Hatchbox phoenix configuration
# Phoenix
if grep -q '^ "phoenix"' mix.lock; then
source $HOME/.asdf/asdf.sh
source $HOME/.asdf/completions/asdf.bash
export $(cat $RELEASE_DIR/../../.rbenv-vars | xargs)
echo '
-----> Detected Phoenix app.'
mix local.rebar --force
mix local.hex --force
@maxivak
maxivak / 00.md
Last active May 23, 2024 13:24
Sending emails with ActionMailer and Sidekiq

Sending emails with ActionMailer and Sidekiq

Send email asynchroniously using Sidekiq.

ActionMailer

Create your mailer us usual:

@parsonsmatt
parsonsmatt / gist:f64393b9349592b6f1c1
Last active August 28, 2020 17:36
class composition in ruby
# In Haskell, you write a function like this:
# f :: a -> b
# which reads as "f is a function from type a to b"
#
# Function composition allows you to chain functions together,
# building more powerful and complex composite functions from
# simpler component functions.
#
# OOP does not have a similar mechanism. Composition in OOP seems
# to mostly be limited to aggregation and delegation, neither of

#Install WDI_MELB style

##Stage 1 - Ruby Version Manager

go to rvm.io copy and paste the two commands

command no. 1

@mattswann
mattswann / Allergies_test.rb
Last active August 29, 2015 14:20
Allergy warm up...
require 'minitest/autorun'
require 'minitest/reporters' # optional
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new() # optional
require_relative './allergies'
class AllergiesTest < MiniTest::Test
@jayzz55
jayzz55 / PT-Melb.md
Last active August 29, 2015 14:17 — forked from mattswann/PT-Melb.md

###PT PLANNER ####Melbourne Public Transport Journey Planner

There are 3 train lines:

The Alamein line has the following stops: Flinders Street, Richmond, East Richmond, Burnley, Hawthorn, and Glenferrie.

The Glen Waverly line has the following stops: Flagstaff, Melbourne Central, Parliament, Richmond, Kooyong and Tooronga.

The Sandringham line has the following stops: Southern Cross, Richmond, South Yarra, Prahran, and Windsor.

@jayzz55
jayzz55 / Gemfile
Last active August 29, 2015 14:10 — forked from eliotsykes/Gemfile
# Add poltergeist gem to Gemfile, in :test group,
# then run `bundle` to install
group :test do
...
gem 'poltergeist'
...
end

Queen Attack

In the game of chess, a queen can attack pieces which are on the same row, column, or diagonal.

A chessboard can be represented by an 8 by 8 array.

Write a program that positions two queens on a chess board and indicates whether or not they are positioned so that they can attack each other.

@Integralist
Integralist / Ruby Lambdas.md
Last active August 8, 2023 05:10
Ruby lambdas

Lambda: standard

# Creating a lambda
l = lambda { |name| "Hi #{name}!" }

# Executing the lambda
l.call("foo") # => Hi foo!
@speric
speric / poodir-notes.md
Last active May 15, 2024 13:39
Notes From "Practical Object-Oriented Design In Ruby" by Sandi Metz

Chapter 1 - Object Oriented Design

The purpose of design is to allow you to do design later, and it's primary goal is to reduce the cost of change.

SOLID Design:

  • Single Responsibility Principle: a class should have only a single responsibility
  • Open-Closed Principle: Software entities should be open for extension, but closed for modification (inherit instead of modifying existing classes).
  • Liskov Substitution: Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.
  • Interface Segregation: Many client-specific interfaces are better than one general-purpose interface.