Skip to content

Instantly share code, notes, and snippets.

@mlovic
mlovic / banner_conflicts.diff
Created September 18, 2018 12:23
All changes made to banner-related files during the translatable code refactor
Generated with:
git diff ayto/master..javier/refactor-translatable-specs -- `find . -not -path '*/\.*' -name '*banner*'`
diff --git a/app/controllers/admin/banners_controller.rb b/app/controllers/admin/banners_controller.rb
index 7d3773e..b17c17d 100644
--- a/app/controllers/admin/banners_controller.rb
+++ b/app/controllers/admin/banners_controller.rb
@@ -41,8 +41,9 @@ class Admin::BannersController < Admin::BaseController
@mlovic
mlovic / admin_notif_merge.diff
Created August 21, 2018 08:55
Changes applied when merging "Make Admin Notifications translatable" branch with new refactor branch
05cc266f9f7f2f9132a5db6f322e9b05a6192e32
diff --cc app/controllers/admin/admin_notifications_controller.rb
index b15272a,1dd0303..33e99f9
--- a/app/controllers/admin/admin_notifications_controller.rb
+++ b/app/controllers/admin/admin_notifications_controller.rb
@@@ -63,17 -62,6 +63,13 @@@ class Admin::AdminNotificationsControll
private
def admin_notification_params
- params.require(:admin_notification).permit(:title, :body, :link, :segment_recipient)
@mlovic
mlovic / pdf2txt.sh
Created September 6, 2016 17:15
Shell script that takes a pdf of scanned text, and uses the Tesseract OCR library to produce a text file
#!/bin/bash
#
# Takes pdf of scanned text, and uses the Tesseract OCR library to produce
# a text version.
set -e
[ -z "$1" ] && echo "USAGE: pdf2txt INPUT_PATH [OUTPUT_PATH]" && exit 1
input="$1"
@mlovic
mlovic / mocks_and_stubs.md
Last active June 1, 2020 16:24
Difference between mocks and stubs using ruby with mocha library

This gist aims to explain the difference between stubs and mocks and when each should be used. For an introduction to stubs and mocks, start somewhere else, like here.

 

  • Stub: used to isolate the object under test from its dependencies, preventing the test from being influenced by code outside the object. This way the test can't be made to fail or be broken by code which is not part of the specific functionality being tested. Stubs also lead to less code being run, which helps keep tests fast. A stub has no expectations. It doesn't care if it is called or how many times.

    For example, you might stub out a message sent to a database connection if all you are trying to test is the type of the method's return value.

 

@mlovic
mlovic / header.scss
Created February 5, 2015 17:42
Sample sass code for a header. Uses Bourbon and Neat libraries.
@import "../bourbon/bourbon";
@import "../neat/neat";
@import url(http://fonts.googleapis.com/css?family=Lato:100,300,400,700,900);
body {
/*font-family: $lucida-grande;*/
font-family: 'Lato', sans-serif;
}
$header-height: 65px;