query
stringlengths
7
9.55k
document
stringlengths
10
363k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
============================================================================== Pseudocode Algorithm 1. Prepare the decks. Generate 52 unique cards. Repeat for cases with more than 1 deck. Shuffle all the cards. 2. Allow user to place bets, knowing that wins pay 1:1 and blackjack pays 2:1 on one deck and 3:1 on more than one deck. 3. Deal 2 cards to each player. 4. Allow player to either hit (be dealt another card) or stay (no more cards) until all players are either "busted" or satisfied with their position. See rules of card addition. 5. Dealer gets two cards and must hit until a total of at least 17. Dealer can choose to stay or hit past 17, but aims for the highest hand without breaking a total card sum of 21. 6. When dealer is satisfied, any player with a smaller card total loses their entire bet. Any player with equal sum neither loses nor gains ("push"). Any player with a greater sum wins 1x more than their bet. Any player with blackjack wins 2x or 3x more than their bet depending on the number of decks. 7. Repeat steps 3 6 until the deck(s) is empty. At which time, repeat step 1. 8. Game is over when the player either has no more money to bet or walks away. Card addition rules An ace is worth either 1 or 11, whichever gets closer to 21 without going over Face cards (K, Q, J) are worth 10 All number cards are worth their number, regardless of suit ============================================================================== Method Definitions
def deal(game_hash, player_number = nil) # <= Hash, Integer if game_hash[:dealer_deck].count <= 3 game_hash[:dealer_deck] << prepare_decks(game_hash[:decks]) end if player_number.nil? # if the dealer how_many_cards = game_hash[:dealer_hand].count < 2 ? 2 : 1 how_many_cards.times do card = game_hash[:dealer_deck].pop game_hash[:dealer_hand] << card end else # if not the dealer how_many_cards = game_hash[:current_hands][player_number].count < 2 ? 2 : 1 how_many_cards.times do card = game_hash[:dealer_deck].pop game_hash[:current_hands][player_number] << card end end game_hash end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def determine_dealers_best_total\n # @dealer_hand = ['ace of spades', '5 of spades', '4 of spades', 'ace of diamonds']\n # @player1_hand = ['3 of spades', 'ace of hearts', '4 of spades', 'ace of clubs']\n # @player1_hand = ['ace of clubs', '2 of clubs', 'ace of hearts', '4 of hearts']\n # @dealer_hand...
[ "0.72173995", "0.7212894", "0.7154015", "0.6945892", "0.69367903", "0.6913308", "0.6912597", "0.68993247", "0.6840461", "0.679857", "0.6793847", "0.67831624", "0.67701226", "0.6759967", "0.6750646", "0.67390776", "0.67246604", "0.66962814", "0.66939294", "0.66732585", "0.6669...
0.62978643
72
Use callbacks to share common setup or constraints between actions.
def set_message @message = Message.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def message_params params.require(:message).permit(:subject, :message, :read, :user_id, :sender_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
GET /users or /users.json
def index @users = User.all.includes(:shifts) render :index end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def users(args = {})\n get(\"/users.json\",args)\n end", "def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestC...
[ "0.80617756", "0.77441084", "0.7633772", "0.7551262", "0.75121295", "0.7415968", "0.7389533", "0.7240856", "0.72281533", "0.718402", "0.71254706", "0.7091411", "0.7090834", "0.70858943", "0.70350945", "0.7027718", "0.7009959", "0.6991648", "0.698962", "0.698962", "0.6969425",...
0.0
-1
GET /users/1 or /users/1.json
def show @user = User.find(params[:id]) render :show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n ...
[ "0.788811", "0.7558447", "0.7515899", "0.7298795", "0.7228583", "0.72237515", "0.7199795", "0.7147997", "0.71052223", "0.7095021", "0.7078965", "0.6957582", "0.69508964", "0.6934802", "0.6930263", "0.6906717", "0.68877006", "0.6832729", "0.6832729", "0.68160546", "0.6813898",...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_user @user = User.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Only allow a list of trusted parameters through.
def user_params params.require(:user).permit(:name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end", "def param_whitelist\n [:role, :title]\...
[ "0.69497335", "0.6812623", "0.6803639", "0.6795365", "0.67448795", "0.67399913", "0.6526815", "0.6518771", "0.64931697", "0.6430388", "0.6430388", "0.6430388", "0.63983387", "0.6356042", "0.63535863", "0.63464934", "0.63444513", "0.6337208", "0.6326454", "0.6326454", "0.63264...
0.0
-1
gets personal access token
def personal_access_token # :yields: String @@token end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def personal_access_token\n @personal_access_token ||= ENV['PERSONAL_ACCESS_TOKEN']\n end", "def get_access_token\n\t\treturn @credentials.get_access_token\n\tend", "def personal_access_token\n ENV['PERSONAL_ACCESS_TOKEN']\n end", "def access_token\n end", "def access_token\n ...
[ "0.8045875", "0.79711217", "0.7914528", "0.77924037", "0.7638056", "0.7600398", "0.75705683", "0.75441414", "0.75366634", "0.7527135", "0.7510565", "0.74752945", "0.7473861", "0.7470178", "0.74640566", "0.74618065", "0.7434651", "0.74275583", "0.7427219", "0.7412975", "0.7378...
0.78651553
3
Base API string to get all repos of user ====Attributes +username+ > username of account
def user_repos_url(username,token) # :yields:String BASE_URL + USERS + "#{username}/" + "repos?access_token=#{token}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_all_user_repos\n user = User.find_by(uuid: params[:uuid])\n\n client = Octokit::Client.new(:access_token => user.password)\n repo_list = []\n client.repositories(:user => user.gh_username).each { |repo|\n repo_list.push(repo.name)\n }\n render :json => {:repos => repo_list}\n end", ...
[ "0.7915985", "0.7529958", "0.7230996", "0.70680064", "0.6920562", "0.6887824", "0.68868196", "0.6875116", "0.6854326", "0.67419916", "0.67344606", "0.6658952", "0.6636243", "0.66075385", "0.6582611", "0.6582408", "0.65358686", "0.65331584", "0.6530477", "0.65272677", "0.64756...
0.6932848
4
Build API string for repository related queries ====Attributes +type+ > Options to build API string +username+ > username of account to access repo content +repo_name+ > name of repository
def get_repo_content(type, username, repo_name) # :yields: String case type when Api_options::REPO::LANGUAGES "#{BASE_URL}" + "#{REPOS}" + "#{username}/" + "#{repo_name}/languages" when Api_options::REPO::CONTRIBUTORS BASE_URL + REPOS + "#{username}" + "/" + "#{repo_name}" + "/" + "contributors" when Api_options::REPO::README BASE_URL + REPOS + "#{username}" + "/" + "#{repo_name}" + "/" + "readme" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_repositories_by_type_with_http_info(type, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: RepositoryApi.get_repositories_by_type ...'\n end\n # verify the required parameter 'type' is set\n if @api_client.config.client_side_validation ...
[ "0.684566", "0.6606088", "0.63976187", "0.63220155", "0.6321072", "0.6209828", "0.61083597", "0.6024211", "0.59978443", "0.5990004", "0.5949168", "0.5924148", "0.58295715", "0.57874364", "0.5762074", "0.57574016", "0.5754528", "0.57428545", "0.5739647", "0.5735071", "0.573129...
0.7017994
0
Build API string for user related queries ====Attributes +type+ > Options to build API string +params+ > Additional parameters to narrow search criteria
def get_user_contents(type, params) # :yields: String case type when Api_options::USER::EMAIL unless personal_access_token.nil? "#{BASE_URL}user/emails?access_token=#{params[:app_token]}" else raise "Authentication required" end when Api_options::USER::SEARCH unless params[:number_of_repos] == nil return BASE_URL + SEARCH + USERS + "q=#{params[:by_name]}+repos=#{params[:number_of_repos]}" else return BASE_URL + SEARCH + USERS + "q=#{params[:by_name]}" end when Api_options::USER::FOLLOWERS BASE_URL + USERS + "#{params[:username]}/followers?access_token=#{params[:token]}" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def query_params\n {\n affiliate:,\n access_key:,\n query:,\n offset:,\n limit:\n }\n end", "def query_params\n params.permit(:user_id, :type)\n end", "def query_params\n {\n name:,\n q: query,\n api_key:\n }\n end", "def b...
[ "0.6219499", "0.5977072", "0.58192503", "0.57681745", "0.57603955", "0.5700501", "0.5700501", "0.568811", "0.5643081", "0.5640035", "0.5633253", "0.5585304", "0.55777687", "0.5572262", "0.5552047", "0.5533087", "0.5516396", "0.5499835", "0.54996544", "0.5488445", "0.54844606"...
0.5885413
2
TODO: Extract this to ActiveFedora::Aggregations::ListSource
def ordered_ids Array(solr_document["member_ids_ssim"]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def source_list(label, *list)\n _logger.warn \"Duplicate source_list '#{label}'\" if @result.source_lists.has_key?(label)\n @result.source_lists[label] += list\n end", "def single_datasource_list_item(source, options)\n classes = []\n classes << 'minor_source' if options[:minor]\n query = o...
[ "0.6424516", "0.5920717", "0.5724281", "0.5719691", "0.57161844", "0.5622774", "0.5577545", "0.55591094", "0.5533468", "0.55078435", "0.5504561", "0.5504561", "0.5484806", "0.5484806", "0.5484806", "0.5484806", "0.5484806", "0.5442304", "0.5435037", "0.5435037", "0.5435037", ...
0.0
-1
seperate method for ttyprompt options and outputs selection result.
def main_menu_prompt welcome menu = [ { name: "View list of Recipes", value: 1}, { name: "Input a new recipe into the recipe book", value: 2}, { name: "Edit a recipe from the recipe book", value: 3}, { name: "Display Help information", value: 4}, { name: "Exit", value: 5} ] mm_choice = $prompt.select("Please select an option", menu) return mm_choice end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def option_select \n require \"tty-prompt\"\n prompt = TTY::Prompt.new\n\n puts \"\\n \\n\"\n\n prompt.select(\"What would you like to do? Choose from the options below:\") do |menu|\n menu.choice 'View my favorite players' #MAIN MENU OPTION 1 - SHOWS USER'S FAVORITE PLAYERS\n menu.choice...
[ "0.72823685", "0.7130444", "0.7074955", "0.70017064", "0.6987099", "0.6677503", "0.6524322", "0.64442194", "0.64361256", "0.6368112", "0.63567996", "0.6350123", "0.6335551", "0.6329826", "0.63283414", "0.63157374", "0.6296851", "0.6253647", "0.6227496", "0.62088716", "0.61675...
0.5738694
65
return to recipe book function.
def return_to_recipe_list system "clear" main_menu(1) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def return_book\n\t\tselect = make_selection.to_i\n\t\tselect = verify_book_exists(select)\n\t\tb = Book.find(select)\n\t\tpatron_id = nil\n\t\tb.update_attributes(patron_id: patron_id)\nend", "def get_library_book_return\n\t\tputs \"To return a book,\"\n\t\tprint \" Enter Book Id :\"\n\t\ttarget_book_id=gets.to...
[ "0.63389367", "0.6238858", "0.6072694", "0.6016819", "0.58787477", "0.58437", "0.5819336", "0.5793196", "0.5700857", "0.5688315", "0.5672389", "0.5647701", "0.5626637", "0.55906254", "0.5538519", "0.5538519", "0.5510446", "0.5505953", "0.5477824", "0.54763377", "0.54705846", ...
0.5466112
21
method takes an array of hashes and converts it to json format to be written.
def convert_array_of_hashes(array_of_hashes) new_recipes_hash = {} array_of_hashes.each do |to_merge| to_merge.each do |r,i| new_recipes_hash[r] = i end end json_edit = {"recipes"=>new_recipes_hash} File.write("JSON/recipes.json", JSON.dump(json_edit)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_json(*a)\n to_hash.to_json(*a)\n end", "def to_json(*a)\n to_hash.to_json\n end", "def to_json(*a)\n to_hash.to_json(*a)\n end", "def to_json(*a)\n to_hash.to_json(*a)\n end", "def to_json(*a)\n to_hash.to_json(*a)\n end", "def to_json(*a...
[ "0.726258", "0.71469635", "0.71420974", "0.71420974", "0.71420974", "0.6754364", "0.6753397", "0.6753397", "0.6753397", "0.6753397", "0.6753397", "0.6753397", "0.6753397", "0.6753397", "0.6753397", "0.6753397", "0.6753397", "0.6753397", "0.6739183", "0.67318505", "0.67318505"...
0.7739858
0
def load_commentable resource, id = request.path.split('/')[1,2]
def load_commentable klass = [PhotoShout, Trip].detect {|c| params["#{c.name.underscore}_id"]} @commentable = klass.find(params["#{klass.name.underscore}_id"]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_commentable\n \tresource, id = request.path.split('/')[1,2]\n \t@commentable = resource.singularize.classify.constantize.find(id)\n end", "def load_commentable\n resource, id = request.path.split('/')[1,2]\n @commentable = resource.singularize.classify.constantize.find(id)\n end", "def load_...
[ "0.88641995", "0.8679157", "0.7953624", "0.7929502", "0.79103476", "0.7632983", "0.7456348", "0.7393319", "0.7269405", "0.70087755", "0.679782", "0.67650014", "0.6755195", "0.668312", "0.66661865", "0.6603481", "0.648431", "0.64597785", "0.64325476", "0.64230037", "0.64170074...
0.79188234
4
instead of using price in both attr_ we can make one common attr_accessor :price or attr :price, true
def initialize(venue, date) @venue = venue @date = date end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def price=(new_price)\n\t\t@price = new_price\n\tend", "def hack\n self.price = 200\n end", "def price_as_price\n @price_as_price ||= Price.new(price, price_includes_tax?, tax_rate)\n end", "def set_price(price)\n @price = price\n if self.is_offer?\n self.safe.return\n self.sa...
[ "0.65463316", "0.6495119", "0.64267457", "0.64173347", "0.64070547", "0.64019436", "0.6338681", "0.6331007", "0.63055164", "0.6296991", "0.62498", "0.6242476", "0.6212013", "0.6175609", "0.61500204", "0.6144525", "0.6113508", "0.6113508", "0.6092586", "0.6077841", "0.6065553"...
0.0
-1
Creates a byte string for this storage
def to_s data = [@name.concat(Array.new(32 - @name.size, 0)), @name_size, @type, @color, @left, @right, @child, @created, @modified, @sector, @size].flatten data.pack(PACKING) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_str\n bytes\n end", "def to_str\n bytes\n end", "def to_str\n bytes\n end", "def string()\n len = self.uint32()\n self.bytes(len)\n end", "def to_binary; ''; end", "def to_bytes; end", "def to_bytes; end", "def as_bytes\n raise NotI...
[ "0.742608", "0.742608", "0.742608", "0.6933773", "0.66972446", "0.66629285", "0.66629285", "0.6609333", "0.660893", "0.654298", "0.65130204", "0.6468195", "0.6464204", "0.63933176", "0.63581514", "0.63574606", "0.6353025", "0.63205963", "0.63017064", "0.62929314", "0.6269154"...
0.56831694
79
Sets the color for this storage
def color=(v) RestrictionValidator.validate :storage_color, COLORS.values, v @color = v end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def color=(value)\n @color = value\n end", "def color=(value)\n @color = value\n end", "def set_color(color)\n @color = color\n end", "def set_color=(new_color)\n @@color = new_color\n end", "def setColor(color)\n\t\t@color = color\n\n\tend", "d...
[ "0.75610733", "0.7560204", "0.7527249", "0.74547356", "0.73985094", "0.7281037", "0.7276407", "0.72464037", "0.7206138", "0.70257246", "0.6876966", "0.6757502", "0.67390835", "0.6724575", "0.6643162", "0.662718", "0.6578239", "0.6569187", "0.6567732", "0.6539765", "0.6513767"...
0.8399114
0
sets the name of the stream. This will automatically set the name_size attribute
def name=(v) @name = v.bytes.to_a << 0 @name_size = @name.size * 2 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_name(name)\n @name = name\n end", "def name=(str)\n @name = str\n write_properties\n end", "def name=(name)\n\t\tself.sname = name\n\tend", "def name=(name)\n\t\tself.sname = name\n\tend", "def name_setter(new_name)\n @name = new_name\n end", "def setName(n)\n @name = n\...
[ "0.6841309", "0.6809099", "0.67501354", "0.6749541", "0.6684401", "0.6634158", "0.6628071", "0.65717924", "0.6556741", "0.6540111", "0.6524249", "0.6520003", "0.6520003", "0.6494317", "0.64889723", "0.64889723", "0.64889723", "0.64889723", "0.64889723", "0.64836997", "0.64812...
0.6876063
0
Set the data associated with the stream. If the stream type is undefined, we automatically specify the storage as a stream type. with the exception of storages that are type root, all storages with data should be type stream.
def data=(v) Axlsx.validate_string(v) self.type = TYPES[:stream] unless @type @size = v.size @data = v.bytes.to_a end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_stream\n @stream = Stream.find(params[:id])\n end", "def set_stream\n @stream = Stream.find(params[:id])\n end", "def set_stream\n @stream = Stream.find(params[:id])\n end", "def set_stream\n @stream = Stream.find(params[:id])\n end", "def set_stream\n @...
[ "0.64828366", "0.64828366", "0.6376365", "0.6376365", "0.6376365", "0.6376365", "0.6365004", "0.62902576", "0.6243035", "0.6208514", "0.6162786", "0.6131583", "0.60915697", "0.5996046", "0.59601057", "0.5908263", "0.583643", "0.5817072", "0.58103055", "0.57962215", "0.5779491...
0.6885966
0
Sets the type for this storage.
def type=(v) RestrictionValidator.validate :storage_type, TYPES.values, v @type = v end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_type(v)\n self.type = v\n self\n end", "def set_type(val)\n self.type = val\n self\n end", "def type=(type)\n self['type'] = type\n end", "def type=(type)\n write_attr :type, type\n end", "def type=(type)\n validate_type_values(type)\n @type =...
[ "0.7803669", "0.77690387", "0.7666118", "0.7576077", "0.75413215", "0.7540674", "0.75390345", "0.7535735", "0.7535735", "0.7535735", "0.7535735", "0.7535735", "0.7535735", "0.7535735", "0.75017273", "0.74843335", "0.7405767", "0.72984195", "0.7286711", "0.722446", "0.72206944...
0.8473044
0
Creates a new storage object.
def initialize(name, options = {}) @left = @right = @child = -1 @sector = @size = @created = @modified = 0 options.each do |o| send("#{o[0]}=", o[1]) if respond_to? "#{o[0]}=" end @color ||= COLORS[:black] @type ||= (data.nil? ? TYPES[:storage] : TYPES[:stream]) self.name = name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create identifier, object\n @storage[identifier] = object\n end", "def store_with(name, storage_id = nil, &block)\n @storages << get_class_from_scope(Storage, name)\n .new(self, storage_id, &block)\n end", "def create_storage_volume(create_opts={})\n create_resource :stora...
[ "0.7230349", "0.7080025", "0.6971594", "0.69386107", "0.69264907", "0.6873215", "0.6862497", "0.6721025", "0.6711391", "0.67006856", "0.6688882", "0.66551864", "0.66471195", "0.6640311", "0.6549923", "0.6467817", "0.64262456", "0.6403953", "0.64034796", "0.6382005", "0.637232...
0.0
-1
GET /hierarchies GET /hierarchies.json
def index @title = t('view.hierarchies.index_title') @searchable = true @hierarchies = Hierarchy.filtered_list(params[:q]).page(params[:page]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @page_hierarchies = PageHierarchy.all\n end", "def index\n @fdn_org_hierarchies = Fdn::OrgHierarchy.paginate(:page => params[:page]).order(\"created_by DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @fdn_org_hierarchies }\n end\n ...
[ "0.656682", "0.64662665", "0.64087284", "0.6159568", "0.61079735", "0.6093901", "0.5986009", "0.59761065", "0.5929222", "0.5926409", "0.58960384", "0.58375514", "0.58300513", "0.58197606", "0.58197606", "0.58151203", "0.5781925", "0.5771346", "0.5648535", "0.562694", "0.56109...
0.66676956
0
GET /hierarchies/1 GET /hierarchies/1.json
def show @title = t('view.hierarchies.show_title') @hierarchy = Hierarchy.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @title = t('view.hierarchies.index_title')\n @searchable = true\n @hierarchies = Hierarchy.filtered_list(params[:q]).page(params[:page])\n end", "def index\n @fdn_org_hierarchies = Fdn::OrgHierarchy.paginate(:page => params[:page]).order(\"created_by DESC\")\n\n respond_to do |format|...
[ "0.67585427", "0.65319145", "0.65282327", "0.6358", "0.6014947", "0.60048926", "0.59913737", "0.5953611", "0.59460115", "0.5877344", "0.5805743", "0.5781114", "0.57546324", "0.57455754", "0.57455754", "0.5738148", "0.5735846", "0.57184386", "0.57095104", "0.57095104", "0.5691...
0.65534735
1
GET /hierarchies/new GET /hierarchies/new.json
def new @title = t('view.hierarchies.new_title') @hierarchy = Hierarchy.new end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @title = t('view.hierarchies.new_title')\n @hierarchy = Hierarchy.new(params[:hierarchy])\n\n if @hierarchy.save\n redirect_to [:configs, @hierarchy],\n notice: t('view.hierarchies.correctly_created')\n else\n render action: 'new'\n end\n end", "def new\n @tree = ...
[ "0.7230501", "0.671684", "0.6569649", "0.65053713", "0.6456156", "0.6423745", "0.6408552", "0.63331056", "0.6327048", "0.6320353", "0.6318783", "0.63184905", "0.6318309", "0.62679064", "0.6264775", "0.6261088", "0.62298244", "0.6174088", "0.61627024", "0.6147898", "0.61451674...
0.72300684
1
POST /hierarchies POST /hierarchies.json
def create @title = t('view.hierarchies.new_title') @hierarchy = Hierarchy.new(params[:hierarchy]) if @hierarchy.save redirect_to [:configs, @hierarchy], notice: t('view.hierarchies.correctly_created') else render action: 'new' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @page_hierarchy = PageHierarchy.new(page_hierarchy_params)\n\n respond_to do |format|\n if @page_hierarchy.save\n format.html { redirect_to @page_hierarchy, notice: 'Page hierarchy was successfully created.' }\n format.json { render :show, status: :created, location: @page_hie...
[ "0.64438426", "0.576197", "0.5685173", "0.56788814", "0.56438416", "0.56316876", "0.5529048", "0.5499583", "0.5491541", "0.54882276", "0.54697526", "0.54660237", "0.54594105", "0.5445334", "0.5445334", "0.53873706", "0.53873706", "0.53831327", "0.53766847", "0.5368625", "0.53...
0.6684624
0
PUT /hierarchies/1 PUT /hierarchies/1.json
def update @title = t('view.hierarchies.edit_title') @hierarchy = Hierarchy.find(params[:id]) if @hierarchy.update_attributes(params[:hierarchy]) redirect_to [:configs, @hierarchy], notice: t('view.hierarchies.correctly_updated') else render action: 'edit' end rescue ActiveRecord::StaleObjectError redirect_to edit_configs_hierarchy_url(@hierarchy), alert: t('view.hierarchies.stale_object_error') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_hierarchy\n update_ancestor_ids and update_descendant_ancestor_ids\n end", "def set_resource_hierarchy\n @resource_hierarchy = ResourceHierarchy.find(params[:id])\n end", "def create\n @title = t('view.hierarchies.new_title')\n @hierarchy = Hierarchy.new(params[:hierarchy])\n\n ...
[ "0.6204802", "0.6067747", "0.6008974", "0.5948571", "0.5819243", "0.57844335", "0.56656957", "0.56525433", "0.5607959", "0.56002855", "0.5582301", "0.55759865", "0.55675477", "0.55675477", "0.55277824", "0.54616946", "0.54477334", "0.5369338", "0.5328504", "0.53262156", "0.53...
0.64882064
0
DELETE /hierarchies/1 DELETE /hierarchies/1.json
def destroy @hierarchy = Hierarchy.find(params[:id]) @hierarchy.destroy redirect_to configs_hierarchies_url end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @branch = Branch.find(params[:id])\n @parentTitle = Branch.find(params[:id]).uid\n Branch.where(parent: @parentTitle).delete_all\n @branch.destroy\n render :json => @branch.to_json\n end", "def destroy\n @heirarchy.destroy\n respond_to do |format|\n format.html { redirect...
[ "0.68797195", "0.67984706", "0.6738817", "0.6707028", "0.6707028", "0.66665375", "0.6635615", "0.6570222", "0.6554335", "0.6548461", "0.6492945", "0.6467666", "0.64354926", "0.6426847", "0.64204144", "0.6345561", "0.63427514", "0.6326847", "0.6304188", "0.6262028", "0.6246999...
0.73606485
0
A simple way to short circuit the delivery of an email from within deliver_ methods defined in ActionMailer::Base subclasses.
def do_not_deliver! def self.deliver! ; false ; end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deliver_email\n error = \"We forgot to define #{type}#deliver_email.\\n\"\n # Failing to send email should not throw an error in production\n return warn(error) if Rails.env.production?\n\n raise(error)\n end", "def deliver!\n self.do_deliver\n end", "def deliver!(mail)\n delivery_met...
[ "0.74304795", "0.7339174", "0.7210702", "0.70647824", "0.70462745", "0.7040512", "0.69248825", "0.68834347", "0.67912996", "0.67747235", "0.6770378", "0.6769002", "0.6724918", "0.66929233", "0.6674139", "0.66735137", "0.66625273", "0.66209805", "0.65803075", "0.6566546", "0.6...
0.7765361
0
0x02: LCONST (cbyte1, cbyte2, cbyte3, cbyte4) ... => ..., const
def op2(interp, c1, c2, c3, c4) interp.stack.push([(((c1 << 24) | c2 << 16) | c3 << 8) | c4].pack('I').unpack('i').first) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def const_get(p0) end", "def const!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 35 )\n\n type = CONST\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 156:9: 'const'\n match( \"const\" )\n...
[ "0.65786165", "0.65577316", "0.6499993", "0.6465749", "0.6253413", "0.62361115", "0.6067998", "0.5978632", "0.5971398", "0.5962916", "0.59479827", "0.5853512", "0.5852483", "0.58210266", "0.5797272", "0.57833225", "0.5766297", "0.5728257", "0.5646077", "0.5590617", "0.5590617...
0.0
-1
0x0a: ADD () ..., value1, value2 => ..., result
def op10(interp) interp.stack.push(Integer(interp.stack.pop + interp.stack.pop)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add(val1, val2) val1 + val2 end", "def add(val)\n \n end", "def ADD(d,x,y) opcode \"add\", [d,x,y] end", "def Add(val)\n self.value += val\n end", "def add (parameter1, parameter2)\n\t# adds two values\n\treturn parameter1 + parameter2\nend", "def add(a,b)\n ret1 = a + b\n ret = r...
[ "0.788121", "0.7452161", "0.72457826", "0.7224627", "0.7142368", "0.71264476", "0.71257234", "0.7109104", "0.71055806", "0.7096391", "0.7065555", "0.7029927", "0.7023179", "0.7015252", "0.70118195", "0.70089626", "0.6978629", "0.69781", "0.6954502", "0.694302", "0.6939894", ...
0.0
-1
0x0b: SUB () ..., value1, value2 => ..., result
def op11(interp) b, a = interp.stack.pop, interp.stack.pop interp.stack.push(Integer(a - b)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def execute_SUB(destination, source)\n\t\tset_auxiliary_carry_flag_from destination.value.lowest_4_bits - source.value.lowest_4_bits\n\t\tperform_arithmetic_operation_storing_result(source, destination, destination.value - source.value)\n\tend", "def subt(a,b)\n a-b\nend", "def sub\n s[-2] = s[-1]-s[-2]\...
[ "0.6877522", "0.68756706", "0.677055", "0.6616078", "0.64879805", "0.6468898", "0.6439154", "0.6395348", "0.6381245", "0.6374204", "0.63424826", "0.6336569", "0.6268483", "0.62634194", "0.62519777", "0.623415", "0.62259233", "0.6224318", "0.6220695", "0.6220695", "0.6220695",...
0.0
-1
0x0c: MUL () ..., value1, value2 => ..., result
def op12(interp) interp.stack.push(Integer(interp.stack.pop * interp.stack.pop)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def *(value)\n mul(value) ;\n end", "def mul(val)\n # imul: //OperandSize == 32 EDX:EAX = EAX * Source\n # 0x00000000000fd317 : imul dword ptr [rcx] ; ret\n tmp = reg_addr\n flat(store(val, tmp), pop_rcx, tmp, libc + 0xfd317)\nend", "def Multiply(val)\n self.value *= val\n end", "def mul!(*args)\...
[ "0.7576631", "0.74604756", "0.7252268", "0.71512437", "0.7111427", "0.71009487", "0.70987487", "0.700383", "0.6997354", "0.6984752", "0.6923019", "0.6907551", "0.6900391", "0.68896955", "0.6854582", "0.6849798", "0.68438864", "0.68243194", "0.68015313", "0.6801447", "0.679914...
0.0
-1
0x0d: POW () ..., value1, value2 => ..., result
def op13(interp) b, a = interp.stack.pop, interp.stack.pop interp.stack.push(Integer(a ** b)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def power(a,b)\n a.to_i ** b.to_i\nend", "def pow base, p\n base ** p\n end", "def #power(a,b)\n\ta ** b\nend", "def power(nb1, nb2)\n return nb1 ** nb2\nend", "def power(base, power)\n base ** power\nend", "def power(x,y)\n\treturn x**y\nend", "def power(a, b)\n return a**b\nend", "def power...
[ "0.7710444", "0.7649185", "0.7601243", "0.7502391", "0.7448411", "0.743326", "0.7412653", "0.7402007", "0.7400347", "0.7375579", "0.7299642", "0.7277034", "0.7232536", "0.7219344", "0.7218645", "0.71759695", "0.71649337", "0.71536005", "0.7146962", "0.7130555", "0.7130555", ...
0.0
-1
0x0e: DIV () ..., value1, value2 => ..., result
def op14(interp) b, a = interp.stack.pop, interp.stack.pop interp.stack.push(Integer(a / b)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def div(p0) end", "def div(x, y)\n x / y\nend", "def div(arg0)\n end", "def on_div(ast_node, context)\n left, right = *ast_node\n\n return on_call_number(context, left) / on_call_number(context, right)\n end", "def fdiv(arg0)\n end", "def rdiv(arg0)\n end", "def divmod(val); end"...
[ "0.8286224", "0.79434836", "0.78617877", "0.7587819", "0.7556864", "0.75559306", "0.74835634", "0.74623597", "0.7356595", "0.73442197", "0.734152", "0.73391944", "0.73286533", "0.7325242", "0.72792625", "0.726031", "0.7256544", "0.7255479", "0.7236879", "0.71541685", "0.71541...
0.0
-1
0x0f: MOD () ..., value1, value2 => ..., result
def op15(interp) b, a = interp.stack.pop, interp.stack.pop interp.stack.push(Integer(a % b)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def modulo(p0) end", "def divmod(val); end", "def mod(first_number, second_number)\n first_number % second_number\nend", "def mod(num1, num2)\n num2.to_f % num1.to_f;\nend", "def divmod(p0) end", "def remainder(val); end", "def modular_function\n num_1 % num_2\n return num_1 % num_2\nend", "def m...
[ "0.79416937", "0.78916276", "0.7870062", "0.7723893", "0.77034104", "0.75900775", "0.75229657", "0.74471945", "0.74471945", "0.72733563", "0.72710216", "0.7255574", "0.7252925", "0.7252925", "0.70717925", "0.70617986", "0.70314336", "0.69560176", "0.6914087", "0.687337", "0.6...
0.0
-1
0xa0: SWAP () ..., value1, value2 => ..., value2, value1
def op160(interp) interp.stack.push(interp.stack.pop, interp.stack.pop) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def swap; end", "def swap!(a, b) self[a], self[b] = self[b], self[a]; self; end", "def swap(a,b)\na,b = b,a\nend", "def swap #\\\n a = pop\n b = pop\n push a\n push b\n end", "def swap(a, b)\n\ta,b=b,a\nend", "def swap\n @store[-1], @store[-2] = @store[-2], @store[-1] if size > 1\n e...
[ "0.74067616", "0.6856741", "0.6777854", "0.66952354", "0.66248596", "0.65681833", "0.65625405", "0.65324557", "0.6490176", "0.647959", "0.6467112", "0.64135075", "0.64113086", "0.6370528", "0.6350168", "0.6333534", "0.62996495", "0.62827665", "0.62693894", "0.62676233", "0.62...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def case_params params.permit(:case_id, :opened, :closed, :updated, :status, :responsible_agency, :category, :request_type, :neighborhood, :request_detail, :address, :supervisor_district, :source, :media_url, :longitude, :latitude) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
Fixme: assumes there are four digits
def generate_expressions(digits, allow_permutations, stats) digit_sets = allow_permutations ? digits.permutation : [digits] digit_sets_examined = 0 stats.setProgressMax(digit_sets.count) if allow_permutations digit_sets.each do |operands| # These generators are hard to understand. # There really should be a more compact notation for this, which then gets intepreted to generate # the loop structure. And some systematic way of ensuring we generate all types of tree. # I *think* I have them all. # I expect to generate 25,000,000 expressions. # For each digit there are (typically) 5 monadic expressions # so the set of all binary expressions over two digits is about 4 * 5 * 5^2 ==> 500 # binary expressions on those binary expressions: 4 * 5 * 500**2 # 5 shapes of trees, thus # 5 * (4 * 5 * (4 * 5 * 5**2)**2) # The real count is higher, since monadic repeating decimal operator applies to digit 9 d = operands.map{|digit| monadic_expressions_over(Digit.new(digit))} expressions_over(d[0], d[1]).each {|b01| # ((0 1) (2 3)) expressions_over(d[2], d[3]).each {|b23| expressions_over(b01, b23).each {|expr| yield(expr)}} # (((0 1) 2) 3) expressions_over(b01, d[2]).each {|b012| expressions_over(b012, d[3]).each {|expr| yield(expr)}} } expressions_over(d[1], d[2]).each {|b12| # ((0 (1 2)) 3) expressions_over(d[0], b12).each {|b012| expressions_over(b012, d[3]).each {|expr| yield(expr)}} # (0 ((1 2) 3)) expressions_over(b12, d[3]).each {|b123| expressions_over(d[0], b123).each {|expr| yield(expr)}} } # (0 (1 (2 3))) expressions_over(d[2], d[3]).each {|b23| expressions_over(d[1], b23).each {|b123| expressions_over(d[0], b123).each {|expr| yield(expr)}}} if allow_permutations digit_sets_examined += 1 stats.setProgress(digit_sets_examined) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def four_digit_parse(num)\n thousands = get_high_order(num,1000)\n num = get_remainder(num, 1000)\n hundreds = get_high_order(num, 100)\n num = get_remainder(num, 100)\n tens = get_high_order(num, 10)\n ones = get_remainder(num, 10)\n \n print \"The number is #{thousands} \" + pluralize(\"thousand\", thou...
[ "0.669225", "0.6547947", "0.65456724", "0.6475431", "0.6473973", "0.6427469", "0.64254713", "0.6421952", "0.6401137", "0.6383441", "0.63727653", "0.6364286", "0.6364286", "0.6364286", "0.63332427", "0.63056356", "0.6268629", "0.6255269", "0.62336564", "0.6206928", "0.61829597...
0.0
-1
A list of all expressions formed by combining all (applicable) monadic operators composed over all binary operators applied to every pair of operands taken from the lists op1 and op2 so if there are two monadic operators, three binary operators, and five values in each op list, this yields (2 + 1) 3 (5^2) expressions The +1 for monadic is because we also consider the "empty" monadic operator
def expressions_over(op1, op2) expressions_over_lists( asArray(op1), asArray(op2)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def monadic_expressions_over(operand)\n [operand] + \n MONADIC_OPERATORS\n .select { |op| op.applies_to?(operand)}\n .map { |op| begin\n MonadicExpression.new(op, operand) \n rescue Noop\n nil\n rescue RangeError\n nil\n ...
[ "0.6867237", "0.6212024", "0.5921986", "0.591898", "0.58926755", "0.5830734", "0.5817509", "0.58133256", "0.5808993", "0.57697266", "0.5755693", "0.5722277", "0.5720798", "0.56983495", "0.56790954", "0.56329346", "0.56067294", "0.56031233", "0.5555522", "0.55297714", "0.55294...
0.66465163
1
Return a list of expressions formed by applying the allowable monadic operators to the operand plus the operand itself (the "null operator") In theory one could apply more than one monadic operator, e.q. Fact(Sqrt(x)) but this makes the tree of possible expressions so large that the program runs all night. I halted it after 231 million expressions.
def monadic_expressions_over(operand) [operand] + MONADIC_OPERATORS .select { |op| op.applies_to?(operand)} .map { |op| begin MonadicExpression.new(op, operand) rescue Noop nil rescue RangeError nil end } .reject(&:nil?) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_expressions(digits, allow_permutations, stats) \n digit_sets = allow_permutations ? digits.permutation : [digits]\n digit_sets_examined = 0\n stats.setProgressMax(digit_sets.count) if allow_permutations\n\n digit_sets.each do |operands|\n\n # These generators are hard to understand.\n # Ther...
[ "0.6183307", "0.59781975", "0.57654935", "0.55676866", "0.55665207", "0.55440825", "0.55084985", "0.5500781", "0.5497084", "0.5448849", "0.54296094", "0.5402332", "0.5375457", "0.53531563", "0.5342312", "0.5330277", "0.5320034", "0.5311668", "0.5289609", "0.5251222", "0.52474...
0.7350763
0
Return files changed between two revisions
def changes(start_ref, end_ref) check_refs(start_ref, end_ref) s = Mixlib::ShellOut.new( "#{@bin} diff -r #{start_ref}:#{end_ref} --summarize #{@repo_path}") s.run_command.error! @logger.info("Diff between #{start_ref} and #{end_ref}") s.stdout.lines.map do |line| m = line.match(/^(\w)\w?\s+(\S+)$/) fail "Could not parse line: #{line}" unless m { :status => m[1] == 'D' ? :deleted : :modified, :path => m[2].sub("#{@repo_path}/", '') } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def changed_files\n DeliveryTruck::Helpers.changed_files(\n DeliveryTruck::Helpers.pre_change_sha(node),\n node['delivery']['change']['sha'],\n node\n )\n end", "def modified_files\n @modified_files ||= begin\n @modified_files = []\n\n rewritten_commits.each d...
[ "0.70801616", "0.68968827", "0.68947685", "0.6869941", "0.6782023", "0.6774032", "0.6773821", "0.6751959", "0.67305547", "0.6655738", "0.6579029", "0.65502065", "0.65133965", "0.6482674", "0.6473766", "0.6441829", "0.64386743", "0.6427315", "0.6427313", "0.6412415", "0.635294...
0.6458959
15
Use callbacks to share common setup or constraints between actions.
def set_receipt @receipt = Receipt.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.61637366", "0.60446453", "0.59452957", "0.591511", "0.58885515", "0.5834122", "0.57761765", "0.5702554", "0.5702554", "0.5652102", "0.5619581", "0.5423898", "0.5409782", "0.5409782", "0.5409782", "0.5394745", "0.53780794", "0.5356209", "0.5338898", "0.53381324", "0.5328622...
0.0
-1
Only allow a trusted parameter "white list" through.
def receipt_params @current_resource ||= @receipt end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", ...
[ "0.7123669", "0.7054077", "0.69472784", "0.6902165", "0.6736001", "0.671985", "0.6687218", "0.6676269", "0.66602534", "0.6556639", "0.6527985", "0.645892", "0.645072", "0.64494324", "0.6445436", "0.64350927", "0.6415061", "0.6415061", "0.6393001", "0.6378958", "0.6378958", ...
0.0
-1
Convert large JSON response into arrays/chunks of 10.
def convert(array) until array.length == 0 @chunks << array.sort_by!{ |truck| truck['applicant']}.first(10).map{|truck| truck.slice('applicant', 'location')}.to_a array.shift(10) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def batch_responses\n return [@result] unless @batch_response\n # if batch response, generate array based on the response hash.\n @result.map do |r|\n next r unless r.is_a?(Hash)\n hash = r[SUCCESS] || r[ERROR]\n Parse::Response.new hash\n end\n end", "def process_arra...
[ "0.59811616", "0.59558254", "0.5901369", "0.58871496", "0.5602479", "0.5567825", "0.5539628", "0.5514828", "0.54927856", "0.5451389", "0.540583", "0.5390088", "0.53595155", "0.53228945", "0.532273", "0.53096205", "0.5305349", "0.5293844", "0.52906364", "0.52844715", "0.526719...
0.5670552
4
check if there are more arrays to display.
def more? return @chunks.length > @index end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_number_of_results(li_arr)\n puts \"#{@@info_indicate} start checking if displaying correct number of results\"\n if result_more_then_ten\n assert_true(li_arr.size == 10, 'display 10 results')\n else\n #result_more\n assert_true(li_arr.size == get_data_total_results, 'display all r...
[ "0.672121", "0.65720326", "0.6530486", "0.6490025", "0.63341045", "0.63048863", "0.6249209", "0.6247321", "0.61863405", "0.61532766", "0.6144648", "0.609044", "0.609044", "0.609044", "0.609044", "0.6055395", "0.6025056", "0.59906846", "0.59902745", "0.5977616", "0.59219855", ...
0.674918
0
Check if the array is empty after conversion.
def none? if @chunks.length == 0 puts "Currently no trucks are open." end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def empty?\r\n @arr.empty?\r\n end", "def empty?\n to_ary.empty?\n end", "def empty?\n to_ary.empty?\n end", "def empty?\n to_ary.empty?\n end", "def empty()\n @arr1.empty?\n end", "def empty?\n @ary.empty?\n end", "def is_empty?\n @array.length == 0\n...
[ "0.7993329", "0.79345655", "0.7884815", "0.7884815", "0.7629054", "0.7544183", "0.7517057", "0.7454431", "0.7434751", "0.7434751", "0.7396941", "0.7374533", "0.7374533", "0.7341111", "0.7340259", "0.7340259", "0.73232496", "0.7306677", "0.7306677", "0.7292096", "0.7278747", ...
0.0
-1
user enters numbers to perform the operation
def number_choice_one puts "Now I need two numbers to use with that operator." puts "Type your first number: " gets.chomp.to_i end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ask_for_digits\r\n puts (\"Calculator\").colorize(:white).on_green\r\n variables = []\r\n input = @@prompt.ask(\"Enter a number between 1000 and 9999 e.g. 1234:\") do |q|\r\n q.convert -> (input) { input.split(/[\\s]/) }\r\n q.convert(:integer, \"Invalid input. Try ag...
[ "0.7239452", "0.71706986", "0.7150562", "0.69894326", "0.69210535", "0.68584454", "0.68116164", "0.68047714", "0.67918", "0.6772298", "0.6743936", "0.6736919", "0.67128915", "0.6712295", "0.6676105", "0.66529185", "0.66207844", "0.65701485", "0.65654874", "0.654853", "0.65454...
0.6702041
14
GET /sub_pages/1 GET /sub_pages/1.xml
def show @sub_page = SubPage.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @sub_page } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @pages = @parent_page.children\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end", "def pages()\n get('subAccountPages')\n end", "def children\n @pages = @page.children\n \n respond_to do |format|\n fo...
[ "0.72068846", "0.715257", "0.65646464", "0.65645725", "0.6408162", "0.62554675", "0.62279344", "0.6179772", "0.61270034", "0.6123061", "0.6113616", "0.6111395", "0.6091797", "0.60798955", "0.60773814", "0.60725313", "0.60725313", "0.60721296", "0.6048122", "0.60423416", "0.60...
0.7120293
2
GET /sub_pages/new GET /sub_pages/new.xml
def new @sub_page = SubPage.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @sub_page } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @page = current_cms.pages.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end", "def new\n @page = Page.new\n @pagelist = @club.all_pages\n \n @page_title = \"New Page\"\n @site_section = \"admin\"\n respon...
[ "0.7165065", "0.713773", "0.7085673", "0.70592964", "0.70215845", "0.69940823", "0.6973551", "0.6936234", "0.6936234", "0.6936234", "0.6936234", "0.6936234", "0.6936234", "0.693501", "0.6904636", "0.6896742", "0.6847191", "0.68231136", "0.67439145", "0.6743006", "0.6735974", ...
0.79460514
0
POST /sub_pages POST /sub_pages.xml
def create @sub_page = SubPage.new(params[:sub_page]) respond_to do |format| if @sub_page.save flash[:notice] = 'SubPage was successfully created.' format.html { redirect_to(@sub_page) } format.xml { render :xml => @sub_page, :status => :created, :location => @sub_page } else format.html { render :action => "new" } format.xml { render :xml => @sub_page.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_pages(id, pages) \n pages = pages.join(',') if pages.class == Array\n args = {userId: id, pageNames: pages}\n post('addPagesToSubAccount', args)\n end", "def new\n @sub_page = SubPage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @su...
[ "0.6419191", "0.6394676", "0.6231377", "0.61369073", "0.6075933", "0.5990323", "0.5965374", "0.5949405", "0.5880902", "0.5877325", "0.5610576", "0.56070626", "0.5602966", "0.55958354", "0.55801505", "0.5517853", "0.55055743", "0.54989386", "0.5470284", "0.5464091", "0.5453202...
0.67531145
0
PUT /sub_pages/1 PUT /sub_pages/1.xml
def update @sub_page = SubPage.find(params[:id]) respond_to do |format| if @sub_page.update_attributes(params[:sub_page]) flash[:notice] = 'SubPage was successfully updated.' format.html { redirect_to(@sub_page) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @sub_page.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @page = @club.pages.find(params[:id])\n @page.parent_id = params[:page][:parent_id];\n @page.bns_parent_id = params[:page][:parent_id];\n respond_to do |format|\n if @page.update_attributes(params[:page])\n flash[:notice] = 'Pages was successfully updated.'\n format.html...
[ "0.66538674", "0.6374301", "0.6263887", "0.6128191", "0.58395606", "0.5837578", "0.5812582", "0.5807003", "0.57889163", "0.5778303", "0.57530296", "0.570161", "0.56945807", "0.56717265", "0.5669095", "0.5660106", "0.5650622", "0.56438977", "0.5627501", "0.5626581", "0.5625061...
0.705846
0
DELETE /sub_pages/1 DELETE /sub_pages/1.xml
def destroy @sub_page = SubPage.find(params[:id]) @sub_page.destroy respond_to do |format| format.html { redirect_to(sub_pages_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @page = @site.pages.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(@parent_page ? admin_site_page_children_url(@site, @parent_page) : admin_site_pages_url(@site)) }\n format.xml { head :ok }\n end\n end", "def delete_page(id)\n @c...
[ "0.66542834", "0.6579719", "0.65310705", "0.6527358", "0.6452424", "0.64117056", "0.6409808", "0.6403431", "0.6360175", "0.6356223", "0.635612", "0.6355506", "0.6317574", "0.63160235", "0.63054866", "0.6296355", "0.6276913", "0.62293005", "0.6210424", "0.6199175", "0.6158371"...
0.7494161
0
Resets the state of the lazy seq. It also calculates any values necessary to get to the offset.
def reset @index = @list.size @cycles = 0 until @list.size >= @offset @list[@index] = @block.call(@list[0..@index-1]) @index += 1 end @index = @offset end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset\n @offset = 0\n end", "def reset(offset = T.unsafe(nil)); end", "def reset\n @current = nil\n @pos = 0\n end", "def reset\n clear\n @position = 0\n @current_index = 0\n end", "def reset\n @index = 0\n @page = 0\n @done = false\n @it...
[ "0.7630092", "0.6880304", "0.6750494", "0.6656298", "0.65884566", "0.65464085", "0.6490764", "0.6470659", "0.6455761", "0.6445606", "0.64419395", "0.6421018", "0.64168435", "0.6367011", "0.6310798", "0.6304099", "0.62968", "0.6280896", "0.6267996", "0.6267996", "0.6244317", ...
0.65702015
5
GET /past_situations GET /past_situations.json
def index @past_situations = PastSituation.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_past_situation\n @past_situation = PastSituation.find(params[:id])\n end", "def past_events\n @events = Event.past\n render json: @events, include: :talks\n end", "def create\n @past_situation = PastSituation.new(past_situation_params)\n\n respond_to do |format|\n if @past_sit...
[ "0.71123224", "0.6358307", "0.631593", "0.6245952", "0.6199012", "0.6122147", "0.6104118", "0.6058148", "0.60443306", "0.59726644", "0.59401417", "0.5908692", "0.5877071", "0.578168", "0.57623214", "0.57385457", "0.5723461", "0.57019526", "0.56656766", "0.5647596", "0.5617807...
0.77810466
0
GET /past_situations/1 GET /past_situations/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @past_situations = PastSituation.all\n end", "def set_past_situation\n @past_situation = PastSituation.find(params[:id])\n end", "def show\n @situation = Situation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @si...
[ "0.7617927", "0.71732724", "0.65732044", "0.655207", "0.6462132", "0.63810754", "0.6209056", "0.61987686", "0.61135846", "0.60549086", "0.60342824", "0.59773225", "0.5950295", "0.58833987", "0.58579475", "0.58474106", "0.58203053", "0.57965", "0.5775378", "0.5772737", "0.5727...
0.0
-1
POST /past_situations POST /past_situations.json
def create @past_situation = PastSituation.new(past_situation_params) respond_to do |format| if @past_situation.save format.html { redirect_to @past_situation, notice: 'Past situation was successfully created.' } format.json { render :show, status: :created, location: @past_situation } else format.html { render :new } format.json { render json: @past_situation.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_past_situation\n @past_situation = PastSituation.find(params[:id])\n end", "def past_situation_params\n params.require(:past_situation).permit(:description, :user_id)\n end", "def index\n @past_situations = PastSituation.all\n end", "def create\n @situation = Situation.new(para...
[ "0.7423822", "0.7117671", "0.70603263", "0.64310116", "0.6362527", "0.6341794", "0.6092197", "0.6075382", "0.6036277", "0.6008453", "0.598957", "0.59537876", "0.5731824", "0.57179224", "0.5685904", "0.5679596", "0.56677705", "0.56274945", "0.5614295", "0.55751234", "0.5572218...
0.75827616
0
PATCH/PUT /past_situations/1 PATCH/PUT /past_situations/1.json
def update respond_to do |format| if @past_situation.update(past_situation_params) format.html { redirect_to @past_situation, notice: 'Past situation was successfully updated.' } format.json { render :show, status: :ok, location: @past_situation } else format.html { render :edit } format.json { render json: @past_situation.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @situation = Situation.find(params[:id])\n\n respond_to do |format|\n if @situation.update_attributes(params[:situation])\n format.html { redirect_to @situation, notice: 'Situation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html...
[ "0.6756361", "0.6724483", "0.6711735", "0.65681595", "0.65236115", "0.63681066", "0.6364969", "0.6027219", "0.6008288", "0.59555966", "0.59212327", "0.5874874", "0.58506304", "0.5843922", "0.58356446", "0.5801507", "0.57274556", "0.57160074", "0.57113504", "0.5685895", "0.568...
0.74254584
0
DELETE /past_situations/1 DELETE /past_situations/1.json
def destroy @past_situation.destroy respond_to do |format| format.html { redirect_to past_situations_url, notice: 'Past situation was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @past_request.destroy\n respond_to do |format|\n format.html { redirect_to past_requests_url, notice: 'Past request was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @situation = Situation.find(params[:id])\n @situation.destroy\...
[ "0.7120398", "0.70963895", "0.70963895", "0.68958426", "0.68176585", "0.66141725", "0.6573365", "0.65576863", "0.65498364", "0.6543546", "0.65308744", "0.65197456", "0.651862", "0.650545", "0.6503611", "0.6457301", "0.6432992", "0.6382226", "0.6381835", "0.63603157", "0.63569...
0.76303494
0
Use callbacks to share common setup or constraints between actions.
def set_past_situation @past_situation = PastSituation.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.61642385", "0.60448", "0.5945487", "0.5915654", "0.58890367", "0.58330417", "0.5776098", "0.5703048", "0.5703048", "0.5654613", "0.5620029", "0.5423114", "0.540998", "0.540998", "0.540998", "0.5393666", "0.53783023", "0.53568405", "0.53391176", "0.5339061", "0.53310865", ...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def past_situation_params params.require(:past_situation).permit(:description, :user_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
output: the input array with vowels removed (a, e, i, o, u) Rules Explicit requirements the input will be an array remove the vowels (a,e,i,o,u) from the input string Implicit requirements modify the original array(?) assume no Test Cases remove_vowels(%w(abcdefghijklmnopqrstuvwxyz)) == %w(bcdfghjklmnpqrstvwxyz) remove_vowels(%w(green YELLOW black white)) == %w(grn YLLW blck wht) remove_vowels(%w(ABC AEIOU XYZ)) == ['BC', '', 'XYZ'] Algorithm take the input array and use map to iterate over the string elements for each iteration, remove the vowels from the string and return the new string value return the return value of map Tips use gsub(/[aeiou]/, '')
def remove_vowels(arr) arr.map { |string| string.gsub(/[aeiou]/i, '') } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_vowels(string_array)\n string_array.map { |string| string.gsub(/[aeiou]/i, \"\") }\nend", "def remove_vowels(array)\n array.map { |string| string.gsub(/[aeiouAEIOU]/, \"\") }\nend", "def remove_vowels(arr)\n arr.map do |str|\n str.gsub(/[AEIOUaeiou]/,'')\n end\nend", "def remove_vowels(arra...
[ "0.8463791", "0.83881456", "0.8316745", "0.8280287", "0.82540345", "0.82362205", "0.8204978", "0.8201672", "0.8196874", "0.8181852", "0.81672996", "0.8162539", "0.8151119", "0.81474185", "0.8146728", "0.814473", "0.8129624", "0.81218684", "0.8105749", "0.8070679", "0.80702245...
0.84462726
1
CMSC 330 Project 1 Name: Stewart Valencia FUNCTION DECLARATIONS Parse takes in a a standard maze file and converts it into Simple maze format
def parse(file) line = file.gets if line == nil then return end #Invalid stores invalid line and valid stores valid lines invalid = Array.new valid = Array.new #i is used as a counter of invalid and j of valid i = 0 j = 0 #Makes sure it has these in the lines if (line !~ /^(maze:) / )&& (line !~ /(:){3}/) && (line !~ /(->)/) #Will do this everytime it's invalid puts "invalid maze" invalid[i] = line i += 1 else # read 1st line, must be maze header m, sz, start, arrow, ends = line.split(/\s/,5) #Makes sure it matches numbers if (sz =~ /[^0-9]/) && (start =~ /[^0-9:]/) && (ends =~ /[^0-9:]/) puts "invalid maze" invalid[i] = line i+=1 else start[":"] = " " ends[":"] = " " #valid will only be used when there's no invalid lines if i == 0 valid[j] ="#{sz} " + start + " " + ends j += 1 end end end # read additional lines while line = file.gets do # begins with " and ends with ", must be path specification if line =~ /"/ #Must only have letters, semicolon, and numbers if (line =~ / /) || (line !~ /[:A-Za-z0-9]/) || (line !~ /"$/) if i == 0 puts "invalid maze" #Will only print this if it wasn't already is end invalid[i] = line i += 1 else #Will try to split each paths with ", pathways = line.split(/\",/) #Will try to parse each path pathways.each{ |paths| if (paths =~ /:{2}/) || (paths =~ /(,,)/) if i == 0 puts "invalid maze" end invalid[i] = line i += 1 break else half1, half2 = paths.split(/:/, 2) half2.chop! half2.chomp!("\"") if (half2 =~ /[:-]/) || (half2 =~ /"/) if i == 0 puts "invalid maze" end invalid[i] = line i += 1 break end #Will delete stuff that isn't necessary paths.delete!(":") paths.gsub!(/[,(]/, " ") part1, part2 = paths.split(/[)]/) part1[0] = "" part1.gsub!("\\\"", "\"") part2.delete!("\"") part2.delete!(" ") if part2 =~ /[A-Za-ce-km-qstv-z]/ if i == 0 puts "invalid maze" end invalid[i] = line i += 1 break end if i == 0 valid[j] = "path "+ part1 +" "+ part2 j += 1 end end } end # otherwise must be cell specification (since maze spec must be valid) else cell, directions, weights = line.split(/\s/,3) #Make sure it's in this format if (line !~ /^(\d+)+(,)+(\d+)+:+\s+([udlr]+|\s)+\s/) && (weights !~ /0-9.,/) if i == 0 puts "invalid maze" end invalid[i] = line i += 1 else #Clear these withfaces cell[","] = " " cell[":"] = " " if weights == nil weights = " " else weights = weights.gsub(/,/, " ") #sub commas for spaces end if i == 0 valid[j] = cell + directions +" " +weights j += 1 end end end end #Will print valid only if invalid is empty if i > 0 puts invalid else puts valid end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse(file)\n line = file.gets\r\n if line == nil then return end\r\n counter = 0\r\n increase = 0\r\n \r\n # read 1st line, must be maze header, check if valid\r\n if line !~ /^maze:\\s([\\d]+)\\s([\\d]+):([\\d]+)\\s->\\s([\\d]+):([\\d]+)$/\r\n if $tag\r\n $invalid[increase] =...
[ "0.70719707", "0.6785249", "0.6747017", "0.6478495", "0.63345665", "0.6276175", "0.60227174", "0.59872305", "0.5931315", "0.58391505", "0.56799436", "0.5661832", "0.56243813", "0.55833834", "0.55612993", "0.55447763", "0.55209523", "0.5382925", "0.5382925", "0.5382925", "0.53...
0.68140304
1
the following is a parser that reads in a simpler version of the maze files. Use it to get started writing the rest of the assignment, if you like. You can feel free to move or modify this function however you like in working on your assignment.
def read_and_print_simple_file(file) line = file.gets if line == nil then return end # read 1st line, must be maze header sz, sx, sy, ex, ey = line.split(/\s/) puts "header spec: size=#{sz}, start=(#{sx},#{sy}), end=(#{ex},#{ey})" # read additional lines while line = file.gets do # begins with "path", must be path specification if line[0...4] == "path" ws = w.split(/\s/) ws.each {|w| puts " weight #{w}"} puts "path spec: #{name} starts at (#{x},#{y}) with dirs #{ds}" # otherwise must be cell specification (since maze spec must be valid) else x, y, ds, w = line.split(/\s/,4) puts "cell spec: coordinates (#{x},#{y}) with dirs #{ds}" ws = w.split(/\s/) ws.each {|w| puts " weight #{w}"} end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse(file)\n line = file.gets\n if line == nil then return end\n #Invalid stores invalid line and valid stores valid lines\n invalid = Array.new\n valid = Array.new\n #i is used as a counter of invalid and j of valid\n i = 0\n j = 0\n \n #Makes sure it has these in the lines\n if (line !~ /^(maz...
[ "0.79976064", "0.79490626", "0.7444323", "0.71838504", "0.6848978", "0.6821851", "0.66929847", "0.6561786", "0.64910114", "0.640432", "0.6330116", "0.629528", "0.6123282", "0.600357", "0.5948941", "0.5945685", "0.57799745", "0.57275724", "0.57245666", "0.57245666", "0.5722149...
0.6741257
6
create maze will create a maze from the file
def create_maze(file) line = file.gets if line == nil then return end # read 1st line, must be maze header sz, sx, sy, ex, ey = line.split(/\s/) #course is the maze course @course = Array.new(sz.to_i) @course.map!{Array.new(sz.to_i)} @course[sx.to_i][sy.to_i] = Cell.new(sx.to_i, sy.to_i) @start_x = sx.to_i @start_y = sy.to_i @course[sx.to_i][sy.to_i].change_mode("Start") @course[ex.to_i][ey.to_i] = Cell.new(ex.to_i, ey.to_i) @end_x = ex.to_i @end_y = ey.to_i @course[ex.to_i][ey.to_i].change_mode("End") @paths = Array.new # read additional lines while line = file.gets do # begins with "path", must be path specification if line[0...4] == "path" p, name, x, y, d = line.split(/\s/) ds = d.split(//) temp = Path.new(nil, nil, nil, nil) temp.initialize(name, x.to_i, y.to_i, ds) @paths.push(temp) # otherwise must be cell specification (since maze spec must be valid) else x, y, d, w = line.split(/\s/,4) if @course[x.to_i][y.to_i] == nil @course[x.to_i][y.to_i] = Cell.new(x.to_i,y.to_i) end ds = d.split(//) ws = w.split(/\s/) (0...ds.size).each { |i| @course[x.to_i][y.to_i].new_direction(ds[i], ws[i])} end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse(file)\n line = file.gets\n if line == nil then return end\n #Invalid stores invalid line and valid stores valid lines\n invalid = Array.new\n valid = Array.new\n #i is used as a counter of invalid and j of valid\n i = 0\n j = 0\n \n #Makes sure it has these in the lines\n if (line !~ /^(maz...
[ "0.6679669", "0.6581515", "0.6552489", "0.65433854", "0.6469093", "0.63532436", "0.6295988", "0.62710226", "0.6258575", "0.61091346", "0.6062021", "0.6035284", "0.60067374", "0.59285074", "0.5915203", "0.5913335", "0.5873624", "0.5747137", "0.56624186", "0.56517416", "0.56443...
0.8010126
0
These are just getter methods for the Maze class
def path_arr() return @paths end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize\n @start_vertical = nil\n @start_horizontal = nil\n @processed_maze = nil\n end", "def fullmaze\n\t\ttopbottom = \"+-\" * @width + \"+\"\n\t\tmiddle = \"|\" + \" |\" * @width\n\t\treturn topbottom + (middle + topbottom) * @height\n\tend", "def redesign\r\n\t\tm = MazeMaker.new(@n,@m)\r...
[ "0.62905574", "0.60333776", "0.5790398", "0.5762651", "0.57577646", "0.57577646", "0.57577646", "0.57577646", "0.57577646", "0.57577646", "0.57100964", "0.56899786", "0.56795615", "0.566857", "0.56506383", "0.564854", "0.56472", "0.5645049", "0.56377506", "0.56377506", "0.563...
0.0
-1
Closed checks which rooms are closed
def closed(file) line = file.gets rooms = 0 if line == nil then return end size, sx, sy, ex, ey = line.split(/\s/) rooms = size.to_i*size.to_i while line = file.gets do if line[0...4] != "path" # checks for lines that do have these open walls if line =~ /[lurd]/ rooms-= 1 end end end puts rooms end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_closed?(timeslot)\n !self.is_open?(timeslot)\n end", "def other_side_closed\n room = $manager.find @container\n @open = false\n room.output \"The #{@generic} closes.\"\n end", "def closed?\n state == \"closed\"\n end", "def closed?\n status == 'closed'\n end", "def closed?\n ...
[ "0.66574323", "0.6636437", "0.62771755", "0.6270062", "0.6259675", "0.62453717", "0.6234344", "0.6224798", "0.6224643", "0.6220455", "0.62017137", "0.6200209", "0.6194015", "0.6183311", "0.618163", "0.61430216", "0.61404836", "0.6120383", "0.6098952", "0.6098952", "0.60802466...
0.5856118
55
Opens checks which rooms are open
def opens(file) line = file.gets ups = 0 downs = 0 lefts = 0 rights = 0 if line == nil then return end while line = file.gets do if line[0...4] != "path" # check for each letter and adds it to letter count if line =~ /[u]/ ups+= 1 end if line =~ /[d]/ downs+= 1 end if line =~ /[l]/ lefts+= 1 end if line =~ /[r]/ rights+= 1 end end end puts "u: #{ups}, d: #{downs}, l: #{lefts}, r: #{rights}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def opens\n if open_status == true || unlocked_status == false\n raise ArgumentError.new(\"You cannot open a door that is already open or locked!\")\n else\n door_hash[:open_status] = true\n end\n end", "def other_side_opened\n room = $manager.find @container\n @open = true\n room.ou...
[ "0.6918005", "0.6460691", "0.6353031", "0.6275771", "0.62058157", "0.6158698", "0.6140789", "0.611116", "0.60607344", "0.60473156", "0.6013684", "0.59955746", "0.59928817", "0.59897053", "0.59480447", "0.59410584", "0.59325486", "0.5919292", "0.5869313", "0.5863236", "0.58337...
0.0
-1
Rooms check which nowalls rooms are connected and the size of them
def room(file) line = file.gets rooms = 0 if line == nil then return end sz, sx, sy, ex, ey = line.split(/\s/) size = sz.to_i #Course will represents cells #These cells will repsents if it's open or not course = Array.new(size) course.map!{Array.new(size, "No")} #find_open_rooms will be a recursive method that counts #each open room connected each other def find_open_rooms(x, y, course) temp = 0 if (course[x][y] != "Yes") return 0 else #Makes sure it marks as Counted course[x][y] = "Counted" temp+=1 if x != 0 temp += find_open_rooms(x-1, y, course) end if x != course.size-1 temp += find_open_rooms(x+1, y, course) end if y != 0 temp += find_open_rooms(x, y-1, course) end if y != course.size-1 temp += find_open_rooms(x, y+1, course) end return temp end end while line = file.gets do #Only looks at cell specifications if line[0...4] != "path" x, y, directions, w = line.split(/\s/,4) # checks if all below is true if (directions !~ /[A-Za-ce-km-qstv-z]/ && directions.size == 4) if (x.to_i != 0 && y.to_i != 0 && y.to_i != size-1 && x.to_i != size-1) if directions =~ /l/ if directions =~ /u/ if directions =~ /r/ if directions =~ /d/ course[x.to_i][y.to_i] = "Yes" end end end end end end end end #Will go through each room and counts near open cells (1...size-2).each{|x| (1...size-2).each{ |y| sum = find_open_rooms(x,y,course) if sum > rooms rooms = sum end } } puts rooms end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_rooms\n room_count = 0\n rooms = Array.new(@width)\n rooms.each_index() do |index|\n rooms[index] = Array.new(@height, 0)\n end\n @map.each_index() do |x|\n @map[x].each_index() do |y|\n if(!is_solid?(x, y) && rooms[x][y] == 0)\n room_count += 1\n flood_f...
[ "0.68814766", "0.68128604", "0.65847117", "0.6574085", "0.64681286", "0.629629", "0.6287625", "0.6276685", "0.6267227", "0.62613356", "0.6250152", "0.6246719", "0.62357056", "0.61711884", "0.615951", "0.6143267", "0.61134136", "0.6109113", "0.60338074", "0.6009083", "0.595801...
0.58835346
30
find_open_rooms will be a recursive method that counts each open room connected each other
def find_open_rooms(x, y, course) temp = 0 if (course[x][y] != "Yes") return 0 else #Makes sure it marks as Counted course[x][y] = "Counted" temp+=1 if x != 0 temp += find_open_rooms(x-1, y, course) end if x != course.size-1 temp += find_open_rooms(x+1, y, course) end if y != 0 temp += find_open_rooms(x, y-1, course) end if y != course.size-1 temp += find_open_rooms(x, y+1, course) end return temp end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_rooms\n room_count = 0\n rooms = Array.new(@width)\n rooms.each_index() do |index|\n rooms[index] = Array.new(@height, 0)\n end\n @map.each_index() do |x|\n @map[x].each_index() do |y|\n if(!is_solid?(x, y) && rooms[x][y] == 0)\n room_count += 1\n flood_f...
[ "0.6536642", "0.6517919", "0.61310875", "0.5849586", "0.5839352", "0.5813837", "0.57657665", "0.5745814", "0.57366186", "0.5680168", "0.56243664", "0.5582815", "0.5571131", "0.5564992", "0.55153036", "0.55023515", "0.5481043", "0.547959", "0.54329115", "0.54265726", "0.541282...
0.7179136
0
Will find paths that can be used and prints them out sorted in cost
def paths_list(file) maze = Maze.new maze.create_maze(file) pathways = Hash.new my_paths = maze.path_arr() my_course = maze.get_course if my_paths.size == 0 puts "None" end (0...my_paths.size).each {|i| sum = 0 temp = my_paths[i] location_x = temp.get_x location_y = temp.get_y my_directions = temp.get_directions (0...my_directions.size).each{ |counter| move = my_directions[counter] current = my_course[location_x][location_y] the_weight = current.get_directions sum+= the_weight[move] if move =~ /[u]/ location_y-= 1 end if move =~ /[d]/ location_y+= 1 end if move =~ /[l]/ location_x-= 1 end if move =~ /[r]/ location_x+= 1 end } pathways[temp.get_name] = sum } sorted_list = pathways.sort {|a,b| a[1]<=>b[1]} (0...sorted_list.size).each{ |i| if i == sorted_list.size-1 print sorted_list[i][0] else print sorted_list[i][0]+", " end } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solver(flights)\n (p all_paths(flights)).min_by { |path| cost_of_path(path) }\nend", "def min_cost(costs)\n prev_color_path1 = 0\n prev_color_path2 = 1\n path1 = costs[0][prev_color_path1]\n path2 = costs[0][prev_color_path2]\n \n if costs[0][2] < path1\n if path1 < path2\n ...
[ "0.6331068", "0.6287477", "0.6103588", "0.6022337", "0.59359884", "0.5863342", "0.58402133", "0.5837982", "0.57899207", "0.5751737", "0.5743422", "0.5724431", "0.56606597", "0.5645837", "0.56349003", "0.562751", "0.5612622", "0.56069815", "0.5606357", "0.55798185", "0.5564722...
0.6518968
0
Will just pretty print out the simple maze It prints every three lines as they represents cells So it prints each row
def print_maze(file) maze = Maze.new maze.create_maze(file) my_course = maze.get_course total_length = (my_course.size*2)+2 print_output = Array.new(total_length) (0...my_course.size).each{ |y| top = "+" middle = "|" bottom = "+" (0...my_course.size).each{ |x| if my_course[x][y] != nil my_directions = my_course[x][y].get_directions else my_directions = Hash.new(nil) end if x != my_course.size-1 && my_course[x+1][y] != nil my_directions2 = my_course[x+1][y].get_directions else my_directions2 = Hash.new(nil) end if y != my_course.size-1 && my_course[x][y+1] != nil my_directions3 = my_course[x][y+1].get_directions else my_directions3 = Hash.new(nil) end if my_course[x][y] != nil case my_course[x][y].get_mode when "Start" middle += "s" when "End" middle += "e" else middle += " " end else middle += " " end if x != my_course.size-1 && !my_directions.empty? if my_directions.has_key?("r") middle += " " else middle += "|" end else middle += "|" end if y != my_course.size-1 && !my_directions.empty? if my_directions.has_key?("d") bottom+= " +" else bottom += "-+" end else bottom += "-+" end top += "-+" } if y == 0 puts top end puts middle puts bottom } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_maze\n # Special handling: print the top line.\n puts @columns.times.inject(\"+\") {|str, x| str << \"---+\" }\n\n # For each cell, print the right and bottom wall, if it exists.\n @rows.times do |y|\n line = @columns.times.inject(\"|\") do |str, x|\n str <...
[ "0.83364797", "0.82598066", "0.7985972", "0.78948337", "0.77928185", "0.77928185", "0.77541333", "0.7665795", "0.76403904", "0.7631494", "0.7577084", "0.7538794", "0.7506433", "0.74530387", "0.73205227", "0.73205227", "0.73042214", "0.7276174", "0.72486633", "0.7232458", "0.7...
0.73822373
14
solve will use breadth first search to see if a maze is solvable
def solve(file) maze = Maze.new maze.create_maze(file) my_course = maze.get_course solution = Array.new solution.push(maze.get_start) sol = 0 while !solution.empty? temp = solution.pop if temp.get_mode == "End" sol = 1 end if !temp.get_directions.empty? && temp.get_mode != "flag" temp.change_mode("flag") if temp.get_directions.has_key?("u") && temp.get_y != 0 solution.push(my_course[temp.get_x][temp.get_y-1]) end if temp.get_directions.has_key?("d") && temp.get_y != my_course.size-1 solution.push(my_course[temp.get_x][temp.get_y+1]) end if temp.get_directions.has_key?("l") && temp.get_x != 0 solution.push(my_course[temp.get_x-1][temp.get_y]) end if temp.get_directions.has_key?("r") && temp.get_x != my_course.size-1 solution.push(my_course[temp.get_x+1][temp.get_y]) end end end if sol == 0 puts "false" else puts "true" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solve\n traverse maze.cell_at(0,0)\n maze\n end", "def solve(begX, begY, endX, endY); MazeSolver.new(plane,graph).solve(begX, begY, endX, endY) end", "def solve\r\n matrix = @maze\r\n finished = false\r\n\r\n start = Discovered.new(@starting_point[:x],@starting_point[:y],nil)\r\n f...
[ "0.8301563", "0.779876", "0.77496237", "0.77233315", "0.74082357", "0.73738074", "0.7371906", "0.7217091", "0.7179009", "0.6947015", "0.69214106", "0.6912705", "0.68520105", "0.6782293", "0.6749021", "0.6692386", "0.66413796", "0.6533767", "0.64892745", "0.6459825", "0.642877...
0.712743
9
Cookbook Name:: serverdensity Provider:: default
def whyrun_supported? true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def define_suits\n [{ 'name' => 'default',\n 'run_list' => [\"recipe[#{@cookbook}::default]\"],\n 'attributes' => 'nil' }]\n end", "def render_defaults\n template '/etc/default/haproxy' do\n cookbook 'consul-haproxy'\n source 'haproxy_defaults.erb'\n mode '0644'\n act...
[ "0.57736444", "0.57661384", "0.5720701", "0.569794", "0.56869066", "0.56248313", "0.56086606", "0.5535494", "0.553136", "0.54637915", "0.5435965", "0.5422934", "0.5422819", "0.5397542", "0.5384478", "0.5378592", "0.5352528", "0.5339167", "0.5335042", "0.533063", "0.53298277",...
0.0
-1
this should be overridden for each specific type of file class
def setup_class_info @file_model = nil @resource_assoc = :generic_files end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def files_for(klass); end", "def file_type_class\n self.file_type.downcase.split.join('-') + '-file'\n end", "def file_class\n @file_class ||\n if superclass.respond_to?(:file_class)\n superclass.file_class\n else\n ::Gollum::File\n end\n end", ...
[ "0.75069284", "0.7451649", "0.7346521", "0.69549996", "0.6806763", "0.6806763", "0.6806763", "0.6806763", "0.6806763", "0.6806763", "0.6806763", "0.6806763", "0.6806763", "0.6806763", "0.6806763", "0.6796876", "0.6796876", "0.6796876", "0.6796876", "0.6796876", "0.6796876", ...
0.6768596
21
This used to be only for manifests, but now destroys both manifest and upload files
def destroy_manifest respond_to do |format| format.html do @file.smart_destroy! render plain: 'OK' end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cleanup_files(resource)\n remove_public_dir(resource) # where the local manifest file is stored\n remove_s3_data_files(resource)\n rescue StandardError => e\n msg = \"An unexpected error occurred when cleaning up files for resource #{resource.id}: \"\n msg << e.full_message\n ...
[ "0.6911415", "0.6702488", "0.65736127", "0.65240616", "0.6458586", "0.6453229", "0.6395846", "0.6392707", "0.63749045", "0.63527715", "0.63398063", "0.6335296", "0.6335296", "0.63269764", "0.62997407", "0.6290601", "0.6289396", "0.62476707", "0.62287134", "0.6214924", "0.6208...
0.6582711
2
quick start guide for setup because the bucket needs to be set a certain way for CORS, also This example based on
def presign_upload render plain: hmac_data, status: :ok end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_me\r\n bucket_name = 'doc-example-bucket'\r\n allowed_methods = %w[GET PUT POST DELETE]\r\n allowed_origins = %w[http://www.example.com]\r\n allowed_headers = %w[*]\r\n expose_headers = %w[x-amz-server-side-encryption x-amz-request-id x-amz-id-2]\r\n max_age_seconds = 3000\r\n region = 'us-west-2'\r...
[ "0.7941364", "0.6709744", "0.6668508", "0.66292477", "0.6519559", "0.6517356", "0.64682627", "0.642347", "0.6403792", "0.63930297", "0.6374707", "0.63069886", "0.6298175", "0.6281615", "0.6230247", "0.6215177", "0.6208396", "0.6176992", "0.6173278", "0.6166212", "0.6153658", ...
0.0
-1
set the resource correctly per action
def resource @resource ||= if %w[destroy_error destroy_manifest].include?(params[:action]) @file_model.find(params[:id]).resource else Resource.find(params[:resource_id]) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_resource\n @resource = Resource.find(params[:id])\n end", "def set_resource\n @resource = Resource.find(params[:id])\n end", "def set_resource\n @resource = Resource.find(params[:id])\n end", "def set_resource\n @resource = Resource.find(params[:id])\n end", "def set_resource\n @...
[ "0.7142925", "0.7142925", "0.7142925", "0.7142925", "0.7142925", "0.7142925", "0.7126735", "0.7126735", "0.7126735", "0.7126735", "0.7126735", "0.7126735", "0.7126735", "0.7126735", "0.7126735", "0.7126735", "0.7126735", "0.7126735", "0.7068282", "0.70447886", "0.7025966", ...
0.0
-1
king = pieces.where(piece_type: "King", color: color).take pieces.where(color: opposing_color(color)).any? do |p| p.valid_move?(king.x_position, king.y_position)
def remove! update_attributes(x_position: nil, y_position: nil) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check?(player_color)\n all_pieces = pieces\n current_king = all_pieces.select { |piece| piece.is_a?(King) && piece.color_eql?(player_color) }.first\n enemy_pieces = all_pieces.select { |piece| piece.color_opposite?(player_color) }\n enemy_pieces.any? do |piece|\n piece.valid_moves.include?(cur...
[ "0.78338444", "0.78181213", "0.7808819", "0.78070873", "0.7795153", "0.76853466", "0.7560291", "0.749485", "0.7411411", "0.7402315", "0.7376694", "0.7316257", "0.7295266", "0.72000694", "0.71648246", "0.7108869", "0.7108157", "0.7076404", "0.70724535", "0.7043888", "0.7008024...
0.0
-1
Simple Wrapper commenting style. Example : This is a sample comment
def style_it(comment_lines) max_length = max_line_length comment_lines min_whitespace = min_whitespace comment_lines #Builds the opening of the comment section. Maintaining leading whitespace. opening = "#{min_whitespace}#{@options[:literal]}#{build(max_length + 5) unless @options[:semi]}\n" #Adds special styles to the comment lines. #Lines with different # indentations are aligned together. #However, the actual indentation is retained. #For example : # # Main comment # # Sub comment #Changes to : # # Main comment # # Sub comment comment_lines.map! do |line| leading_whitespace = line[/^[\t\s]+/] || "" line = line.sub(@options[:literal],'').lstrip.chomp line = "#{min_whitespace}#{@options[:literal]} #{leading_whitespace.sub(min_whitespace,'')}#{line}" end #Builds closing section of the comments. closing = "#{min_whitespace}#{@options[:literal]}#{build(max_length + 5)}\n" [opening, ensure_newlines(comment_lines), closing].join end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def comment(string); end", "def comment(string); end", "def comment(string); end", "def comment(string); end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", ...
[ "0.79219633", "0.79219633", "0.79219633", "0.79219633", "0.7634553", "0.7634553", "0.7634553", "0.7634553", "0.7634553", "0.7634553", "0.7634553", "0.7634553", "0.7634553", "0.7634553", "0.7634553", "0.7634553", "0.7634553", "0.7634553", "0.7634553", "0.7634553", "0.7634553",...
0.0
-1
def self.exclude_from_json sup = super [:node_id].concat(sup) end
def before_save self.available = true if self.available.nil? super end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def as_json(options={})\n\toptions[:except] ||= [:id, :chat_id]\n super\n end", "def excluded_node_list\n config[\"nodes\"] ? config[\"nodes\"][\"exclude\"] : []\n end", "def exclude; end", "def excluded; end", "def as_json(options={})\n exclusion_list = []\n exclusion_list += ConfigCenter::D...
[ "0.68015647", "0.6628223", "0.64138216", "0.6355162", "0.63349515", "0.6263501", "0.6211047", "0.61971116", "0.6108778", "0.61080074", "0.61080074", "0.61080074", "0.6056679", "0.6034011", "0.6024915", "0.5994473", "0.59793895", "0.5935263", "0.5933223", "0.591099", "0.590419...
0.0
-1
Create a new NFA state and return its index
def new_state() @state_counter += 1 return @state_counter end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index_state(index)\r\n @state[index]\r\n end", "def new_state\n newID = @@nextID\n @@nextID += 1\n @state[newID] = true\n @transition[newID] = {}\n newID \n end", "def new_state\n newID = @@nextID\n @@nextID += 1\n @state[newID] = true\n ...
[ "0.668923", "0.62340784", "0.62340784", "0.62340784", "0.61017436", "0.6090627", "0.6046317", "0.60184443", "0.59342545", "0.5825408", "0.58164036", "0.5783588", "0.57379735", "0.5694856", "0.5668974", "0.56403637", "0.5626782", "0.56104034", "0.5603496", "0.5552091", "0.5542...
0.6984496
0
Helper method to expand the lambda transition table to the given size to allow indexing to work properly.
def expand_lambda(row, col) (row - @lambda_table.size + 1).times do |r| @lambda_table << [] end @lambda_table.each.with_index do |table_row, row_index| (col - @lambda_table[row_index].size + 1).times do |c| table_row << 0 end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def expand_transition_table(row)\n (row - @transition_table.size + 1).times do |r|\n @transition_table << {}\n end\n end", "def index(key, size)\n if @items[key.sum % size] && @items[key.sum % size].key != key\n resize\n key.sum % size\n else\n key.sum % size\n end\n end", ...
[ "0.61998117", "0.55568904", "0.5463833", "0.5463833", "0.5389041", "0.5371754", "0.5217718", "0.51464075", "0.50386983", "0.4940363", "0.488287", "0.48804033", "0.4879019", "0.48709714", "0.4868018", "0.48530996", "0.48530996", "0.48488143", "0.48488143", "0.482632", "0.47989...
0.69317764
0
Helper method to expand the character transition table to the given size to allow indexing to work properly.
def expand_transition_table(row) (row - @transition_table.size + 1).times do |r| @transition_table << {} end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_size!(size) \n @transforms << SIZES[size]\n self \n end", "def expand_tabs(n=8)\n n = n.to_int\n raise ArgumentError, \"n must be >= 0\" if n < 0\n return gsub(/\\t/, \"\") if n == 0\n return gsub(/\\t/, \" \") if n == 1\n str = self.dup\n while\n str.gsub...
[ "0.5698663", "0.54605854", "0.54605854", "0.5347712", "0.53115046", "0.52487564", "0.52487564", "0.5203234", "0.51869816", "0.51790607", "0.51658875", "0.51353216", "0.5130447", "0.51088285", "0.5102324", "0.50966144", "0.5081986", "0.50518805", "0.5037958", "0.5033271", "0.5...
0.6260987
0
Set the lambda transition table at the given index to the given value
def set_lambda(row, col, value) expand_lambda(row, col) @lambda_table[row][col] = value end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_transition(row, col, value)\n expand_transition_table(row)\n\n # Values from the parse tree can have single quotes (for prettier output), so remove those\n col.gsub!(\"'\", \"\")\n\n @characters.add(col)\n\n @transition_table[row][col] = value\n end", "def set _index, _value\n <<-SQF\n...
[ "0.5995145", "0.5989006", "0.59640336", "0.58430105", "0.5841669", "0.5599347", "0.5541248", "0.5496415", "0.54821706", "0.54560333", "0.5439336", "0.5434445", "0.5425122", "0.5348511", "0.5337321", "0.533553", "0.53227705", "0.53202", "0.5291467", "0.527007", "0.5269934", ...
0.7381148
0
Set the character transition table at the given index to the given value
def set_transition(row, col, value) expand_transition_table(row) # Values from the parse tree can have single quotes (for prettier output), so remove those col.gsub!("'", "") @characters.add(col) @transition_table[row][col] = value end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update(index, value)\n index = input_to_index(index)\n @cells[index] = value.token\n end", "def move(board, index, char)\n board[index] = char\nend", "def move(board, index, char = \"X\")\n board[index.to_i] = char\nend", "def move(board, index, character)\n board[index] = character\nend", "d...
[ "0.6348432", "0.6068711", "0.60185283", "0.60073155", "0.594566", "0.5916975", "0.5901362", "0.5901046", "0.5886798", "0.5886798", "0.5878441", "0.5852426", "0.58447427", "0.58075136", "0.58039916", "0.58019763", "0.5798078", "0.57912976", "0.57827556", "0.5772167", "0.575312...
0.7283439
0
Delegate node processing to the proper function based on node contents
def process_node(node, this, nxt) if node.value == "ALT" node_alt(node, this, nxt) elsif node.value == "SEQ" node_seq(node, this, nxt) elsif node.value == "*" node_kleene(node, this, nxt) elsif node.value == "lambda" leaf_lambda(node, this, nxt) else leaf_child(node, this, nxt) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_node(node, process_text)\n node_text = ''\n if node.element?\n case node.node_name\n when 'p', 'div'\n node_text.concat(process_paragraph_node(node))\n when 'span'\n node_text.concat(process_span_node(node))\n when ...
[ "0.73014975", "0.6974971", "0.6913398", "0.6908071", "0.6862659", "0.669268", "0.668563", "0.6559103", "0.65389925", "0.6506127", "0.6506127", "0.6503551", "0.6463552", "0.6450895", "0.6387938", "0.6387938", "0.63545024", "0.6273062", "0.6252931", "0.6252931", "0.62346596", ...
0.6861601
5
Process a nonlambda leaf node
def leaf_child(node, this, nxt) set_transition(this, node.value, nxt) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def leaf(node, tag)\r\n end", "def process_node(node, this, nxt)\n if node.value == \"ALT\"\n node_alt(node, this, nxt)\n elsif node.value == \"SEQ\"\n node_seq(node, this, nxt)\n elsif node.value == \"*\"\n node_kleene(node, this, nxt)\n elsif node.value == \"lambda\"\n leaf...
[ "0.7226787", "0.7155272", "0.68130296", "0.6617634", "0.6616383", "0.6600431", "0.6503128", "0.642154", "0.6296505", "0.6291728", "0.6291728", "0.62416226", "0.6228988", "0.6082728", "0.6059941", "0.60255873", "0.59915996", "0.59821206", "0.5939619", "0.59369266", "0.5910396"...
0.5630621
71
Process a lambda leaf node
def leaf_lambda(node, this, nxt) set_lambda(this, nxt, 1) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def on_tlambda *xs\n unless @found\n @level += 1\n end\n super\n end", "def lambda; end", "def process_node(node, this, nxt)\n if node.value == \"ALT\"\n node_alt(node, this, nxt)\n elsif node.value == \"SEQ\"\n node_seq(node, this, nxt)\n elsif node.value ...
[ "0.69031954", "0.68600696", "0.68097043", "0.6620142", "0.65834427", "0.6539456", "0.6317021", "0.6294657", "0.6248681", "0.62391585", "0.610013", "0.609447", "0.6028737", "0.59476095", "0.5938961", "0.5930491", "0.592066", "0.5903158", "0.5847614", "0.58412385", "0.5831433",...
0.7682579
0
Process a SEQ node
def node_seq(node, this, nxt) a = this b = new_state() # Create a sequence of transitions between this and next, # creating more states as needed node.children.each.with_index do |child, index| if index == node.children.size - 1 b = nxt end process_node(child, a, b) a = b b = new_state() end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_sequence(sequence)\n @current_node = @init_node\n sequence.each do |instance|\n next_label = instance.label\n next_node = @label_to_node[next_label]\n if !next_node\n next_node = Node.new\n next_node.label = next_label\n next_node.output = insta...
[ "0.60957325", "0.59824646", "0.58607316", "0.5742197", "0.5706333", "0.5659964", "0.5583424", "0.556615", "0.5561262", "0.554636", "0.5545945", "0.5499404", "0.5466801", "0.5437941", "0.5436652", "0.535207", "0.53329575", "0.5331753", "0.52378374", "0.5203827", "0.51801205", ...
0.60148907
1
Process an ALT node
def node_alt(node, this, nxt) # Create an edge between this and next for each child node.children.each do |child| process_node(child, this, nxt) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_node(node, this, nxt)\n if node.value == \"ALT\"\n node_alt(node, this, nxt)\n elsif node.value == \"SEQ\"\n node_seq(node, this, nxt)\n elsif node.value == \"*\"\n node_kleene(node, this, nxt)\n elsif node.value == \"lambda\"\n leaf_lambda(node, this, nxt)\n else\n ...
[ "0.6459001", "0.6377301", "0.58076614", "0.5666244", "0.56052804", "0.5595802", "0.53169453", "0.53071123", "0.5287267", "0.52767265", "0.5256526", "0.5227539", "0.52127624", "0.5203414", "0.5203414", "0.5203414", "0.5203414", "0.5203414", "0.5203414", "0.5203414", "0.5203414...
0.60124975
2
Get all states connected to the given state by lambda transitions
def get_lambda_transitions(state) transitions = [] @lambda_table[state].each.with_index do |value, index| if value == 1 transitions << index end end return transitions end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def transitions_to(state)\n find_all_transitions(:to_state => state)\n end", "def get_to_states_when_transitioning_from(state)\n @transitions.inject([]) do |memo, t| \n memo.concat(Array(t.to)) if t.from == state\n memo\n end\n end", "def available_transitions_from(stat...
[ "0.73753726", "0.7279341", "0.71944445", "0.6958163", "0.65138036", "0.64554495", "0.6447005", "0.6403662", "0.6337205", "0.63058335", "0.6285079", "0.6179185", "0.61432815", "0.6104482", "0.60849065", "0.6066728", "0.6028193", "0.60233676", "0.60031605", "0.60031605", "0.598...
0.7953708
0
Get all states connected to the given state by transitions on the given character
def get_transitions(state, char) transition = @transition_table[state][char] if transition return [transition] else return [] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def transition_symbols_for(state)\n trans = {}\n return trans if @transitions[state].nil?\n @transitions[state].each do |k,v|\n tmp = v.is_a?(Array) ? v : [v]\n tmp.each do |i|\n k.is_a?(Symbol) ? @cats[k].each {|s| trans.push_at(s, v)} : trans.push_at(k, i)\n end\n ...
[ "0.6657204", "0.65155816", "0.64571327", "0.644069", "0.63492", "0.632816", "0.6299944", "0.5954222", "0.59406304", "0.5915749", "0.5887417", "0.58108747", "0.5809376", "0.5758775", "0.5697374", "0.5667693", "0.5650025", "0.5603414", "0.5597176", "0.55736715", "0.5557672", ...
0.78209174
0
Put in humanreadable format for output
def to_s width = 3 translations = { "\n" => "\\n", "\t" => "\\t", " " => "\\s" } str = "Transition table:\n" str += "".ljust(width) @characters.each do |c| c = translations[c] if translations.has_key?(c) str += c.ljust(width) end str += "\n" @transition_table.each.with_index do |row, index| str += index.to_s.ljust(width) @characters.each do |c| str += row[c].to_s.ljust(width) end str += "\n" end str += "\nLambda table:\n" str += "".ljust(width) (0..@state_counter).each do |row| str += row.to_s.ljust(width) end str += "\n" (0..@state_counter).each.with_index do |row, index| str += index.to_s.ljust(width) (0..@state_counter).each do |col| str += @lambda_table[row][col].to_s.ljust(width) end str += "\n" end return str end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format; end", "def format; end", "def format; end", "def format; end", "def format; end", "def format; end", "def format; end", "def format; end", "def to_s\r\n pretty_output\r\n end", "def to_s ; format ; end", "def format\n output = @sum.to_s\n\n if @verbose\n @raw.ea...
[ "0.74310786", "0.74310786", "0.74310786", "0.74310786", "0.74310786", "0.74310786", "0.74310786", "0.74310786", "0.7297118", "0.7093108", "0.6937744", "0.6916991", "0.6916991", "0.6916991", "0.6916864", "0.683037", "0.6730375", "0.6665356", "0.6665356", "0.66582316", "0.66412...
0.0
-1
The default parameters of 0 and a "blank" city name indicate a the selection of "All Locations".
def store_city(city_id = 0, city_name = "") session[:city_id] = city_id session[:city_name] = city_name end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def options_for_select_for_cities\n options_for_select(City.all.collect {|c| [c.name, c.id]} << [\"All Locations\", \"0\"])\n end", "def set_city\n end", "def city; end", "def city; end", "def city; end", "def city; end", "def city; end", "def city; end", "def city_name\n\t\treturn \"Mysore\...
[ "0.7081916", "0.7006558", "0.6502067", "0.6502067", "0.64983076", "0.64983076", "0.64983076", "0.64983076", "0.6477578", "0.62928706", "0.62928706", "0.62928706", "0.6280618", "0.62395185", "0.62395185", "0.62395185", "0.62395185", "0.62395185", "0.62395185", "0.62395185", "0...
0.0
-1
Returns the current city. City is stored in session (chosen by user) and if set, we retreive it. A user can also choose "All Locations" specified by setting it to 0.
def current_city if session[:city_id] && session[:city_id] != 0 return City.find(session[:city_id]) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def current_city\n return City.find(1)\n end", "def current_city\n if @city \n @city.name\n elsif @institute\n @institute.name\n else #failsafe\n end\n end", "def city\n return @city\n end", "def city\n fetch('world_cup.cities')\n ...
[ "0.8165855", "0.792241", "0.76281035", "0.7488985", "0.7377652", "0.73093647", "0.7184821", "0.70620626", "0.69702333", "0.6912362", "0.6906902", "0.69044685", "0.6901435", "0.6737177", "0.6697768", "0.66382426", "0.65963286", "0.65655154", "0.65655154", "0.6555898", "0.65294...
0.87655
0
Tell Devise to redirect after sign_in
def after_sign_in_path_for(resource_or_scope) case resource_or_scope.class.name when 'Venue' venue_root_url(:protocol => 'http') when 'Admin' admin_root_url(:protocol => 'http') else super end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sign_in_and_redirect(resource_or_scope, *args); end", "def signed_in_user\n store_location #pour ensuite rediriger l'utilisateur vers la destination qu'il voulait avant\n # d'etre rediriger vers la pagne d'authentification\n redirect_to signin_url, notice: \"Please sign in.\" unless s...
[ "0.76016676", "0.7533555", "0.7516287", "0.74453616", "0.74453616", "0.74107146", "0.7404843", "0.7342297", "0.72871006", "0.7281476", "0.72744393", "0.72733134", "0.7252388", "0.7233766", "0.72313976", "0.7225987", "0.72242963", "0.7221892", "0.72192985", "0.720326", "0.7181...
0.0
-1
Tell Devise to redirect after sign_out
def after_sign_out_path_for(resource_or_scope) login_url(:protocol => 'http') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n redirect_path = after_sign_out_path_for(\"user\")\n signed_out = (Devise.sign_out_all_scopes ? sign_out : sign_out(\"user\"))\n set_flash_message :notice, :signed_out if signed_out && is_navigational_format?\n super\n end", "def sign_out_and_redirect!(return_to = \"/\")\n sign_out_u...
[ "0.8180696", "0.8046369", "0.7981075", "0.7891747", "0.7873793", "0.7809308", "0.7747988", "0.7734582", "0.77254647", "0.77203584", "0.7718171", "0.7677872", "0.76550907", "0.7645172", "0.7616369", "0.7607544", "0.7600334", "0.7583442", "0.7570735", "0.7567907", "0.7556958", ...
0.0
-1
Override the doorkeeper method to provide more helpful error messages when auth fails. Note the OAuth spec enforces the status, keys, and the `error` of the response, but not the `error_description`. Note that there a few other solutions to this at
def create super resource_owner_id = authorize_response.try(:token).try(:resource_owner_id) user = User.find_by_id( resource_owner_id ) unless resource_owner_id.blank? # A suspended user might have a valid access token raise INat::Auth::SuspendedError if user&.suspended? rescue INat::Auth::BadUsernamePasswordError headers.delete "WWW-Authenticate" self.status = 400 self.response_body = { error: "invalid_grant", error_description: I18n.t( "devise.failure.invalid" ) }.to_json rescue INat::Auth::SuspendedError headers.delete "WWW-Authenticate" self.status = 400 self.response_body = { error: "invalid_grant", error_description: I18n.t( :this_user_has_been_suspended ) }.to_json rescue INat::Auth::ChildWithoutPermissionError headers.delete "WWW-Authenticate" self.status = 400 self.response_body = { error: "invalid_grant", error_description: I18n.t( :please_ask_your_parents_for_permission ) }.to_json rescue INat::Auth::UnconfirmedError headers.delete "WWW-Authenticate" self.status = 400 self.response_body = { error: "invalid_grant", error_description: I18n.t( "devise.failure.unconfirmed" ) }.to_json rescue INat::Auth::UnconfirmedAfterGracePeriodError headers.delete "WWW-Authenticate" self.status = 400 self.response_body = { error: "invalid_grant", error_description: I18n.t( :email_conf_required_after_grace_period, requirement_date: I18n.l( User::EMAIL_CONFIRMATION_REQUIREMENT_DATETIME.to_date, format: :long ) ) }.to_json end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def auth_error(e)\n json_response({ message: e.message }, :unprocessable_entity)\n end", "def authentication_error\n # User's token is either invalid or not in the right format\n render json: {error: t('unauthorized')}, status: 401 # Authentication timeout\n end", "def authentication_e...
[ "0.7166644", "0.70246273", "0.70245755", "0.7016008", "0.7016008", "0.7016008", "0.69587374", "0.69350463", "0.6923917", "0.6760733", "0.6700048", "0.66711164", "0.66711164", "0.66462475", "0.6596029", "0.653278", "0.6519973", "0.6516971", "0.6515558", "0.6515558", "0.6515558...
0.0
-1