This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defprotocol JsonApiClient.RequestPath do | |
| @moduledoc """ | |
| The `JsonApiClient.RequestPath` protocol provides a single function to be implemented that maps | |
| a given Elixir term to a string representation of an url path. | |
| """ | |
| @doc """ | |
| Converts `term` to a string representation of a given path. | |
| """ | |
| @spec to_path(term()) :: String.t |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "benchmark" | |
| require "ostruct" | |
| BadContext = Class.new(OpenStruct) | |
| class BetterContext | |
| attr_accessor :a, :b, :c, :d, :e, :f | |
| end | |
| def test_it(klass, &b) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| digits n = | |
| findDigits (rem n 10) [] (quot n 10) | |
| where addDigit d ds = (abs d): ds | |
| findDigits d ds 0 = addDigit d ds | |
| findDigits d ds b = findDigits (rem b 10) (addDigit d ds) (quot b 10) | |
| divisableDigits n = | |
| length (filter divisable (digits n)) | |
| where zero 0 = True | |
| zero _ = False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Deal types currently included in xml sitemap | |
| # * "LocalDeal", "EscapesDeal", "AtHomeDeal", "FamiliesDeal" | |
| # * live event deals are included | |
| # URLs are generated with LS::Routing | |
| # * Need to support a mobile version of the url for alternate content and mobile sitemap in near future. | |
| def search_engine_ignore?(deal) | |
| deal.exclusive? || deal.boomerang? || !deal.active? | |
| end | |
| # this logic expands to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void Condition_H::Wait() { | |
| IntStatus oldLevel = interrupt->SetLevel(IntOff); | |
| count++; | |
| if (mon->next_count > 0) { | |
| mon->next->V(); | |
| mon->next_count--; | |
| } | |
| else mon->mutex->V(); | |
| sem->P(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| paragraphs.join("\n").split(/\W/) | |
| .reject { |w| w.size < 4 } | |
| .map(&:downcase) | |
| .reduce(Hash.new(0)) { |words, word| words[word] += 1; words } | |
| .sort { |a, b| a.last <=> b.last } | |
| .take(16) | |
| .map(&:first) | |
| .join(' ') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Spree::DataImport.for(:taxons).run("https://abcdef012356789:[email protected]/taxons.xml") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def load_resource | |
| "#{controller_name.classify}".constantize.find(params[:id]) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Order.class_eval do | |
| def amount | |
| line_items.map(&:amount).sum | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| zone.try(:user).try(:has_carrier?, carrier.try(:name)) |
NewerOlder