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
Checks if a network exists or not
def network_exists?(name) net_obj = Com::Vmware::Vcenter::Network.new(vapi_config) filter = Com::Vmware::Vcenter::Network::FilterSpec.new(names: Set.new([name])) net = net_obj.list(filter) raise format("Unable to find target network: %s", name) if net.empty? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def network_exists?(network_name)\n networks_list.include?(network_name)\n end", "def network_exists?(name)\n net_api = VSphereAutomation::VCenter::NetworkApi.new(api_client)\n raise_if_unauthenticated net_api, \"checking for VM network `#{name}`\"\n\n nets = net_api.list({ filter_names:...
[ "0.83544916", "0.8068502", "0.7202114", "0.6857433", "0.68385494", "0.67289007", "0.6660758", "0.6647937", "0.65889585", "0.6517109", "0.6439652", "0.6284661", "0.62508065", "0.6232452", "0.62237513", "0.61374754", "0.6129674", "0.6090193", "0.6085285", "0.60835993", "0.60765...
0.82898605
1
Validates the host name of the server you can connect to
def get_host(name) # create a host object to work with host_obj = Com::Vmware::Vcenter::Host.new(vapi_config) if name.nil? host = host_obj.list else filter = Com::Vmware::Vcenter::Host::FilterSpec.new(names: Set.new([name])) host = host_obj.list(filter) end raise format("Unable to find target host: %s", name) if host.empty? host[0] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_server(name)\n return true unless name # if no name is provided, just go with the defaults\n valid = name.is_a? String\n begin\n u = URI.parse(name)\n valid = false unless u.class == URI::HTTP || u.class == URI::HTTPS\n rescue URI::InvalidURIEr...
[ "0.74241996", "0.73861295", "0.7304909", "0.7213267", "0.7098527", "0.70523435", "0.6987495", "0.69399804", "0.6856166", "0.6856166", "0.6824608", "0.6824093", "0.680345", "0.66413265", "0.65983105", "0.6589409", "0.65585434", "0.6521371", "0.65205455", "0.64969575", "0.64735...
0.0
-1
Gets the folder you want to create the VM
def get_folder(name) # Create a filter to ensure that only the named folder is returned filter = Com::Vmware::Vcenter::Folder::FilterSpec.new(names: Set.new([name])) folder_obj = Com::Vmware::Vcenter::Folder.new(vapi_config) folder = folder_obj.list(filter) raise format("Unable to find folder: %s", name) if folder.empty? folder[0].folder end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_vbox_vm_dir(client_name)\n message = \"Getting:\\tVirtualBox VM directory\"\n command = \"VBoxManage list systemproperties |grep 'Default machine folder' |cut -f2 -d':' |sed 's/^[ ]*//g'\"\n vbox_vm_base_dir = execute_command(message,command)\n vbox_vm_base_dir = vbox_vm_base_...
[ "0.68042755", "0.6696341", "0.6696341", "0.6678664", "0.66052973", "0.64466584", "0.6395029", "0.63356286", "0.6280226", "0.62693256", "0.6264736", "0.6257353", "0.6237181", "0.6216561", "0.6195987", "0.6146943", "0.6146176", "0.6107727", "0.6041936", "0.60311973", "0.6028049...
0.5706598
60
Gets the name of the VM you are creating
def get_vm(name) filter = Com::Vmware::Vcenter::VM::FilterSpec.new(names: Set.new([name])) vm_obj = Com::Vmware::Vcenter::VM.new(vapi_config) vm_obj.list(filter)[0] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def vm_name\n if !name || name.empty?\n \"#{user.id}-#{project.name.gsub('.','-')}-#{Time.zone.now.to_i.to_s.sub(/^../,'')}\".downcase\n else\n name\n end\n end", "def vagrant_vm_name(name)\n return \"vagrant-#{name}-#{ENV['USER']}\"\nend", "def computername\n vm.os_profile.computer_n...
[ "0.76915306", "0.69701385", "0.6910907", "0.67271996", "0.6541935", "0.6498251", "0.6447349", "0.64256537", "0.6354848", "0.63476133", "0.63163006", "0.6306579", "0.6294003", "0.62569034", "0.62361115", "0.6226915", "0.6205531", "0.6201566", "0.6201566", "0.6197333", "0.61942...
0.62187296
16
Gets the info of the cluster
def get_cluster(name) cl_obj = Com::Vmware::Vcenter::Cluster.new(vapi_config) # @todo: Use Cluster::FilterSpec to only get the cluster which was asked # filter = Com::Vmware::Vcenter::Cluster::FilterSpec.new(clusters: Set.new(['...'])) clusters = cl_obj.list.select { |cluster| cluster.name == name } raise format("Unable to find Cluster: %s", name) if clusters.empty? cluster_id = clusters[0].cluster cl_obj.get(cluster_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __cluster_info\n health = JSON.parse(Net::HTTP.get(URI(\"#{__cluster_url}/_cluster/health\")))\n nodes = if version == '0.90'\n JSON.parse(Net::HTTP.get(URI(\"#{__cluster_url}/_nodes/?process&http\")))\n else\n JSON.parse(Net::HTTP.get(URI(\"#{__clust...
[ "0.85554856", "0.78559995", "0.77614355", "0.75723714", "0.75172704", "0.739303", "0.73542136", "0.70964354", "0.7090487", "0.7062964", "0.70492405", "0.70368177", "0.7015252", "0.70037967", "0.69502634", "0.6947804", "0.693547", "0.6921948", "0.6805798", "0.6773381", "0.6753...
0.67662495
20
Gets the name of the resource pool
def get_resource_pool(name) # Create a resource pool object rp_obj = Com::Vmware::Vcenter::ResourcePool.new(vapi_config) # If no name has been set, use the first resource pool that can be found, # otherwise try to find by given name if name.nil? # Remove default pool for first pass (<= 1.2.1 behaviour to pick first user-defined pool found) resource_pool = rp_obj.list.delete_if { |pool| pool.name == "Resources" } debug("Search of all resource pools found: " + resource_pool.map { |pool| pool.name }.to_s) # Revert to default pool, if no user-defined pool found (> 1.2.1 behaviour) # (This one might not be found under some circumstances by the statement above) return get_resource_pool("Resources") if resource_pool.empty? else # create a filter to find the named resource pool filter = Com::Vmware::Vcenter::ResourcePool::FilterSpec.new(names: Set.new([name])) resource_pool = rp_obj.list(filter) debug("Search for resource pools found: " + resource_pool.map { |pool| pool.name }.to_s) end raise format("Unable to find Resource Pool: %s", name) if resource_pool.empty? resource_pool[0].resource_pool end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resource_pool(name)\n @manifest[\"resource_pools\"].find { |res| res[\"name\"] == name }\n end", "def pool_name()\n #This is a stub, used for indexing\n end", "def name\n 'pooler'\n end", "def resource_name\n @resource_name ||= get_resource_name\n end...
[ "0.7984184", "0.791868", "0.71183026", "0.70955676", "0.6997517", "0.6997517", "0.6997517", "0.6932114", "0.6919304", "0.6879321", "0.6873212", "0.6858333", "0.67995685", "0.6781424", "0.6704315", "0.6655591", "0.6655591", "0.66438574", "0.661397", "0.6602401", "0.65832496", ...
0.65813
21
Get location of lookup service
def lookup_service_host # Allow manual overrides return config[:lookup_service_host] unless config[:lookup_service_host].nil? # Retrieve SSO service via RbVmomi, which is always co-located with the Lookup Service. vim = RbVmomi::VIM.connect @connection_options vim_settings = vim.serviceContent.setting.setting sso_url = vim_settings.select { |o| o.key == "config.vpxd.sso.sts.uri" }&.first&.value # Configuration fallback, if no SSO URL found for some reason ls_host = sso_url.nil? ? config[:vcenter_host] : URI.parse(sso_url).host debug("Using Lookup Service at: " + ls_host) ls_host end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_location(location)\n client = Weatherman::Client.new\n client.lookup_by_location(location)\nend", "def location\n fetch('doraemon.locations')\n end", "def location\n fetch('hey_arnold.locations')\n end", "def get_location(user_location)\n\tclient=Weatherman::Client.n...
[ "0.6801704", "0.67613333", "0.6681403", "0.65907353", "0.65626335", "0.65594304", "0.65248835", "0.6492449", "0.64749235", "0.6453345", "0.6439432", "0.627982", "0.62766397", "0.62718785", "0.6271654", "0.62700903", "0.6205303", "0.619846", "0.61938053", "0.61883193", "0.6172...
0.6901233
0
The main connect method
def connect # Configure the connection to vCenter lookup_service_helper = LookupServiceHelper.new(lookup_service_host) vapi_urls = lookup_service_helper.find_vapi_urls debug("Found vAPI endpoints: [" + vapi_urls.to_s + "]") vim_urls = lookup_service_helper.find_vim_urls debug("Found VIM endpoints: [" + vim_urls.to_s + "]") node_id = vim_urls.select { |id, url| url.include? vcenter_host }.keys.first debug("NodeID of vCenter " + config[:vcenter_host] + " is " + node_id.to_s) vapi_url = lookup_service_helper.find_vapi_url(node_id) debug("vAPI Endpoint for vCenter is " + vapi_url) # Create the VAPI config object ssl_options = {} ssl_options[:verify] = config[:vcenter_disable_ssl_verify] ? :none : :peer @vapi_config = VAPI::Bindings::VapiConfig.new(vapi_url, ssl_options) # get the SSO url sso_url = lookup_service_helper.find_sso_url sso = SSO::Connection.new(sso_url).login(config[:vcenter_username], config[:vcenter_password]) token = sso.request_bearer_token vapi_config.set_security_context( VAPI::Security.create_saml_bearer_security_context(token.to_s) ) # Login and get the session information @session_svc = Com::Vmware::Cis::Session.new(vapi_config) @session_id = session_svc.create vapi_config.set_security_context( VAPI::Security.create_session_security_context(session_id) ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def connect(*) end", "def connect; end", "def connect!; end", "def connect!; end", "def connect\n end", "def connect!\n end", "def connect\n\tend", "def connect\n # Implement in subclass\n end", "def run\n connect\n end", "def connect(*args)\n raise NotImple...
[ "0.8985493", "0.8954996", "0.8809826", "0.8809826", "0.87242395", "0.85432994", "0.8534175", "0.8248769", "0.80545926", "0.7658598", "0.7457163", "0.7457163", "0.72509724", "0.72356784", "0.72230744", "0.7221076", "0.7205399", "0.71830297", "0.71814495", "0.7173433", "0.71728...
0.0
-1
== GET /about The "About Virgo" page.
def index end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def about\n # Static Page\n end", "def about\n @current_nav_identifier = :about\n params[:name] = @current_nav_identifier\n set_page\n render 'show'\n end", "def about; render; end", "def about_us\n # it's deliberate that there's no code in here... but we should have a helpful error whe...
[ "0.7456414", "0.7287543", "0.7133497", "0.7106585", "0.70982873", "0.70844775", "0.70844775", "0.7071669", "0.7057822", "0.7037717", "0.69981843", "0.69981843", "0.69981843", "0.69981843", "0.69981843", "0.69981843", "0.69981843", "0.69981843", "0.69981843", "0.69981843", "0....
0.0
-1
== GET /about/list/:topic An informational listing on a given subject. == GET /about/list/library == GET /about/list/libraries == GET /about/list/location == GET /about/list/locations
def list @topic = get_topic(params) @topic_list = get_topic_list(@topic) respond_to do |format| format.html format.xml { render xml: @topic_list.to_xml } format.json { render json: @topic_list.to_json } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list\n\t\t@notes = Note.where(topic: params[:topic])\n\tend", "def index\n joins = {:user_id => doorkeeper_token.resource_owner_id, :slug => params[:topic_id]}\n joins.merge!(:application_id => doorkeeper_token.application_id) unless has_scope?(\"read_any_publications\")\n @publications = Topi...
[ "0.6889292", "0.6699159", "0.6665145", "0.66056716", "0.6537002", "0.65369064", "0.6529126", "0.65150285", "0.6494337", "0.64824903", "0.64824903", "0.64824903", "0.64688253", "0.64487106", "0.6432399", "0.6428444", "0.6428444", "0.6428444", "0.64223737", "0.6414862", "0.6401...
0.7695852
0
== GET /about/solr == GET /about/solr?lens=:lens Administratoronly Solr information.
def solr @solr_fields = get_solr_fields @solr_info = get_solr_information end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solr(url, handler, params={})\n connection, solr_url = connection(url)\n req_url = solr_url.path + '/select?' + hash_to_query_string(params.merge(:qt => handler))\n # puts \"*** requesting to Solr: #{req_url}\"\n connection.get(req_url)\nend", "def solr_stats\n @solr_stats = get_solr_statistics\n r...
[ "0.6705973", "0.6662194", "0.6624481", "0.6564986", "0.6513837", "0.6383423", "0.62608135", "0.62519354", "0.6242167", "0.6222342", "0.6206506", "0.61802095", "0.6170342", "0.616341", "0.6140831", "0.608454", "0.60834855", "0.6073331", "0.60699946", "0.6045608", "0.60370624",...
0.71127635
0
== GET /about/solr_stats Administratoronly Solr information.
def solr_stats @solr_stats = get_solr_statistics render 'about/solr' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solr\n @solr_fields = get_solr_fields\n @solr_info = get_solr_information\n end", "def index\n @config_vars = ENVIRONMENT_VARIABLES_TO_PRINT\n @corpus_size = RLetters::Solr::CorpusStats.new.size\n @ping = RLetters::Solr::Connection.ping\n @solr_info = RLetters::Solr::Connection.info\n e...
[ "0.654221", "0.6466917", "0.64406633", "0.6387317", "0.6387317", "0.6262488", "0.6156257", "0.6109965", "0.6075348", "0.60701334", "0.6035382", "0.60095936", "0.59551084", "0.59423053", "0.5930332", "0.58983016", "0.5861903", "0.5861903", "0.5857144", "0.5856435", "0.58140063...
0.8535216
0
== GET /about/eds Administratoronly EBSCO EDS information.
def eds @eds_session = get_eds_session @eds_fields = get_eds_fields end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @eds = Ed.all\n end", "def show\n @emedidor = Emedidor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @emedidor }\n end\n end", "def show\n @user = User.find(params[:user_id])\n @eod = Eod.find_by(params[:i...
[ "0.61865294", "0.6038151", "0.6032974", "0.59458154", "0.5898988", "0.5857836", "0.5843201", "0.5842271", "0.57661015", "0.5714306", "0.56690526", "0.5663047", "0.5659392", "0.56367344", "0.56284386", "0.562764", "0.56273156", "0.5614681", "0.5614054", "0.5579406", "0.5579322...
0.578008
8
== GET /about/log Administratoronly application log viewer.
def log count = default_log_lines(params) lines = get_file_lines(log: true, tail: count) respond_with(lines) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n unless current_user.has_role? :admin\n flash[:alert] = \"Access To Logs Denied\"\n redirect_to root_path\n end\n end", "def logs(app_name)\n\t\tget(\"/apps/#{app_name}/logs\")\n\tend", "def logs_for(application)\n logs_at_url(get(\"/apps/#{application}/logs?logplex=true\", 2))\n ...
[ "0.6876982", "0.67404073", "0.66599977", "0.65677613", "0.6564658", "0.65309817", "0.6479322", "0.64707935", "0.64099896", "0.64097726", "0.6381973", "0.6358364", "0.6340605", "0.62992835", "0.62937105", "0.62471324", "0.6245345", "0.61996603", "0.6188809", "0.6172863", "0.61...
0.0
-1
== DELETE /about/log Administratoronly command to wipe the application log.
def log_wipe lines = wipe_log respond_with(lines, template: 'about/log') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear_log\n request('clearLog')\n end", "def clear_log\r\n\r\n file = Rails.public_path.join('bg_worker.log')\r\n FileUtils.rm file\r\n flash[:warning] = \"Cleared log file\"\r\n redirect_to :action => :list\r\n end", "def delete_log(log_file = '')\n File.delete(log_file) if File....
[ "0.70575684", "0.6709301", "0.6520443", "0.64608884", "0.6441817", "0.64084476", "0.635158", "0.6290828", "0.62805754", "0.60182387", "0.59994334", "0.59255266", "0.5911193", "0.5891146", "0.58537716", "0.5843142", "0.58160335", "0.5813592", "0.58046234", "0.57949734", "0.577...
0.68820006
1
Override __prefix__ class method to have better prefixes for some of these longer vocabulary names.
def __prefix__ __name__.demodulize.underscore.dasherize.to_sym end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def name_prefix; end", "def prefixes; end", "def prefixes; end", "def words_with_prefix(prefix, words)\n raise NotImplementedError # TODO\nend", "def prefix; end", "def prefix; end", "def prefix; end", "def prefix; end", "def prefix; end", "def prefix; end", "def prefix; end", "def prefix; e...
[ "0.6865738", "0.675726", "0.675726", "0.66747403", "0.6585286", "0.6585286", "0.6585286", "0.6585286", "0.6585286", "0.6585286", "0.6585286", "0.6585286", "0.6585286", "0.6585286", "0.6540014", "0.65229684", "0.6400325", "0.63975704", "0.6286913", "0.6269063", "0.62565523", ...
0.69234943
0
change the board after a player turn
def update_board n = 0 board.each do |i| i.map do |j| if j[0] == ' ' j[1] = movements[n].to_s n += 1 end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def turn\n marker = @turn_count.even? ? marker = \"X\" : marker = \"O\"\n move\n print \"Current board: \"\n show_board\n @player +=1\n end", "def turn\n current_move = current_player.move(@board)\n current_token = current_player.token\n if self.board.valid_move?(current_move...
[ "0.8102404", "0.7805564", "0.773246", "0.7715782", "0.768786", "0.7647275", "0.7639785", "0.7625166", "0.76076376", "0.7606632", "0.7598623", "0.75931555", "0.75767934", "0.75388366", "0.75085104", "0.7506252", "0.747426", "0.747426", "0.7466406", "0.7455933", "0.74388796", ...
0.0
-1
show the current state of the board
def show_board i = 0 while i < board.length j = 0 while j < board[i].length print board[i][j] j += 1 end print "\n" i += 1 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display\n puts \"===Current Board Status===\"\n @bingo_board.each { |row| puts print row }\n end", "def display_board\n board =\n \" _______ _______ _______\n | | | |\n A| #{@state[:A1]} | #{@state[:A2]} | #{@state[:A3]} |\n |_______|_______|__...
[ "0.7617608", "0.75484383", "0.7472257", "0.7432845", "0.7389793", "0.7350878", "0.7260307", "0.7223427", "0.7216529", "0.715123", "0.7107057", "0.7088462", "0.7060572", "0.7056883", "0.70512", "0.70473623", "0.7043213", "0.7008691", "0.70036346", "0.70026743", "0.6998717", ...
0.0
-1
look if some diagonal or the row or the column of the last player movement provides a winner for the game
def find_winner(move) condition1 = (move / 3).ceil * 3 condition2 = (move - 1) % 3 line = players[turn % 2].symbol + players[turn % 2].symbol + players[turn % 2].symbol winner_conditions(condition1, condition2, line) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_winner\n cells_t = cells.transpose\n row_winner(cells)\n row_winner(cells_t)\n diagonal_winner unless winner\n announce_winner if winner\n winner\n end", "def has_winner?\n (@last_insert_x > 0) ? (check_column || check_row) : false\n \n end", "def check_columns_for_winner\n ...
[ "0.79820615", "0.7954588", "0.79442495", "0.7917773", "0.789783", "0.78936964", "0.7892042", "0.78843594", "0.7867181", "0.78084165", "0.7803592", "0.77971774", "0.77396137", "0.7722822", "0.77032244", "0.7686745", "0.7679554", "0.7673448", "0.76709867", "0.7666093", "0.76198...
0.0
-1
if some diagonal or the row or the colum has the same symbol three times then there is a winner
def winner_conditions(condition1, condition2, line) row1 = (movements[condition1 - 1] + movements[condition1 - 2] + movements[condition1 - 3] == line) column1 = (movements[condition2] + movements[condition2 + 3] + movements[condition2 + 6] == line) diagonal1 = (movements[0] + movements[4] + movements[8] == line) diagonal2 = (movements[2] + movements[4] + movements[6] == line) return unless row1 or column1 or diagonal1 or diagonal2 show_board puts players[turn % 2].name + ' is the winner' @game_continue = false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def winner\n #see if there are four in a row\n @columns.times do |c|\n @rows.times do |r|\n check = @slots[c][r]\n if check != nil\n if (r <= @rows - 4) && [check, @slots[c][r+1], @slots [c][r+2], @slots[c][r+3]].uniq...
[ "0.7630748", "0.75893897", "0.75762457", "0.7372566", "0.73712337", "0.7312676", "0.7307261", "0.7251087", "0.72448343", "0.7225901", "0.721839", "0.72162235", "0.7211894", "0.7203242", "0.7182131", "0.7175452", "0.7158557", "0.7152796", "0.71334827", "0.71304524", "0.7095169...
0.0
-1
`index` is expected to respond to `index_name` and `index_type`
def call response = client.mget options pairs = response["docs"].map { |doc| [doc["_id"], doc["_source"]] } pairs.to_h end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index_type\n name\n end", "def construct_index\n end", "def index_type(env)\n @index_type\n end", "def index\n set_index\n end", "def indexes\n raise 'not implemented'\n end", "def index(name, type = :find)\n @defined_indexes ||= {}\n @defined_inde...
[ "0.8215665", "0.7866423", "0.770663", "0.7693401", "0.7592965", "0.75419486", "0.7472974", "0.7468542", "0.744928", "0.7423644", "0.74081415", "0.7379237", "0.7373606", "0.73323494", "0.7313775", "0.7313775", "0.73129433", "0.73129433", "0.7292974", "0.7292974", "0.72646356",...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_partner @partner = Partner.find_by(osra_id: params[:partner_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 trusted parameter "white list" through.
def product_params params.require(:product).permit(:code, :name, :product_brand_id, :product_cost, :cargo_cost, :total_cost, :units_sale_allowed, :is_mix_box, {prices_attributes: [:id, :customer_category_id, :company_profit_percent, :seller_profit_percent, :total_profit_percent, :seller_commission_over_price_percent, :price]}, {product_boxes_attributes: [:_destroy, :id, :box_id, :stock_min, :stock_max]}, {mix_box_details_attributes: [:_destroy, :id, :product_id, :quantity]}, {box_ids: []}) 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.7121987", "0.70541996", "0.69483954", "0.6902367", "0.6733912", "0.6717838", "0.6687021", "0.6676254", "0.66612333", "0.6555296", "0.6527056", "0.6456324", "0.6450841", "0.6450127", "0.6447226", "0.6434961", "0.64121825", "0.64121825", "0.63913447", "0.63804525", "0.638045...
0.0
-1
Make department requirement junction when new requirement is made. Also serves as a Model.within(dept), minus foreign key injection
def core(d) dept = Department.search!(d) raise "[Requirement.core] Error: core already declared for department #{dept.name}" unless dept.core_requirements.empty? requirement = make "#{dept.abbreviation}" # make junctions mk = self.method(:make) self.define_singleton_method(:make) do |*args| req = mk.call(*args) Departments_Requirement.create(department_id: dept.id, requirement_id: req.id) req end @within_model = dept yield @within_model = nil self.define_singleton_method :make, mk end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def department_set(dept)\n self.department.set dept\n end", "def setup_departments\n Department.delete_all \n Employee.delete_all\n dep = Department.create(:name=> 'department1', :city => 'Littleton', :state => 'CO') \n employee1 = dep.employees.create(:first_name=>\"first_1\", ...
[ "0.56608427", "0.56564736", "0.5552948", "0.553551", "0.5534745", "0.5534745", "0.5534745", "0.5512788", "0.54641384", "0.5439059", "0.52215725", "0.5196148", "0.5161448", "0.5145264", "0.5126229", "0.51245975", "0.5052786", "0.49754107", "0.49749613", "0.49749613", "0.497496...
0.64783174
0
Configure the isaac backend for basic functions
def configure # Give the bot a handle to config and handler conf = @config # Configure the bot @bot = Isaac::Bot.new @bot.configure{|c| c.server = conf[:server] c.port = conf[:port] c.ssl = conf[:ssl] c.nick = conf[:nick] c.password = conf[:password] c.realname = conf[:name] c.environment = :production c.verbose = conf[:verbose] || false c.log = $log } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main_audio ; end", "def ayah_init\r\n ayah = AYAH::Integration.new(\"d5fbcc5d5d32f645158e72fc00b55eea205b13b4\", \"3969dc9a22c5378abdfc1d576b8757a8638b16d7\")\r\n end", "def backends=(_arg0); end", "def create_audio!(enc, manifest, s3_input, s3_output)\n\n # Create or load the Audio Config\n ...
[ "0.58001405", "0.5630417", "0.5626259", "0.56152296", "0.54894656", "0.54694736", "0.54372865", "0.54372686", "0.53559417", "0.53166527", "0.52689433", "0.52419055", "0.5233905", "0.5224675", "0.51922506", "0.5191189", "0.51908624", "0.51848185", "0.51399815", "0.5138905", "0...
0.57062036
1
Registers a handler for all messages There can be only one handler, and this method basically defers to isaac's register call.
def register(handler) conf = @config bot = self isaac = @bot @bot.register{|type, msg| begin $log.debug "Received message: #{type} #{msg}" handler.dispatch(type, msg, bot.clone_state(msg)) # TODO: send a binding? rescue Exception => e $log.warn e.to_s $log.debug e.backtrace.join("\n") end } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_message_handler(&block)\n @message_handlers << block\n end", "def register_handler(handler)\n handler.handled_events.each do |event_type|\n (event_handlers[event_type] ||= []) << handler\n Twitch::Bot::Logger.debug \"Registered #{handler} for #{event_type}\"\n end\...
[ "0.7107442", "0.7007717", "0.699381", "0.6832381", "0.6692404", "0.6556771", "0.6504314", "0.6460172", "0.63218206", "0.6253323", "0.62477714", "0.6231994", "0.620173", "0.6184407", "0.6158149", "0.61345863", "0.6126857", "0.61178595", "0.6112451", "0.60783076", "0.60772026",...
0.69780576
3
Run the bot This can be done in a blocking or nonblocking way if verify is true and threaded is true, the bot will sit and check that it has successfully connected before continuing (and raise an exception on connection failure).
def run(threaded=true, verify=true) $log.info "Starting IRC Bot..." if threaded then # Run the bot. @thread = Thread.new do $log.info "Bot thread started." @bot.start end # Wait for it to connect if verify then delay = 0 while(not @bot.connected? and delay < @config[:connect_timeout]) do sleep(0.5) delay += 0.5 end raise "Bot timed out during first connect." if(delay >= @config[:connect_timeout]) end else @bot.start end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(async = false)\n @bot.run(async)\n end", "def run\n @bot.run\n end", "def run\n Telebot::Bot.new(@token).run do |chat, message|\n if block_given?\n yield(chat, message)\n elsif !chat.nil?\n id = message.chat.id\n if id.positive?\n post(\n me...
[ "0.64450514", "0.6265872", "0.62259525", "0.6147667", "0.61247224", "0.6115461", "0.5882167", "0.5845172", "0.58262604", "0.5772978", "0.5741848", "0.56309247", "0.56008327", "0.5597614", "0.55508184", "0.550517", "0.5467129", "0.5466942", "0.5432297", "0.54012644", "0.539777...
0.80901283
0
Is the bot currently connected? Falls through to Isaac.
def connected? @bot.connected? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def connected?\n @bot.connected?\n end", "def is_connected?\n if @client.is_connected?\n @log.info \"Asked if bot is connected: YES it is\"\n return true\n else\n @log.info \"Asked if bot is connected: NO it isn't\"\n return false\n end\n end", "def connected?\n ...
[ "0.7953467", "0.78557104", "0.74663305", "0.72863525", "0.7250291", "0.718196", "0.7154962", "0.7110553", "0.7110553", "0.71059996", "0.7084845", "0.704109", "0.6996413", "0.69754934", "0.69754934", "0.69754934", "0.69754934", "0.69754934", "0.69680333", "0.6943595", "0.69175...
0.8032407
0
Close the bot's connection to the server Accepts a timeout to allow the server to respond.
def disconnect(reason = nil, timeout = 5) # Quit and wait for replies from server @bot.quit(reason) sleep(timeout) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def close(timeout = false)\n # Return immediately if the server isn't listening\n return unless @ml.locked?\n \n # Ask the loop to close\n @close_in.putc 'x' # Tell select to close\n\n \n # Wait for loop to end\n elapsed_time = 0\n while @ml.locked? do\n sleep(0....
[ "0.71344316", "0.6993407", "0.65065193", "0.643313", "0.6368979", "0.63612384", "0.6358971", "0.6353435", "0.63488334", "0.63235235", "0.62913907", "0.6269492", "0.6260138", "0.6253904", "0.6249656", "0.61766124", "0.61196434", "0.6100018", "0.6086067", "0.60844946", "0.60653...
0.6988718
2
Produce a bot object with stateful defaults. IMPORTANT: This must remain threadsafe, since it is the unsafe side of all interactions between services and the [safe] isaac lib.
def clone_state(msg) # Construct a new class cls = Class.new() do # Require the isaac agent and # the raw message from isaac def initialize(isaac, msg) @msg = msg @bot = isaac end # Which server is the bot # connected to? def server @bot.server end # Which nick does the bot # currently have? def nick @bot.nick end # Tell the bot to join a channel def join(channel) @bot.join(channel) end # Is the bot currently connected? def connected? @bot.connected? end # Say something. # # Wraps isaac's call with a default value # from msg def say(msg, recipient = nil) recipient ||= @msg.reply_to if @msg @bot.msg(recipient, msg) end # Action something # # Wraps isaac's call with a default value # from msg def action(msg, recipient) recipient ||= @msg.reply_to if @msg @bot.action(recipient, msg) end end # Return an instance of the new class # with defaults from the message # and a link back to isaac. return cls.new(@bot, msg) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bot()\n merge(bot: 'true')\n end", "def bot\n @bot ||= Bot.new(ua)\n end", "def create_bot\n $bot = Discordrb::Bot.new(\n token: $config['discord_secret'],\n client_id: $config['discord_client'],\n log_mode: :quiet,\n intents: [\n :servers,\n :server_member...
[ "0.6545891", "0.6527316", "0.63246363", "0.6132673", "0.5985924", "0.59445447", "0.5904658", "0.58430815", "0.5829416", "0.56998587", "0.56829256", "0.5665055", "0.56577706", "0.5585114", "0.5574673", "0.5553582", "0.5547002", "0.5543602", "0.5518594", "0.54613763", "0.542034...
0.6130291
4
Which server is the bot connected to?
def server @bot.server end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def current_server\n @_current_server\n end", "def current_server\n @_current_server\n end", "def server\n @server.to_s\n end", "def get_server\n get_general['server']\n end", "def bot_mode\n self['BOT']\n end", "def server\n servers[0]\n end", "d...
[ "0.6890562", "0.6890562", "0.6842552", "0.6810676", "0.673647", "0.67030543", "0.6667216", "0.6579218", "0.65775716", "0.65214145", "0.64920014", "0.6402963", "0.63250816", "0.630544", "0.62802505", "0.62802505", "0.62707716", "0.6261175", "0.6242128", "0.6240805", "0.6227667...
0.7476169
0
Which nick does the bot currently have?
def nick @bot.nick end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nick\r\n return for_context(nil, false) { |c| c.nick }\r\n end", "def nickname\n @nick\n end", "def nick\n @name\n end", "def nick(nick)\n @nick = nick\n sendmsg(\"NICK #{nick}\")\n end", "def nick(msg)\n if msg.user.last_nick == @settings['identity']['nick']\n bot....
[ "0.7959913", "0.78586936", "0.7832504", "0.73713166", "0.7224003", "0.71348643", "0.7099389", "0.7083882", "0.69918257", "0.6970741", "0.69122684", "0.6911308", "0.6890828", "0.68761694", "0.6825434", "0.6795342", "0.67913824", "0.67271507", "0.67045605", "0.66967267", "0.667...
0.8594065
0
Tell the bot to join a channel
def join(channel) @bot.join(channel) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def channel_join(m, channel)\r\n if_admin(m) { @bot.join(channel) }\r\n end", "def join(channel)\n\t\t\tsend_to_server(\"JOIN #{channel}\")\n\t\tend", "def join_channel(message)\n message.send_raw \"JOIN ##{message.channel.name}\"\n end", "def irc_send_join(channel)\n # We send an IRC me...
[ "0.80779046", "0.80608284", "0.8025712", "0.7705018", "0.7528838", "0.75123936", "0.71361214", "0.7085131", "0.6968965", "0.6820501", "0.6793049", "0.67460245", "0.6730669", "0.6632969", "0.66176176", "0.66052604", "0.65724325", "0.65570456", "0.6484972", "0.6443919", "0.6440...
0.83357835
0
Is the bot currently connected?
def connected? @bot.connected? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def connected?\n @bot.connected?\n end", "def is_connected?\n if @client.is_connected?\n @log.info \"Asked if bot is connected: YES it is\"\n return true\n else\n @log.info \"Asked if bot is connected: NO it isn't\"\n return false\n end\n end", "def connected?\n clien...
[ "0.89154196", "0.8841808", "0.82395846", "0.78141755", "0.77785826", "0.7771428", "0.773878", "0.77067035", "0.7702226", "0.7694188", "0.7681079", "0.7657826", "0.76428205", "0.76137465", "0.75990915", "0.7592038", "0.7586019", "0.7586019", "0.7586019", "0.7586019", "0.758601...
0.8816846
2
Say something. Wraps isaac's call with a default value from msg
def say(msg, recipient = nil) recipient ||= @msg.reply_to if @msg @bot.msg(recipient, msg) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def say_hi(name, age = -1) #age has default value (-1)\r\n puts (\"Hello\" + name + \", you are\" + age.to_s)\r\nend", "def greeting (msg = \"Hello World\")\n puts msg\nend", "def say(words = 'hello') #a default parameter that is used whenever our method is called without any arguments.\n puts words + '...
[ "0.6711911", "0.6651502", "0.6518562", "0.6458587", "0.644703", "0.6440648", "0.6389932", "0.6389932", "0.6389932", "0.63770586", "0.63670427", "0.63670427", "0.6351791", "0.63340735", "0.629681", "0.6273162", "0.6245632", "0.62354666", "0.6220577", "0.61735755", "0.6170899",...
0.0
-1
Action something Wraps isaac's call with a default value from msg
def action(msg, recipient) recipient ||= @msg.reply_to if @msg @bot.action(recipient, msg) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def default_action(msg)\n #\n # do nothing.\n #\n end", "def message=(_arg0); end", "def message=(_arg0); end", "def ACK02=(arg)", "def message(msg = T.unsafe(nil), ending = T.unsafe(nil), &default); end", "def ACK01=(arg)", "def ACK03=(arg)", "def ACK10=(arg)"...
[ "0.66745883", "0.6062719", "0.6062719", "0.5985372", "0.5946264", "0.5938049", "0.59353685", "0.5877914", "0.5841647", "0.5830896", "0.58167243", "0.57681346", "0.575328", "0.5717683", "0.5717683", "0.5696746", "0.56804657", "0.56781524", "0.5678042", "0.566213", "0.5653517",...
0.0
-1
Construct a hook bot
def initialize # Keep track of hooks and what object owns what @hooks = {} @cmds = {} @modules = {} # Prevent access to hooks when other things are # editing or using them. @hooks_mutex = Mutex.new end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_hooks(*args)\r\n make :hook, *args\r\n end", "def create_bot\n derp = @config\n @bot = Cinch::Bot.new do \n configure(&derp)\n end\n end", "def create_hook!\n hook = client.create_hook(\n full_name,\n 'web',\n {\n url: Constants::HOOK_URL,\n...
[ "0.68922573", "0.68791735", "0.68699443", "0.67480004", "0.6576622", "0.64313495", "0.6293837", "0.6262295", "0.6184542", "0.60404617", "0.6029501", "0.6029349", "0.59977984", "0.597626", "0.5916502", "0.5914196", "0.58998305", "0.58806276", "0.58385444", "0.5832876", "0.5824...
0.5878174
18
Register a command, only invoked when COMMAND_RX is triggered. mod A link to the module object, used in tracking threads name A name for this command, for unregistering later trigger A regex which, if the command matches (see COMMAND_RX), will cause the callback to fire types The types of message to respond to. p A procedure to run when all the checks work out
def register_command(mod, name, trigger, types = /channel/, &p) raise "Please define a block" if not block_given? raise "That command is already hooked." if @cmds[name] raise "The module given is not a module" if not mod.is_a?(HookService) # Ensure types is an array and is full of regex types = [types] if not types.is_a?(Array) types.map!{|x| (x.is_a? Regexp) ? x : Regexp.new(x.to_s)} # convert to rx if not already @hooks_mutex.synchronize{ # Ensure default and register @cmds[name] ||= {} @cmds[name] = {:types => types, :trigger => trigger, :proc => p, :module => mod} # register hook or command for a given module @modules[mod] ||= {:hooks => [], :cmds => [], :threads => [], :threaded => mod.threaded?} @modules[mod][:cmds] << name } $log.debug "Registered command '#{name}'" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def register_hook(mod, name, trigger = nil, types = /channel/, &p)\n raise \"Please define a block\" if not block_given?\n raise \"That command is already hooked.\" if @hooks[name]\n raise \"The module given is not a module\" if not mod.is_a?(HookService)\n trigger ||= lamb...
[ "0.6438206", "0.6047119", "0.6015615", "0.58937085", "0.5891112", "0.5639508", "0.5610444", "0.55031943", "0.54022527", "0.5361733", "0.53507745", "0.5316901", "0.5295533", "0.5295533", "0.5277333", "0.52728903", "0.52683675", "0.52515525", "0.5175824", "0.516278", "0.5160571...
0.7320989
0
Register a hook to be run on any message. mod A link to the module object, used in tracking threads name A name for this hook, for unregistering later trigger A procedure to run. If this returns true, it will cause the callback to fire. types The types of message to respond to. p A procedure to run when all the checks work out
def register_hook(mod, name, trigger = nil, types = /channel/, &p) raise "Please define a block" if not block_given? raise "That command is already hooked." if @hooks[name] raise "The module given is not a module" if not mod.is_a?(HookService) trigger ||= lambda{|*| return true} # set trigger if someone has allowed it to be default raise "Cannot call the trigger expression (type: #{trigger.class})! Ensure it responds to call()" if not trigger.respond_to?(:call) # Ensure types is an array and is full of regex types = [types] if not types.is_a?(Array) types.map!{|x| (x.is_a? Regexp) ? x : Regexp.new(x.to_s)} # convert to rx if not already @hooks_mutex.synchronize{ # Ensure defaults and register @hooks[name] ||= {} @hooks[name] = {:types => types, :trigger => trigger, :proc => p, :module => mod} # Register a given hook or command for a give module @modules[mod] ||= {:hooks => [], :cmds => [], :threads => [], :threaded => mod.threaded?} @modules[mod][:hooks] << name } $log.debug "Registered hook '#{name}'" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dispatch_hooks(msg, type, bot)\n return if @hooks.length == 0\n\n @hooks_mutex.synchronize{\n @hooks.each{|name, hook|\n types, trigger, p, mod, mod_info = hook[:types], hook[:trigger], hook[:proc], hook[:module], @modules[hook[:module]]\n\n # Go through and kill any old thre...
[ "0.6690939", "0.6446525", "0.60287565", "0.6013262", "0.59964734", "0.59964734", "0.5715657", "0.56536424", "0.56026316", "0.5518584", "0.54847103", "0.54602575", "0.54424983", "0.5437172", "0.5415499", "0.53846705", "0.53805155", "0.5349809", "0.533685", "0.533685", "0.53119...
0.7221015
0
Remove a selection of hooks by name If the first argument is a number, it will be used as the timeout when waiting for any threads to end. If no timeout is given, it will wait indefinitely for threads to end.
def unregister_hooks(*names) # Load a timeout if one is given names.delete(nil) timeout = nil if names and names[0].is_a?(Numeric) then timeout = names[0].to_f names = names[1..-1] end # Then unhook things @hooks_mutex.synchronize{ names.each{|name| $log.debug "Unregistering hook: #{name}..." hook = @hooks.delete(name) mod = hook[:module] @modules[mod][:hooks].delete(name) cleanup_module(mod, timeout) } } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove(name)\n if hook = by_name(name)\n hook.destroy!\n end\n end", "def unregister_commands(*names)\n # Load a timeout if one is given\n names.delete(nil)\n timeout = nil\n if names and names[0].is_a?(Numeric) then\n timeout = names[0].to_f\n names = na...
[ "0.60684276", "0.60297287", "0.5662722", "0.5517949", "0.546", "0.54435277", "0.53744686", "0.53689307", "0.53615576", "0.53613186", "0.535067", "0.5311134", "0.52910626", "0.5247928", "0.5224371", "0.5220938", "0.5214941", "0.5199518", "0.5158245", "0.51174766", "0.5105547",...
0.730544
0
Remove cmd by name If the first argument is a number, it will be used as the timeout when waiting for any threads to end. If no timeout is given, it will wait indefinitely for threads to end.
def unregister_commands(*names) # Load a timeout if one is given names.delete(nil) timeout = nil if names and names[0].is_a?(Numeric) then timeout = names[0].to_f names = names[1..-1] end # And then unhook things @hooks_mutex.synchronize{ names.each{|name| $log.debug "Unregistering command: #{name}..." cmd = @cmds.delete(name) mod = cmd[:module] @modules[mod][:cmds].delete(name) cleanup_module(mod, timeout) } } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove name, type = nil, &block\n debug \"Runner#remove name:#{name}, type:#{type}\" \n \n batch \"#{name}.#{type}\", \"kill\", true\n batch \"#{name}.#{type}\", \"rm\", true \n unregister_all(/#{name}\\.#{type}\\./)\n end", "def delete(name, _options = {})\n ...
[ "0.574469", "0.5506502", "0.5496572", "0.5301204", "0.52708554", "0.52347267", "0.52190846", "0.52145755", "0.51994157", "0.5180374", "0.51475143", "0.5128506", "0.51164967", "0.509563", "0.5060454", "0.50186694", "0.5002888", "0.4968418", "0.4963091", "0.49486768", "0.493202...
0.58705926
0
Unregister everything by a given module
def unregister_modules(timeout=nil, *mods) mods.each{|mod| raise "no modules registed." if not @modules[mod] $log.debug "Unregistering module: #{mod.class}..." unregister_hooks(timeout, *@modules[mod][:hooks]) #if @modules[mod] # At this point @modules[mod] may have been caught in the cleanup system unregister_commands(timeout, *@modules[mod][:cmds]) if @modules[mod] } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unregister_all(timeout = nil)\n $log.debug \"Unregistering all modules...\"\n # clone to avoid editing whilst iterating\n unregister_modules(timeout, *@modules.keys.clone) \n end", "def deregister_all(session)\n namespace = session.namespace_const\n session.modules.each do |m|...
[ "0.74722874", "0.74537235", "0.72099257", "0.6884662", "0.68139005", "0.67116714", "0.6612138", "0.64030534", "0.6338498", "0.6237953", "0.6221447", "0.6220193", "0.6220193", "0.62041533", "0.6143791", "0.6132789", "0.61292493", "0.611779", "0.60821664", "0.6080475", "0.60655...
0.7372883
2
Register a module by calling hook_thyself. Since modules should extend HookService, they should implement hook_thyself in order to make initial hooks.
def register_module(mod) $log.debug "Registering module: #{mod.class}..." mod.hook_thyself end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def register_hook(mod, name, trigger = nil, types = /channel/, &p)\n raise \"Please define a block\" if not block_given?\n raise \"That command is already hooked.\" if @hooks[name]\n raise \"The module given is not a module\" if not mod.is_a?(HookService)\n trigger ||= lamb...
[ "0.62208337", "0.61620885", "0.5999698", "0.59990335", "0.59953105", "0.59561485", "0.59293103", "0.5878872", "0.57645583", "0.5731485", "0.57212275", "0.5720117", "0.5718751", "0.57021195", "0.56959605", "0.5677144", "0.56751263", "0.5620916", "0.56035733", "0.55920416", "0....
0.7623903
0
Unregister all hooks and commands by unloading all modules.
def unregister_all(timeout = nil) $log.debug "Unregistering all modules..." # clone to avoid editing whilst iterating unregister_modules(timeout, *@modules.keys.clone) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unregister_hooks(*names)\n # Load a timeout if one is given\n names.delete(nil)\n timeout = nil\n if names and names[0].is_a?(Numeric) then\n timeout = names[0].to_f\n names = names[1..-1]\n end\n\n # Then unhook things\n @hooks_mutex.synchronize{\n names...
[ "0.7282198", "0.7212914", "0.71175766", "0.7104871", "0.7079972", "0.7006872", "0.68909824", "0.6859601", "0.6843821", "0.6721234", "0.66921777", "0.66297454", "0.6579977", "0.65479416", "0.64810187", "0.6434752", "0.6395531", "0.63487756", "0.6330146", "0.6302321", "0.624605...
0.74080807
0
Receive a message from the HookBot. The 'bot' argument is a custom class including defaults taken from msg.
def dispatch(type, msg, bot) $log.debug "Received a message of type #{type}" type = type.to_s if(msg and msg.message =~ COMMAND_RX) then dispatch_command(msg, type, bot) else dispatch_hooks(msg, type, bot) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def receive_msg msg\n # stub, overwrite this in your handler\n end", "def receive_message(message)\n # Check if user send text.\n if !message.text.nil?\n model_response = send_to_api_ai(message.text)\n # Save message text from client to bot\n Message.cre...
[ "0.6636218", "0.6195777", "0.60778636", "0.60042053", "0.59741753", "0.5926893", "0.5863052", "0.5844815", "0.5825211", "0.5750855", "0.5741626", "0.57260656", "0.571037", "0.5695213", "0.56849235", "0.56703174", "0.56309474", "0.56189674", "0.5580634", "0.55194515", "0.54942...
0.605383
3
Remove any threads from the thread listing if they are not alive.
def purge_module_threads(mod) return if not @modules[mod] @modules[mod][:threads].delete_if{|t| not t.alive? } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cleanup()\n @threads.each do |name, thread| \n @threads.delete name if thread.state == :dead\n end\n end", "def exit_cleanup()\n\n threadRelease = false\n\n while not threadRelease\n # Poll each thread until there all dead\n if @localteams.empty...
[ "0.76112205", "0.6745489", "0.67278695", "0.6429435", "0.6192859", "0.61753416", "0.6065739", "0.6035887", "0.6032581", "0.60127836", "0.5985929", "0.5870762", "0.5861252", "0.58442265", "0.583116", "0.58232397", "0.5758778", "0.5741034", "0.5722103", "0.56800944", "0.565563"...
0.6377801
4
Join all threads of a given module with an overall timeout
def join_module_threads(threads, timeout = nil) return if not threads threads.each{|t| # Keep track of time start = Time.now # Allow the thread to close for up to timeout seconds t.join(timeout) # Then subtract how long it took for the next one timeout -= (Time.now - start) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def join(timeout)\n @thread.join timeout\n end", "def join\n @threads.each { |t| t.join }\n @threads.clear\n end", "def join_threads\n @worker_threads.each do |name, t|\n puts \"Joining thread: #{name}\"\n t.join\n end\n @worker_threads = {}\n end", "def join\n ...
[ "0.69774336", "0.6723436", "0.6447908", "0.6335663", "0.6331302", "0.6317171", "0.6242954", "0.62136984", "0.6190614", "0.61132056", "0.61046004", "0.60708666", "0.60655725", "0.6061742", "0.60146165", "0.5878396", "0.5857489", "0.5849045", "0.58001727", "0.575175", "0.574974...
0.8145977
0
Dispatch things to hooks
def dispatch_hooks(msg, type, bot) return if @hooks.length == 0 @hooks_mutex.synchronize{ @hooks.each{|name, hook| types, trigger, p, mod, mod_info = hook[:types], hook[:trigger], hook[:proc], hook[:module], @modules[hook[:module]] # Go through and kill any old threads, purge_module_threads(mod) # If the module is not threaded, we must find the current # thread in order to let it finish before starting a new one thread_to_await = mod_info[:threads][0] if not mod_info[:threaded] # Check types match the rx types.each{|type_trigger| if type_trigger.match(type) then $log.debug "Inspecting hook '#{name}' for module #{mod.class} (threaded? #{mod_info[:threaded]}) [#{trigger.call(msg)}]" begin # Check the hook trigger works if it's of the right type if(trigger.call(msg)) then # Then invoke raise "Too many active threads for module: #{mod_info[:name]}." if mod_info[:threads].length > MAX_MODULE_THREADS $log.debug "Dispatching hook '#{name}'..." mod_info[:threads] << invoke(prepare_vars(bot, msg, name), p, [], thread_to_await) $log.debug "Running hook #{name}: #{mod_info[:threads].length}/#{MAX_MODULE_THREADS} threads." end rescue Exception => e $log.error "Error in callback '#{name}' => #{e}" $log.debug "Backtrace: #{e.backtrace.join("\n")}" end end } # /types.each } # /@hooks.each } # /synchronize end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def perform_hooks!\n @perform_hooks = true\n end", "def hooks\n # ???\n end", "def fire(hook, *args); end", "def hook1; end", "def pre_hook_send(handler); end", "def action_hook; end", "def around_hooks; end", "def perform\n\n begin\n\n # acquire lock and fetch the loc...
[ "0.70549625", "0.69858056", "0.6834492", "0.67891943", "0.66985357", "0.6669872", "0.66516715", "0.6519832", "0.6518559", "0.6513162", "0.6478594", "0.64385027", "0.64381707", "0.6407273", "0.63715243", "0.63507575", "0.6339826", "0.63356465", "0.63339627", "0.63265985", "0.6...
0.6997882
1
Prepare values for callbacks This defines what variables callbacks can access without calling a method
def prepare_vars(bot, msg, name) { :callback_name => name, :server => bot.server, :bot_nick => bot.nick, :hooks => @hooks, :cmds => @cmds, :modules => @modules, :bot => bot, # These don't always exist for all message types, # but should be reliable if you subscribe to the # right type of events :nick => (msg)? msg.nick : nil, :recipient => (msg)? msg.recipient : nil, :reply_to => (msg)? msg.reply_to : nil, :message => (msg)? msg.message : nil, :user => (msg)? msg.user : nil, :host => (msg)? msg.host : nil, :channel => (msg)? msg.channel : nil, :error => (msg)? msg.error : nil, :raw_msg => (msg)? msg : nil # TODO: make this simply 'msg' } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prep_variables\n end", "def callback\n\t\tvars = self.instance_variables\n\t\tvars.collect do |v|\n\t\t\tif eligible(\"#{v}\")\n\t\t\t\tval = @old[\"#{v}\"]\n\t\t\t\teval(\"#{v} = #{val}\")\n\t\t\tend \n\t\tend\n\tend", "def callback=(_arg0); end", "def callbacks; end", "def callbacks; end", "def ...
[ "0.6501131", "0.63889474", "0.61723524", "0.5989991", "0.5989991", "0.5582395", "0.55480546", "0.55272174", "0.5432736", "0.54235876", "0.5405034", "0.53950524", "0.5358864", "0.5338389", "0.53379947", "0.5331397", "0.5331397", "0.5307122", "0.52959067", "0.52928996", "0.5269...
0.6240231
2
Invoke something with certain vars set.
def invoke(vars, block, args=[], thread_to_await=nil) # Construct a new class cls = Class.new # Set up pre-defined variables vars.each{|n, v| cls.send :define_method, n.to_sym, Proc.new{|| return v} } # and the call that runs the hook cls.send :define_method, :__hookbot_invoke, block # then call, in a thread, waiting for any old threads # should we have been passed one return Thread.new(thread_to_await, cls, args){ |thread_to_await, cls, args| thread_to_await.join if thread_to_await and thread_to_await.is_a(Thread) and thread_to_await.alive? begin cls.new.__hookbot_invoke(*args) rescue Exception => e $log.error "Error in callback thread: #{e}" $log.debug "#{e.backtrace.join("\n")}" end } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _perform(args); end", "def call(*args)\n\t filtered_args, vm = prepare_call(args)\n\t perform_call(filtered_args, vm)\n\tend", "def perform(*args); end", "def method_missing(method_name, *args, &block)\n @variables[method_name.to_sym].call\n end", "def invoke\n execute_only(:invoke)\n ...
[ "0.6603789", "0.6291481", "0.6198658", "0.6034645", "0.60200137", "0.5961701", "0.5930861", "0.5917767", "0.58554447", "0.5802808", "0.5783377", "0.57720214", "0.5748923", "0.57003963", "0.56816256", "0.5584135", "0.5580536", "0.5580136", "0.5573728", "0.5573728", "0.5573728"...
0.0
-1
converts amount in float or integer into Money object
def money(amount) Money.new((amount * 100).to_i) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def money\n Money.from_amount(amount.to_f)\n end", "def to_money amount\n\t\t\tamount.to_f.round(2) rescue 0.0\n\t\tend", "def coerce_money(v)\n SpookAndPuff::Money.new(v.to_s)\n end", "def to_currency(amount)\n\n decimal = BigDecimal.new(amount.to_s)\n\n full_integer = (decimal * 100)\n\n ...
[ "0.8190561", "0.77708507", "0.7509132", "0.7434018", "0.73027354", "0.7203289", "0.7181826", "0.71665597", "0.713698", "0.7114385", "0.7096725", "0.7091911", "0.7039345", "0.7034379", "0.6992524", "0.69801664", "0.69664097", "0.6963474", "0.6931813", "0.6844594", "0.6834525",...
0.7804323
1
Given a hash with numeric values, return the key for the smallest value
def key_for_min_value(name_hash) min_key = "" min_value = "" if name_hash == {} return nil else name_hash.each do |name, value| if min_value == "" || value < min_value min_value = value min_key = name end end min_key end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n hash.each do |key, value|\n if value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\nend", "def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n...
[ "0.8821222", "0.8777674", "0.87769854", "0.8745862", "0.8689437", "0.86553806", "0.865241", "0.86165065", "0.8587693", "0.8572328", "0.85674095", "0.8550907", "0.8529734", "0.8529734", "0.85182345", "0.84936565", "0.8475531", "0.8475531", "0.8466132", "0.8449126", "0.84490585...
0.0
-1
Caching index action as page caches_page :index GET /orgs/1/map.html HTML
def index end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @maps = Map.order(name: :asc)\n @title = 'Maps'\n @page_class = 'maps'\n end", "def index\n @maps = Map.all\n end", "def index\n @organisations = Queries::Organisations.order_by_most_recent\n @markers = build_map_markers(@organisations)\n end", "def render_index_mapview\n ...
[ "0.69520056", "0.6661119", "0.6482857", "0.6466864", "0.64429617", "0.64428544", "0.63820994", "0.6355083", "0.6286354", "0.627518", "0.62417454", "0.6201808", "0.6199001", "0.619711", "0.619149", "0.61901766", "0.6164313", "0.6159369", "0.61497134", "0.61031294", "0.6076383"...
0.0
-1
POST /orgs/1/map.html HTMl POST /orgs/1/map/create.html HTML /for passenger/
def create raise Marker::NoRequiredFields if params[:markers].blank? # params[:markers].each do |marker| # @org.markers.create!(marker) # end Request.add( params[:org_id], current_user, "marker", "add", { :markers => params[:markers][0..2] }) respond_success "Спасибо, Ваш запрос отправлен" rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved => e respond_error rescue Marker::NoRequiredFields => e respond_error e.message end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n #FIXME check\n @map = Map.new(params[:map])\n\n respond_to do |format|\n if @map.save\n format.html { redirect_to(@map, :notice => 'Map was successfully created.') }\n format.xml { render :xml => @map, :status => :created, :location => @map }\n else\n format.ht...
[ "0.696807", "0.67800295", "0.6774688", "0.66232926", "0.6618976", "0.6596585", "0.65922004", "0.6589328", "0.65365005", "0.64882874", "0.64482844", "0.64244074", "0.6401308", "0.63497764", "0.6334888", "0.6326622", "0.630105", "0.62724584", "0.62549067", "0.62375546", "0.6208...
0.54740477
91
Private: helper method to check if authorization parameters match the set environment variables Returns true or false
def authorized? @auth ||= Rack::Auth::Basic::Request.new(request.env) user = ENV["HTTP_USER"] pass = ENV["HTTP_PASS"] @auth.provided? && @auth.basic? && @auth.credentials && @auth.credentials == [user, pass] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authorized(authorization)\n if (ENV['SECRET_NAME'])\n creds = get_secret(ENV['SECRET_NAME'])\n calculated = \"Basic \" + Base64.encode64(\"#{creds['a2user'] || creds['A2USER']}:#{creds['a2pass'] || creds['A2PASS']}\")\n return (authorization || \"\").strip == (calculated || \"\").strip\n end\n if (...
[ "0.7383269", "0.709127", "0.7014855", "0.6940197", "0.68365604", "0.6814474", "0.6773212", "0.67322725", "0.6712682", "0.6698364", "0.668633", "0.66711974", "0.66477764", "0.6636364", "0.6578134", "0.65577257", "0.65548086", "0.6539311", "0.65208304", "0.6485632", "0.6425355"...
0.7017645
2
Returns a unique, deterministically reproducible index into an array We are hashing based on strings, let's use the ascii value of each string as a starting point.
def index(key, size) sum = 0 place = 1 key.each_byte do |c| sum = sum + c*place place += 1 end sum%size end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_unique(array)\n unique_id = 0\n\n array.each do |num|\n unique_id ^= num\n end\n\n unique_id\nend", "def generateKey(string)\r\n key = {}\r\n stringIterator = 0\r\n\r\n (string.length).times do\r\n charactersIterator = string[stringIterator] - 1\r\n divisorsIterator = 0\r\n divisors =...
[ "0.63834584", "0.62408745", "0.6144398", "0.60990644", "0.60592127", "0.6046242", "0.6042425", "0.60280126", "0.5992942", "0.5906817", "0.5871855", "0.5838909", "0.58250093", "0.5816861", "0.57664907", "0.57522625", "0.5751663", "0.57400036", "0.5729892", "0.57130796", "0.570...
0.0
-1
Calculate the current load factor
def load_factor @items*1.0/size end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_factor\n puts \"Load Factor: #{new_load_factor = @item_count / @size.to_f}\"\n return new_load_factor\n end", "def load_factor\n puts \"load_factor: #{@values} / #{@size}\"\n (@values + 0.0) / @size\n end", "def load_factor\n max_pax / capacity.to_f\n end", "def load_factor\n @c...
[ "0.8291456", "0.80895066", "0.80326515", "0.7949917", "0.77805996", "0.7604256", "0.7575579", "0.7466798", "0.7421441", "0.7403656", "0.7399935", "0.7399935", "0.73053604", "0.7291829", "0.71660674", "0.70975053", "0.7044498", "0.70077485", "0.69255835", "0.68608534", "0.6761...
0.7146284
15
Simple method to return the number of items in the hash
def size @array.length end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def size\n return @hash.length\n end", "def length\n hash.keys.length\n end", "def size\n @hash.size\n end", "def size\n @hash.size\n end", "def size\n @hash.size\n end", "def size\n @hash_array.length\n end", "def size\n @hash_array.length\n end", "def size\n ...
[ "0.82830465", "0.82106954", "0.8109915", "0.8109915", "0.8109915", "0.79695594", "0.79695594", "0.78124315", "0.77486163", "0.76849425", "0.7678069", "0.7656559", "0.7636084", "0.76298493", "0.761464", "0.761464", "0.7574793", "0.7569945", "0.7478816", "0.7444118", "0.7398974...
0.0
-1
letters that appear more than once in the string. You may assume the string contains only lowercase letters. Count the number of letters that repeat, not the number of times they repeat in the string. Difficulty: hard.
def num_repeats(string) count = {} string.each_char {|x| count[x] = string.count(x)} count.select! {|k, v| v > 1} count.length end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def num_repeats(string)\n i = 0 \n count = 0\n check = nil\n \n while i < string.length\n letter = string[i]\n i2 = 1 \n while i2 < string.length\n letter2 = string[i2]\n \n if i < i2\n if letter == letter2\n if ...
[ "0.84525627", "0.84508854", "0.8428997", "0.840122", "0.8345946", "0.83324635", "0.8319042", "0.8304465", "0.825565", "0.82428324", "0.8176287", "0.81723094", "0.8164172", "0.8147924", "0.81423587", "0.81220293", "0.81118584", "0.8094156", "0.8070209", "0.80575156", "0.805054...
0.7980196
24
UNIT TESTS FOR METHOD connect_angels_with_other(cities)
def test_angel_camp_connections map = Map.new # checking if Angel camp on index @cities[1] # is connected with...... # # First: with Nevada, it should be on index 0 of array connections # checking Angel camp is connected with Nevada # checking by name assert_equal 'Nevada City', map.cities[1].connections[0].name # # checking by ID assert_equal 0, map.cities[1].connections[0].id # # Second: # Checking Angel camp is connected with Sutter Creek assert_equal 'Sutter Creek', map.cities[1].connections[1].name # checking by id assert_equal 2, map.cities[1].connections[1].id # # Third: # checking Angel camp is connected with Virgina City # checking by name assert_equal 'Virginia City', map.cities[1].connections[2].name # checking by id assert_equal 3, map.cities[1].connections[2].id end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_validate_cities\n skip('this is a helper method for validating location names')\n # ignored cities are ones for which I don't know the location code\n # that the API accepts\n ignored_cities = %w(chongqing koln cologne dusseldorf eugene honolulu\n milan southbay)\n ci...
[ "0.67130727", "0.65000224", "0.64120615", "0.62656534", "0.60036236", "0.5957624", "0.5855112", "0.5818224", "0.5816393", "0.5793313", "0.576407", "0.5761168", "0.57517266", "0.57243514", "0.57153165", "0.56975263", "0.5655579", "0.5648212", "0.5623234", "0.56030244", "0.5550...
0.7062134
0
UNIT TESTS FOR METHOD connect_sutter_with_other(cities)
def test_connect_sutter map = Map.new # testing connect with Coloma assert_equal 4, map.cities[2].connections[1].id # testing connect angel camp assert_equal 1, map.cities[2].connections[0].id end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_validate_cities\n skip('this is a helper method for validating location names')\n # ignored cities are ones for which I don't know the location code\n # that the API accepts\n ignored_cities = %w(chongqing koln cologne dusseldorf eugene honolulu\n milan southbay)\n ci...
[ "0.6770048", "0.65557903", "0.64728314", "0.62022567", "0.6044166", "0.5971957", "0.59166145", "0.5823278", "0.57693213", "0.5763808", "0.57588565", "0.57450837", "0.5724179", "0.57118154", "0.5698426", "0.56920874", "0.5664725", "0.5646683", "0.56414545", "0.5622036", "0.562...
0.6878134
0
PUT /workout_templates/1 PUT /workout_templates/1.json
def update @workout_template = WorkoutTemplate.find(params[:id]) respond_to do |format| if @workout_template.update_attributes(params[:workout_template]) format.html { redirect_to @workout_template, notice: 'Workout template was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @workout_template.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_workout_template\n @workout_template = WorkoutTemplate.find(params[:id])\n end", "def workout_template_params\n # params.require(:workout_template).permit(:title, :isTemplate, :boolean, :exerciseCount, :user_id,:id)\n params .permit(:title, :isTemplate, :boolean, :exerciseCount, :user_...
[ "0.7166186", "0.62536865", "0.62524974", "0.62363636", "0.6178014", "0.6150158", "0.5980344", "0.59165096", "0.5878204", "0.5869198", "0.5859482", "0.5850555", "0.5828405", "0.58210343", "0.578458", "0.5782863", "0.5777991", "0.5773472", "0.5736808", "0.5723785", "0.5718111",...
0.7241972
0
DELETE /workout_templates/1 DELETE /workout_templates/1.json
def destroy @workout_template = WorkoutTemplate.find(params[:id]) @workout_template.destroy respond_to do |format| format.html { redirect_to workout_templates_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n super \"/templates/#{template_id}.json\", {}\n end", "def destroy\n @inspection_template.destroy\n respond_to do |format|\n format.html { redirect_to inspection_templates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @template_shift = Template...
[ "0.7443243", "0.71824217", "0.7181598", "0.7115013", "0.7107723", "0.70816416", "0.70725995", "0.7044704", "0.70158654", "0.7015127", "0.7009052", "0.6989359", "0.69866323", "0.6977606", "0.6973286", "0.69618255", "0.695753", "0.6954994", "0.695063", "0.694221", "0.69258916",...
0.7972006
0
this could be optimized a tiny bit by only calling superclass.build_xray but i am le tired
def build_xray @build_xray ||= begin retval = Hash.new { |hash,key| hash[key] = {} } klasses = [] klass = self while klass && klass <= UIView klasses.unshift(klass) klass = klass.superclass end klasses.each do |klass| xray_props = klass.xray xray_props && xray_props.each do |key,values| values.keys.each do |check_unique| retval.each do |section, editors| editors.delete(check_unique) end end retval[key].merge!(values) end end # clean out nil-editors and empty sections retval.each do |section, editors| editors.each do |property, editor| editors.delete(property) unless editor end retval.delete(section) if editors.length == 0 end retval end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_xml\n raise NotImplementedError, \"Override build_xml in subclass\"\n end", "def build_xml(builder)\n super(builder)\n builder.Type { |b| self.object_type.build_xml(b) } if object_type\n end", "def initialize(arry = [])\n @base = arry.collect{|el| el } # poor man's clone\n @...
[ "0.5859437", "0.5634151", "0.55204886", "0.551021", "0.5495675", "0.5474111", "0.5443462", "0.5440317", "0.53660965", "0.53269243", "0.5323505", "0.5304804", "0.52597165", "0.52544576", "0.52079296", "0.51994175", "0.5156718", "0.51438683", "0.51424146", "0.5129548", "0.51177...
0.69425344
0
main method (num > arr)
def pull(group_number) @form[INPUT_NAME] = group_number button = @form.button_with(name: BUTTON_NAME) schedule_page = @agent.submit(@form, button) teachers_links = schedule_page.links.select { |t| TEACHER_NAME_REGEX === t.to_s } teachers_links.uniq(&:text).map { |t| t.click.search(FIO_XPATH).first.text } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subarray(arr,num)\n\t#sort the array, use pointers\n\tj = 0\n\ti = 0\n\tsum = 0\n\twhile j < arr.length\n\t\tif sum < num\n\t\t\t#moving up the array if sum is less than number\n\t\t\tsum += arr[j]\n\t\t\tj += 1\n\t\telse\n\t\t\tminLen = [9000, j-i].min\n\t\t\tif i == (j-1)\n\t\t\t\treturn 1\n\t\t\tend\n\t\t\t...
[ "0.6257693", "0.62250674", "0.61015284", "0.60349137", "0.59681964", "0.5947764", "0.5939012", "0.59074765", "0.58770305", "0.5870524", "0.58109397", "0.57808965", "0.57603765", "0.5711973", "0.57119614", "0.5695944", "0.5691354", "0.5688366", "0.5664739", "0.5662924", "0.563...
0.0
-1
can slug the username
def slug self.username.downcase.gsub(" ", "-") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def slug\n username.strip.downcase.gsub(\" \",\"-\")\n end", "def slug\n username.downcase.gsub(\" \", \"-\")\n end", "def slug \n sloog = self.username.gsub(\" \", \"-\").downcase\n end", "def slug\n self.username.split(\" \").join(\"-\").downcase\n end", "def slug\n s...
[ "0.8435804", "0.8367536", "0.83382463", "0.832017", "0.832017", "0.8291674", "0.8223764", "0.8178415", "0.7684794", "0.7222219", "0.7099", "0.6982988", "0.6962085", "0.6920815", "0.6908066", "0.6907833", "0.6907679", "0.6907679", "0.68866897", "0.68746984", "0.68727815", "0...
0.81962353
7
receive the name in a method downcase the name split the name into an array of words "first last".split(' ') swap the first and last name .reverse change the vowels aeiou to the next vowel in the sequence split the word into an array run method to shuffle vowel letters over if its an edge case change the consonants to the next consonant in the alphabet run method to shuffle consonant letters over capitailize again Felicia Torres This downcases the name, splits it and reverses it.
def spy_name(real_name) ####Still in progress...###### new_name = real_name.downcase adjust = new_name.split(' ') first_n = adjust[0].split('') last_n = adjust[1].split('') index = 0 until index == first_n.last vowels = ["a", "e", "i", "o", "u"] if first_n[index] == ["a", "e", "i", "o"] first_n[index] = vowels.next elsif first_n[index] == "u" first_n[index] = "a" elsif first_n[index] == "z" first_n[index] = "b" else first_n[index].next first_n[index] = first_n[index].next end index += 1 end #don't forget to return the method index = 0 until index == last_n.last vowels = ["a", "e", "i", "o", "u"] if last_n[index] == ["a", "e", "i", "o"] last_n[index] = vowels.next elsif last_n[index] == "u" last_n[index] = "a" elsif last_n[index] == "z" last_n[index] = "b" else last_n[index].next last_n[index] = last_n[index].next end index += 1 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def scrambler (name)\n\tswapped = name.split.rotate.join(\" \") # Take name and flip it.\n\tswapped.downcase! # Make string lowercase.\n\tname1 = swapped.tr(\"aeiou\", \"eioua\") # Shift all vowels by 1 place.\n\tname2 = name1.tr(\"bcdfghjklmnpqrstvwxyz\", \"cdfghjklmnpqrstvwxyzb\") # Shift all conconants by 1 pl...
[ "0.77351695", "0.75496525", "0.7407175", "0.73109394", "0.7303107", "0.72255796", "0.721326", "0.7208969", "0.720212", "0.720212", "0.7192026", "0.7176667", "0.7155657", "0.7142886", "0.71254236", "0.7119707", "0.71136874", "0.7111007", "0.7098042", "0.7076834", "0.7073612", ...
0.70827025
19
Eigenclass Return a new instance of Vedeu::Interfaces::Clear.
def initialize(name = Vedeu.focus) @name = present?(name) ? name : Vedeu.focus end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear\n raise NotImplementedError\n end", "def clear\n raise NotImplementedError\n end", "def clear()\n\t\treturn Clear.new\n\tend", "def clear\n raise \"not implemented\"\n end", "def clear\n initialize\n end", "def clear\n initialize\n end", "def clear\n i...
[ "0.67737883", "0.67737883", "0.659532", "0.654139", "0.6377399", "0.6377399", "0.6368172", "0.61095244", "0.6105818", "0.6105818", "0.6105818", "0.61013424", "0.59717953", "0.5964348", "0.5950841", "0.594352", "0.59091365", "0.59091365", "0.59091365", "0.59091365", "0.5909136...
0.0
-1
For each visible line of the interface, set the foreground and background colours to those specified when the interface was defined, then starting write space characters over the area which the interface occupies.
def output Vedeu.timer("Clearing interface: '#{name}'") do @_clear ||= Vedeu::Buffers::Clear.new(height: height, name: name, width: width).buffer end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw_internal(text,align=0,replace=false,raw=false)\n if raw\n print_lines = [text]\n else\n text.gsub!('\\t',' ')\n print_lines = text.split('\\n',-1)\n # Check for highlights in the first line\n if print_lines[0].include?('\\\\h')\n print_lines[0].gsub!('\\\\h','')\n ...
[ "0.61942387", "0.60718477", "0.5986297", "0.59728473", "0.59654534", "0.59220773", "0.58990914", "0.5858564", "0.5855485", "0.5821235", "0.58011276", "0.5780415", "0.5769211", "0.57365894", "0.5670238", "0.56543183", "0.56215304", "0.5611865", "0.56101644", "0.5600343", "0.55...
0.0
-1
Must be an admin to access dashboard
def verify_admin? return if current_user.admin? flash[:alert] = "Sorry, only admins allowed to view the dashboard." redirect_to :root end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ensure_admin!\n authorize! :read, :admin_dashboard\n end", "def ensure_admin!\n authorize! :read, :admin_dashboard\n end", "def ensure_admin_user\n redirect_to dashboard_index_path unless is_admin?\n end", "def admin_only\n unless current_user.admin?\n redirect_to :back, :alert => \"Ac...
[ "0.81276625", "0.81276625", "0.7951534", "0.7830267", "0.77779573", "0.7712869", "0.767829", "0.7672848", "0.7661495", "0.764393", "0.764393", "0.764393", "0.7610345", "0.76047313", "0.75939715", "0.75939524", "0.758793", "0.75872076", "0.75818545", "0.7568248", "0.75581044",...
0.74010396
51
Only allow a list of trusted parameters through.
def admin_dashboard_params params.fetch(:admin_dashboard, {}) 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
Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice. Time: O(n) Space: O(n)
def two_sum(array, target) num_hash = {} array.each_with_index do |num, index| difference = target - num if num_hash[difference] return [num_hash[difference], index] else num_hash[num] = index end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def two_sum(nums, target)\n target_indexes = []\n nums.each_with_index do |primary, index|\n nums.each_with_index do |num, i|\n if primary + num == target && index != i\n target_indexes << index\n target_indexes << i\n end\n end\n end\n ...
[ "0.8142612", "0.80411804", "0.8015824", "0.79371834", "0.7869232", "0.77379245", "0.7722962", "0.7717175", "0.7687424", "0.76793766", "0.7673087", "0.76660806", "0.7646365", "0.7631855", "0.7626491", "0.7626396", "0.76148856", "0.75894606", "0.75551647", "0.75548625", "0.7549...
0.7394598
28
fetch currency rates from application configuration file config/currency_rate.yml will return currency rates along with it's type
def currency_rates @currency_rates = fetch_currency_rates end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def currency_rates\n response['rates'][currency.target_currency.to_s]\n end", "def available_currencies\n set_default_rate\n currency_rates.keys\n end", "def update_rates\n clear_rates\n add_currency_rate(\"EUR\", 1)\n add_currency_rates(config[\"exchange_rates\"]) # rates from ...
[ "0.76544577", "0.7239134", "0.72228706", "0.7119703", "0.70455575", "0.70168304", "0.69450223", "0.6929443", "0.6825915", "0.67561793", "0.66868603", "0.6650373", "0.6592395", "0.65588903", "0.6504443", "0.64992106", "0.6494795", "0.64883167", "0.64810306", "0.64431286", "0.6...
0.74599874
1
GET /trust_moneys GET /trust_moneys.json
def index @trust_moneys = TrustMoney.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_trust_objects_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: NsxComponentAdministrationApi.get_trust_objects ...\"\n end\n # resource path\n local_var_path = \"/trust-management\"\n\n # query parameters\n que...
[ "0.5751301", "0.5500747", "0.53771687", "0.5355662", "0.53144306", "0.5300288", "0.52667034", "0.52211887", "0.5193867", "0.51418126", "0.5121417", "0.5094779", "0.50687957", "0.5034705", "0.50021213", "0.4988404", "0.49769038", "0.49628618", "0.49396548", "0.4939509", "0.487...
0.59640765
0
GET /trust_moneys/1 GET /trust_moneys/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @trust_moneys = TrustMoney.all\n end", "def get_trust_objects_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: NsxComponentAdministrationApi.get_trust_objects ...\"\n end\n # resource path\n local_var_path = \"...
[ "0.6088963", "0.5720106", "0.541263", "0.53974366", "0.53008777", "0.5203522", "0.5193611", "0.51872385", "0.51235723", "0.5114555", "0.5101144", "0.5039", "0.5031927", "0.4996512", "0.49871236", "0.49567235", "0.49361736", "0.49341616", "0.49259254", "0.49168906", "0.4908501...
0.0
-1
POST /trust_moneys POST /trust_moneys.json
def create @trust_money = TrustMoney.new(trust_money_params) respond_to do |format| if @trust_money.save format.html { redirect_to @trust_money, notice: 'Trust money was successfully created.' } format.json { render :show, status: :created, location: @trust_money } else format.html { render :new } format.json { render json: @trust_money.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_create_trust? \n request.env['RAW_POST_DATA'] =~ %r[<CreateTrust>] \n end", "def postEntityUser_trust( entity_id, user_id, trust)\n params = Hash.new\n params['entity_id'] = entity_id\n params['user_id'] = user_id\n params['trust'] = trust\n return doCurl(\"post\",\"/entity/user_trust\"...
[ "0.5523912", "0.55049187", "0.5178948", "0.51492435", "0.5119799", "0.5092038", "0.5042583", "0.50357723", "0.49923077", "0.49550903", "0.4938231", "0.49223912", "0.48975712", "0.48963857", "0.48731193", "0.48671374", "0.48496756", "0.4841221", "0.48371908", "0.48151177", "0....
0.4850628
16
PATCH/PUT /trust_moneys/1 PATCH/PUT /trust_moneys/1.json
def update respond_to do |format| if @trust_money.update(trust_money_params) format.html { redirect_to @trust_money, notice: 'Trust money was successfully updated.' } format.json { render :show, status: :ok, location: @trust_money } else format.html { render :edit } format.json { render json: @trust_money.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update!(**args)\n @trust_prop = args[:trust_prop] if args.key?(:trust_prop)\n end", "def update!(**args)\n @trust_settings_for_client = args[:trust_settings_for_client] if args.key?(:trust_settings_for_client)\n end", "def update\n respond_to do |format|\n if @truste...
[ "0.6510162", "0.64779127", "0.61509436", "0.6076243", "0.5976691", "0.5937054", "0.5885354", "0.58324695", "0.5803035", "0.5798475", "0.5789043", "0.5742952", "0.56697446", "0.56017435", "0.5592119", "0.5576621", "0.5568902", "0.55615926", "0.55545837", "0.55084616", "0.55070...
0.5727918
12
DELETE /trust_moneys/1 DELETE /trust_moneys/1.json
def destroy @trust_money.destroy respond_to do |format| format.html { redirect_to trust_moneys_url, notice: 'Trust money was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def destroy\n @moresmalltrial = Moresmalltrial.find(params[:id])\n @moresmalltrial.destroy\n\n respond_to do |format|\n format.html { redirect_to moresmalltrials_url }\n format.json { head :...
[ "0.6612225", "0.6435048", "0.642754", "0.6395023", "0.63516265", "0.6321232", "0.63130873", "0.6241977", "0.6236176", "0.6235031", "0.62324655", "0.6185294", "0.615585", "0.6150322", "0.61460894", "0.6117683", "0.6115404", "0.61024165", "0.6095944", "0.6092853", "0.6082935", ...
0.65613014
1
Use callbacks to share common setup or constraints between actions.
def set_trust_money @trust_money = TrustMoney.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 trust_money_params params.require(:trust_money).permit(:source_type, :agency_id, :etc) 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 /alumni_news_items GET /alumni_news_items.json
def index @undergrad_cat = NewsItemCategory.find(2) @alumni_news_items = @undergrad_cat.news_items # @alumni_news_items = AlumniNewsItem.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n respond_to do |format|\n format.html # index.html.haml\n format.json { render :json => @news_items }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @news_item }\n end\n end", "def i...
[ "0.7233282", "0.6933822", "0.66139245", "0.6610566", "0.65969634", "0.6571096", "0.6530904", "0.6519706", "0.64900935", "0.6449386", "0.6429913", "0.6424784", "0.6420015", "0.63949746", "0.63637286", "0.6360672", "0.6357958", "0.62923354", "0.6290286", "0.6260707", "0.6243574...
0.6782471
2
GET /alumni_news_items/1 GET /alumni_news_items/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @news_item }\n end\n end", "def index\n respond_to do |format|\n format.html # index.html.haml\n format.json { render :json => @news_items }\n end\n end", "def i...
[ "0.70880896", "0.70823866", "0.6791093", "0.66198057", "0.6564841", "0.65466505", "0.6528711", "0.6506889", "0.6488905", "0.64824665", "0.6431809", "0.6416213", "0.63568264", "0.6353612", "0.6343249", "0.63359964", "0.6335246", "0.6325119", "0.63034606", "0.62951523", "0.6275...
0.0
-1
POST /alumni_news_items POST /alumni_news_items.json
def create @alumni_news_item = AlumniNewsItem.new(alumni_news_item_params) respond_to do |format| if @alumni_news_item.save format.html { redirect_to @alumni_news_item, notice: 'Alumni news was successfully created.' } format.json { render action: 'show', status: :created, location: @alumni_news_item } else format.html { render action: 'new' } format.json { render json: @alumni_news_item.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n respond_to do |format|\n if @news_item.save\n format.html { redirect_to @news_item, :notice => 'News item was successfully created.' }\n format.json { render :json => @news_item, :status => :created, :location => @news_item }\n else\n format.html { render ...
[ "0.69212556", "0.679088", "0.6723702", "0.6716267", "0.67068595", "0.6584015", "0.65362185", "0.640015", "0.6383678", "0.6381812", "0.6381812", "0.6365448", "0.63312453", "0.6326434", "0.62806755", "0.625567", "0.6251146", "0.62226677", "0.6180844", "0.61353314", "0.61287814"...
0.7126492
0
PATCH/PUT /alumni_news_items/1 PATCH/PUT /alumni_news_items/1.json
def update respond_to do |format| if @alumni_news_item.update(alumni_news_item_params) format.html { redirect_to @alumni_news_item, notice: 'Alumni news was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render json: @alumni_news_item.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @news_item.update_attributes(params[:news_item])\n format.html { redirect_to @news_item, :notice => 'News item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: 'edit' }\n for...
[ "0.68376845", "0.66334856", "0.662979", "0.65002084", "0.6474196", "0.6450485", "0.6431119", "0.6429213", "0.6350141", "0.6314212", "0.62687004", "0.6259719", "0.62417406", "0.62033004", "0.6198649", "0.6178684", "0.6169075", "0.61415565", "0.6141403", "0.6119451", "0.6110288...
0.7107624
0
DELETE /alumni_news_items/1 DELETE /alumni_news_items/1.json
def destroy @alumni_news_item.destroy respond_to do |format| format.html { redirect_to alumni_news_items_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @news_item.destroy\n \n respond_to do |format|\n format.html { redirect_to news_items_url }\n format.json { head :ok }\n end\n end", "def destroy\n @news_item.destroy\n respond_to do |format|\n format.html { redirect_to admin_news_items_url, notice: 'News...
[ "0.7383478", "0.72197795", "0.70828426", "0.7070211", "0.70491827", "0.70027846", "0.6960674", "0.6952112", "0.6912653", "0.68666136", "0.6832792", "0.682805", "0.6815279", "0.6811384", "0.68070203", "0.67974824", "0.6794741", "0.67810625", "0.6780675", "0.6776958", "0.677312...
0.77582276
0
Use callbacks to share common setup or constraints between actions.
def set_alumni_news_item @alumni_news_item = AlumniNewsItem.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 alumni_news_item_params params.require(:alumni_news_item).permit(:title, :content) 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
Overwrite to provide default options.
def default_options {} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_default_options\n end", "def default_options=(opts); end", "def default_options; {} end", "def option(options)\n default_options.merge! options\n end", "def options\n original_options = super\n user_defaults = @config\n user_defaults.merge(original_options)\n end", ...
[ "0.84135216", "0.81497043", "0.7876203", "0.7871955", "0.77495855", "0.7716972", "0.7716972", "0.77077246", "0.77077246", "0.77077246", "0.76613855", "0.7633435", "0.7599269", "0.75796056", "0.75796056", "0.7528701", "0.7499236", "0.74059355", "0.73624355", "0.736217", "0.736...
0.7318091
27
Callback called after initialization.
def after_initialize end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def after_initialize; end", "def after_initialize; end", "def after_initialize; end", "def after_initialize; end", "def after_initialize\n end", "def after_initialize\n end", "def after_initialized\n end", "def after_initialize(&block); end", "def post_init\n end", "def on_initializat...
[ "0.80069876", "0.80069876", "0.80069876", "0.80069876", "0.79419285", "0.79419285", "0.7929937", "0.7924348", "0.78855515", "0.7848953", "0.7838372", "0.7807316", "0.77661324", "0.77393824", "0.7725614", "0.7725614", "0.7679504", "0.76715547", "0.7515325", "0.7494911", "0.745...
0.80124795
0
Callback before begin assertions.
def before_assert end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def before_assert(symbol=nil, &block)\n if block_given?\n @before_assert_callbacks << block\n elsif symbol\n @before_assert_callbacks << symbol\n end\n end", "def assertions; end", "def assertions; end", "def assert\n\traise \"Assertion fail...
[ "0.6926338", "0.67333734", "0.67333734", "0.656793", "0.656793", "0.65607977", "0.6560058", "0.6560058", "0.65542305", "0.65458816", "0.6536247", "0.65192246", "0.6517277", "0.6498014", "0.6498014", "0.64941454", "0.64876235", "0.64876235", "0.6475417", "0.6475417", "0.647541...
0.788816
0
only including this show method for the sake of the cancelling a session it shouldn't be actually accessible as a page (because there's no need) update: also works as a way for someone to book a session by opening the link in a new tab. Woop!
def show update end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n # allow non-js peeps to destroy their session\n end", "def set_show_session\n session[:cheese_order] = nil\n session[:current_page] = nil\n end", "def session; end", "def session; end", "def session; end", "def session; end", "def show\n # Remember where the user is so if they'...
[ "0.66385925", "0.6331114", "0.61879855", "0.61879855", "0.61879855", "0.61879855", "0.61628985", "0.6119198", "0.6112874", "0.60910314", "0.6001623", "0.5994266", "0.59591526", "0.595192", "0.5914905", "0.5898938", "0.5878766", "0.5836117", "0.5777711", "0.575785", "0.5752891...
0.0
-1
When a user performs a search, this method is used to filter out results that are hidden from the user based on what they're searching for. For example, if a user searches for post flags by flagger name, they can see their own flags, and if they're a moderator they can see flags on other users' uploads, but they can't see flags on their own uploads.
def visible_for_search(relation, attribute = nil) relation end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hide_filter\n perm_links = ministry.lmi_hide.map { |lmi| \"lmi_total_#{lmi}\" }\n query = table[:perm_link].does_not_match(\"%_custom_%\")\n query = query.and(table[:perm_link].not_in(perm_links)) if perm_links.any?\n query\n end", "def filter_findings\n findings\n end", "def hide_...
[ "0.6334397", "0.63224846", "0.6149986", "0.606387", "0.60252094", "0.5999065", "0.58453584", "0.58444136", "0.5786225", "0.57678837", "0.5725121", "0.5703746", "0.56858015", "0.56816006", "0.5672651", "0.56722015", "0.56695783", "0.5667469", "0.5656655", "0.5644497", "0.56290...
0.0
-1
The list of attributes that are permitted to be returned by the API.
def api_attributes record.class.column_names.map(&:to_sym) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attributes\n @allowed_attributes\n end", "def restricted_attributes\n if model.respond_to?(:restricted_alchemy_resource_attributes)\n model.restricted_alchemy_resource_attributes\n else\n []\n end\n end", "def showable_attributes\n return attributes if...
[ "0.81178725", "0.77115315", "0.74468434", "0.73411125", "0.7229378", "0.7209567", "0.7171707", "0.71683663", "0.7085622", "0.7066835", "0.7061077", "0.7008751", "0.69908464", "0.6959041", "0.6956525", "0.69564134", "0.692772", "0.692772", "0.692772", "0.6891234", "0.6873543",...
0.0
-1
The list of attributes that are permitted to be used as data attributes in tables and in the tag on show pages.
def html_data_attributes data_attributes = record.class.columns.select do |column| column.type.in?(%i[integer boolean datetime float uuid interval]) && !column.array? end.map(&:name).map(&:to_sym) api_attributes & data_attributes end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attributes\n @allowed_attributes\n end", "def list_attributes\n list = \"Age: #{@age} Earth years old\\nSize: #{@size}\\nVisitor Count: #{@visitor_count}\\nInhabitants: #{@inhabitants}\\n\"\n return list\n end", "def attribute_list # :nodoc:\n [:id, :version, :uid, :user, :timestamp, :c...
[ "0.7580632", "0.72128683", "0.7202275", "0.7202074", "0.714402", "0.7090582", "0.7079916", "0.7048852", "0.7030326", "0.6994557", "0.6994492", "0.6980055", "0.69781053", "0.6971298", "0.6969956", "0.6955982", "0.6954862", "0.6909662", "0.68979704", "0.68924457", "0.68919957",...
0.72819895
1
Convert to hash, encoding subrepos as path to their repofile Used for serialization to disk so that a .repo doesn't hold information about its repo's grandchildren
def to_hash { "path_to" => @path_to, "url" => @url, "subrepos" => @subrepos.each(&:path_to), "isHead" => @is_head, } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def repo_to_hash(repo)\n { :path => repo.path }\n end", "def repo_to_hash(repo)\n { :path => repo.path }\n end", "def hash_from_git(tree)\n ({}).tap do |objs|\n tree.each do |b|\n objs[b.name] = (\n case b\n when Grit::Tree\n hash_from...
[ "0.7141848", "0.7141848", "0.6206251", "0.6089584", "0.6037521", "0.59238327", "0.5913882", "0.59111756", "0.584282", "0.58198816", "0.5798512", "0.5783281", "0.57764965", "0.5745922", "0.56756926", "0.56717056", "0.5670672", "0.5669056", "0.5663526", "0.5659797", "0.5659541"...
0.64014906
2
=== Group Querying ===
def is_in_role_group? name group_members = i_am_i_can.role_group_model.find_by!(name: name)._roles.names (get_roles.names & group_members).present? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def group\n return if record.respond_to?(:where)\n record.group\n end", "def get_groups\n sparql = SPARQL.parse(\"SELECT DISTINCT ?uri ?label\n WHERE {\n ?uri <http://www.bbc.co.uk/ontologies/sport/hasMatch> ?match_uri .\n ?uri <#{RDF::RDFS.l...
[ "0.7249811", "0.69476086", "0.68611515", "0.679284", "0.65190023", "0.65134776", "0.64668787", "0.6462983", "0.639155", "0.63870037", "0.63638943", "0.6359463", "0.6276422", "0.6264285", "0.6194671", "0.615772", "0.615772", "0.615772", "0.6118337", "0.6109248", "0.6106193", ...
0.0
-1
Resets arguments passed to generate
def reset(state) note 'Reset' state[:description] = '' state[:params] = [] state[:return] = '' state[:example] = '' state[:in_param] = false state[:in_return] = false state[:in_example] = false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset\n @args = nil\n end", "def reset! #:nodoc:\n @@args = false\n @@banner = false\n @@header = Array.new\n @@options = Array.new\n @@footer = Array.new\n end", "def _rl_reset_argument()\r\n @rl_numeric_arg = @rl_arg_sign = 1\r\n @rl_explicit_arg = false\r\n @_r...
[ "0.7613592", "0.67471886", "0.6509575", "0.6277423", "0.62344766", "0.6204325", "0.6170612", "0.6170612", "0.6170612", "0.6170612", "0.61696476", "0.61696476", "0.6145702", "0.61323303", "0.6123948", "0.6123948", "0.6075356", "0.60731447", "0.60702443", "0.60436994", "0.60436...
0.6119415
16
Remembers a user in the database for use in persistent sessions.
def remember self.remember_token = User.new_token update_attribute(:remember_digest, User.digest(remember_token)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset_user\n return unless exists?(:previous_user)\n set :user, fetch(:previous_user)\n unset :previous_user\n clear_sessions\n end", "def change_password\n @user = User.find_by_id(session[:remember_token])\n end", "def set_user\n zeus = User.find(@zeus_user.id)\n ...
[ "0.68847036", "0.65202016", "0.6288528", "0.6221299", "0.6220095", "0.6177217", "0.6141952", "0.61285347", "0.61285347", "0.6122638", "0.6121868", "0.6121868", "0.61191475", "0.6094944", "0.6088155", "0.6087507", "0.6085413", "0.6080089", "0.6078", "0.6067664", "0.604671", ...
0.0
-1
Returns true if the given token matches the digest.
def authenticated?(remember_token) BCrypt::Password.new(remember_digest).is_password?(remember_token) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authenticated?(digest, token)\n digest = send(\"#{digest}_digest\")\n # Use metaprogramming to select the appropriate token attribute based on\n # the parameter digest.\n return false if digest.nil? # Digest does not exist in the database.\n BCrypt::Password.new(digest).is_password?(token)\n ...
[ "0.78424853", "0.76170635", "0.7406786", "0.72879815", "0.7143585", "0.71428716", "0.71428716", "0.7028208", "0.6984801", "0.6964507", "0.6905196", "0.6859846", "0.6843323", "0.6824065", "0.67973304", "0.67884517", "0.67749035", "0.676529", "0.6751168", "0.67464095", "0.67436...
0.0
-1
This looks up the product first directly by the product_id, then using the product_id as the EAN.
def extract_product_id(order_line_product_id) api.lookup_product(order_line_product_id)['number'] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def product\n Product.find_by_outer_id(outer_id) || Product.find_by_num_iid(num_iid)\n end", "def product\n id = self.product_id\n found_product = FarMar::Product.find(id)\n return found_product\n end", "def product(product_id)\n FarMar::Product.all.find { |product| product.id == product_id }\...
[ "0.7176233", "0.7140765", "0.70057446", "0.68903685", "0.6846688", "0.6843145", "0.68376046", "0.67133564", "0.6656534", "0.66530675", "0.66346174", "0.66017276", "0.65703595", "0.6565071", "0.65458477", "0.6461577", "0.64559615", "0.6426951", "0.6374022", "0.63371766", "0.63...
0.5938873
52