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 |
|---|---|---|---|---|---|---|
display a single generic object | def show_single_generic_object
return unless init_show_variables
@lastaction = 'generic_object'
@item = @record.generic_objects.find { |e| e[:id] == params[:generic_object_id].to_i }
drop_breadcrumb(:name => _("%{name} (All Generic Objects)") % {:name => @record.name}, :url => show_link(@record, :displ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display\n tp self\n end",
"def show\n @objecttype = Objecttype.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @objecttype }\n end\n end",
"def show\n @tobject = Tobject.find(params[:id])\n\n respond_to do |format... | [
"0.68325436",
"0.6812218",
"0.6693576",
"0.664057",
"0.64307487",
"0.64223903",
"0.63752884",
"0.6324245",
"0.6321331",
"0.6321331",
"0.6321331",
"0.6321331",
"0.6320492",
"0.63204676",
"0.62913907",
"0.62398285",
"0.6232475",
"0.6231869",
"0.6224385",
"0.62209994",
"0.619776... | 0.7877504 | 1 |
Get all info for the node about to be displayed | def get_node_info(treenodeid, _show_list = true)
@nodetype, id = parse_nodetype_and_id(valid_active_node(treenodeid))
# resetting action that was stored during edit to determine what is being edited
@sb[:action] = nil
# Reset session to same values as first time in
session[:adv_search]["Service"] =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def node_info(client)\n client.send_message('DOM.describeNode', objectId: @object_id)\n end",
"def extract_node_details(node)\n item = node\n url = item.url\n caption = item.caption\n selected = active_node?(node)\n [caption, url, selected ]\n end",
"def get_node_inf... | [
"0.7046785",
"0.690793",
"0.6847386",
"0.6840915",
"0.6774039",
"0.67494494",
"0.6708203",
"0.67055523",
"0.66742414",
"0.6667571",
"0.66520905",
"0.66453505",
"0.6643694",
"0.66378284",
"0.66322184",
"0.661427",
"0.66050106",
"0.6601522",
"0.65901333",
"0.65814346",
"0.65578... | 0.6509199 | 31 |
Select/load filter from Global/My Filters | def load_adv_search
adv_search_build("Service")
session[:edit] = @edit
@explorer = true
@nodetype, id = parse_nodetype_and_id(valid_active_node(x_node))
if @nodetype == "ms"
listnav_search_selected(id) unless params.key?(:search_text)
if @edit[:adv_search_applied] &&
MiqExpress... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filters\n end",
"def set_filter\n @filter = Filter.friendly.find(params[:id])\n end",
"def global_filter; end",
"def filters; end",
"def filters; end",
"def filters\n @filters ||= {}\n end",
"def add_filter\n @filter = true \n end",
"def global_filter=(_arg0); end",
"def load... | [
"0.7142963",
"0.7100917",
"0.7021472",
"0.6912884",
"0.6912884",
"0.68746656",
"0.68654925",
"0.6816565",
"0.68160045",
"0.68157107",
"0.68157107",
"0.68157107",
"0.67686534",
"0.67237437",
"0.67237437",
"0.6666473",
"0.66419053",
"0.66398567",
"0.6636177",
"0.66291696",
"0.6... | 0.0 | -1 |
set partial name and cell header for edit screens | def set_right_cell_vars(action)
case action
when "dialog_provision"
partial = "shared/dialogs/dialog_provision"
header = @right_cell_text
action = "dialog_form_button_pressed"
when "ownership"
partial = "shared/views/ownership"
header = _("Set Ownership for Service")
acti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit_partial \n return 'edit_' + self.class.to_s.underscore\n end",
"def edit\n @title = t 'business_unit_type.edit_title'\n end",
"def partial\n \"/otus/page/taxon_name_header\"\n end",
"def edit\n\t\t@page_name = \" - Edit Show\"\n\tend",
"def edit\n @title = \"Edit user\"\n end",... | [
"0.6458695",
"0.600238",
"0.6002088",
"0.5955902",
"0.59065366",
"0.59065366",
"0.5835586",
"0.5725616",
"0.57050896",
"0.56903857",
"0.56120527",
"0.56120527",
"0.56120527",
"0.56120527",
"0.56120527",
"0.56120527",
"0.56120527",
"0.56120527",
"0.56120527",
"0.56120527",
"0.... | 0.5590325 | 31 |
Replace the right cell of the explorer | def replace_right_cell(options = {})
if @flash_array && @refresh_partial == "layouts/flash_msg"
javascript_flash
return
end
action, replace_trees = options.values_at(:action, :replace_trees)
@explorer = true
partial, action_url, @right_cell_text = set_right_cell_vars(action) if action # ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def replace_right_cell(options = {})\n nodetype, replace_trees, presenter = options.values_at(:nodetype, :replace_trees, :presenter)\n replace_trees = @replace_trees if @replace_trees # get_node_info might set this\n replace_trees = Array(replace_trees)\n @explorer = true\n\n trees = build_replaced_... | [
"0.72275037",
"0.7073244",
"0.66780865",
"0.6128713",
"0.5739107",
"0.562745",
"0.56102073",
"0.55582786",
"0.55332005",
"0.5502166",
"0.550026",
"0.5478145",
"0.5457529",
"0.5457068",
"0.5457068",
"0.5457068",
"0.5457068",
"0.5454134",
"0.54530966",
"0.5450171",
"0.5448202",... | 0.70980674 | 1 |
Overwriting from application controller | def find_record_with_rbac(db, id)
options = @find_with_aggregates ? { :named_scope => :with_aggregates } : {}
super(db, id, options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def controller=(_arg0); end",
"def controller=(_arg0); end",
"def controller=(_arg0); end",
"def controller(controller); end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def ... | [
"0.62650055",
"0.62650055",
"0.62650055",
"0.6262141",
"0.61537665",
"0.61537665",
"0.61537665",
"0.61537665",
"0.61537665",
"0.61537665",
"0.61537665",
"0.61537665",
"0.61537665",
"0.61537665",
"0.60159564",
"0.59972453",
"0.59648484",
"0.5801068",
"0.5797354",
"0.5789378",
... | 0.0 | -1 |
Cleans up ThreadAccessor state after given block executes | def clean_thread_context(logger: nil, namespace: nil)
if store(namespace).present?
if logger.nil?
puts "WARNING: ThreadAccessor variables set outside ThreadAccessor context: #{store(namespace).keys.join(", ")}"
else
logger.warn("ThreadAccessor variables set outside Th... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unfreeze(&block); end",
"def without_locking(&block)\n self.class.without_locking(&block)\n end",
"def thread_cleanup\n # do nothing, i think?\n end",
"def clean(&block)\n if block\n @clean = block\n else\n @clean\n end\n end",
"def te... | [
"0.623052",
"0.60515404",
"0.6020112",
"0.58528274",
"0.5790806",
"0.5772987",
"0.5772091",
"0.5644207",
"0.5634282",
"0.55808765",
"0.55705845",
"0.5564658",
"0.5543091",
"0.5517681",
"0.549853",
"0.54560655",
"0.5434994",
"0.5410208",
"0.5392921",
"0.53892004",
"0.5387261",... | 0.6414882 | 0 |
validate fields and populate errors array | def valid?()
if( requiredFieldsPresent? )
# check each condition, saving off error if one exists (ugh...)
@errors << "byr is not valid #{@args["byr"]}" if !byrValid?(@args["byr"])
@errors << "iyr is not valid #{@args["iyr"]}" if !iyrValid?(@args["iyr"])
@errors << "eyr is not valid #{@args["... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_errors\n @errors = []\n @errors << 'Expiration date is a required field' unless expiration_date\n @errors << 'Expiration Date is not a valid date' unless expiration_date.is_a? Date\n @errors << 'Card type is a required field' unless card_type\n @errors << 'Card type is not supported' unle... | [
"0.7396426",
"0.72930163",
"0.7260202",
"0.7222482",
"0.7217415",
"0.7199595",
"0.7117902",
"0.709108",
"0.70824033",
"0.706568",
"0.7062043",
"0.69657934",
"0.6948704",
"0.69349146",
"0.69130474",
"0.68661946",
"0.6777279",
"0.67764026",
"0.67019695",
"0.66854787",
"0.668312... | 0.0 | -1 |
GET /otherinfos GET /otherinfos.json | def index
@otherinfos = Otherinfo.where(:place_id => params[:m_place_id]).order('name asc')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_otherinfo\n @otherinfo = Otherinfo.find(params[:id])\n end",
"def show\n @other = Other.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @other }\n end\n end",
"def show\n @author_extra = AuthorExtra.find(params[:id... | [
"0.6198035",
"0.59847987",
"0.5877927",
"0.58435",
"0.58412296",
"0.5817476",
"0.58164257",
"0.5784245",
"0.5766928",
"0.57652986",
"0.57463866",
"0.5739338",
"0.57251924",
"0.5724998",
"0.57062095",
"0.56823945",
"0.566041",
"0.5649639",
"0.5634633",
"0.5617222",
"0.56132925... | 0.0 | -1 |
GET /otherinfos/1 GET /otherinfos/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_otherinfo\n @otherinfo = Otherinfo.find(params[:id])\n end",
"def show\n @other = Other.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @other }\n end\n end",
"def show\n @mosttwo = Mosttwo.find(params[:id])\n\n ... | [
"0.6417007",
"0.6289703",
"0.6149955",
"0.6099723",
"0.6027676",
"0.6016006",
"0.601456",
"0.595686",
"0.59269893",
"0.5914949",
"0.5894778",
"0.58887184",
"0.5867549",
"0.58532363",
"0.5844791",
"0.5825948",
"0.5824132",
"0.58212006",
"0.5798935",
"0.5783753",
"0.5783153",
... | 0.0 | -1 |
POST /otherinfos POST /otherinfos.json | def create
@otherinfo = Otherinfo.new(otherinfo_params)
@otherinfos = Otherinfo.where(:place_id => params[:m_place_id]).order('name asc')
@rawotherinfos = Otherinfo.all.order('updated_at desc')
@otherinfo.place_id = params[:m_place_id]
if @otherinfo.save
flash[:success]='New record ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def otherinfo_params\n params.require(:otherinfo).permit(:name)\n end",
"def create\n @other_contactinfo = OtherContactinfo.new(other_contactinfo_params)\n\n respond_to do |format|\n if @other_contactinfo.save\n format.html { redirect_to @other_contactinfo, notice: 'Other contactinfo wa... | [
"0.6737763",
"0.6268914",
"0.6260776",
"0.5993247",
"0.59558886",
"0.5914491",
"0.5905215",
"0.56812525",
"0.56374186",
"0.56212145",
"0.5577824",
"0.5435975",
"0.54034424",
"0.5393086",
"0.5331369",
"0.5270189",
"0.5269393",
"0.52627885",
"0.52437204",
"0.5206583",
"0.520623... | 0.5438454 | 11 |
PATCH/PUT /otherinfos/1 PATCH/PUT /otherinfos/1.json | def update
if @otherinfo.update(otherinfo_params)
flash[:success]='Record updated'
redirect_to new_otherinfo_path(:m_place_id => params[:m_place_id], :country_name => params[:country_name])
else
flash[:danger]='Denied. Record existed or spaces entered'
@otherinfos = Otherinfo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @other_contactinfo.update(other_contactinfo_params)\n format.html { redirect_to @other_contactinfo, notice: 'Other contactinfo was successfully updated.' }\n format.json { render :show, status: :ok, location: @other_contactinfo }\n else\n f... | [
"0.6413377",
"0.6376815",
"0.6317799",
"0.62835705",
"0.62079126",
"0.6180163",
"0.6161033",
"0.6145472",
"0.6137077",
"0.610943",
"0.6074583",
"0.60416204",
"0.6014978",
"0.5984057",
"0.5974846",
"0.59635377",
"0.59461665",
"0.5927254",
"0.59002703",
"0.5886818",
"0.58511233... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_otherinfo
@otherinfo = Otherinfo.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 otherinfo_params
params.require(:otherinfo).permit(:name)
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 |
Gets issues from github and creates an array of name/value hashes out of the issue titles formatted to PUT the updated fields in Zendesk to update the selection | def process_issue_array
issues_array = combine_multiple_repos_issues
cleaned_array = clean_array_for_zendesk( issues_array )
return cleaned_array
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_github_issues\n @github_issues = octokit_client.issues(repo_name).each_with_object({}) { |issue, issues|\n issues[issue[\"number\"]] = issue\n }\n end",
"def get_my_issues\n get_json( GITHUB_ISSUES_URL ).each do |item|\n puts \"#{ item[ 'repository' ][ 'full_name' ] }: ##{ item[ 'number' ... | [
"0.71504486",
"0.6923115",
"0.6712036",
"0.6668716",
"0.66452044",
"0.66297156",
"0.6622152",
"0.66207266",
"0.65812665",
"0.6577771",
"0.65747994",
"0.6541066",
"0.6535425",
"0.6500181",
"0.645229",
"0.6389228",
"0.6361695",
"0.6343631",
"0.6343342",
"0.63147557",
"0.6314447... | 0.5747453 | 59 |
Takes issues tagged from multiple repos and combines them into a single array to use in ticket field | def combine_multiple_repos_issues
all_tagged_issues_array = []
repos = ENV[ "GIT_ISSUES_REPO" ]
repos = repos.split(' ')
repos.each do | a |
repos_issues = get_issues( a, ENV[ "GIT_LABEL" ] )
all_tagged_issues_array.push( repos_issues ).flatten!
end
return all_tagged_issues_array
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_issue_array\n\t\tissues_array = combine_multiple_repos_issues\n\t\tcleaned_array = clean_array_for_zendesk( issues_array )\n\t\t\n\t\treturn cleaned_array\n\tend",
"def process_repos\n url_template = if @options.preview\n 'https://api.github.com/search/issues?q=is:pr+repo:cockpit-p... | [
"0.6923177",
"0.6654345",
"0.6561039",
"0.6427474",
"0.6311243",
"0.6262872",
"0.61847764",
"0.6169384",
"0.61307514",
"0.6128518",
"0.6076697",
"0.60670865",
"0.60276216",
"0.59895426",
"0.59874517",
"0.5930425",
"0.5844918",
"0.58364683",
"0.5786832",
"0.5783062",
"0.575897... | 0.8392352 | 0 |
Get issues from github repo and return the issues with a specific label This is separated from the cleaned issues as it may be used to provide a useful user facing display of issues | def get_issues( url, label )
issues = @git.client.issues( url, :per_page => 100 )
cleaned_issues = parse_issue_array( issues, label )
puts cleaned_issues.inspect
return cleaned_issues
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def issues_with(repository, type, label, &block)\n query_string = \"repo:#{repository} #{type}:\\\"#{label}\\\"\"\n issues = github.search_issues(query_string)[:items].map { |item| item[:number] }\n\n if block_given?\n issues.each do |issue|\n yield(issue)\n end\n end\n\n issues\nend",
"def issue... | [
"0.7235091",
"0.7235091",
"0.69672877",
"0.6673685",
"0.6634947",
"0.661118",
"0.6563231",
"0.6509336",
"0.64705074",
"0.6456412",
"0.64119005",
"0.6336298",
"0.630698",
"0.6305248",
"0.62922865",
"0.62458676",
"0.62441564",
"0.62366676",
"0.62286425",
"0.6217266",
"0.62091",... | 0.7867932 | 0 |
Make a pretty issue array to use in Zendesk display | def parse_issue_array( issues, label )
tagged_issues_array = []
issues.each do | a |
labels = a[ 'labels' ]
labels.each do | b |
if b[ 'name' ] == label
matched_issue = {}
matched_issue[ 'url' ] = a[ 'html_url' ]
matched_issue[ 'title' ]= a[ 'title' ]
matched_issue[ 'number' ] = a[ 'nu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_issue i, width = columns\n return unless i['created_at']\n ERB.new(<<EOF).result binding\n<% p = i['pull_request']['html_url'] if i.key?('pull_request') %>\\\n<%= bright { no_color { indent '%s%s: %s' % [p ? '↑' : '#', \\\n*i.values_at('number', 'title')], 0, width } } %>\n@<%= i['user']['logi... | [
"0.6494976",
"0.6221224",
"0.61150885",
"0.610995",
"0.5976272",
"0.59702814",
"0.5941562",
"0.5885566",
"0.58834624",
"0.5799784",
"0.57546204",
"0.57364213",
"0.57293016",
"0.571117",
"0.56980115",
"0.56911856",
"0.56667775",
"0.5661137",
"0.56509215",
"0.56484807",
"0.5647... | 0.531308 | 51 |
Takes an array of git issue hashes and puts what's needed into a santized array of hashes to display a cleaned title and tag in Zendesk | def clean_array_for_zendesk( issue_array )
titles = []
issue_array.each do | a |
issues = {}
title = a[ 'title' ]
url = a[ 'url' ]
url = url.gsub(/^https:\/\/github.com\/CozyCo\//, '')
url = url.gsub(/\/issue\w/, '')
url = url.to_s
issues[ 'name' ] = title + ' (' + url + ')'
url.gsub!(/\//, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_issue_array\n\t\tissues_array = combine_multiple_repos_issues\n\t\tcleaned_array = clean_array_for_zendesk( issues_array )\n\t\t\n\t\treturn cleaned_array\n\tend",
"def collect_issues_from_commits \n git.commits\n .flat_map { |c| c.message.match(issue_number_regexp)&.captures }\n ... | [
"0.6954863",
"0.6262439",
"0.62105954",
"0.6180127",
"0.60747665",
"0.6058654",
"0.6005939",
"0.5918167",
"0.587681",
"0.58627427",
"0.5849961",
"0.5828762",
"0.5825827",
"0.5808096",
"0.5752289",
"0.57313573",
"0.57255507",
"0.5655047",
"0.5637564",
"0.56079614",
"0.5605456"... | 0.7070068 | 0 |
Call with a hash mapping instance paths to absolute paths. This will compare with the last | def update_instance(key, opts, files)
instance = instance_for_key(key, opts)
last_hash = @file_hashes[key] || {}
# If they are not equal, we might as well throw everything. The biggest cost is from
# Chance re-running, and it will have to anyway.
if not last_hash.eql? fi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def autoloaded_paths_matching_absolute(absolute_path)\n @autoloaded_paths.keys.select do |path|\n absolute_path == DeepCover.custom_requirer.resolve_path(path)\n end\n end",
"def find_alternative_paths\n reset\n \n @pairs.reverse!\n find_paths\n @pairs.reverse!\n\n ... | [
"0.60322636",
"0.5927993",
"0.5743139",
"0.5624078",
"0.5439433",
"0.5387254",
"0.5365254",
"0.5353893",
"0.5349474",
"0.53278995",
"0.53238845",
"0.53054607",
"0.5304324",
"0.53023916",
"0.52994776",
"0.529469",
"0.5292025",
"0.5288816",
"0.52859676",
"0.5277407",
"0.5273043... | 0.52026856 | 25 |
Create our bucket client | def initialize(hash = {})
# Emulate the XMLRPC client
server = hash[:Server]
port = hash[:Port] || Puppet[:masterport]
environment = Puppet[:environment]
if hash.include?(:Path)
@local_path = hash[:Path]
@rest_path = nil
else
@local_path = nil
@rest_path = "... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_bucket(bucket_key,access_token)\n response = RestClient.post(\"#{API_URL}/oss/v2/buckets\",\n { bucketKey: bucket_key, policyKey:'transient'}.to_json,\n { Authorization: \"Bearer #{access_token}\", content_type:'application/json' })\n return resp... | [
"0.7133064",
"0.7033738",
"0.7009548",
"0.698552",
"0.6891243",
"0.6852154",
"0.6800088",
"0.678206",
"0.67811966",
"0.66937757",
"0.6657348",
"0.6638982",
"0.6637885",
"0.6564926",
"0.649228",
"0.64442605",
"0.6399221",
"0.63830066",
"0.63825655",
"0.63755715",
"0.6344164",
... | 0.0 | -1 |
Back up a file to our bucket | def backup(file)
raise(ArgumentError, "File #{file} does not exist") unless ::File.exist?(file)
contents = IO.binread(file)
begin
file_bucket_file = Puppet::FileBucket::File.new(contents, :bucket_path => @local_path)
files_original_path = absolutize_path(file)
dest_path = "#{@rest_path}#{f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drain(bucket, backup_file)\n open_connection\n s3_bucket = find_bucket(bucket)\n if s3_bucket[backup_file]\n log(\"Removing existing #{backup_file}\", :info)\n S3Object.delete(backup_file.to_s, bucket)\n end\n log(\"Uploading #{backup_file} to S3\", :info)\n S3Object.store(backu... | [
"0.6956034",
"0.68546796",
"0.67472273",
"0.65626985",
"0.6541171",
"0.6536038",
"0.6383449",
"0.63554555",
"0.63435",
"0.62815046",
"0.621076",
"0.61994284",
"0.6199314",
"0.6186686",
"0.61858034",
"0.6157402",
"0.6150441",
"0.61371124",
"0.6127646",
"0.6107464",
"0.60912806... | 0.7567554 | 0 |
Retrieve a file by sum. | def getfile(sum)
source_path = "#{@rest_path}md5/#{sum}"
file_bucket_file = Puppet::FileBucket::File.indirection.find(source_path, :bucket_path => @local_path)
raise Puppet::Error, "File not found" unless file_bucket_file
file_bucket_file.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_file_named name\n @files_hash[name]\n end",
"def find_file_named name\n @store.find_file_named name\n end",
"def fetch(filename, filesize)\n end",
"def rid_by_file; end",
"def sum_from_file(filename)\n\nend",
"def sum_from_file(filename)\nend",
"def sum_from_file(filename)\nend",
... | [
"0.60489064",
"0.58971435",
"0.5866315",
"0.58259934",
"0.58029205",
"0.5802443",
"0.5802443",
"0.5787637",
"0.5765826",
"0.57617414",
"0.57617414",
"0.5733719",
"0.5732094",
"0.56452805",
"0.56380326",
"0.5610591",
"0.56098264",
"0.55958563",
"0.5585833",
"0.5563856",
"0.556... | 0.7445288 | 0 |
Normalises the filename for use across platforms. | def normalize_filename
self.filename = Pathname.normalize_path(filename)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize_filename\n self.name = Pathname.normalize_filename(name)\n end",
"def sanitized_filename(filename)\n filename.strip.tap do |name|\n # NOTE: File.basename doesn't work right with Windows paths on Unix\n # get only the filename, not the whole path\n name.sub! /\\A.*(\\\\|\\/)/, ... | [
"0.8173414",
"0.7568906",
"0.7533771",
"0.753104",
"0.75101256",
"0.748665",
"0.7334101",
"0.7305624",
"0.7263333",
"0.72316015",
"0.72148776",
"0.71690816",
"0.7117396",
"0.7105106",
"0.7101808",
"0.70894176",
"0.7064929",
"0.7061152",
"0.70519507",
"0.7033371",
"0.7018672",... | 0.81258965 | 1 |
Returns a list of Folder and File objects. | def search(q)
results = []
url = "https://#{@subdomain}.sharefile.com/rest/search.aspx?op=search&query=#{q}&authid=#{@authid}&fmt=json"
response = JSON.parse(open(url).read)
if response["error"] == false #success
response["value"].each do |item|
if item["type"] == "folder"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def files\n FileList.new(`#@native.files`)\n end",
"def get_files\n fields = \"next_page_token, files(id, name, owners, parents, mime_type, sharedWithMeTime, modifiedTime, createdTime)\"\n\n folders = []\n @files = []\n\n #Go through pages of files and save files and folders\n next_token =... | [
"0.67096245",
"0.6698341",
"0.6648169",
"0.6640232",
"0.6625997",
"0.6620235",
"0.6565813",
"0.65584165",
"0.6499724",
"0.64949656",
"0.64798695",
"0.6458104",
"0.64532447",
"0.6399092",
"0.63720226",
"0.6359811",
"0.6358074",
"0.6356288",
"0.63495594",
"0.63444567",
"0.63428... | 0.0 | -1 |
Returns a list of all the account employees. | def employees
emps = []
url = prefix + "liste"
users = response(url)
if users.class == Array #success
users.each do |u|
emps << User.new(u["id"], @authid, @subdomain)
end
return emps
else #failed
return users
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list \n @employees = Employee.find( :all ) # return an array of all Employees\n end",
"def get_employees\n @employees = User.find_user_not_admin_not_client(get_company_id)\n end",
"def list_employees(opts = {})\n data, _status_code, _headers = list_employees_with_http_info(opts)\n ret... | [
"0.76910156",
"0.7645903",
"0.7418108",
"0.7418108",
"0.7383682",
"0.712769",
"0.7113111",
"0.7113111",
"0.7113111",
"0.69646853",
"0.6839058",
"0.681238",
"0.6683692",
"0.66142917",
"0.6598541",
"0.65652823",
"0.6562635",
"0.65524125",
"0.65524125",
"0.65524125",
"0.65524125... | 0.7815447 | 0 |
Returns a list of all the account clients. | def clients
clis = []
url = prefix + "listc"
users = response(url)
if users.class == Array #success
users.each do |u|
clis << User.new(u["id"], @authid, @subdomain, u)
end
return clis
else #failed
return users
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_clients\n resp = get CLIENT_API_PATH\n result = process_response(resp)\n return [] if result.empty? # In case response is {}\n result.each.map { |c| Resources::Client.new(c) }\n end",
"def clients\n clients = []\n each { |rec| clients << rec[:client] }\n cl... | [
"0.78739303",
"0.7529056",
"0.7508446",
"0.7460774",
"0.7343631",
"0.73254687",
"0.72849697",
"0.7258026",
"0.72576785",
"0.7208851",
"0.7147244",
"0.71173406",
"0.703367",
"0.703367",
"0.70053625",
"0.69667196",
"0.69457334",
"0.6835437",
"0.68292415",
"0.68100184",
"0.67973... | 0.77485037 | 1 |
str.split.each do |word| word.reverse! end.join(" ") end str = "hello world" puts str.object_id 47435609148580 puts spin_me(str) "olleh dlrow" puts spin_me(str).object_id 47435609148360 | def spin_me(arr)
arr.each do |word|
word.reverse!
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def spin_me(str)\n str.split.each do |word|\n word.reverse!\n end.join(\" \")\nend",
"def spin_me(str)\n str.split.each do |word|\n word.reverse!\n end.join(\" \")\nend",
"def spin_me(str)\n str.split.each do |word|\n word.reverse!\n end.join(\" \")\nend",
"def spin_me(str)\n str.split.each d... | [
"0.7622889",
"0.7622889",
"0.7622889",
"0.7622889",
"0.7622889",
"0.7622889",
"0.7622889",
"0.762199",
"0.760676",
"0.6314249",
"0.63012415",
"0.618495",
"0.6165869",
"0.61523414",
"0.61057377",
"0.60997295",
"0.6087675",
"0.6084279",
"0.60735524",
"0.6061077",
"0.6046897",
... | 0.61342466 | 14 |
assigns reps for one movement | def rep_range
reps = nil
if movement[:rep_range] == "High"
reps = rand(30..50)
elsif movement[:rep_range] == "Moderate"
reps = rand(11..29)
else
reps = rand(3..10)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move\n\t\t@x += 0\n\t\t@y += @vel\n\tend",
"def move\n case @direction\n when \"N\" then @y += 1 unless @y + 1 > @plateau.y || @@rover_locations.values.include?([@x, @y + 1])\n when \"E\" then @x += 1 unless @x + 1 > @plateau.x || @@rover_locations.values.include?([@x + 1, @y])\n when \"S\" then ... | [
"0.61512446",
"0.61164594",
"0.6025633",
"0.6000427",
"0.5926261",
"0.58886945",
"0.58371156",
"0.5826367",
"0.5818589",
"0.58183205",
"0.581571",
"0.581571",
"0.581571",
"0.581571",
"0.5774202",
"0.5751505",
"0.57326144",
"0.57262945",
"0.56907815",
"0.5682501",
"0.5680166",... | 0.5664065 | 22 |
has_primary_key postgres supports `db.primary_key`, mysql doesn't, so fall back to analyzing the schema. | def has_primary_key(db, table, key)
return db.primary_key(table) == key.to_s if db.respond_to?(:primary_key)
pk_column_info = db.schema(table).find { |column_info| column_info[0] == key }
return false if pk_column_info.nil?
pk_column_info[1][:primary_key] == true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def primary_key?\n schema && schema[:primary_key]\n end",
"def supports_primary_key?\n true\n end",
"def has_primary_key_column?\n @has_primary_key_column ||= !primary_key_name.nil?\n end",
"def supports_primary_key?\n true\n end",
"def supports_primary_key? #:nodoc:\n ... | [
"0.8201218",
"0.7773991",
"0.77128637",
"0.76927286",
"0.7617757",
"0.75260925",
"0.74581444",
"0.7351858",
"0.7345158",
"0.73330474",
"0.72567457",
"0.72473776",
"0.72031695",
"0.7200522",
"0.7200522",
"0.7176845",
"0.71470714",
"0.71142554",
"0.70397997",
"0.7016785",
"0.69... | 0.8430307 | 0 |
vs. (assuming we want to reuse this function) | def sum a, b
return a + b
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def same; end",
"def private; end",
"def overload; end",
"def anchored; end",
"def probers; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def terpene; end",
"def diff2; end",
"def diff1; end",
"def isolated; end",
"def isolated; end",
"def common\n ... | [
"0.68659693",
"0.6618561",
"0.64555377",
"0.63743705",
"0.63301635",
"0.6184814",
"0.6184814",
"0.6184814",
"0.6184814",
"0.61434245",
"0.6082241",
"0.60627675",
"0.59341115",
"0.59341115",
"0.59223044",
"0.59093183",
"0.59037405",
"0.59000957",
"0.5892069",
"0.5889533",
"0.5... | 0.0 | -1 |
Internal: Remove any nested client channels that have empty UIDs, so that they don't fail validations when the user doesn't want to add them. | def remove_ignored_client_channel_uids
remove_ignored_uid_fields!(params[:client][:client_channels_attributes]) if params[:client]
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prune_empty_groups\n @channels.each_value do |channel|\n channel.leave_group if channel.group? && channel.recipients.empty?\n end\n end",
"def channel_ids_to_remove\n @channel_ids_to_remove ||= begin\n cids = []\n if self.respond_to?(:message)\n cids << self.try(:messa... | [
"0.69302756",
"0.63749653",
"0.5770723",
"0.57541806",
"0.5657092",
"0.5523503",
"0.54988545",
"0.54894006",
"0.54668105",
"0.53891546",
"0.5320112",
"0.53100544",
"0.52864647",
"0.52663344",
"0.52562517",
"0.52537405",
"0.5216095",
"0.5214585",
"0.5192817",
"0.51607585",
"0.... | 0.70579845 | 0 |
def edit end def update | def destroy
@favorite = Favorite.find(params[:id])
@favorite.destroy
# @venue = Venue.find(params[:venue_id])
# @favorite = current_user.favorites.where(venue_id: params[:venue_id])
# Favorite.destroy(@favorite.ids.first)
redirect_to :back
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit\n \n end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
... | [
"0.88136274",
"0.8813391",
"0.8813391",
"0.8813391",
"0.8813391",
"0.8813391",
"0.8813391",
"0.8813391",
"0.8813391",
"0.8813391",
"0.8813391",
"0.8813391",
"0.8813391",
"0.8813391",
"0.8813391",
"0.8813391",
"0.8813391",
"0.8813391",
"0.8813391",
"0.8813391",
"0.8813391",
... | 0.0 | -1 |
Run the command or the program file with a binding. And capture calls that raised when running it. | def run(binding)
if Options.encoding_options_enabled?
Encoding.default_external = @options.external_encoding
Encoding.default_internal = @options.internal_encoding
end
$DEBUG = @options.debug
$VERBOSE = @options.verbose
Dir.chdir(@options.working_directory) if @options.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exec\n binding.pry\n # command.run(*service.exec(args.command))\n end",
"def bind; binding() end",
"def run_with_binding\n binding = get_binding\n yield binding\n end",
"def run(command)\n puts command\n `#{command}`.tap &method(:puts)\nend",
"def bind(*) end",
"def call(b... | [
"0.65606797",
"0.6469242",
"0.6183608",
"0.60644835",
"0.58981466",
"0.58239204",
"0.58053416",
"0.58053416",
"0.5794835",
"0.57555974",
"0.5727184",
"0.5683296",
"0.5668106",
"0.5664082",
"0.56288236",
"0.56168705",
"0.5616025",
"0.56044376",
"0.55827373",
"0.5580514",
"0.55... | 0.61106676 | 3 |
Compare strings sizes Define 2 variables: longest & shortest Join shortestlongestshortest | def short_long_short(first, second)
if first.size > second.size
longest = first
shortest = second
elsif second.size > first.size
longest = second
shortest = first
else
return 'Impossibru!'
end
shortest.concat(longest, shortest)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def short_long_short(str1, str2)\n str_arr = [str1, str2]\n short_str = str_arr.min { |a, b| a.size <=> b.size }\n long_str = str_arr.max { |a, b| a.size <=> b.size }\n \n short_str + long_str + short_str\nend",
"def short_long_short(string1, string2)\n long_string = ' '\n short_string = ' '\n\n if strin... | [
"0.74066716",
"0.7090232",
"0.7066109",
"0.7041725",
"0.7021079",
"0.69028795",
"0.69006157",
"0.689945",
"0.68788666",
"0.6875983",
"0.6875765",
"0.68618184",
"0.6811681",
"0.6809411",
"0.6743554",
"0.6742137",
"0.6717887",
"0.6701911",
"0.6697713",
"0.6697549",
"0.6691202",... | 0.67488855 | 14 |
GET /parent_types GET /parent_types.json | def index
@parent_types = ParentType.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @parent_type = ParentType.find(params[:id])\n end",
"def parent_type_from_request\n [*belongs_to].find { |parent| request.path.split('/').include? parent.to_s }\n end",
"def parent_type\n @parent_type ||= parent_type_from_params || parent_type_from_request\n end",... | [
"0.67118716",
"0.66516095",
"0.663728",
"0.6598066",
"0.65740526",
"0.6425569",
"0.6376784",
"0.63746434",
"0.6299972",
"0.626684",
"0.6253826",
"0.6236069",
"0.6174553",
"0.6073835",
"0.6073835",
"0.6073835",
"0.6073835",
"0.607021",
"0.6026572",
"0.60212725",
"0.6007252",
... | 0.76336896 | 0 |
GET /parent_types/1 GET /parent_types/1.json | def show
@parent_type = ParentType.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @parent_types = ParentType.all\n end",
"def parent_type\n @parent_type ||= parent_type_from_params || parent_type_from_request\n end",
"def parent_type\n @parent_type ||= parent_type_from_params || parent_type_from_request\n end",
"def parent_type_from_request\n ... | [
"0.7562762",
"0.691016",
"0.6839084",
"0.66766566",
"0.663496",
"0.66186196",
"0.6560294",
"0.650293",
"0.64233583",
"0.63005686",
"0.62997377",
"0.62628824",
"0.62628824",
"0.62144524",
"0.61794966",
"0.6147507",
"0.6088569",
"0.60437024",
"0.60437024",
"0.60437024",
"0.6043... | 0.720101 | 1 |
POST /parent_types POST /parent_types.json | def create
@parent_types = ParentType.all
@parent_type = ParentType.create(parent_type_params)
=begin
respond_to do |format|
if @parent_type.save
format.html { redirect_to @parent_type, notice: 'Parent type was successfully created.' }
format.json { render :show, status: :created, loc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parent_type_params\n params.require(:parent_type).permit(:parent_type_title, :notes)\n end",
"def set_parent_type\n @parent_type = ParentType.find(params[:id])\n end",
"def create\n @shape_type = ShapeType.new(params[:shape_type])\n\n\t\t# get the parent shape type\n\t\tparent = ShapeTyp... | [
"0.6986574",
"0.67265725",
"0.66040635",
"0.6489657",
"0.64515644",
"0.62956405",
"0.6291675",
"0.6240002",
"0.62373626",
"0.618307",
"0.6162013",
"0.6156472",
"0.6116311",
"0.60936564",
"0.60936564",
"0.60936564",
"0.60936564",
"0.6079468",
"0.6055594",
"0.5961619",
"0.59230... | 0.75422376 | 0 |
PATCH/PUT /parent_types/1 PATCH/PUT /parent_types/1.json | def update
@parent_types = ParentType.all
@parent_type = ParentType.find(params[:id])
@parent_type.update_attributes(parent_type_params)
=begin
respond_to do |format|
if @parent_type.update(parent_type_params)
format.html { redirect_to @parent_type, notice: 'Parent type was successfully... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @shape_type = ShapeType.find(params[:id])\n\n\t\t# get the parent shape type\n\t\tparent = ShapeType.find(params[:parent_shape])\n\n respond_to do |format|\n\t\t\tif parent.nil?\n\t format.html { render action: \"edit\" }\n\t format.json { render json: @shape_type.errors, status: :unpr... | [
"0.69638675",
"0.6897291",
"0.652954",
"0.6508352",
"0.6356801",
"0.6356801",
"0.6356801",
"0.6356801",
"0.6356801",
"0.6349267",
"0.6314867",
"0.62255603",
"0.61524934",
"0.6132734",
"0.601878",
"0.5867936",
"0.5818164",
"0.5814242",
"0.5781629",
"0.5770346",
"0.5763274",
... | 0.737867 | 0 |
DELETE /parent_types/1 DELETE /parent_types/1.json | def destroy
@parent_types = ParentType.all
@parent_type = ParentType.find(params[:id])
@parent_type.destroy
=begin
@parent_type.destroy
respond_to do |format|
format.html { redirect_to parent_types_url, notice: 'Parent type was successfully destroyed.' }
format.json { head :no_content ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @type = Type.find(params[:id])\n @parent_type = Type.where(:parent_id => @type.id)\n respond_to do |format|\n if @type.destroy\n @parent_type.destroy_all\n flash.now[:notice] = 'Type was successfully deleted.'\n @type = Type.new\n get_paginated_types\n e... | [
"0.75021863",
"0.69639045",
"0.6961152",
"0.6756143",
"0.66859657",
"0.66527414",
"0.6640537",
"0.6640537",
"0.6640537",
"0.6640537",
"0.6640537",
"0.6640537",
"0.6640537",
"0.66316223",
"0.6615586",
"0.6587885",
"0.65738404",
"0.6568903",
"0.65407014",
"0.6527399",
"0.651297... | 0.7408782 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_parent_type
@parent_type = ParentType.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 parent_type_params
params.require(:parent_type).permit(:parent_type_title, :notes)
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 /expenses GET /expenses.json | def index
@expenses = Expense.all
respond_with @expenses
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @expenses = find_expenses.all\n render json: @expenses\n end",
"def index\n @expenses = Expense.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @expenses }\n end\n end",
"def expenses\n @expenses ||= Harvest::API::Expenses.n... | [
"0.8207424",
"0.7868928",
"0.7521715",
"0.7485303",
"0.73566276",
"0.72700804",
"0.71818566",
"0.7099663",
"0.70841765",
"0.70841765",
"0.70841765",
"0.70841765",
"0.70841765",
"0.7070414",
"0.6989723",
"0.69714546",
"0.6969409",
"0.6900681",
"0.6863176",
"0.6781842",
"0.6775... | 0.7466285 | 4 |
GET /expenses/1 GET /expenses/1.json | def show
respond_with @expense
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @expenses = find_expenses.all\n render json: @expenses\n end",
"def index\n @expenses = Expense.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @expenses }\n end\n end",
"def index\n @api_v1_expenses = Api::V1::Expense.all\n ... | [
"0.7852153",
"0.76643664",
"0.7582055",
"0.73080707",
"0.73080707",
"0.73080707",
"0.73080707",
"0.73080707",
"0.7251809",
"0.72369164",
"0.72013515",
"0.71863693",
"0.70798296",
"0.6971261",
"0.69470507",
"0.6900109",
"0.6899645",
"0.6838902",
"0.68240345",
"0.67582136",
"0.... | 0.63898754 | 44 |
POST /expenses POST /expenses.json api :POST, '/expenses.json' param :description, :comment, :amount, :datetime | def create
@expense = Expense.create(expense_params)
@expense.user_id = current_user.id
@expense.save!
respond_with @expense, status: 201
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expense_params\n params.require(:expense).permit(:description, :comment, :amount, :datetime)\n end",
"def create\n @api_v1_expense = Api::V1::Expense.new(api_v1_expense_params)\n\n respond_to do |format|\n if @api_v1_expense.save\n format.html { redirect_to @api_v1_expense, notice: ... | [
"0.72051096",
"0.68709165",
"0.67940253",
"0.66466165",
"0.6639812",
"0.66342473",
"0.657864",
"0.655785",
"0.6556278",
"0.6539775",
"0.6523351",
"0.65120786",
"0.6467779",
"0.64367974",
"0.6391737",
"0.63820755",
"0.6375367",
"0.6370195",
"0.63402164",
"0.6335097",
"0.632289... | 0.63717014 | 17 |
PATCH/PUT /expenses/1 PATCH/PUT /expenses/1.json | def update
respond_with Expense.update(params[:id], expense_params), status: 204
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @expense = Expense.find params.fetch(:id)\n\n if @expense.update(expense_params)\n render json: @expense\n else\n render json: @expense.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_expense.update(api_v1_expense_p... | [
"0.7248082",
"0.72346777",
"0.709356",
"0.7013842",
"0.700139",
"0.686158",
"0.686158",
"0.68436813",
"0.67908907",
"0.6763711",
"0.67226046",
"0.67052156",
"0.67052156",
"0.67052156",
"0.6672167",
"0.6638457",
"0.6638457",
"0.66367996",
"0.660783",
"0.659185",
"0.65893495",
... | 0.74732983 | 0 |
DELETE /expenses/1 DELETE /expenses/1.json | def destroy
respond_with @expense.destroy, status: 204
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @expense = Expense.find(params[:id])\n @expense.destroy\n\n respond_to do |format|\n format.html { redirect_to expenses_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @expense = Expense.find(params[:id])\n @expense.destroy\n\n respond_to do |format|\n ... | [
"0.7657695",
"0.7657695",
"0.7635413",
"0.762301",
"0.75940335",
"0.7556879",
"0.7556879",
"0.74879384",
"0.74002934",
"0.7357415",
"0.7357415",
"0.7334415",
"0.72726315",
"0.72726315",
"0.72726315",
"0.72726315",
"0.72726315",
"0.72726315",
"0.7239536",
"0.72328955",
"0.7210... | 0.71496665 | 21 |
Use callbacks to share common setup or constraints between actions. | def set_expense
puts params.inspect
@expense = Expense.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 expense_params
params.require(:expense).permit(:description, :comment, :amount, :datetime)
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 |
Sorts the words (alphabetically). | def sortwords(words
return words.sort
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_words\n audit\n @_sort_words ||= words.sort { |a, b| b.last <=> a.last }\n end",
"def wordsorting (sentence)\n\t# removing punctuation and splitting sentence\n\twordlist = sentence.gsub(/\\W/, ' ').split(\" \")\n\t#sorting alpahbetically + upcase\n\tputs wordlist.sort_by { |word| word.upcase }\n... | [
"0.84755564",
"0.80587226",
"0.7877827",
"0.7664976",
"0.7593899",
"0.75931174",
"0.7585818",
"0.74547493",
"0.7400987",
"0.7338565",
"0.7325031",
"0.73165804",
"0.7275638",
"0.72525465",
"0.724706",
"0.722888",
"0.72180194",
"0.7204511",
"0.7108617",
"0.71002233",
"0.7034992... | 0.8266789 | 1 |
Prints the first word after popping it off. | def print_first_word(words)
word = words.shift
puts wor
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_first_word(words)\r\n puts word = words.pop(1)\r\n end",
"def puts_first_word(words)\n word = words.shift() # 'poop' replaced with 'pop'\n puts word\nend",
"def puts_first_word(words)\n word = words.shift()\n puts word\nend",
"def puts_first_word(words)\r\n word = words.shift()\r... | [
"0.83026797",
"0.79127467",
"0.74938226",
"0.7432668",
"0.68752015",
"0.68028194",
"0.66796434",
"0.6629198",
"0.6469374",
"0.644606",
"0.63878274",
"0.63536876",
"0.6197669",
"0.61641616",
"0.612812",
"0.60739785",
"0.6040556",
"0.60192764",
"0.60168356",
"0.6011262",
"0.601... | 0.77423066 | 2 |
Prints the last word after popping it off. | def 2print_last_word(words)
word = words.pop
puts word
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_last_word(words)\r\n puts words.pop\r\n end",
"def puts_last_word(words)\r\n word = words.pop()\r\n puts word\r\nend",
"def puts_last_word(words)\n word = words.pop\n puts word\nend",
"def puts_last_word(words)\n word = words.pop() # added parentheses, took out '-1'\n puts wor... | [
"0.8370286",
"0.80284226",
"0.80281776",
"0.7980584",
"0.7080554",
"0.69681627",
"0.68048",
"0.6652077",
"0.65737766",
"0.6540685",
"0.6456399",
"0.6409811",
"0.63593435",
"0.62084055",
"0.61711943",
"0.61613",
"0.61491215",
"0.61082906",
"0.60804945",
"0.60773087",
"0.605751... | 0.8208337 | 1 |
Takes in a full sentence and returns the sorted words. | def sort_sentence(sentence)
words = break_words(sentence)
return sort_words(words)
ed
# Prints the first and last words of the sentence.
def print_first_and_last(sentence
words = break_words(sentence)
print_first_word(word)
print_last_word(words)
end
demetri_martin_joke = "I used to play sports.
Then I realiz... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_sentence(sentence)\n words = break_words(sentence)\n return sort_words(words)\nend",
"def sort_sentence(sentence)\r\n words = break_words(sentence)\r\n sort_words(words)\r\n end",
"def sort_sentence(sentence)\n words = break_words(sentence)\n sort_words(words)\nend",
"def word_sor... | [
"0.81174713",
"0.80459726",
"0.7981296",
"0.7915561",
"0.7832548",
"0.76904315",
"0.7669052",
"0.7423833",
"0.7393661",
"0.718388",
"0.71242714",
"0.7117637",
"0.71112424",
"0.70322424",
"0.7024562",
"0.6908491",
"0.6884174",
"0.68541557",
"0.6842072",
"0.68255866",
"0.682274... | 0.6257252 | 68 |
Prints the first and last words of the sentence. | def print_first_and_last(sentence
words = break_words(sentence)
print_first_word(word)
print_last_word(words)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_first_and_last(sentence)\r\n words = break_words(sentence)\r\n puts print_first_word(words)\r\n puts print_last_word(words)\r\n end",
"def puts_first_and_last(sentence)\n words = break_words(sentence)\n puts_first_word(words)\n puts_last_word(words)\nend",
"def puts_first_and_last(... | [
"0.8663398",
"0.8283942",
"0.8283942",
"0.8283942",
"0.8094512",
"0.74387604",
"0.72902304",
"0.7270152",
"0.7270152",
"0.7270152",
"0.7167875",
"0.6711124",
"0.64211285",
"0.63916683",
"0.6390024",
"0.6358301",
"0.63018066",
"0.62566245",
"0.6085116",
"0.6047937",
"0.6030603... | 0.82583404 | 4 |
Default value for category_id key, if blank. | def assign_default_category_id
self.category_id = self.id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def category_id; (category.id rescue ''); end",
"def category_id\n if category then category.category_id end\n end",
"def get_category_type_id\n category_type ? category_type.id : 0\n end",
"def category_1\n cat = item_hash.deep_find([:primary_category, :category_id])\n cat.nil? ? nil :... | [
"0.7705098",
"0.72282434",
"0.6610562",
"0.6601009",
"0.6491731",
"0.6416548",
"0.64105344",
"0.63254714",
"0.63029534",
"0.6202889",
"0.61932784",
"0.61357963",
"0.6132263",
"0.6102078",
"0.6073176",
"0.604343",
"0.6028114",
"0.6014167",
"0.60099405",
"0.60099405",
"0.595914... | 0.7638289 | 1 |
If the file is movable (usually this means that both the file and the destination are on the filesystem), use the underlying storage's ability to move. Otherwise we "imitate" moving by deleting the file after it was uploaded. | def put(io, context)
if move?(io, context)
if movable?(io, context)
move(io, context)
else
super
io.delete if io.respond_to?(:delete)
end
else
super
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def movable?(io, id)\n io.respond_to?(:path) ||\n (io.is_a?(UploadedFile) && io.storage.is_a?(Storage::FileSystem))\n end",
"def movable?(io, id)\n io.respond_to?(:path) ||\n (io.is_a?(UploadedFile) && io.storage.is_a?(Storage::FileSystem))\n end",
"def movable?(io, co... | [
"0.68016803",
"0.68016803",
"0.6620756",
"0.64205253",
"0.61775815",
"0.61541384",
"0.61401486",
"0.610477",
"0.6103808",
"0.60962933",
"0.6083569",
"0.6049548",
"0.60246843",
"0.59906846",
"0.5954851",
"0.593244",
"0.5900898",
"0.58556783",
"0.5841155",
"0.57734716",
"0.5723... | 0.0 | -1 |
Ask the storage if the given file is movable. | def movable?(io, context)
storage.respond_to?(:move) && storage.movable?(io, context[:location])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def movable?(io, id)\n io.respond_to?(:path) ||\n (io.is_a?(UploadedFile) && io.storage.is_a?(Storage::FileSystem))\n end",
"def movable?(io, id)\n io.respond_to?(:path) ||\n (io.is_a?(UploadedFile) && io.storage.is_a?(Storage::FileSystem))\n end",
"def movable?(destin... | [
"0.7003081",
"0.7003081",
"0.67692757",
"0.6326422",
"0.6225114",
"0.5889261",
"0.58287877",
"0.57776004",
"0.5685472",
"0.5641023",
"0.5604032",
"0.5551719",
"0.54994243",
"0.5488807",
"0.54754233",
"0.54729664",
"0.5471267",
"0.5447105",
"0.54253733",
"0.54253733",
"0.54144... | 0.70579386 | 0 |
refer to login lecture/session and cookies | def find_current_user #for madlib/user connection - am i using this?
@user_found = User.find_by(id: session[:user_id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def login_from_cookie\n user = cookies.signed[:remember_me_token] && user_class.sorcery_adapter.find_by_remember_me_token(cookies.signed[:remember_me_token]) if defined? cookies\n if user && user.has_remember_me_token?\n set_remember_me_cookie!(user)\n session[:user_... | [
"0.7328381",
"0.7246429",
"0.72402745",
"0.72143364",
"0.7184021",
"0.71681565",
"0.713809",
"0.71192306",
"0.71038425",
"0.7098067",
"0.70932704",
"0.70847565",
"0.7079183",
"0.7065034",
"0.7043338",
"0.7035861",
"0.70202833",
"0.70202833",
"0.70202833",
"0.70202833",
"0.702... | 0.0 | -1 |
GET /settings GET /settings.json | def show
@setting = @department.setting
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def settings\n get('/account/settings.json')\n end",
"def get_settings\n request :get, \"_settings\"\n end",
"def get_settings\n request :get, \"_settings\"\n end",
"def get_settings\n get_uri = @data['uri'] + '/settings'\n response = @client.rest_get(get_uri, {}, @api_v... | [
"0.89007413",
"0.8499342",
"0.8499342",
"0.81988335",
"0.8194717",
"0.8035411",
"0.7977636",
"0.78468674",
"0.7711764",
"0.77005863",
"0.7669449",
"0.75457764",
"0.75348586",
"0.75291604",
"0.752877",
"0.74548715",
"0.73692334",
"0.7367028",
"0.7360977",
"0.7311814",
"0.73001... | 0.0 | -1 |
PATCH/PUT /settings/1 PATCH/PUT /settings/1.json | def update
@department = current_user.userable.department
@setting = @department.setting
respond_to do |format|
if @setting.update(setting_params)
format.html { redirect_to settings_url, notice: "Konfigurasi Berhasil diperbarui, #{undo_link(@setting)}" }
# format.json { head :no_conten... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit_settings(settings)\n queries = password_hash\n queries[:query][:settings] = \"#{settings.to_json}\"\n put \"/setup/api/settings\", queries\n end",
"def update_settings(settings)\n request :put, \"_settings\", nil, settings\n end",
"def update_settings(settings)\n ... | [
"0.7347256",
"0.71586704",
"0.71586704",
"0.6971706",
"0.69424593",
"0.6892918",
"0.68656254",
"0.6863019",
"0.67846864",
"0.67140096",
"0.67108405",
"0.67108405",
"0.670984",
"0.6671152",
"0.66373813",
"0.66282284",
"0.6597911",
"0.6553432",
"0.6549346",
"0.6540286",
"0.6540... | 0.5725744 | 97 |
Never trust parameters from the scary internet, only allow the white list through. | def setting_params
params.require(:setting).permit(:supervisor_skripsi_amount, :supervisor_pkl_amount, :examiner_amount, :maximum_lecturer_lektor_skripsi_lead, :maximum_lecturer_aa_skripsi_lead, :allow_remove_supervisor_duration, :lecturer_lead_skripsi_rule, :lecturer_lead_pkl_rule, :allow_student_create_pkl, :ma... | {
"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 |
Pile state notionally contains whether a pile is Contraband this turn; but that's actually stored on the Game object because we wipe that clean each turn. Synthesise it onto the pile. | def state
ret = self[:state] || {}
if game.facts[:contraband] && game.facts[:contraband].include?(card_type)
ret[:contraband] = true
end
return ret
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pile_cards\n if type == :basic\n basic_pile\n elsif type == :war\n war_pile\n elsif type == :mutally_assured_destruction\n destruction_pile\n end\n end",
"def black_king_capturable?\n black_king = black_pieces.select{|p| p.is_a?(King)}.first\n if black_king\n capturabl... | [
"0.58819294",
"0.56690544",
"0.55960464",
"0.5577687",
"0.555158",
"0.52765036",
"0.5238097",
"0.5217847",
"0.5172214",
"0.5169428",
"0.51601976",
"0.51453495",
"0.51306427",
"0.5112712",
"0.51113904",
"0.5095236",
"0.50843906",
"0.5071578",
"0.5054494",
"0.5032495",
"0.50260... | 0.5867027 | 1 |
init a store instance | def initialize(store, store_config, local_directory)
@local_directory = local_directory
@store = Store.new(store, store_config)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(store)\n @store = store\n end",
"def initialize( store )\n @store = store\n end",
"def initialize(store: Store.new)\n @store = store\n end",
"def initialize_store(store_name)\n PStore.new(store_name)\nend",
"def initialize(params = {})\n params = { sto... | [
"0.8299698",
"0.82802826",
"0.8029973",
"0.7960249",
"0.7664492",
"0.75870353",
"0.7534686",
"0.7479689",
"0.7453756",
"0.7311542",
"0.7210115",
"0.71673775",
"0.715529",
"0.71412325",
"0.70870686",
"0.7068991",
"0.7041218",
"0.7013658",
"0.6989408",
"0.6866086",
"0.6859532",... | 0.73408455 | 9 |
Init a Syncer object, and start syncing | def start
syncer = Syncer.new(@local_directory, @store)
syncer.sync
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start\n init_client unless @client\n\n log.info 'Bot starting to sync'\n\n @client.start_syncing\n end",
"def start_synchronize(updater); end",
"def initialize\n super\n\n self.callbacks = ::ActiveSupport::HashWithIndifferentAccess.new\n self.callbacks_queue = []\n\n s... | [
"0.7381174",
"0.6598583",
"0.641118",
"0.6362544",
"0.63611573",
"0.63611573",
"0.63323164",
"0.62500876",
"0.62199163",
"0.6100524",
"0.60466486",
"0.60466486",
"0.60466486",
"0.60419357",
"0.6036321",
"0.6036321",
"0.6027636",
"0.59892046",
"0.5949807",
"0.59150314",
"0.590... | 0.734769 | 1 |
Overrides Blacklight::SearchBuilderblacklight_params We need to do this because so much of what advanced_search is doing depends on it and currenlty there isn't a cleaner way beyond overriding it. | def blacklight_params
params = super
# This method needs to be idempotent.
if params["processed"]
params
else
process_params!(params, params_process_chain)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def with(blacklight_params = {})\n params_copy = blacklight_params.dup\n blacklight_params.delete(:routingHash)\n if params_copy[:q].present?\n # #add_query_to_solr assumes the presence of search_field, which we don't set\n # on bento page, so we set it here if absent. we MUST do this, otherwise... | [
"0.7399508",
"0.6793084",
"0.64289415",
"0.6123201",
"0.60984457",
"0.60808027",
"0.60469925",
"0.59704095",
"0.5961426",
"0.5910215",
"0.58478624",
"0.5832312",
"0.58296275",
"0.5804014",
"0.5803729",
"0.5802184",
"0.5797221",
"0.5776785",
"0.5737943",
"0.57333446",
"0.57208... | 0.6339584 | 3 |
Updates in place the query values in params by folding the named procedures passed in through the values. | def process_params!(params, procedures)
params ||= {}
procedures ||= []
params["processed"] = true
ops = params_field_ops(params)
ops.each { |op, f|
query_key, query_value = f
# Fold the procedures onto the query value.
params[query_key] = procedures.reduce(query_v... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def substitute_values(param_vals)\n @param_mids.inject(@prefix) do |accum, (param, mid)|\n accum + (param_vals[param] || param) + mid\n end\n end",
"def compute_query_api_pattern_params(query_api_method_name, container, used_query_params)\n container[:params] = compute_query_api_pattern_para... | [
"0.6382295",
"0.6144336",
"0.59185106",
"0.5902987",
"0.571294",
"0.571123",
"0.5510942",
"0.5507395",
"0.5507395",
"0.5507395",
"0.5507395",
"0.5506011",
"0.5506011",
"0.5505726",
"0.5501574",
"0.5459883",
"0.5367824",
"0.53377825",
"0.5323194",
"0.5301572",
"0.52866",
"0.... | 0.77074164 | 0 |
Helper function that transforms the params in the typical blacklight_params advanced search format into a list of tuples of the form [[op, field])] where op is the operator and field is a key value pair, [query_key, query_value]. | def params_field_ops(params)
begin
fields = params.to_unsafe_h.compact.select { |k| k.match(/(^q$|^q_)/) }
ops = params.to_unsafe_h.fetch("op_row", ["default"])
ops.zip(fields)
rescue
[]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_params **params\n [\n INTERNAL_PARAMS.each_with_object({}) do |param, acc|\n acc[param] = params.delete(param)\n end.reject { |_, v| v.nil? },\n params\n ]\n end",
"def args_from_params(query_params)\n [\n *criteria_... | [
"0.6144782",
"0.6142862",
"0.61411023",
"0.61277175",
"0.6086954",
"0.6064815",
"0.6015565",
"0.6010667",
"0.5979988",
"0.5954069",
"0.5900209",
"0.5821603",
"0.57871634",
"0.5783671",
"0.5782908",
"0.5754523",
"0.5746199",
"0.57086325",
"0.56994754",
"0.56797004",
"0.5628075... | 0.6323315 | 0 |
toprtl diagonal Define display_board that accepts a board and prints out the current state. | def display_board(board)
puts " #{board[0]} | #{board[1]} | #{board[2]} "
puts "-----------"
puts " #{board[3]} | #{board[4]} | #{board[5]} "
puts "-----------"
puts " #{board[6]} | #{board[7]} | #{board[8]} "
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_board\n\t\t\tsystem(\"cls\")\n\t\t\tprint \"\\n\"\n\t\t\t 7.downto(0).each_with_index{|x|\n\t\t\t\t print \"#{x+1}| \"\n\t\t\t\t\t8.times{|y|\n\t\t\t\t\tif y%2==0 && x%2 == 0 || y%2==1 && x%2 == 1\n\t\t\t\t\t\tif @board[y][x] != nil && @board[y][x].color == \"white\"\n\t\t\t\t\t\t\tprint @board[y][x]... | [
"0.76373965",
"0.76123405",
"0.75596225",
"0.75596225",
"0.75457376",
"0.7542049",
"0.7511473",
"0.74830383",
"0.7443204",
"0.7423727",
"0.7384564",
"0.7380199",
"0.7380199",
"0.73782104",
"0.73782104",
"0.73782104",
"0.73782104",
"0.73782104",
"0.73782104",
"0.73782104",
"0.... | 0.7165633 | 96 |
code your move method here! def move(board, position, player = 'X') | def move(board, position, player = 'X')
#player = current_player(board) #w/o this line, tictactoe spec will run properly
position = position.to_i - 1
board[position] = player
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move(board, position , player= \"X\" )\n\tposition = position.to_i\n\tboard[position -1] = player\n\tdisplay_board(board)\nend",
"def move(move_position, player=\"X\")\n @board[move_position] = player\n end",
"def move(board, position, current_player= \"X\")\n board[position.to_i - 1] = current_player... | [
"0.88477045",
"0.8594708",
"0.84886265",
"0.84832203",
"0.8450455",
"0.84063154",
"0.83152544",
"0.82929957",
"0.8265965",
"0.82556814",
"0.8145136",
"0.8145136",
"0.8098796",
"0.8082725",
"0.7993675",
"0.7969816",
"0.79698116",
"0.79649496",
"0.7923512",
"0.7916754",
"0.7912... | 0.8006523 | 14 |
code your valid_move? method here | def valid_move?(board, position)
position = position.to_i - 1
if position_taken?(board, position)
return false
else
if position.between?(0,8) && (board[position] != "X" || board[position] != "O")
return true
else
return false
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_move?(new_x, new_y)\n true\n end",
"def valid_move?(move_index)\r\n #valid if position is NOT taken\r\n valid = !self.position_taken?(move_index)\r\n if valid == true\r\n if move_index.between?(0,8)\r\n valid = true\r\n else\r\n valid = false\r\n end\r\n end... | [
"0.82555014",
"0.8206571",
"0.80988276",
"0.8078809",
"0.8062644",
"0.8059585",
"0.80573076",
"0.79910356",
"0.79760164",
"0.7954171",
"0.79520303",
"0.79362106",
"0.7926097",
"0.7923089",
"0.7916774",
"0.7911268",
"0.79109216",
"0.7906181",
"0.79061437",
"0.7892746",
"0.7857... | 0.7789093 | 44 |
Returns a description of how to use this plugin | def usage
[
"#{at_nick} mahlzeit - #{nick} fragt wer zu Mittag fahren will",
"#{at_nick} stats - #{nick} sendet dir deine Statistik",
"#{at_nick} ich - #{nick} fuegt dich zur Liste hinzu",
]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def description\n \"Derelict::Plugin::Manager for #{instance.description}\"\n end",
"def get_help\n [self.class::DESCRIPTION, self.class::USAGE]\n end",
"def plugin_info\n {\n 'name' => plugin_name,\n 'description' => 'The Core plugin provides a lot of the basic ... | [
"0.73201376",
"0.72512347",
"0.71277803",
"0.7016416",
"0.70075893",
"0.69829094",
"0.69358015",
"0.69358015",
"0.69358015",
"0.69358015",
"0.69358015",
"0.69358015",
"0.69358015",
"0.69358015",
"0.69358015",
"0.69358015",
"0.6907128",
"0.6892188",
"0.6881885",
"0.6881885",
"... | 0.0 | -1 |
Replies with a random string selected from +places+. | def handle(time, sender_nick, message)
words = words(message)
phrase = words.join(' ')
puts phrase
if sent_to_me?(message)
puts "hier"
if phrase == "mahlzeit"
puts "1"
mahlzeit()
elsif phrase == "stats"
puts "2"
stats(sender_nick)
elsif phrase == ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def choose_place(places)\n userPlaceIds=@user.histories.pluck(:place_id)\n selectPlace=places.select do |place|\n !userPlaceIds.include?(place[\"place_id\"])\n end\n randomPlace = rand(0..selectPlace.count-1)\n selectPlace.present? ? selectPlace[randomPlace] : nil\n end",
"def randomly( word... | [
"0.7080004",
"0.65821457",
"0.61001897",
"0.6047525",
"0.6047525",
"0.60470086",
"0.6040409",
"0.6030278",
"0.6028495",
"0.6027629",
"0.60134125",
"0.5952812",
"0.5911697",
"0.58686244",
"0.586174",
"0.58504647",
"0.5836323",
"0.58238864",
"0.58045936",
"0.5790955",
"0.578668... | 0.0 | -1 |
=begin Description: Following action will list all the snacks in listing page. Argument: NIL Return: Products with(id, name) =end | def get_snacks_list
@complete_snacks_list = Spree::Product.select('id, name').limit(10).order("updated_at desc")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def snacks\n\n @snacks = Spree::Product.limit(5).order('id desc')\n @snacks.sort_by! { |x| x[:name].downcase }\n end",
"def index\n @snacks = Snack.all\n end",
"def list_snacks\n snacks = Snack.all\n snacks.each do |snack|\n puts \"#{snack.name}\"\n snack.machines.each do |machine|\n pu... | [
"0.76530224",
"0.6481596",
"0.6166926",
"0.61195076",
"0.596384",
"0.59536237",
"0.58875895",
"0.5870653",
"0.5836811",
"0.5804512",
"0.5802742",
"0.57855606",
"0.5728528",
"0.5724594",
"0.57118237",
"0.57101965",
"0.56936973",
"0.5692813",
"0.5681295",
"0.5664606",
"0.565190... | 0.7355577 | 1 |
testing protected methods and everything in this module is protected | def authenticated?; super; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def protected_method\n end",
"def testing\n # ...\n end",
"def test_private_method\n make_controller :private_method\n get :index\n assert_protected\n get :secret_ferret_brigade\n assert_protected\n end",
"def self_test; end",
"def self_test; end",
"def __dummy_test__\n ... | [
"0.72368467",
"0.70708376",
"0.6995882",
"0.6930213",
"0.6930213",
"0.68168336",
"0.6735226",
"0.6681606",
"0.66737187",
"0.6672524",
"0.66294885",
"0.6625224",
"0.66233426",
"0.65888625",
"0.65888625",
"0.6524283",
"0.6524283",
"0.6505696",
"0.6438397",
"0.64125836",
"0.6406... | 0.0 | -1 |
Let's return to implementing existing core ruby methods to learn about blocks. The Enumerablemap method iterates over the members of a collection, using the associated block to perform some sort of operation on each collection member. The returned values from the block are then built up into an Array that is then retur... | def map(arr)
new_arr = []
for el in arr
new_arr << yield(el)
end
new_arr
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def map(arr) # creating our own map method\n\tnewArr = [] # declaring an empty array to push our results inside\n\tarr.each do |i| # run the block of code to iterate inside each elements in an array\n\t\tnewArr << yield(i) # push the modified elements inside our newArr []\n\tend\n\tnewArr\nend",
"def map(&block)... | [
"0.8052947",
"0.8011478",
"0.8011478",
"0.7886645",
"0.78786373",
"0.782487",
"0.7824117",
"0.78146315",
"0.7686366",
"0.76805204",
"0.7644029",
"0.7627865",
"0.7618681",
"0.7605525",
"0.7560407",
"0.7558743",
"0.755783",
"0.75466675",
"0.75466675",
"0.7536199",
"0.7513269",
... | 0.7514949 | 20 |
Drops should be equal to another drop if the sources are the same or if the object is the source. | def ==(comparison_object)
self.source == (comparison_object.is_a?(self.class) ? comparison_object.source : comparison_object)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eql?(other) self.class == other.class and target==other.target and source==other.source; end",
"def eql?(other) self.class == other.class and target==other.target and source==other.source; end",
"def prepare_reuse_validation_diff(other)\n original = self.reload!.comparable\n reference = other... | [
"0.6287926",
"0.6287926",
"0.56855637",
"0.55154455",
"0.5470282",
"0.54678696",
"0.54556453",
"0.54162174",
"0.53696615",
"0.53696615",
"0.5335804",
"0.5322248",
"0.53130597",
"0.53119105",
"0.53051203",
"0.5304619",
"0.53016824",
"0.5295001",
"0.52924716",
"0.52840984",
"0.... | 0.50590897 | 52 |
This is a helper method for adding methods to return the paths of each of the versions of an image. The attachment_name parameter should be the name of the attachment as created in the model. The param_name is the name by which it is referred to in the drop. So, if you have an attachment called 'hack' in the model and ... | def has_attached_image(attachment_name, param_name=nil)
Spritz::ASSET_STYLES.keys.each do |image_name|
method_name = (param_name.blank? ? '' : "#{param_name}_") + "#{image_name}_path"
eval <<-END
def #{method_name}
@#{attachment_name}_#{image_name}_path ||= source.#{attachment_name}.fi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def define_attachment_methods!\n attachment = self\n name = attachment_name\n\n define_method :\"#{name}_attacher\" do |**options|\n if !instance_variable_get(:\"@#{name}_attacher\") || options.any?\n instance_variable_set(:\"@#{name}_attacher\", attachment.build_attacher(s... | [
"0.5686316",
"0.55052704",
"0.5451111",
"0.54486436",
"0.5442401",
"0.52905536",
"0.523697",
"0.51995707",
"0.50798994",
"0.506765",
"0.5061601",
"0.50051105",
"0.49671078",
"0.49612528",
"0.49370128",
"0.492171",
"0.4906691",
"0.48991403",
"0.4896859",
"0.48851287",
"0.48709... | 0.6346403 | 0 |
Implement your own version of collect | def my_collect(array, &block)
new_array = []
counter =0
if block_given?
while counter < array.length
new_array[counter] = yield(array[counter])
counter +=1
end
return new_array
else
return self.to_enum
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collect; end",
"def collect(*args, &block)\n all.collect(*args, &block)\n end",
"def collect\n end",
"def\tcollect\n\t\ta = []\n\t\tself.each{|v| a << v}\n\t\ta\n\tend",
"def collect!\n els = @elements.collect! {|v| yield(v)}\n Vector.elements(els, false)\n end",
"def map\n reset... | [
"0.7945171",
"0.7451587",
"0.7256824",
"0.7008434",
"0.68928796",
"0.6732169",
"0.6687331",
"0.6664563",
"0.66336006",
"0.6599862",
"0.65917945",
"0.64508456",
"0.62940896",
"0.62785196",
"0.61866087",
"0.6177598",
"0.6115385",
"0.6101845",
"0.6031941",
"0.6005398",
"0.592655... | 0.52530426 | 57 |
This will copy the key to the desired host | def copyKey (ip, username)
puts "Connecting to #{ip} with User -> #{username}....."
# Magic Command - the mirror to ssh-copy-id
system "cat ~/.ssh/id_rsa.pub | ssh #{username}@#{ip} 'mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys'"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy_ssh_key\n copy_file_to_storage_directory(full_keypair_path)\n end",
"def add(host, key); end",
"def accept(host, key)\n @public_keys[host] = key\n File.open(@public_keys_file, 'w') do |f|\n YAML::dump(@public_keys, f)\n end \n end",
"def add(host... | [
"0.7547926",
"0.68913877",
"0.6804767",
"0.6628122",
"0.66163766",
"0.66029334",
"0.6542157",
"0.651184",
"0.63197535",
"0.63007313",
"0.6252288",
"0.6247377",
"0.6182221",
"0.6175844",
"0.61705464",
"0.6117021",
"0.61168194",
"0.61168194",
"0.61046755",
"0.60906315",
"0.6038... | 0.73902005 | 1 |
Will get the hosts we want to deploy the public key too | def getHosts
file = "config.lst"
if File.exist?(file)
lstArray = File.readlines(file).map do |line|
# Used ";" to avoid \t (TAB) which is different across OS'es
RemoteClient.new( *line.split("\;") )
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hosts(key)\n unless @@vendors[key].nil?\n @@vendors[key][:hosts].collect { |id| @@hosts[id] }\n else\n []\n end\n end",
"def hosts; end",
"def hosts; end",
"def hosts; end",
"def deploy(_)\n OneProvisionLogger.info('(Deploy skipped)')\n... | [
"0.71098375",
"0.6980223",
"0.6980223",
"0.6980223",
"0.6854257",
"0.6831326",
"0.68281895",
"0.6785089",
"0.67050165",
"0.6669778",
"0.6669778",
"0.6669778",
"0.6669778",
"0.6629854",
"0.6537384",
"0.65333563",
"0.65199673",
"0.6510769",
"0.6461031",
"0.6451546",
"0.64034915... | 0.0 | -1 |
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the nth prime number? | def nth_prime(n)
arry_prime = []
value = 2
while arry_prime.size < n
if is_prime?(value)
arry_prime << value
end
value += 1
end
arry_prime[-1]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def problem(nth = 6,i = 13)\n while nth < 10001\n i += 2\n nth += 1 if i.prime?\n end\n i\n end",
"def nth_prime(n)\n primes = []\n\tint = 2\n\tuntil primes.length == n\n if int <= 3\n primes << int\n else\n primes << int if (2..Math.sqrt(int)).all? { |x| int % x != 0 }\n ... | [
"0.7696163",
"0.7664297",
"0.7624685",
"0.75854814",
"0.7551536",
"0.75469816",
"0.74904656",
"0.7483468",
"0.7479547",
"0.746471",
"0.7434999",
"0.7428087",
"0.7425985",
"0.74249434",
"0.7410047",
"0.73675174",
"0.73252636",
"0.7319863",
"0.7309978",
"0.728505",
"0.72459924"... | 0.70813835 | 32 |
Largest Prime Factor The prime factors of 13195 are 5, 7, 13 and 29. Thus, the largest prime factor of 13195 is 29. What is the largest prime factor of the number 600851475143 ? | def largest_factor(number)
result = prime_factors(number).sort
result[-1]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def largest_prime_factor\n number = 600851475143\n n = 2\n while n < number\n if number % n == 0\n factor = number / n\n return factor if is_prime?(factor)\n end\n n += 1\n end\nend",
"def largestPrimeFactor\n\tn = 600851475143\n\tfactor = 2\n\tlastFactor = 1\n\n\twhile n > 1\n\t\tif n % f... | [
"0.84101367",
"0.8368567",
"0.7892742",
"0.78567773",
"0.7837646",
"0.7790762",
"0.7776166",
"0.77610415",
"0.77582276",
"0.77563775",
"0.77440107",
"0.77421",
"0.7733982",
"0.7730267",
"0.7721052",
"0.771764",
"0.7690192",
"0.767771",
"0.7667793",
"0.76474214",
"0.7631038",
... | 0.7447844 | 40 |
A Narcissistic Number is a number which is the sum of its own digits, each raised to the power of the number of digits. must return true or false depending upon whether the given number is a Narcissistic number. For example, take 153 (3 digits): 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153 | def dig_number(number)
arr_dig = number.to_s.chars
count = arr_dig.size
arr_dig.map {|dig| dig.to_i ** count}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def narcissistic?(num)\n digits = num.to_s.chars.map(&:to_i)\n pwrs = digits.map! { |digit| digit**digits.size }\n pwrs.reduce(:+) == num\nend",
"def narcissistic?(value)\n digit_count = value.digits.length\n return value == value.digits.map! { |d| d**digit_count }.reduce(:+)\nend",
"def is_narcissist... | [
"0.8524762",
"0.84302074",
"0.82808626",
"0.79534686",
"0.7771258",
"0.73561126",
"0.7139342",
"0.7134939",
"0.7075871",
"0.69588166",
"0.68944955",
"0.68920964",
"0.6887616",
"0.6796446",
"0.67538154",
"0.67164207",
"0.6695544",
"0.6678805",
"0.66436684",
"0.65898716",
"0.65... | 0.0 | -1 |
Let sum_of_proper_divisors(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n). If we run a number, num1, through the function, we will get num2. What if we run num2 through the function? If sum_of_proper_divisors(num1) == num2 AND sum_of_proper_divisors(num2) == num1, wher... | def sum_of_proper_divisors(n)
sum_factor1 = factors_numbers(n).reduce(:+)
number2 = sum_factor1
sum_factor2 = factors_numbers(number2).reduce(:+)
if (n == sum_factor2) && (number2 == sum_factor1) && (n != number2)
return "Yes, amicable with #{number2}"
else
"No"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_proper_divisors_sum(num)\n\tsum = 0\n\tsqrt = Math.sqrt(num)\n\n\t# add all divisors into sum\n\t(1..sqrt).each do |n|\n\t\t# if num is a proper divisor\n\t\tif num % n == 0\n\t\t\t# add it--and its pair (other than 1 and sqrt)--into sum\n\t\t\tif [1,sqrt].include?(n)\n\t\t\t\tsum += n\n\t\t\telse\n\t\t\t... | [
"0.7496924",
"0.74205357",
"0.73277867",
"0.71549046",
"0.70964897",
"0.7041229",
"0.6971315",
"0.6950206",
"0.68802667",
"0.68738353",
"0.68720394",
"0.68682575",
"0.6859391",
"0.68123955",
"0.67846906",
"0.67490447",
"0.67312276",
"0.6709103",
"0.6704058",
"0.6689075",
"0.6... | 0.8131516 | 0 |
Count the palindromes. Determine how many palindromes are in a string. Order of the string must be preserved. A palindrome is a string that is the same characters reading it forwards as reading it backwards. Anagram must be of length 3 or more and preserve the given order. EX: is_palindrome?("banana") == 2 there are 2 ... | def is_palindrome?(string)
counter = 0
if string.length == 0 || string.length == 1
return counter
elsif string[0]==string[-1]
is_palindrome?(string[1..-2])
counter += 1
elsif string[0]!=string[-1]
is_palindrome?(string[1..-1])
else
false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_palindrome(string)\n joined_str = string.gsub(/[^0-9a-z]/i, '').downcase\n reverse_str = reverser(joined_str.clone)\n difference_count = 0\n joined_str.length.times do |i|\n difference_count += 1 if joined_str[i] != reverse_str[i]\n end\n\n if difference_count != 0\n return false\n else\n re... | [
"0.7514369",
"0.7408426",
"0.7274876",
"0.72559774",
"0.72190046",
"0.72067636",
"0.72031945",
"0.7169884",
"0.7134805",
"0.71227056",
"0.7109024",
"0.7092453",
"0.7090322",
"0.7056979",
"0.70248306",
"0.70212245",
"0.70188046",
"0.7017396",
"0.7013061",
"0.7001468",
"0.69928... | 0.75378484 | 0 |
Define a method that accepts two arguments, a string and an integer. The method should return a copy of the string with the nth letter removed. | def remove_nth_letter(string, n)
string[0..n-1] + string[n+1..-1]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_nth_letter(string, n)\n\nend",
"def remove_nth_letter(string, n)\n string.delete!(string[n])\nend",
"def remove_nth_letter(string, n)\n string[0...n] + string[n + 1..-1]\nend",
"def remove_char(str)\n str[1..-2]\nend",
"def remove_char(s)\n #s = string\n s = s[1..-2]\n return s\nend",
"def... | [
"0.8559485",
"0.8248828",
"0.812142",
"0.6744251",
"0.6646491",
"0.6597266",
"0.6568994",
"0.6498533",
"0.6420847",
"0.6401374",
"0.6397267",
"0.63551176",
"0.6313464",
"0.63092947",
"0.6260834",
"0.62138987",
"0.61878514",
"0.61777407",
"0.6162288",
"0.614498",
"0.6132467",
... | 0.8022394 | 3 |
Define a method that chunks an array into a nested array of subarrays of length n. The last array may be of length less than n if the original array's size does not divide evenly by n. chunk([1,2,3,4,5], 2) => [[1,2], [3,4], [5]] | def chunk(array, n)
arr_result = []
sub_arr = []
i = 0
while i < array.length
num = array[i]
if sub_arr.length == n
arr_result << sub_arr
sub_arr = []
end
sub_arr << num
i += 1
end
arr_result << sub_arr
arr_result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chunk(array, n)\nend",
"def chunk(array, n)\n\nend",
"def chunk(array, n)\n \n results = []\n until array.empty?\n results << array.shift(n)\n end\n \n results\n\nend",
"def array_chunk(array, size)\n result = []\n index = 0\n while array.length > index do\n resul... | [
"0.784023",
"0.7767573",
"0.7702775",
"0.7702758",
"0.76556486",
"0.75363696",
"0.75284046",
"0.75283825",
"0.7388212",
"0.71040416",
"0.6939282",
"0.69087833",
"0.6786093",
"0.66954434",
"0.6692829",
"0.6609564",
"0.6603057",
"0.65976316",
"0.65789217",
"0.6565457",
"0.65243... | 0.8114498 | 0 |
Define a method that multiplies the frequencies of the periods, commas, hyphens, semicolons, question marks, and exclamation points in a given string and returns the product. If any punctuation does not occur, don't include it in the product, i.e., don't multiply by zero! | def product_punctuation(str)
sign_str = "!.,-;?"
result = 1
if str == sign_str
return result
end
numbers_sign = str.each_char.count {|elem| sign_str.include?(elem)}
result *= numbers_sign
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def product_punctuation(str)\nend",
"def product_punctuation(str)\n\nend",
"def product_punctuation(str)\n\n p new_hash = Hash.new(0)\n # p new_hash2 = {}\n str.split(\"\").each do |el|\n if \",.-;?!\".include?(el)\n new_hash[el] += 1\n end\n end\n new_hash.values.reduce(:*)\nend",
"def prod... | [
"0.7340966",
"0.724903",
"0.7166471",
"0.6533699",
"0.6195395",
"0.5992582",
"0.59547704",
"0.59418565",
"0.5918774",
"0.59151125",
"0.59151125",
"0.5908595",
"0.5908595",
"0.58982646",
"0.58965224",
"0.58919656",
"0.58919656",
"0.5866834",
"0.5855366",
"0.5840882",
"0.580121... | 0.8122944 | 0 |
Translate a sentence into piglatin! The first consonants go to the end of the word, then add "ay". | def pig_latin(sentence)
words = sentence.split
result = words.map do |word|
latinize(word)
end
result.join(" ")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pig_latin_sentence(sentence)\r\n\tnew_sentence = \"\"\r\n\tsentence.split.each do |word|\r\n\t\tif word[0].downcase =~ /[aeiou]/\r\n\t\t\tword << \"way\" \r\n\t\telse\r\n\t\t\tn = /[aeiou]/.match word.downcase\r\n\t\t\tword = n.to_s + n.post_match + n.pre_match + \"ay\"\r\n\t\tend\r\n\t\tnew_sentence << word\r... | [
"0.8682276",
"0.8590262",
"0.8543074",
"0.8531962",
"0.8480306",
"0.8429678",
"0.8399851",
"0.839944",
"0.83662647",
"0.8337475",
"0.8329728",
"0.8295034",
"0.8283078",
"0.82632536",
"0.8248267",
"0.82395166",
"0.8234308",
"0.8222498",
"0.81927204",
"0.8167851",
"0.81635016",... | 0.8128013 | 26 |
GET /programmes GET /programmes.json | def index
@programmes = Programme.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @programmes }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @programs = Program.where(:user_id => current_user.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @programs }\n end\n end",
"def show\n @programme = Programme.find(params[:id])\n\n respond_to do |format|\n format.html # show.h... | [
"0.69034076",
"0.6866331",
"0.66709983",
"0.6647374",
"0.65649474",
"0.65044814",
"0.65044814",
"0.63181525",
"0.63022363",
"0.63022363",
"0.62657845",
"0.62535954",
"0.62083",
"0.6204104",
"0.61362046",
"0.61132884",
"0.61022866",
"0.6067264",
"0.60495085",
"0.6040252",
"0.6... | 0.7775246 | 0 |
GET /programmes/1 GET /programmes/1.json | def show
@programme = Programme.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @programme }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @programmes = Programme.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @programmes }\n end\n end",
"def index\n @programs = Program.where(:user_id => current_user.id)\n\n respond_to do |format|\n format.html # index.html.erb\n... | [
"0.77159256",
"0.7189967",
"0.70815015",
"0.70815015",
"0.7031768",
"0.6935075",
"0.68796545",
"0.6811549",
"0.6643124",
"0.6548802",
"0.65461004",
"0.6514467",
"0.6514467",
"0.64955676",
"0.64955676",
"0.648221",
"0.64465773",
"0.6398448",
"0.63698345",
"0.6325205",
"0.63047... | 0.735676 | 1 |
GET /programmes/new GET /programmes/new.json | def new
@enquiry = Enquiry.find(params[:id])
@enquiry.programmes.build
respond_to do |format|
format.html # new.html.erb
format.json { render json: @programme }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @program = Program.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @program }\n end\n end",
"def new\n @program = Program.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @program }\n ... | [
"0.7882953",
"0.7882953",
"0.7675684",
"0.7397495",
"0.7356041",
"0.73411775",
"0.72730505",
"0.7272778",
"0.72458005",
"0.7243871",
"0.72436655",
"0.71465915",
"0.7129194",
"0.7089781",
"0.7077555",
"0.7067398",
"0.704563",
"0.7037358",
"0.7037358",
"0.7037358",
"0.7010333",... | 0.701447 | 20 |
POST /programmes POST /programmes.json | def create
@programme = Programme.new(params[:programme])
respond_to do |format|
if @programme.save
format.html { redirect_to @programme, notice: 'Programme was successfully created.' }
format.json { render json: @programme, status: :created, location: @programme }
else
form... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @programme = Programme.new(programme_params)\n @programme.user = current_user\n @programme.programme_status = 'draft'\n\n\n respond_to do |format|\n if @programme.save\n format.html { redirect_to new_spec_path(programme: @programme.id), notice: 'Programme was successfully creat... | [
"0.6739392",
"0.63904655",
"0.62975454",
"0.6274852",
"0.6241923",
"0.61724377",
"0.61671275",
"0.6159695",
"0.6157146",
"0.609938",
"0.60571206",
"0.60571206",
"0.60564405",
"0.60319865",
"0.60317314",
"0.60113597",
"0.6003334",
"0.5936821",
"0.5923215",
"0.58190566",
"0.581... | 0.7027268 | 0 |
PUT /programmes/1 PUT /programmes/1.json | def update
@programme = Programme.find(params[:id])
respond_to do |format|
if @programme.update_attributes(params[:programme])
if (params[:programme][:notes_attributes])
tl("Registration",@programme.registration.id,'A note to a programme has been created for this registra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @programme.update(programme_params)\n format.html { redirect_to @programme, notice: 'Programme was successfully updated.' }\n format.json { render :show, status: :ok, location: @programme }\n else\n format.html { render :edit }\n for... | [
"0.67882335",
"0.6687964",
"0.6686946",
"0.6588181",
"0.6577229",
"0.6577229",
"0.6550848",
"0.6391545",
"0.6383559",
"0.6380455",
"0.6342388",
"0.63268924",
"0.6325602",
"0.62289083",
"0.62195414",
"0.6207419",
"0.6181845",
"0.61800754",
"0.61790246",
"0.6178531",
"0.6174938... | 0.57945955 | 53 |
DELETE /programmes/1 DELETE /programmes/1.json | def destroy
@programme = Programme.find(params[:id])
@programme.destroy
respond_to do |format|
format.html { redirect_to @programme.registration }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @programme.destroy\n respond_to do |format|\n format.html { redirect_to programmes_url, notice: 'Programme was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @program.destroy\n respond_to do |format|\n format.html { redirect... | [
"0.7096878",
"0.69497526",
"0.68645376",
"0.6859226",
"0.6859226",
"0.67862403",
"0.6764997",
"0.6764997",
"0.6764997",
"0.6764997",
"0.6753685",
"0.66971374",
"0.667136",
"0.66665107",
"0.6663424",
"0.6651507",
"0.66368955",
"0.6621613",
"0.6604266",
"0.65994",
"0.65727186",... | 0.695136 | 1 |
method to generate the forecast text for the wind | def generate_forecast_text
@text = I18n.t("forecast_text.wind.text_start")
@text.concat(create_strength_text)
@text.concat(create_wind_text)
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_wind_text\n text = I18n.t(\"forecast_text.wind.text_maximum\")\n text.concat((@extreme_values.maximum * 3.6).ceil.to_s)\n text.concat(I18n.t(\"forecast_text.wind.text_maximum_unit\"))\n text.concat(create_prevalent_direction_text)\n text.concat(I18n.t(\"forecast_text.w... | [
"0.7431767",
"0.69098824",
"0.6661661",
"0.64000607",
"0.6244477",
"0.621299",
"0.6044913",
"0.5894051",
"0.57939905",
"0.5729695",
"0.5629905",
"0.5609508",
"0.5564858",
"0.5533732",
"0.5533122",
"0.5518387",
"0.54810494",
"0.54617274",
"0.5451191",
"0.54406804",
"0.54275197... | 0.84187055 | 0 |
method to generate the warning text for the measurand | def generate_warning_text
@warnings
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def warning(text); end",
"def warning(text); end",
"def create_warnings\n @warnings= \"\"\n @warnings.concat(\"\\n\") if (!@temperature_text.warnings.empty?)\n @warnings.concat(@temperature_text.warnings)\n @warnings.concat(\"\\n\") if (!@wind_text.warnings.empty?)\n @warnings.concat(@... | [
"0.7318499",
"0.7318499",
"0.7291689",
"0.723727",
"0.723727",
"0.7043616",
"0.69389117",
"0.690439",
"0.69021016",
"0.6887592",
"0.6887592",
"0.68745464",
"0.68670666",
"0.6824537",
"0.6758065",
"0.6753776",
"0.67522705",
"0.67522705",
"0.67522705",
"0.67522705",
"0.67522705... | 0.82079476 | 0 |
method to generate the text about the day | def create_strength_text
wind_strength = I18n.t("forecast_text.wind.strength_normal")
if (is_threshold_active?(:hurricane_day))
wind_strength = I18n.t("forecast_text.wind.strength_extremly_stormy")
elsif (is_threshold_active?(:storm_day))
wind_strength = I18n.t("forecast_text.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def event_day_text(event, cols)\n if cols == 1\n max_size = 84/num_days\n else\n max_size = 42/(num_days * cols)\n end\n if event.title.size > (max_size)\n text = event.title[0..(max_size - 1)] + '..'\n else\n text = event.title\n end\n text = \"<b>\" ... | [
"0.7187629",
"0.7143471",
"0.71416104",
"0.6906027",
"0.68605435",
"0.67403203",
"0.6712403",
"0.6711883",
"0.6680466",
"0.66405857",
"0.66191614",
"0.6615583",
"0.6594843",
"0.65937907",
"0.6522414",
"0.6520705",
"0.651675",
"0.6497998",
"0.64453566",
"0.6441802",
"0.6434513... | 0.0 | -1 |
method to generate the text with wind values | def create_wind_text
text = I18n.t("forecast_text.wind.text_maximum")
text.concat((@extreme_values.maximum * 3.6).ceil.to_s)
text.concat(I18n.t("forecast_text.wind.text_maximum_unit"))
text.concat(create_prevalent_direction_text)
text.concat(I18n.t("forecast_text.wind.text_mean")... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_forecast_text\n @text = I18n.t(\"forecast_text.wind.text_start\")\n @text.concat(create_strength_text)\n @text.concat(create_wind_text)\n nil\n end",
"def windStr \n \"windStr\" \n end",
"def create_strength_text\n wind_strength = I18n.t(\"forecast_t... | [
"0.7265868",
"0.674465",
"0.6327411",
"0.6192039",
"0.6163627",
"0.61153007",
"0.60628736",
"0.6045976",
"0.6034717",
"0.599421",
"0.59571147",
"0.5819712",
"0.580709",
"0.57657385",
"0.5762417",
"0.57211936",
"0.5715577",
"0.5699017",
"0.56906676",
"0.56858444",
"0.5675199",... | 0.8014512 | 0 |
method to create the text for the prevalent wind direction | def create_prevalent_direction_text
if (@prevalent_direction == nil)
return I18n.t("forecast_text.wind.direction_circular")
end
return WrfForecast::Directions.new().get_direction_string(@prevalent_direction)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_wind_text\n text = I18n.t(\"forecast_text.wind.text_maximum\")\n text.concat((@extreme_values.maximum * 3.6).ceil.to_s)\n text.concat(I18n.t(\"forecast_text.wind.text_maximum_unit\"))\n text.concat(create_prevalent_direction_text)\n text.concat(I18n.t(\"forecast_text.w... | [
"0.7190327",
"0.7072079",
"0.6736276",
"0.65006846",
"0.6099762",
"0.6070816",
"0.6028022",
"0.60115266",
"0.58985084",
"0.5838108",
"0.5742611",
"0.57337356",
"0.5691589",
"0.568897",
"0.5647533",
"0.55884784",
"0.55884784",
"0.5561102",
"0.5544559",
"0.5525317",
"0.54771036... | 0.76943624 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.