Skip to content

Instantly share code, notes, and snippets.

View lornatumuhairwe's full-sized avatar

Lorna Tumuhairwe lornatumuhairwe

View GitHub Profile
@lornatumuhairwe
lornatumuhairwe / Dockerfile
Last active August 18, 2020 08:08
Phoenix api dockerfile
FROM elixir:1.10-alpine
WORKDIR /usr/src/app
COPY mix.* ./
RUN mix local.hex --force && mix local.rebar --force
RUN mix deps.get
COPY . .
@lornatumuhairwe
lornatumuhairwe / ex_json_schema_examples.exs
Last active March 12, 2020 14:15
Examples on usage of ex_json_schema
"""ex_json_schema validates json but first, convert it to a map.
The schema is the structure you expect the json to have.
You can setup a schema by passing your desired structure through `ExJsonSchema.Schema.resolve` method"""
schema = %{"type" => "object"} |> ExJsonSchema.Schema.validate()
# Validate using ExJsonSchema.Validator.validate method
ExJsonSchema.Validator.validate(schema, %{})
:ok
# Removing a dependency from your mix.exs file doesn't remove it from the mix.lock file and the deps directory.
# To removes dependencies from mix.lock file run
mix deps.unlock --unused
# To remove dependencies from deps directory run
mix deps.clean --unused
@lornatumuhairwe
lornatumuhairwe / 99bottles.rb
Last active December 11, 2018 15:26
my solution to the 99 bottles of OOP challenge
class Bottles
def initialize
@song = <<-SONG
99 bottles of beer on the wall, 99 bottles of beer.
Take one down and pass it around, 98 bottles of beer on the wall.
98 bottles of beer on the wall, 98 bottles of beer.
Take one down and pass it around, 97 bottles of beer on the wall.
97 bottles of beer on the wall, 97 bottles of beer.
@lornatumuhairwe
lornatumuhairwe / 00_Heroku-Release-Phase-Review-Apps-Rails_README.md
Created October 10, 2018 09:10 — forked from stevenharman/00_Heroku-Release-Phase-Review-Apps-Rails_README.md
Heroku Release Phase script for managing Rails DB migrations, and playing nice with Review Apps and postdeploy scripts

Heroku Release Phase + Review Apps + Rails

This is a simplified, but fairly thorough, set of scripts and configuration to enable Heroku Release Phase for Rails apps. Further, this particular set up plays nicely with Heroku Review Apps in that the release phase script will:

  1. Fail, loudly, if the DB does not yet exist.
  2. Load the DB schema if the current schema version (as determined by bin/rails db:version) is 0.
  3. Run DB migrations otherwise.

For a "normal" app that usually means it will run the DB migrations.

@lornatumuhairwe
lornatumuhairwe / Gemfile
Created September 3, 2018 05:57 — forked from jeroenr/Gemfile
Make will_paginate generate ajax links
source 'https://rubygems.org'
gem 'rails', '3.2.3'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
@lornatumuhairwe
lornatumuhairwe / Assignment2_Lorna_Tumuhairwe.py
Created August 24, 2016 11:18
Code for assignment2 django girls program 2016
import random
questions = {
"Tea": "would you like a cup of tea?",
"Coffee": "Do you like a cup of coffee?",
"Juice": "Would you like a glass of juice?",
"Mojito": "Would like a mojito?"
}
ingredients = {
"Tea": ["Ginger", "cinnamon", "Fennel seed"],