Skip to content

Instantly share code, notes, and snippets.

@kushniryb
kushniryb / Module#prepend.md
Last active November 2, 2020 13:12
Module#prepend usage

Consider using Module#prepend over Module#class_eval as it's much cleaner and least invasive method of overriding existing Spree functionality.

Please, refer to the following articles for additional details about Module#prepend and method lookup in Ruby:

Usage example:

{
"categories": {
"scientific_premises": {
"auditory": [{ name: "blabla", type: "integer"}, {}, {}]
}
}
}
@kushniryb
kushniryb / pwad.sql
Last active January 31, 2018 09:45
MySQL Points Within a Distance
SET @radius = 30;
SET @lat = 49.536252845380;
SET @lng = 23.786006985056;
SET @earth_radius = 6371;
SELECT
shops.name AS 'Shop Name', shops.id AS 'Shop ID', addresses.lat AS 'Address Lat', addresses.lng AS 'Address Lng', address AS 'Address Line', (
@earth_radius * acos (
cos ( radians(@lat) )
@kushniryb
kushniryb / homework_rack.md
Last active November 16, 2016 22:43
homework_rack

Task

Custom router & middleware implementation

Requirements

  • Implement basic authentication middleware which redirects to 401 page unless password is ILoveRuby

  • Implement custom router that handles following types of requests: GET, POST

@kushniryb
kushniryb / homework_2.md
Last active November 4, 2016 23:24
Kottans Homework #2 [Enumerable / Comparable / Enumerators]

Task 1: Comparable

Create a superhero class with the following attributes:

  • name
  • strength *
  • agility *
  • intelligence *

You should be able to compare different superheroes based on the avarage of attributes marked with *

Display the list of superheroes sorted by an average, as well as by each of the attributes marked with *