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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
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
from collections import defaultdict | |
class SuperWordSearch: | |
""" | |
Solves the Super Word Search variation of the word search problem. | |
""" | |
# All 8 directions (left to right, top to bottom, etc.) | |
DIRECTIONS = ((0,1),(1,0),(-1,0),(0,-1),(1,1),(1,-1),(-1,1),(-1,-1)) |
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
# Append shard ranges as new shard groups are brought online | |
# Format: [Cutoff User ID, Min Shard, Max Shard] | |
USER_ID_SHARD_MAPPING = [ | |
[0, 1, 10], | |
[30000, 11, 20], | |
[500000, 21, 50], | |
] | |
# Consistent shard that falls within a shard range by the user’s ID | |
def consistent_shard(user) |
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
form do |f| | |
f.form_buffers.last << f.autocompleted_input(:product_name, url: autocomplete_product_name_orders_path, label: 'Product') | |
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
ActiveAdmin.register Product do | |
authorized_actions = [:index, :show, :new, :create] | |
authorized_actions << :destroy if current_admin_user.super_admin? | |
actions authorized_actions | |
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 :all, default: true do |products| | |
products.where('1 = 1') | |
end |