curl -X PURGE <url of cached badge image here>
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 extract_values_striped(hash, *keys) | |
| hash.values_at(*keys).map { |value| value.respond_to?(:strip) ? value.strip : value } | |
| end | |
| # test case ... | |
| test "#extract_values_striped helper takes a hash & keys list, then return their values stripe" do | |
| my_collection = { book: 'the pragmatic programmer', language: 'ruby', hoppy: 'swimming' } | |
| values = extract_values_striped(my_collection, :book, :hoppy, :toy) |
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
| /// Slighty adapted from: stackoverflow.com/a/10478008 | |
| using System; | |
| using System.Collections; | |
| using System.Linq; | |
| using System.Collections.Generic; | |
| using System.Reflection; | |
| using System.Text; | |
| public class ObjectDumper |
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
| Array.prototype.sample = function() { | |
| return this[Math.floor(Math.random() * this.length)] | |
| }; | |
| Array.prototype.remove = function(element) { | |
| var index = this.indexOf(element); | |
| if (index > -1) { | |
| this.splice(index, 1); | |
| } | |
| return this; |
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 authorize_for_my_action(child_record) | |
| raise Pundit::NotAuthorizedError unless ParentPlociy.new(pundit_user, child_record).my_action? | |
| skip_authorization | |
| 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
| App.LibraryRoute = App.ApplicationRoute.extend({ | |
| activate: function () { | |
| //no longer enter | |
| this._super(); | |
| only called once on entering a route. | |
| }, | |
| beforeModel: function () { | |
| // any state you want in place before the model is initialized, this is called before any model promises are resolved | |
| // also could be used to conditionally prevent access to a route by throwing transition.abort |
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
| # https://stackoverflow.com/a/35963024 | |
| module Flattener | |
| def deep_flatten | |
| flatten.map do |item| | |
| case item | |
| when Hash, Array | |
| item.deep_flatten | |
| else | |
| item |
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
| namespace :system do | |
| desc 'Update the system rules ' | |
| task :update_rules do | |
| on roles(:all) do | |
| within release_path do | |
| with rails_env: fetch(:rails_env) do | |
| execute :rake, 'system:update_rules' | |
| end | |
| 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
| scope :with_scope, -> { where(id: ARRAY_COLLECTION.map(&:id)) } |