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 |
|---|---|---|---|---|---|---|
POST /cotiz_apps POST /cotiz_apps.json | def create
@cotiz_app = CotizApp.new(cotiz_app_params)
respond_to do |format|
if @cotiz_app.save
format.html { redirect_to cotiz_app_path(@cotiz_app), notice: 'Cotiz app was successfully created.' }
format.json { render :show, status: :created, location: @cotiz_app }
else
format.html { render :new }
format.json { render json: @cotiz_app.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @app = App.new(app_params)\n\n if @app.save\n render json: @app, status: :created, location: @app\n else\n render json: @app.errors, status: :unprocessable_entity\n end\n end",
"def create_app(name, url)\n JSON.parse((@cloudvox_api[\"/applications/create.json\"].post :call_... | [
"0.7014279",
"0.69154334",
"0.67668414",
"0.65505975",
"0.6537957",
"0.6537957",
"0.6456246",
"0.6445254",
"0.63990986",
"0.6395038",
"0.63841283",
"0.6348803",
"0.63391256",
"0.6332053",
"0.63165224",
"0.62793344",
"0.62699795",
"0.6263665",
"0.6250768",
"0.62279874",
"0.621... | 0.7350217 | 0 |
PATCH/PUT /cotiz_apps/1 PATCH/PUT /cotiz_apps/1.json | def update
respond_to do |format|
if @cotiz_app.update(cotiz_app_params)
format.html { redirect_to @cotiz_app, notice: 'Cotiz app was successfully updated.' }
format.json { render :show, status: :ok, location: @cotiz_app }
else
format.html { render :edit }
format.json { render json: @cotiz_app.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_app data={}\n put '/app', data\n end",
"def update\n @app = @client.app(params[:id])\n\n respond_to do |format|\n if @app.update_attributes(params[:app]) # FIXME\n format.html { redirect_to @app, notice: 'App was successfully updated.' }\n format.json { head :no_co... | [
"0.6923472",
"0.68712246",
"0.67298466",
"0.6681554",
"0.66156673",
"0.66156673",
"0.6515584",
"0.6515584",
"0.65035",
"0.65035",
"0.65035",
"0.64690644",
"0.6447963",
"0.6447963",
"0.6447963",
"0.6447963",
"0.6447963",
"0.63959014",
"0.6378787",
"0.63649786",
"0.63495135",
... | 0.6965362 | 0 |
DELETE /cotiz_apps/1 DELETE /cotiz_apps/1.json | def destroy
@cotiz_app.destroy
respond_to do |format|
format.html { redirect_to cotiz_apps_url, notice: 'Cotiz app was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @client.app_destroy(params[:id])\n\n respond_to do |format|\n format.html { redirect_to apps_url }\n format.json { head :no_content }\n end\n end",
"def destroy(name)\n\t\tdelete(\"/apps/#{name}\")\n\tend",
"def destroy(name)\n\t\tdelete(\"/apps/#{name}\")\n\tend",
"def webh... | [
"0.72765744",
"0.70685446",
"0.70685446",
"0.70478565",
"0.6902837",
"0.6845121",
"0.6807613",
"0.6807613",
"0.6807613",
"0.68056977",
"0.68056977",
"0.6745641",
"0.6737259",
"0.66894203",
"0.66691405",
"0.66691405",
"0.66691405",
"0.66691405",
"0.66685176",
"0.666208",
"0.66... | 0.7126609 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_cotiz_app
@cotiz_app = CotizApp.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 cotiz_app_params
params.require(:cotiz_app).permit(:name, :lastname, :dni_type, :dni_number, :local_code_area, :local_phone, :movil_code_area, :movil_phone, :birthday, :marital_status, :sex, :email, :vehicle_year, :vehicle_brand, :vehicle_model, :vehicle_version, :plaque, :intermediate_code, :state, :plan_code, :plan_review, :discount_rate, :vehicle_use, :kilometer_zero, :vehicle_type)
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 |
Vowels (a,e,i,o,u), digits, punctuation, and whitespace should not be doubled. | def double_consonants(string)
result_string = ''
string.each_char do |letter|
(letter =~ /[b-df-hj-np-tv-z]/i) == 0 ? result_string << letter << letter : result_string << letter
end
result_string
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vowels # :nodoc:\n /((?<!q)u|[aeio]|(?<=[bcdfghjklmnprstvwxz])y).*$/\n end",
"def vowels_6(words)\n words.downcase.match(/a|e|i|o|u/).to_s\nend",
"def vowels_5(letter)\n letter.downcase.match(/a|e|i|o|u/) != nil\nend",
"def vowels_2(letter)\n case letter.downcase\n when \"a\" then true\n ... | [
"0.7184114",
"0.6964012",
"0.69342595",
"0.6885545",
"0.68598",
"0.6849794",
"0.68184143",
"0.679643",
"0.67508227",
"0.67462623",
"0.6729141",
"0.66968936",
"0.6673613",
"0.6667262",
"0.66664934",
"0.6662529",
"0.665183",
"0.66472036",
"0.66356295",
"0.6624161",
"0.66104037"... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def login_params
params.require(:login).permit(:email, :password_string)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
GET /vendes GET /vendes.json | def index
@vendes = Vende.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def venue(vid, options = {})\n options.merge!({ :query => { :key => @api_key } })\n self.class.get(\"/venues/#{vid}\", options)\n end",
"def show\n @verse = Verse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @verse }\n end\n en... | [
"0.6965574",
"0.687169",
"0.687169",
"0.687169",
"0.67113096",
"0.6622217",
"0.6622217",
"0.6509304",
"0.64776975",
"0.64758956",
"0.6470687",
"0.64691764",
"0.6466657",
"0.6452153",
"0.6396807",
"0.63904",
"0.6374928",
"0.6358149",
"0.6315742",
"0.6301385",
"0.6299803",
"0... | 0.74491656 | 0 |
GET /vendes/1 GET /vendes/1.json | def show
@vendes = Vende.find([params[:id1], params[:id2], params[:id3]])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @verse = Verse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @verse }\n end\n end",
"def show\n @verse = Verse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render... | [
"0.72244555",
"0.72244555",
"0.72244555",
"0.7219203",
"0.6991049",
"0.69616663",
"0.6807133",
"0.6725661",
"0.6721408",
"0.6715923",
"0.66644055",
"0.6619724",
"0.65934914",
"0.6585137",
"0.65832114",
"0.6560898",
"0.6552727",
"0.65236753",
"0.6519273",
"0.6519273",
"0.65158... | 0.6769352 | 7 |
POST /vendes POST /vendes.json | def create
if(params[:numero][:item].length <= 0)
problema = 'É necessário definir uma quantidade para a compra.'
redirect_to vende_new_path, notice: problema
return
end
@vende = Vende.new(vende_params)
@vende.fornecedor = @fornecedores[params[:selecao][:fornecedor].to_i]
@vende.item = @item[params[:selecao][:item].to_i]
respond_to do |format|
if @vende.save
@vende.item.quantidade += params[:numero][:item].to_i
@vende.item.save
format.html { redirect_to item_index_path, notice: 'A compra foi registrada com sucesso.' }
format.json { render :show, status: :created, location: @vende }
else
format.html { render :new }
format.json { render json: @vende.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @vendedor = Vendedor.new(vendedor_params)\n\n respond_to do |format|\n if @vendedor.save\n format.html { redirect_to @vendedor, notice: 'Vendedor was successfully created.' }\n format.json { render :show, status: :created, location: @vendedor }\n else\n format.html... | [
"0.64392316",
"0.64392316",
"0.64200115",
"0.63583183",
"0.63583183",
"0.63572156",
"0.62350345",
"0.6230081",
"0.6063456",
"0.60543364",
"0.6041747",
"0.6028796",
"0.6023297",
"0.60036063",
"0.59975135",
"0.5932965",
"0.5930491",
"0.5918064",
"0.58818746",
"0.587562",
"0.586... | 0.5621986 | 46 |
PATCH/PUT /vendes/1 PATCH/PUT /vendes/1.json | def update
@vende = Vende.find([params[:id1], params[:id2], params[:id3]])
respond_to do |format|
if @vende.update(vende_params)
format.html { redirect_to vende_show_path(@vende.idVende, @vende.idFornecedor, @vende.idItem), notice: 'A compra foi atualizada com sucesso.' }
format.json { render :show, status: :ok, location: @vende }
else
format.html { render :edit }
format.json { render json: @vende.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def update\n @vet = Vet.find(params[:id])\n\n respond_to do |format... | [
"0.6880758",
"0.65456736",
"0.64426166",
"0.64044815",
"0.6331962",
"0.6250297",
"0.62300116",
"0.62142175",
"0.6205373",
"0.61985284",
"0.6183485",
"0.617412",
"0.61679864",
"0.61648023",
"0.61648023",
"0.6153438",
"0.6153438",
"0.61349654",
"0.6134087",
"0.6126634",
"0.6116... | 0.6422936 | 3 |
DELETE /vendes/1 DELETE /vendes/1.json | def destroy
@vende = Vende.find([params[:id1],params[:id2],params[:id3]])
@vende.destroy
respond_to do |format|
format.html { redirect_to vende_index_path, notice: 'A compra foi removida com sucesso.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n client.delete(\"/#{id}\")\n end",
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def destroy\n @sinh_vien = SinhVien.find(params[:id])\n @sinh_vien.destroy\n\n respond_to do |format| \n format.json { head :no_cont... | [
"0.73311424",
"0.7200804",
"0.7098685",
"0.6975547",
"0.69643784",
"0.6926705",
"0.6919703",
"0.6919703",
"0.6898435",
"0.6889885",
"0.68805623",
"0.68673235",
"0.6842153",
"0.6837586",
"0.68353105",
"0.68250644",
"0.68208313",
"0.6810859",
"0.68059635",
"0.6800967",
"0.68003... | 0.7111063 | 2 |
GET /items GET /items.json | def item_index
#@items = Item.all
if (params[item_index_path].nil? ||
params[item_index_path][:nome].empty?)
nome = nil
else
nome = params[item_index_path][:nome]
end
if nome != nil
@items = Item.where("nome like '%#{nome}%'")
else
@items = Item.all
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @items = Item.find(params[:id])\n render json: @items\n end",
"def items\n\t\tresponse = self.get('items').body\n\t\titems = JSON.parse(response)\n\t\tparse_items(items)\n\t\treturn items\n\tend",
"def getItems()\n return mergeWithAPI(@item_json)['data']\n end",
"def index\n @items =... | [
"0.79562956",
"0.7546286",
"0.74375594",
"0.7434485",
"0.73975587",
"0.7358414",
"0.7358414",
"0.7358414",
"0.7358414",
"0.7357372",
"0.7313286",
"0.73129123",
"0.7311041",
"0.7306297",
"0.7281173",
"0.7273615",
"0.72629416",
"0.72484964",
"0.72301924",
"0.71767205",
"0.71181... | 0.0 | -1 |
GET /items/1 GET /items/1.json | def item_show
@item = Item.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @items = Item.find(params[:id])\n render json: @items\n end",
"def get_item( item )\n @session.base_url = \"http://cl.ly\"\n resp = @session.get( \"/\" + item )\n \n raise ItemNotFound if resp.status == 404\n Crack::JSON.parse(resp.body)\n end",
"def show\n item = I... | [
"0.7736526",
"0.7547988",
"0.74948645",
"0.73696035",
"0.7328169",
"0.7293223",
"0.7287578",
"0.71326286",
"0.71247333",
"0.71196556",
"0.70882183",
"0.70882183",
"0.70882183",
"0.70882183",
"0.70882183",
"0.70882183",
"0.70882183",
"0.70882183",
"0.70882183",
"0.70882183",
"... | 0.643418 | 87 |
POST /items POST /items.json | def item_create
@item = Item.new(item_params)
respond_to do |format|
if @item.save
format.html { redirect_to item_index_path, notice: 'O item foi criado com sucesso.' }
format.json { render :show, status: :created, location: @item }
else
format.html { render :item_new }
format.json { render json: @item.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n item = list.items.create!(item_params)\n render json: item, status: 201\n end",
"def create\n\t\titem = Item.create(item_params)\n\t\trender json: item\n\tend",
"def create\n @item = @client.items.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { ... | [
"0.7971939",
"0.7285761",
"0.7231758",
"0.721958",
"0.71792215",
"0.71131957",
"0.7062943",
"0.7053179",
"0.6988855",
"0.69712186",
"0.6903009",
"0.68806237",
"0.6871792",
"0.6840092",
"0.6840092",
"0.6840092",
"0.6840092",
"0.6840092",
"0.6840092",
"0.6840092",
"0.6839645",
... | 0.6528123 | 67 |
PATCH/PUT /items/1 PATCH/PUT /items/1.json | def item_update
@item = Item.find(params[:id])
respond_to do |format|
if @item.update(item_params)
format.html { redirect_to item_show_path(@item), notice: 'O item foi atualizado com sucesso.' }
format.json { render :show, status: :ok, location: @item }
else
format.html { render :edit }
format.json { render json: @item.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: Item.update(params[\"id\"], params[\"item\"])\n end",
"def update\n\n if @api_v1_item.update(api_v1_item_params)\n render json: @api_v1_item\n else\n render json: @api_v1_item.errors\n end\n end",
"def update\n\n #update the item of request_item\n if (par... | [
"0.7442021",
"0.71437544",
"0.7139624",
"0.70251447",
"0.70026696",
"0.69958323",
"0.6980672",
"0.69373846",
"0.69218457",
"0.68723136",
"0.6832834",
"0.68177253",
"0.6805765",
"0.6805765",
"0.6794939",
"0.67887527",
"0.67887527",
"0.67887527",
"0.67887527",
"0.67887527",
"0.... | 0.6538576 | 89 |
DELETE /items/1 DELETE /items/1.json | def item_destroy
@item = Item.find(params[:id])
@item.destroy
respond_to do |format|
format.html { redirect_to item_index_path, notice: 'O item foi removido com sucesso.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n render json: Item.delete(params[\"id\"])\n end",
"def delete(items)\n item_ids = items.collect { |item| item.id }\n args = {ids: item_ids.to_json}\n return @client.api_helper.command(args, \"item_delete\")\n end",
"def destroy\n @item = Item.find(params[:id... | [
"0.7906849",
"0.76885504",
"0.7604411",
"0.7585917",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.758546",
"0.7547388",
"0.7539847",
"0.7528851",
... | 0.7223437 | 52 |
Use callbacks to share common setup or constraints between actions. | def set_vende
@vende = Vende.find([params[:id1], params[:id2], params[:id3]])
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 vende_params
params.require(:vende).permit(:idFornecedor, :idItem, :data, :valor)
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 |
Use callbacks to share common setup or constraints between actions. | def set_item
@item = Item.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 item_params
params.require(:item).permit(:nome, :marca, :descricao, :quantidade, :quantidadeMinima)
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 |
Deep_merge self with another array | def deep_merge!(second)
return nil unless second
type_assert(second, Array)
changed = nil
second.each_index do |k|
if self[k].is_a?(Array) and second[k].is_a?(Array)
changed |= true if self[k].deep_merge!(second[k])
elsif self[k].is_a?(Hash) and second[k].is_a?(Hash)
changed |= true if self[k].deep_merge!(second[k])
elsif exclude?(second[k])
self << second[k]
changed |= true
end
end
return nil unless changed
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deep_merge_and_concat_arrays(other_hash)\n self.merge(other_hash) do |key, oldval, newval|\n next newval unless newval.kind_of?(oldval.class)\n\n newval = case oldval\n when Hash then oldval.deep_merge(newval)\n ... | [
"0.73962086",
"0.7259331",
"0.7259331",
"0.7162417",
"0.7096968",
"0.7096968",
"0.70661205",
"0.70347327",
"0.6991646",
"0.697121",
"0.68268013",
"0.68137926",
"0.6769874",
"0.6757451",
"0.6535142",
"0.64994806",
"0.64959973",
"0.6473021",
"0.646753",
"0.64633155",
"0.6441381... | 0.7419372 | 0 |
3 Forms: Multiplied by an Integer, returns a single array with the repeated contents of self Multiplied by a String, returns self.join Multiplied by an Array, returns the setwise crossproduct of the two Arrays | def *(second)
ret = []
case second
when Integer
second.times { |i| ret += dup }
when String
return join(second)
when Array
each { |x| second.each { |y| ret << [x,y].flatten } }
else
raise TypeError.new("can't convert #{second.class} into Integer")
end
return ret
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def combinator(a, b)\n a.product(b).map{ |c| c.join('') }\nend",
"def cross(a, b)\n return a.map{|i| b.map{|j| \"#{i}#{j}\" }}.flatten\nend",
"def multiply_list(arr1, arr2)\r\nresult = []\r\ncounter = 0\r\n\r\narr1.length.times do |num|\r\n result << arr1[counter] * arr2[counter]\r\n counter += 1\r\nend\r\np... | [
"0.729676",
"0.68340594",
"0.6411254",
"0.6361705",
"0.6337209",
"0.63033515",
"0.62736666",
"0.6205616",
"0.61936027",
"0.6161841",
"0.6071653",
"0.60468435",
"0.6037281",
"0.60222816",
"0.6021302",
"0.60151774",
"0.6014136",
"0.5982264",
"0.5976896",
"0.59756625",
"0.595891... | 0.0 | -1 |
Returns the setwise nth power of self. (The length of the return value is equal to: self.length n) e.g [0,1] 0 => [] e.g [0,1] 1 => [[0], [1]] e.g [0,1] 2 => [[0, 0], [0, 1], [1, 0], [1, 1]] e.g [0,1] 3 => [[0, 0, 0], [0, 0, 1], [0, 1, 0], [0, 1, 1], [1, 0, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1]] | def **(n)
type_assert(n, Integer)
ret = []
if n > 1
ret = dup
(n - 1).times {
temp = []
ret.each { |x| each { |y| temp << [x,y].flatten } }
ret = temp
}
elsif n == 1
ret = map { |item| [item] }
end
return ret
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nth_powers(n)\n (1..9).to_a.map {|num| num**n}\nend",
"def rpower(n) end",
"def pow n\n raise ShapeError, \"Only works with 2D square matrices.\" if\n shape[0] != shape[1] or shape.size != 2\n raise TypeError, \"Only works with integer powers\" unless n.is_a?(Integer)\n\n sequence = (integer... | [
"0.7318158",
"0.7002567",
"0.6892573",
"0.6864533",
"0.6838933",
"0.6778653",
"0.6730761",
"0.66100556",
"0.6608169",
"0.652762",
"0.64908427",
"0.6446248",
"0.6394883",
"0.63770723",
"0.63316494",
"0.6323741",
"0.63158756",
"0.63013273",
"0.6287471",
"0.62827545",
"0.6251998... | 0.6236951 | 22 |
Returns a new Array rejecting objects based on if the blockmapped values are unique | def uniq_by(&block)
ret = dup
ret.uniq_by!(&block)
ret
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_uniq_by(&block)\n result = []\n self.each do |e|\n unless result.any?{|x| yield(x,e)} then result.push(e) end\n end\n return result\n end",
"def test_removes_duplicates\n stream = FromArray.new([2, 2, 3, 4, 1, 1, 2, 5, 4, 3, 6])\n collected = stream.distinct.collect\n as... | [
"0.6161584",
"0.61330646",
"0.5962543",
"0.58935755",
"0.5878819",
"0.5876917",
"0.5831879",
"0.5830337",
"0.5748441",
"0.57479435",
"0.5726957",
"0.57084346",
"0.56825763",
"0.56660473",
"0.5642922",
"0.5633066",
"0.5629993",
"0.5614592",
"0.5607612",
"0.5598222",
"0.5596324... | 0.5152694 | 91 |
Creates a hash with keys equal to the contents of self and values equal to the mapped array's values | def map_to_h(&block)
[self, map(&block)].transpose.to_h
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_array_final(name,value)\n\thash_final = Hash[name.zip(value.map)]\n\treturn hash_final\nend",
"def a_to_h\n self.map.with_index.to_h.invert\n end",
"def arrays_to_hash(keys,values)\n hash = {}\n keys.size.times { |i| hash[ keys[i] ] = values[i] }\n hash\n end",
"def to_hash (keyArr,... | [
"0.6954221",
"0.667791",
"0.6667553",
"0.6614353",
"0.660126",
"0.6539504",
"0.65394926",
"0.6523456",
"0.65196526",
"0.6485393",
"0.64732385",
"0.6442644",
"0.6374007",
"0.6346524",
"0.6295127",
"0.62603945",
"0.62603945",
"0.62258184",
"0.62234604",
"0.62212104",
"0.6171794... | 0.6255213 | 17 |
Chunks an array into segments of maximum length [1,2,3,4,5,6,7,8,9,10].chunk(3) => [[1,2,3], [4,5,6], [7,8,9], [10]] | def chunk(max_length=nil, &block)
if ::RUBY_VERSION >= "1.9" && block_given?
super(&block)
else
each_slice(max_length).to_a
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chunk_array(array, pieces=2)\n len = array.length;\n mid = (len/pieces)\n chunks = []\n start = 0\n 1.upto(pieces) do |i|\n last = start+mid\n last = last-1 unless len%pieces >= i\n chunks << array[start..last] || []\n start = last+1\n end\n chunks\nend",
"def array_chunk(array, size)\n ... | [
"0.7789122",
"0.77442306",
"0.76834136",
"0.7586428",
"0.7547452",
"0.7515887",
"0.7503938",
"0.74878424",
"0.74426687",
"0.7440348",
"0.73984575",
"0.71264064",
"0.70850015",
"0.7066823",
"0.70651895",
"0.6906536",
"0.6759753",
"0.6622339",
"0.6536958",
"0.6397453",
"0.63646... | 0.5890361 | 38 |
Statistics from: Add each object of the array to each other in order to get the sum, as long as all objects respond to + operator | def sum
flatten.compact.inject(:+)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def running_total_3 arr\n sum = 0\n arr.each_with_object([]) do |elm, obj|\n sum += elm\n obj << sum\n end\nend",
"def ary_add(array)\n if array.length.even?\n ary_couples = array.each_slice(2)\n final_ary = []\n ary_couples.each do |duo|\n ary_sum = duo[0] + duo[-1]\n final_ary << ary_s... | [
"0.7020941",
"0.7007614",
"0.69660926",
"0.6923252",
"0.6916463",
"0.6788755",
"0.67874813",
"0.678443",
"0.678215",
"0.6733471",
"0.67297935",
"0.6704181",
"0.66710913",
"0.66666186",
"0.6612406",
"0.66064614",
"0.6578425",
"0.65658224",
"0.6553381",
"0.6546339",
"0.65363705... | 0.62550914 | 53 |
Calculate squares of each item | def squares
map { |i| i ** 2 }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_of_squares\n\t\t\tinject(0) do |sum, elem|\n\t\t\t\tsum + (elem ** 2)\n\t\t\tend\n\t\tend",
"def sum_of_squares\n end",
"def compute_squares(array)\n arrayFinal = []\n array.each do |element|\n arrayFinal << element * element\n end\n return arrayFinal\nend",
"def sum_of_the_square... | [
"0.7376637",
"0.73459613",
"0.7299356",
"0.7256988",
"0.7236448",
"0.71125644",
"0.7098374",
"0.70313305",
"0.69424134",
"0.6941581",
"0.68782854",
"0.687741",
"0.68583536",
"0.68235004",
"0.67987317",
"0.67937857",
"0.6789746",
"0.6775975",
"0.6766538",
"0.671675",
"0.670402... | 0.7194783 | 5 |
Return a new array containing the rank of each value Ex: [1, 2, 2, 8, 9] => [0.0, 1.5, 1.5, 3.0, 4.0] | def ranks(already_sorted=false)
a = already_sorted ? self : sort
map { |i| (a.index(i) + a.rindex(i)) / 2.0 }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_relative_ranks(nums)\n output = Array.new(nums.length, nil)\n sorted_nums = nums.sort\n rank = nums.length\n \n sorted_nums.each do |n|\n idx = nums.find_index(n)\n \n ranking = case rank\n when 1\n \"Gold Medal\"\n when 2\n ... | [
"0.72014445",
"0.6899863",
"0.6838216",
"0.6471516",
"0.6397918",
"0.6371648",
"0.62964755",
"0.6221101",
"0.6188427",
"0.60675484",
"0.60029715",
"0.59982115",
"0.5982656",
"0.5981197",
"0.59584236",
"0.5958072",
"0.59575117",
"0.59446967",
"0.5897093",
"0.5882956",
"0.58774... | 0.77505755 | 0 |
Calculate square roots of each item | def sqrts
map { |i| Math.sqrt(i) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def r\n Math.sqrt(@elements.values.inject(0) { |v, e| v + ( e * e ) } )\n end",
"def r\n v = 0\n # for e in @elements ; v += e*e ; end\n my_elems = @elements\n my_size = my_elems.size\n for i in 0..my_size-1 do\n e = my_elems[i]\n v += e * e\n end\n return Math.sqrt(v)\n end",... | [
"0.71287197",
"0.7055348",
"0.66283906",
"0.63326186",
"0.6307592",
"0.6268789",
"0.6265017",
"0.62390107",
"0.6188733",
"0.6177145",
"0.6159816",
"0.61431956",
"0.61353004",
"0.6108467",
"0.60909307",
"0.60608053",
"0.6049108",
"0.6034228",
"0.60099113",
"0.5991862",
"0.5964... | 0.69810915 | 2 |
Calculate the arithmetic mean of the array, as long as all objects respond to / operator | def mean
a = flatten.compact
(a.size > 0) ? a.sum.to_f / a.size : 0.0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mean array\n array.inject(:+).to_f / array.length.to_f\n end",
"def mean( array )\n sum( array ) / array.size\nend",
"def mean(array)\n array.sum(0.0) / array.size\nend",
"def mean(array)\n array.inject(:+).to_f / array.size\nend",
"def mean(arr)\n arr.reduce(:+) / arr.size\nend",
"def me... | [
"0.8026164",
"0.7965435",
"0.7840859",
"0.781363",
"0.7721671",
"0.7631358",
"0.760541",
"0.7543677",
"0.7476033",
"0.7451416",
"0.74441445",
"0.74403894",
"0.7362555",
"0.7362555",
"0.73275566",
"0.7305645",
"0.73042995",
"0.72749245",
"0.72717917",
"0.72662354",
"0.72308975... | 0.7114749 | 31 |
TODO Geometric mean Calculate the number of occurences for each element of the array | def frequencies
inject(Hash.new(0)) { |h,v| h[v] += 1; h }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_occurrences(array)\n\toccurences = {}\n\n\tarray.each do |element|\n\t\toccurences[element] = array.count(element)\n\tend\n\n\toccurences.each do |element, count|\n\t\tputs \"#{element} => #{count}\"\n\tend\t\nend",
"def count_occurrences_improved(arr)\n counts = Hash.new { |h, k| h[k] = 0 }\n arr.ea... | [
"0.75095016",
"0.7423873",
"0.7411716",
"0.7352451",
"0.73041356",
"0.7292364",
"0.7258012",
"0.7239625",
"0.7180657",
"0.7163519",
"0.71381974",
"0.70951384",
"0.70890206",
"0.7024875",
"0.70159745",
"0.7000266",
"0.6994475",
"0.699259",
"0.69811153",
"0.6974915",
"0.6961496... | 0.0 | -1 |
Return the variance of self | def variance(population=false)
m = mean.to_f
map { |v| (v - m) ** 2 }.sum / (size - (population ? 0 : 1))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def variance\n stats.variance\n end",
"def variance\n avg = self.average\n self.inject(0) { |acc, i| acc + (i - avg)**2 }\n end",
"def variance; end",
"def variance\n Variance.new(self)\n end",
"def get_variance\n end",
"def variance\n\t\treturn variance_population\n\ten... | [
"0.88112146",
"0.87517035",
"0.86486274",
"0.86243165",
"0.8429456",
"0.8319094",
"0.81996113",
"0.81186646",
"0.8078394",
"0.8054828",
"0.80539304",
"0.8048288",
"0.7966728",
"0.7889491",
"0.7880096",
"0.7880096",
"0.7880096",
"0.7880096",
"0.7880096",
"0.78673494",
"0.78641... | 0.75537544 | 33 |
Return the (sample|population) standard deviation of self If population is set to true, then we consider the dataset as the complete population Else, we consider the dataset as a sample, so we use the sample standard deviation (size 1) | def standard_deviation(population=false)
size > 1 ? Math.sqrt(variance(population)) : 0.0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def standard_deviation\n\t\treturn standard_deviation_population\n\tend",
"def standard_deviation(population)\n Math.sqrt(variance(population)[0])\n end",
"def standard_deviation(population)\n Math.sqrt(variance(population))\n end",
"def standard_deviation(population)\n Math.sqrt(variance(popula... | [
"0.7556692",
"0.75055075",
"0.745539",
"0.745539",
"0.745539",
"0.745539",
"0.745539",
"0.73103726",
"0.7146089",
"0.70553815",
"0.70553815",
"0.70553815",
"0.70553815",
"0.70553815",
"0.70553815",
"0.70553815",
"0.70553815",
"0.70293045",
"0.6952549",
"0.69228",
"0.6856963",... | 0.83030546 | 0 |
Return the median of sorted self | def median(already_sorted=false)
return nil if empty?
a = already_sorted ? self : sort
m_pos = size / 2
size % 2 == 1 ? a[m_pos] : (a[m_pos-1] + a[m_pos]).to_f / 2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def median\n sorted = self.dup.sort\n\n result = 0\n\n middle = length / 2\n if sorted.length.odd?\n return self.take(middle + 1).last\n else\n return (self.drop(middle).first + self.take(middle).last)/2.0\n end\n end",
"def median\n\t\tif self.size == 0\n \t\t \tnil\n \t\telse\n\t\t... | [
"0.84356564",
"0.830011",
"0.826604",
"0.81957793",
"0.8154851",
"0.8139805",
"0.80997384",
"0.79185075",
"0.7912321",
"0.7911392",
"0.7877509",
"0.7865097",
"0.7860981",
"0.7749078",
"0.7718396",
"0.7671361",
"0.76502115",
"0.7559174",
"0.7558747",
"0.75414664",
"0.753631",
... | 0.8352187 | 1 |
Return the first quartile of self | def first_quartile(already_sorted=false)
return nil if size < 4
a = already_sorted ? self : sort
a[0..((size / 2) - 1)].median(true)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upper_quartile\n return nil if self.empty?\n sorted_array = self.sort\n u = (0.25*(3*sorted_array.length))\n if (u-u.truncate).is_a?(Integer)\n return sorted_array[(u-u.truncate)-1]\n else\n sample = sorted_array[u.truncate.abs-1]\n sample1 = sorted_array[(u.truncate.abs)]\n ... | [
"0.7881366",
"0.78067815",
"0.7729704",
"0.7727807",
"0.73552096",
"0.7242762",
"0.6980854",
"0.6805487",
"0.6645342",
"0.659492",
"0.65498644",
"0.65478987",
"0.65459645",
"0.65096515",
"0.64554197",
"0.6220465",
"0.6194773",
"0.6120734",
"0.59320456",
"0.59271383",
"0.59256... | 0.7724602 | 4 |
Return the last quartile of self | def last_quartile(already_sorted=false)
return nil if size < 4
a = already_sorted ? self : sort
a[((size / 2) + 1)..-1].median(true)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upper_quartile\n return nil if self.empty?\n sorted_array = self.sort\n u = (0.25*(3*sorted_array.length))\n if (u-u.truncate).is_a?(Integer)\n return sorted_array[(u-u.truncate)-1]\n else\n sample = sorted_array[u.truncate.abs-1]\n sample1 = sorted_array[(u.truncate.abs)]\n ... | [
"0.7941594",
"0.7309715",
"0.71225643",
"0.707646",
"0.6827354",
"0.67552996",
"0.65865767",
"0.65329295",
"0.6437631",
"0.6437631",
"0.6407008",
"0.6321258",
"0.6218294",
"0.61754596",
"0.6139626",
"0.60484475",
"0.5982809",
"0.5965405",
"0.5962164",
"0.595652",
"0.59543157"... | 0.77454823 | 1 |
Return an array containing the first, the second and the last quartile of self | def quartiles(already_sorted=false)
a = already_sorted ? self : sort
[a.first_quartile(true), a.median(true), a.last_quartile(true)]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quartiles(arr)\n sort_arr = arr.sort()\n len = sort_arr.size()\n q1_q2_q3 = [0.25, 0.5, 0.75].collect { |v|\n indx_f = (len * v) - 0.5\n indx_i = indx_f.to_i()\n if (indx_i == indx_f)\n sort_arr[indx_i]\n else\n res = indx_f - indx_i\n ... | [
"0.7472987",
"0.7395117",
"0.7305122",
"0.7294271",
"0.7286123",
"0.7148764",
"0.69869804",
"0.69820255",
"0.69732004",
"0.67282915",
"0.657471",
"0.64538187",
"0.6400989",
"0.63289654",
"0.617717",
"0.6151461",
"0.5900768",
"0.5685632",
"0.5662324",
"0.56574154",
"0.56195873... | 0.7901459 | 0 |
Calculate the interquartile range of self | def interquartile_range(already_sorted=false)
return nil if size < 4
a = already_sorted ? self : sort
a.last_quartile - a.first_quartile
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quartile_boundaries # rubocop:disable Metrics/AbcSize\n top = scores.reject { |x| gh_outliers.include? x }.max\n range = (1..top).to_a\n range = [0] * 3 if range.empty?\n mids = (1..3).map do |q|\n index = (q * range.size / 4) - 1\n range[index]\n end\n bounds = (mid... | [
"0.6569966",
"0.6517537",
"0.6513215",
"0.5985709",
"0.59720194",
"0.5899295",
"0.5861813",
"0.58231366",
"0.56851685",
"0.55971926",
"0.55808467",
"0.55548203",
"0.55548203",
"0.5547355",
"0.55465704",
"0.551249",
"0.55070895",
"0.5501385",
"0.54908925",
"0.5468018",
"0.5460... | 0.7973543 | 0 |
Return a hash of modes with their corresponding occurences | def modes
fre = frequencies
max = fre.values.max
fre.select { |k, f| f == max }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def modes\n\t\tmodes_array = Array.new\n\t\tmost = self.most\n\t\tcounts = self.counts\n\t\tcounts.each_pair do |key,value|\n\t\t\tif value == most\n\t\t\t\tmodes_array.push(key)\n\t\t\tend\n\t\tend\n\t\treturn modes_array\n\t end",
"def mode(mode)\n mode_return = mode.inject(Hash.new()) do |key, value|\n \tke... | [
"0.79912645",
"0.7467443",
"0.7390026",
"0.73849964",
"0.7284402",
"0.7284402",
"0.71767175",
"0.714082",
"0.7140163",
"0.7140163",
"0.7131274",
"0.7018434",
"0.69578797",
"0.6912201",
"0.6874979",
"0.67804855",
"0.6757016",
"0.6749022",
"0.6718262",
"0.6715813",
"0.6616455",... | 0.6697923 | 20 |
Return the midrange of sorted self | def midrange(already_sorted=false)
return nil if empty?
a = already_sorted ? self : sort
(a.first + a.last) / 2.0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def midpoint\n\t\t(@startrange+@endrange)/2\n\tend",
"def mid\n (min + max) / 2\n end",
"def bisect\n n = self.size\n l = n / 2\n [self[0...l], self[l...n]]\n end",
"def range_start; range.first; end",
"def search_lower_boundary(array, range=nil, &block)\n range = 0 ... array.length i... | [
"0.70859903",
"0.7018904",
"0.6787075",
"0.6699827",
"0.66334826",
"0.6573943",
"0.65570045",
"0.6383912",
"0.6352373",
"0.63284576",
"0.6316773",
"0.6303665",
"0.6301006",
"0.6301006",
"0.6259834",
"0.6248967",
"0.621563",
"0.61595666",
"0.61540717",
"0.6151175",
"0.61499465... | 0.8239994 | 0 |
Return the statistical range of sorted self | def statistical_range(already_sorted=false)
return nil if empty?
a = already_sorted ? self : sort
(a.last - a.first)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upper_bound; end",
"def range(arr)\n # your code goes here\n sorted_arr = arr.sort\n sorted_arr.last - sorted_arr.first\nend",
"def range(arr)\n arr.sort[-1] - arr.sort[0]\nend",
"def range(arr)\n # your code goes here\n arr = arr.sort\n arr.last - arr.first\nend",
"def calc_r_range\n R_RAN... | [
"0.6537923",
"0.6505457",
"0.6437323",
"0.62853205",
"0.62638193",
"0.6254092",
"0.6252861",
"0.62428623",
"0.62379956",
"0.6223598",
"0.6212536",
"0.6187387",
"0.6177299",
"0.6171568",
"0.6139635",
"0.6137811",
"0.6077239",
"0.6077239",
"0.6077239",
"0.6077239",
"0.60745144"... | 0.80069935 | 0 |
Return all statistics from self in a simple hash | def statistics(already_sorted=false)
sorted = sort
{
:first => self.first,
:last => self.last,
:size => self.size,
:sum => self.sum,
:squares => self.squares,
:sqrts => self.sqrts,
:min => self.min,
:max => self.max,
:mean => self.mean,
:frequencies => self.frequencies,
:variance => self.variance,
:standard_deviation => self.standard_deviation,
:population_variance => self.variance(true),
:population_standard_deviation => self.standard_deviation(true),
:modes => self.modes,
# Need to be sorted...
:ranks => sorted.ranks(true),
:median => sorted.median(true),
:midrange => sorted.midrange(true),
:statistical_range => sorted.statistical_range(true),
:quartiles => sorted.quartiles(true),
:interquartile_range => sorted.interquartile_range(true)
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stats\n Stats.all.inject({}) do |acc_hash, keyval|\n key, val = keyval\n acc_hash.merge(key => val[self.name])\n end\n end",
"def med_stats_hash(_assessed_data); end",
"def stats\n {}\n end",
"def hash\n return super unless has_size?\n\n res = 0\n each do |el|\n ... | [
"0.74265677",
"0.7398405",
"0.70937407",
"0.6971761",
"0.68907857",
"0.6807114",
"0.67671156",
"0.6738522",
"0.67299694",
"0.67299694",
"0.67299694",
"0.67275226",
"0.6724931",
"0.67198455",
"0.6607523",
"0.65862215",
"0.6580835",
"0.6557218",
"0.65545756",
"0.65532833",
"0.6... | 0.677809 | 6 |
Convert camelcase methods begining with a lowercase letter into underscored methods | def genability_method_name_converter(method_name)
method_name.to_s.gsub(/(?:^|_)(.)/){ $1.upcase }.gsub(/^[A-Z]/){ $&.downcase }.to_sym
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def underscorize!\n self.replace(self.scan(/[A-Z][a-z]*/).join(\"_\").downcase)\n end",
"def camelize_methodname\n self.titleize.gsub(' ', '').camelize(:lower)\n end",
"def underscore!\n gsub!('::', '_')\n gsub!(/([A-Z\\d]+)([A-Z][a-z])/, '\\1_\\2')\n gsub!(/([a-z\\d])([A-Z])/, '\\1_\\2')\n ... | [
"0.76091784",
"0.72535545",
"0.7171149",
"0.69981337",
"0.6950097",
"0.6937985",
"0.6884385",
"0.68650943",
"0.686485",
"0.68633574",
"0.6860571",
"0.68515754",
"0.68515754",
"0.685152",
"0.6839155",
"0.6802069",
"0.6795727",
"0.6795727",
"0.6782644",
"0.67729574",
"0.674207"... | 0.7545032 | 1 |
Method to readback existing photos string and update with names of uploaded files | def photo_exists?(db, filename)
query = db.exec("select photo from imageuploader where photo = '#{filename}'")
query == nil ? true : false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n # creates tag objects for photos\n tag_array = tag_params['tags'].split(',').each do |x|\n x.strip!\n end\n tag_array.each do |x| \n if Tag.find_by(name: x)\n @tag = Tag.find_by(name: x)\n else\n @tag = Tag.create(name: x)\n end\n Tagging.create... | [
"0.61088085",
"0.6004024",
"0.58788776",
"0.58666235",
"0.5800906",
"0.5790378",
"0.5771745",
"0.5739356",
"0.5732168",
"0.5724217",
"0.5712559",
"0.57100713",
"0.5686222",
"0.56636226",
"0.56599575",
"0.56553125",
"0.5639766",
"0.56360954",
"0.5623595",
"0.5623595",
"0.56084... | 0.0 | -1 |
Method to update imageuploader record with photo name for photos uploaded via Image Uploader prototype | def update_pg(db, filename)
v_filename = filename
begin
db.prepare('q_statement',
"insert into imageuploader (photo) values ($1)") # bind parameters
db.exec_prepared('q_statement', [v_filename])
db.exec("deallocate q_statement")
rescue PG::Error => e
puts 'Exception occurred'
puts e.message
ensure
db.close if db
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_photo(album_id, photo_id, file, filename)\n \n end",
"def update\n ActiveRecord::Base.transaction do\n @album.update!(name: params[:name])\n @album.album_images.destroy_all\n # 画像登録数が多くなるUIになったらSQLの負荷を減らすためにactiverecord-importを入れる\n # https://github.com/zdennis/activer... | [
"0.7002523",
"0.6393307",
"0.63641095",
"0.62847435",
"0.6238652",
"0.61932206",
"0.61873245",
"0.61612046",
"0.6131177",
"0.6066775",
"0.6066775",
"0.604904",
"0.6033999",
"0.6031726",
"0.6027009",
"0.59722173",
"0.5965315",
"0.59652877",
"0.59614885",
"0.59537953",
"0.59373... | 0.5810636 | 42 |
Method to extract & decode base64 string | def decode_image(filename, data)
data_index = data.index('base64') + 7
filedata = data.slice(data_index, data.length)
decoded_image = Base64.decode64(filedata)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decode_base64\n #self.unpack(\"m*\").first\n # This should be the above line but due to a bug in the ruby base64 decoder\n # it will only decode base64 where the lines are in multiples of 4, this is\n # contrary to RFC2045 which says that all characters other than the 65 used\n # are to be ignor... | [
"0.8503476",
"0.8273909",
"0.81770414",
"0.803056",
"0.801333",
"0.7890712",
"0.7890712",
"0.78380156",
"0.78380156",
"0.7764959",
"0.7755302",
"0.7582409",
"0.7556929",
"0.74470615",
"0.7417188",
"0.7366588",
"0.7193683",
"0.7157388",
"0.7093891",
"0.7073843",
"0.70340145",
... | 0.658798 | 40 |
Method to write decoded photo to swap directory | def write_swap_file(filename, decoded_image)
f = File.new "./public/swap/#{filename}", "wb"
f.write(decoded_image)
f.close if f
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_swap_file(filename, decoded_image)\n\n f = File.new \"./public/swap/#{filename}\", \"wb\"\n # f = File.new \"../public/swap/#{filename}\", \"wb\" # inline testing path\n f.write(decoded_image)\n f.close if f\n\nend",
"def write_swap_file(filename, decoded_image)\n\n f = File.new \"./public/swap/#... | [
"0.78100127",
"0.78100127",
"0.6780021",
"0.66460437",
"0.65646744",
"0.64621854",
"0.64165395",
"0.640076",
"0.62775105",
"0.623569",
"0.6179903",
"0.6062739",
"0.6045793",
"0.6029024",
"0.6025131",
"0.6025131",
"0.5978163",
"0.59608185",
"0.59608185",
"0.593011",
"0.5878255... | 0.77819914 | 2 |
Method to call photo processing methods | def process_photo(db, filename, data)
# PG update-related methods
update_pg(db, filename) if photo_exists?(db, filename) == false
# S3 update-related methods
decoded_image = decode_image(filename, data)
write_swap_file(filename, decoded_image)
save_file_to_s3_bucket(filename)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_image\n\t\tImageProcessingJob.perform_later(id)\n\tend",
"def processed_image\n @image = @picture.image_file\n if @image.nil?\n raise MissingImageFileError, \"Missing image file for #{@picture.inspect}\"\n end\n if @size.present?\n if params[:crop_size].present? && p... | [
"0.62912685",
"0.62309486",
"0.6227876",
"0.61595184",
"0.6129797",
"0.6120623",
"0.6085588",
"0.60155815",
"0.5999526",
"0.59879494",
"0.59528977",
"0.5949975",
"0.5944901",
"0.59356034",
"0.5910429",
"0.5885947",
"0.5885947",
"0.58722603",
"0.58143646",
"0.5809426",
"0.5806... | 0.6283042 | 1 |
This overrides the Objectmethod method to return the mocked method when the mocked method is being requested. For methods that aren't being tested, this method returns a proc that will raise an error when called. This is to assure that only the mocked grpc method is being called. | def method(symbol)
return @mock_method if symbol == @expected_symbol
# The requested method is not being tested, raise if it called.
proc do
raise "The method #{symbol} was unexpectedly called during the " \
"test for #{@expected_symbol}."
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_grpc_method(grpc_method_object)\n owner = grpc_method_object.owner\n\n return VALUE_UNKNOWN unless owner.instance_variable_defined?(:@rpc_descs)\n\n method, = owner.rpc_descs.find do |k, _|\n ::GRPC::GenericService.underscore(k.to_s) == grpc_method_... | [
"0.64466083",
"0.6170441",
"0.6035084",
"0.58090174",
"0.5789547",
"0.5788984",
"0.5743467",
"0.5743467",
"0.5734726",
"0.57290107",
"0.5713403",
"0.56846136",
"0.5655599",
"0.5643108",
"0.5631159",
"0.5600474",
"0.558413",
"0.5580466",
"0.5579326",
"0.55616844",
"0.55427486"... | 0.61301595 | 35 |
GET /subjects GET /subjects.json | def index
admin_only
@subjects = Subject.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_subjects\n if params[:c].present?\n sc_id = params[:c].to_i\n subjects = Subject.joins(:school_cycle_has_subjects).where(\"school_cycle_id = ?\", sc_id)\n msg = { \"success\": \"true\", \"subjects\": subjects }\n else\n msg = { \"success\": false, \"subjects\": 0 }\n end\n\n ... | [
"0.76131374",
"0.7599248",
"0.7501643",
"0.7327452",
"0.73111886",
"0.7100133",
"0.7097196",
"0.7069668",
"0.7069668",
"0.7065303",
"0.6972029",
"0.6963001",
"0.6937049",
"0.69283664",
"0.68917793",
"0.68695474",
"0.6856061",
"0.6839716",
"0.6808383",
"0.67819476",
"0.6774022... | 0.62214196 | 49 |
GET /subjects/1 GET /subjects/1.json | def show
admin_only
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @subject = Subject.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subject }\n end\n end",
"def get_subjects\n if params[:c].present?\n sc_id = params[:c].to_i\n subjects = Subject.joins(:school_cycle_has_subject... | [
"0.7462031",
"0.73371226",
"0.73158705",
"0.7303327",
"0.7293112",
"0.7209648",
"0.7203975",
"0.7081049",
"0.70791173",
"0.70585805",
"0.70382094",
"0.7033256",
"0.7022359",
"0.7022359",
"0.70181674",
"0.6998612",
"0.69974196",
"0.68754363",
"0.685901",
"0.6858203",
"0.684328... | 0.0 | -1 |
POST /subjects POST /subjects.json | def create
admin_only
@subject = Subject.new(subject_params)
new_tutor_ids = []
unless params[:subject][:people_teaching_attributes].blank?
params[:subject][:people_teaching_attributes].each do |attribute|
id = attribute[1][:incoming_tutor_id]
new_tutor_ids << id unless attribute[1][:_destroy] == "1"
end
end
respond_to do |format|
if @subject.save
unless new_tutor_ids == []
new_tutor_ids.each do |id|
e = ProvidingEnrollment.new
e.user_id = id
e.subject_id = @subject.id
e.save!
end
end
format.html { redirect_to @subject, notice: 'Subject was successfully created.' }
format.json { render :show, status: :created, location: @subject }
else
format.html { render :new }
format.json { render json: @subject.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @subject = Subject.new(params[:subject])\n\n respond_to do |format|\n if @subject.save\n format.html { redirect_to :subjects, :notice => 'Subject was successfully created.' }\n format.json { render :json => @subject, :status => :created, :location => @subject }\n else\n ... | [
"0.7093269",
"0.70017576",
"0.6920761",
"0.6879977",
"0.68733424",
"0.68470126",
"0.68272763",
"0.6759715",
"0.67476565",
"0.6704417",
"0.6680183",
"0.6653926",
"0.66498274",
"0.6640361",
"0.65838623",
"0.6575236",
"0.6574849",
"0.6570703",
"0.65252584",
"0.6524692",
"0.65246... | 0.65735793 | 17 |
PATCH/PUT /subjects/1 PATCH/PUT /subjects/1.json | def update
admin_only
new_tutor_ids_plus_deletion = []
unless params[:subject][:people_teaching_attributes].blank?
params[:subject][:people_teaching_attributes].each do |attribute|
if attribute[1][:incoming_tutor_id].nil?
id = attribute[1][:id]
else
id = attribute[1][:incoming_tutor_id]
end
destroy = attribute[1][:_destroy]
new_tutor_ids_plus_deletion << [id, destroy]
end
end
respond_to do |format|
if @subject.update(subject_params)
unless new_tutor_ids_plus_deletion == []
new_tutor_ids_plus_deletion.each do |pair|
if pair[1] == "1" #that means we should delete this one...
e = ProvidingEnrollment.find_by_user_id_and_subject_id(pair[0], @subject.id)
begin
e.destroy!
rescue
puts 'Looks like that user was added and removed in one go...'
end
else #that means we should make a new one if it doesn't already exist...
if ProvidingEnrollment.find_by_user_id_and_subject_id(pair[0], @subject.id).nil?
e = ProvidingEnrollment.new
e.user_id = pair[0]
e.subject_id = @subject.id
e.save!
end
end
end
end
format.html { redirect_to @subject, notice: 'Subject was successfully updated.' }
format.json { render :show, status: :ok, location: @subject }
else
format.html { render :edit }
format.json { render json: @subject.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @subject = Subject.find(params[:id])\n\n respond_to do |format|\n if @subject.update_attributes(params[:subject])\n\n format.html { redirect_to subjects_url, :notice => 'Subject was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { ... | [
"0.7399212",
"0.7341869",
"0.72854865",
"0.712811",
"0.7044038",
"0.70004374",
"0.70004374",
"0.6995105",
"0.6978002",
"0.68667805",
"0.68179256",
"0.6792362",
"0.67713135",
"0.675009",
"0.6706549",
"0.66950065",
"0.6676277",
"0.66413474",
"0.66335547",
"0.6620601",
"0.661519... | 0.6126359 | 50 |
DELETE /subjects/1 DELETE /subjects/1.json | def destroy
admin_only
@subject.destroy
respond_to do |format|
format.html { redirect_to subjects_url, notice: 'Subject was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @subject = Subject.find(params[:id])\n @subject.destroy\n\n respond_to do |format|\n format.html { redirect_to subjects_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @subject = Subject.find(params[:id])\n @subject.destroy\n\n respond_to do |fo... | [
"0.79004234",
"0.79000086",
"0.7851459",
"0.7812474",
"0.7791248",
"0.77289444",
"0.76450217",
"0.7632434",
"0.75925595",
"0.75750107",
"0.756666",
"0.7557011",
"0.75504565",
"0.7544504",
"0.75413173",
"0.75402933",
"0.75402933",
"0.7490376",
"0.7464556",
"0.7410753",
"0.7399... | 0.75240225 | 17 |
Use callbacks to share common setup or constraints between actions. | def set_subject
@subject = Subject.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 subject_params
params.require(:subject).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 |
TODO: Extract these two out and test | def pct_to_int(pct)
(pct * 100).to_i
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def probers; end",
"def schubert; end",
"def implementation; end",
"def implementation; end",
"def spec; end",
"def spec; end",
"def refutal()\n end",
"def weber; end",
"def identify; end",
... | [
"0.76659733",
"0.65168256",
"0.65168256",
"0.65168256",
"0.65168256",
"0.65002495",
"0.6133471",
"0.60827416",
"0.60827416",
"0.60610324",
"0.60610324",
"0.60417926",
"0.59828824",
"0.5856993",
"0.5845697",
"0.5845697",
"0.58122754",
"0.5792566",
"0.57917315",
"0.5783558",
"0... | 0.0 | -1 |
An array of diagnostics known on the client side overlapping the range provided to the `textDocument/codeAction` request. They are provided so that the server knows which errors are currently presented to the user for the given range. There is no guarantee that these accurately reflect the error state of the resource. The primary parameter to compute code actions is the provided range. | def diagnostics
attributes.fetch(:diagnostics)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def combine_ranges(code, ranges); end",
"def excise(ranges)\n if ranges.class != Array\n raise RuntimeError, \"Argument should be an array of ranges\"\n end\n ranges.each do |r|\n if r.class != Range\n raise RuntimeError, \"Argument should be an array of ranges\"... | [
"0.5396712",
"0.5172819",
"0.51434135",
"0.51339674",
"0.49102306",
"0.49075517",
"0.48887408",
"0.4847368",
"0.48408297",
"0.48395523",
"0.48044944",
"0.4803973",
"0.47924408",
"0.47865552",
"0.47468328",
"0.47366136",
"0.4696615",
"0.46634537",
"0.4653408",
"0.46458054",
"0... | 0.0 | -1 |
Requested kind of actions to return. Actions not of this kind are filtered out by the client before being shown. So servers can omit computing them. | def only
attributes.fetch(:only)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def only_render_implemented_actions\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n raise AbstractController::ActionNotFound unless action_methods.include?(params[:action])\n\n... | [
"0.6636099",
"0.6583316",
"0.652881",
"0.6476836",
"0.6471676",
"0.6460973",
"0.6445921",
"0.6418753",
"0.6418651",
"0.6373288",
"0.63624555",
"0.63468605",
"0.63062125",
"0.6299098",
"0.62914145",
"0.62878686",
"0.62878686",
"0.62351894",
"0.62275934",
"0.61784667",
"0.61732... | 0.0 | -1 |
The reason why code actions were requested. | def trigger_kind
attributes.fetch(:triggerKind)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reason; end",
"def reason; end",
"def reason(*) end",
"def miss_reason; end",
"def reason\n @reason\n end",
"def unsupported_action_message\n return \"Sorry. I don't understand the request\"\n end",
"def reason\n response&.response&.msg\n end",
"def miss_reason=(_a... | [
"0.7057421",
"0.7057421",
"0.68894756",
"0.67101467",
"0.667978",
"0.6470796",
"0.64015114",
"0.63607424",
"0.6275275",
"0.6275275",
"0.62195545",
"0.61636394",
"0.6161066",
"0.61387753",
"0.6086829",
"0.60822767",
"0.5992735",
"0.59445304",
"0.5939497",
"0.5907732",
"0.58887... | 0.0 | -1 |
send email to team's reviewers in case a new submission is made | def mail_assigned_reviewers
# Find review mappings for the work done by this participant's team
mappings = ResponseMap.where(reviewed_object_id: self.assignment.id,
reviewee_id: self.team.id,
type: 'ReviewResponseMap')
unless mappings.nil?
mappings.each do |mapping|
reviewer = mapping.reviewer.user
prepared_mail = MailerHelper.send_mail_to_assigned_reviewers(reviewer, self, mapping)
prepared_mail.deliver_now
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def email(defn, participant, assignment)\n defn[:body][:type] = \"Teammate Review\"\n participant = AssignmentParticipant.find(reviewee_id)\n topic_id = SignedUpTeam.topic_id(participant.parent_id, participant.user_id)\n defn[:body][:obj_name] = assignment.name\n user = User.find(participant.user_id... | [
"0.7813628",
"0.7604943",
"0.75376743",
"0.7473035",
"0.74464285",
"0.7225123",
"0.71534246",
"0.71191245",
"0.70600915",
"0.70539767",
"0.7040182",
"0.7026469",
"0.70193136",
"0.694058",
"0.6929885",
"0.68959534",
"0.6889954",
"0.6888014",
"0.6873786",
"0.6815255",
"0.676423... | 0.7037424 | 11 |
Get authorization from permissions. | def authorization
authorization = 'participant'
authorization = 'reader' if !can_submit && can_review && can_take_quiz
authorization = 'submitter' if can_submit && !can_review && !can_take_quiz
authorization = 'reviewer' if !can_submit && can_review && !can_take_quiz
authorization
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def permission\n Ricer::Irc::Permission.by_permission(self.permissions, authenticated?)\n end",
"def authorize(*args)\n permissions, _opts = _perform_authorization(*args)\n permissions\n end",
"def authorize (permission_name)\n self.allowances.detect {|a| a.permission.name == permission... | [
"0.70807314",
"0.6946983",
"0.6813294",
"0.65549016",
"0.6377053",
"0.637424",
"0.637424",
"0.62863356",
"0.62774515",
"0.62736934",
"0.6250922",
"0.62366915",
"0.62135077",
"0.62022",
"0.61885804",
"0.6158928",
"0.6147652",
"0.6139677",
"0.61132735",
"0.61113715",
"0.6108545... | 0.6295684 | 7 |
I 1 V 5 X 10 L 50 C 100 D 500 M 1,000 | def solution(number)
m, r_1 = number.divmod(1000)
cd, r_2 = r_1.divmod(100)
lx, r_3 = r_2.divmod(10)
vi, r_4 = r_3.divmod(1)
roman = []
m.times { roman << "M" }
if cd <= 3
cd.times { roman << "C" }
elsif cd == 4
roman << "CD"
elsif cd == 5
roman << "D"
elsif cd > 5 && cd < 9
roman << "D"
(cd - 5).times { roman << "C" }
elsif cd == 9
roman << "CM"
end
if lx <= 3
lx.times { roman << "X" }
elsif lx == 4
roman << "XL"
elsif lx == 5
roman << "L"
elsif lx > 5 && lx < 9
roman << "L"
(lx - 5).times { roman << "X" }
elsif lx == 9
roman << "XC"
end
if vi <= 3
vi.times { roman << "I" }
elsif vi == 4
roman << "IV"
elsif vi == 5
roman << "V"
elsif vi > 5 && vi < 9
roman << "V"
(vi - 5).times { roman << "I" }
elsif vi == 9
roman << "IX"
end
roman.join
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cells(n)\n n * @vm.databytes\n end",
"def stanley_and_kerber md_width_li_on_one_side\n\tunless (23..30) === md_width_li_on_one_side\n\t\traise ArgumentError,\n\t\t \"The total sum of the mesio-distal width of the erupted Permanent Central and Lateral Incisors, and the unerupted Canine and Premolar, ... | [
"0.58574486",
"0.54572177",
"0.53385586",
"0.5321848",
"0.5320993",
"0.528839",
"0.5245777",
"0.52432036",
"0.52280235",
"0.5157731",
"0.5088587",
"0.5079294",
"0.5076466",
"0.5044555",
"0.5042276",
"0.50325036",
"0.50258225",
"0.5024539",
"0.50237286",
"0.5020873",
"0.501184... | 0.0 | -1 |
Deletes the draft configuration associated with the running environment. ==== Options application_name: The name of the application the environment is associated with. environment_name: The name of the environment to delete the draft configuration from. ==== Returns response: ==== See Also | def delete_environment_configuration(application_name, environment_name)
options = {
'ApplicationName' => application_name,
'EnvironmentName' => environment_name
}
request({
'Operation' => 'DeleteEnvironmentConfiguration',
:parser => Fog::Parsers::AWS::ElasticBeanstalk::Empty.new
}.merge(options))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @app_config.destroy\n respond_to do |format|\n format.html { redirect_to app_configs_url, notice: 'App config was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @app_config = AppConfig.find(params[:id])\n @app_config.destroy\n\n ... | [
"0.61078584",
"0.59799457",
"0.592325",
"0.58989966",
"0.5856943",
"0.58419627",
"0.5777709",
"0.5765367",
"0.57497185",
"0.57100725",
"0.5705423",
"0.5680208",
"0.56392443",
"0.56345123",
"0.56207675",
"0.55979043",
"0.5589308",
"0.55647504",
"0.5560017",
"0.5558135",
"0.554... | 0.6982228 | 0 |
Function used when GET request is made to show animal | def show
respond_with Animal.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n canonical_url(\"/animals/#{params[:id]}\")\n @animal = Rails.cache.fetch(\"public_animal_#{params[:id]}\", :expires_in => 15.minutes) do\n Animal.includes(:animal_color, :animal_sex, :species, :status, :organization, :spay_neuter).find_by_uuid!(params[:id])\n end\n\n if @animal.public =... | [
"0.7562537",
"0.7558967",
"0.746896",
"0.7386824",
"0.72411305",
"0.7204892",
"0.717894",
"0.7158596",
"0.7140051",
"0.7127728",
"0.7104349",
"0.7072928",
"0.69946903",
"0.6936898",
"0.68804157",
"0.6822894",
"0.67712086",
"0.676803",
"0.6753051",
"0.668484",
"0.6663238",
"... | 0.7078643 | 11 |
Function used when POST request is made to create new animal | def create
animal = Animal.new(animal_params)
if !animal.name.nil?
animal.save
render json: animal, status: 201, location: [:api, animal]
else
render json: { errors: animal.errors }, status: 422
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @animal = Animal.new(animal_params)\n\n respond_to do |format|\n if @animal.save\n format.html { redirect_to @animal, notice: 'Animal was successfully created.' }\n format.json { render :show, status: :created, location: @animal }\n else\n format.html { render :new... | [
"0.7571812",
"0.75703835",
"0.7463624",
"0.74609274",
"0.73819137",
"0.7340471",
"0.7339301",
"0.73378056",
"0.72179586",
"0.7200994",
"0.7142429",
"0.703021",
"0.7020602",
"0.69860846",
"0.69277877",
"0.6891018",
"0.68521684",
"0.6835792",
"0.68105865",
"0.6801357",
"0.67723... | 0.76871145 | 0 |
Function used when PUT/PATCH request is made to update existing animal | def update
animal = Animal.find(params[:id])
if validate_params(animal_params)
animal.update(animal_params)
render json: animal, status: 200, location: [:api, animal]
else
render json: { errors: animal.errors }, status: 422
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n animal = Animal.find(params[:id])\n animal.update(animal_params)\n if animal.valid?\n render json: animal\n else\n render json: animal.errors\n end\n end",
"def update\n animal = Animal.find(params[:id])\n animal.update(animal... | [
"0.8138313",
"0.8004971",
"0.79523504",
"0.79523504",
"0.7938096",
"0.7938096",
"0.7906117",
"0.7756893",
"0.77237546",
"0.77154267",
"0.7680177",
"0.7594237",
"0.7564384",
"0.75463635",
"0.74859256",
"0.74844",
"0.74029857",
"0.73202586",
"0.7111397",
"0.7077323",
"0.7072593... | 0.8196996 | 0 |
Function used when DELETE request is made to remove existing animal | def destroy
animal = Animal.find(params[:id])
animal.destroy
head 204
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @animals = Animal.all\n @animal = Animal.find(params[:id])\n @animal.destroy\n end",
"def destroy\n @animal.destroy\n\n respond_to do |format|\n format.html { redirect_to animals_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @animal = Anima... | [
"0.7517527",
"0.74984276",
"0.7497733",
"0.7478994",
"0.7471941",
"0.7453296",
"0.7448415",
"0.74361783",
"0.7352287",
"0.73242927",
"0.73002374",
"0.7258039",
"0.7258039",
"0.72436833",
"0.72436833",
"0.72182804",
"0.7189344",
"0.7183744",
"0.7181473",
"0.71327615",
"0.71145... | 0.7840579 | 0 |
Returns the user corresponding to the remember token cookie. | def current_user
if cookies.signed[:user_id]
user_id = cookies.signed[:user_id]
user = User.find_by(id: user_id)
token = find_token user.sp_card
if user && token
@current_user = user
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_from_remember_token\n User.authenticate_with_salt(*remember_token)\n end",
"def user_from_remember_token\n User.authenticate_with_salt(*remember_token)\n end",
"def user_from_remember_token\n User.authenticate_with_salt(*remember_token)\n end",
"def user_from_remember_token\n\t\t... | [
"0.83219117",
"0.83219117",
"0.81546134",
"0.8152535",
"0.7719389",
"0.7679927",
"0.7642987",
"0.7612922",
"0.7612922",
"0.7605182",
"0.7547156",
"0.7534549",
"0.75313604",
"0.75001407",
"0.7490964",
"0.7462961",
"0.7442915",
"0.7442915",
"0.7442915",
"0.73899746",
"0.7372749... | 0.0 | -1 |
scenario 'see errors if they omit required fields' do visit new_user_path submit_form expect(User.count).to eq 0 expect(page).to have_text("Email can't be blank") expect(page).to have_text("Password can't be blank") end | def submit_form
click_button 'submit'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expect_fields_to_be_blank\n expect(page).to have_field(\"Email\", with: \"\", type: \"email\")\n expect(find_field(\"Password\", type: \"password\").value).to be_nil\n expect(find_field(\"Password confirmation\", type: \"password\").value).to be_nil\n end",
"def test_invalid_with_empty_attributes\n... | [
"0.7540316",
"0.73243743",
"0.7285988",
"0.69307727",
"0.6904478",
"0.68439585",
"0.68380153",
"0.6722738",
"0.67002064",
"0.6644209",
"0.6639979",
"0.6595129",
"0.65747434",
"0.6571758",
"0.6529216",
"0.6518844",
"0.6506012",
"0.64901954",
"0.64581335",
"0.64474636",
"0.6434... | 0.0 | -1 |
ensure there are no line itmes referencing this product | def ensure_not_referenced_by_any_line_item
unless line_items.empty?
errors.add(:base, 'Line Items Present')
throw :abort
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ensure_not_referenced_by_any_line_item\n\t\t\tunless line_items.empty?\n\t\t\t\terrors.add(:base, 'Line items reference this product')\n\t\t\t\tthrow :abort\n\t\t\tend\n\t\tend",
"def ensure_not_referenced_by_any_line_item_product\n unless line_item_products.empty?\n errors.add(:base, 'Line Items Pro... | [
"0.80028105",
"0.78465253",
"0.77902806",
"0.76523244",
"0.7580965",
"0.75782734",
"0.75760937",
"0.7567407",
"0.7559412",
"0.75290716",
"0.75171095",
"0.74733675",
"0.74703085",
"0.74455",
"0.74443805",
"0.7441162",
"0.74374014",
"0.74250007",
"0.741495",
"0.741495",
"0.7414... | 0.7480815 | 11 |
GET /hand_analytics GET /hand_analytics.json | def index
@hand_analytics = HandAnalytic.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n day = Analytic.where(\"created_at > ?\", Time.now - 1.day).order(\"created_at DESC\")\n @analytics = {}\n @analytics[:projects] = Project.all.order(\"hits DESC\")\n @analytics[:ips] = day.distinct.pluck(:ip)\n @analytics[:visits] = day\n @analytics[:user_agents] = day.distinct.pluck(:... | [
"0.65231967",
"0.62274146",
"0.59944654",
"0.5940445",
"0.59148896",
"0.5900106",
"0.58836186",
"0.5827253",
"0.5816404",
"0.57578623",
"0.5717987",
"0.5687229",
"0.56821907",
"0.56795835",
"0.5665396",
"0.5663804",
"0.5652404",
"0.56078607",
"0.56068164",
"0.5568688",
"0.556... | 0.7412661 | 0 |
GET /hand_analytics/1 GET /hand_analytics/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @hand_analytics = HandAnalytic.all\n end",
"def index\n day = Analytic.where(\"created_at > ?\", Time.now - 1.day).order(\"created_at DESC\")\n @analytics = {}\n @analytics[:projects] = Project.all.order(\"hits DESC\")\n @analytics[:ips] = day.distinct.pluck(:ip)\n @analytics[:visi... | [
"0.7195056",
"0.6406287",
"0.6071644",
"0.600327",
"0.59834516",
"0.58518916",
"0.58080065",
"0.5791028",
"0.57852155",
"0.5771312",
"0.5768996",
"0.5765914",
"0.5749621",
"0.5729206",
"0.57274574",
"0.57147425",
"0.56834155",
"0.56685114",
"0.56251764",
"0.5612357",
"0.56108... | 0.0 | -1 |
POST /hand_analytics POST /hand_analytics.json | def create
@hand_analytic = HandAnalytic.new(hand_analytic_params)
respond_to do |format|
if @hand_analytic.save
format.html { redirect_to @hand_analytic, notice: 'Hand analytic was successfully created.' }
format.json { render action: 'show', status: :created, location: @hand_analytic }
else
format.html { render action: 'new' }
format.json { render json: @hand_analytic.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @hand_analytics = HandAnalytic.all\n end",
"def generate_analytics\n # parameters passed in via query string, see comment above\n statistic = Statistic.find(params[:id]) # yank statistic entry\n user = params[:user] # array of usernames\n # start_time = params[:start_time] # start o... | [
"0.6319662",
"0.6053394",
"0.5974408",
"0.59470457",
"0.5814325",
"0.5808271",
"0.57985157",
"0.57529956",
"0.56928253",
"0.5584448",
"0.5518874",
"0.550932",
"0.54645634",
"0.54586226",
"0.53845876",
"0.5383356",
"0.53303874",
"0.5325939",
"0.53040063",
"0.5300598",
"0.52909... | 0.61672825 | 1 |
PATCH/PUT /hand_analytics/1 PATCH/PUT /hand_analytics/1.json | def update
respond_to do |format|
if @hand_analytic.update(hand_analytic_params)
format.html { redirect_to @hand_analytic, notice: 'Hand analytic was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @hand_analytic.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def update!(**args)\n @analytics = args[:analytics] if args.key?(:analytics)\n @analytics_summary = args[:analytics_summary] if args.key?(:analytics_summary)\n @next_page_token = args[:next_page_token] if args.key... | [
"0.6328208",
"0.62613666",
"0.6257535",
"0.60947806",
"0.6093028",
"0.6086097",
"0.6080252",
"0.6066484",
"0.6059273",
"0.6041856",
"0.5992497",
"0.5989537",
"0.5987736",
"0.59836966",
"0.59547585",
"0.5950895",
"0.59479827",
"0.59394205",
"0.5926133",
"0.5925242",
"0.5914510... | 0.6043575 | 9 |
DELETE /hand_analytics/1 DELETE /hand_analytics/1.json | def destroy
@hand_analytic.destroy
respond_to do |format|
format.html { redirect_to hand_analytics_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.... | [
"0.69336355",
"0.6813213",
"0.67492247",
"0.6737887",
"0.6710716",
"0.65935016",
"0.6578296",
"0.65172136",
"0.6466457",
"0.6459173",
"0.64360934",
"0.64350045",
"0.6424139",
"0.64240706",
"0.6418378",
"0.6418378",
"0.6418378",
"0.6418378",
"0.64146286",
"0.64114237",
"0.6404... | 0.7401738 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_hand_analytic
@hand_analytic = HandAnalytic.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 hand_analytic_params
params.require(:hand_analytic).permit(:flop, :river, :turn, :number_of_players, :my_hand)
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 |
callseq: namespace.default_prefix = "string" Assigns a name (prefix) to the default namespace. This makes it much easier to perform XML::XPath searches. Usage: doc = XML::Document.string('<Envelope xmlns=" doc.root.namespaces.default_prefix = 'soap' node = doc.root.find_first('soap:Envelope') | def default_prefix=(prefix)
# Find default prefix
ns = find_by_prefix(nil)
raise(ArgumentError, "No default namespace was found") unless ns
Namespace.new(self.node, prefix, ns.href)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def namespace_prefix( doc, ns )\n doc_ns = doc.collect_all_namespaces_href_keys\n if doc_ns.key?( ns )\n doc_ns[ ns ].first.nil? ? 'xmlns' : doc_ns[ ns ].first\n else\n 'xmlns'\n end\nend",
"def namespace_prefix( doc, ns )\n doc_ns = doc.collect_all_namespaces_href_keys\n if doc_ns.key?( ns )\n ... | [
"0.6652104",
"0.6592633",
"0.6371908",
"0.6355043",
"0.62655",
"0.6226268",
"0.62248594",
"0.6090976",
"0.607646",
"0.60462433",
"0.60076934",
"0.5953901",
"0.5953901",
"0.58826804",
"0.58068866",
"0.5805378",
"0.5749914",
"0.573508",
"0.57251257",
"0.57251257",
"0.5720432",
... | 0.7225535 | 0 |
Returns styled button tag To use specific theme use :theme options sexy_button "Click Me", :theme => "mytheme" For theme to work, you must add theme to public/stylesheets/sexy_buttons/themes first | def sexy_button(value="Submit", options={})
default_options = {
:type => "submit",
:value => value,
:class => "sexy-button"
}
if options[:theme] or SexyButtons.default_theme != "default"
theme = options[:theme] ? options.delete(:theme) : SexyButtons.default_theme
default_options[:class] << " sexy-button-#{theme}"
end
if options[:class]
options[:class] << " #{default_options[:class]}"
end
content_tag(:button, content_tag(:span, value), default_options.merge(options))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def include_pretty_buttons\n stylesheet_link_tag 'buttons'\n end",
"def render_button\n NfgUi::Components::Elements::Button.new({ **integrated_slat_action_button_component_options, body: (block_given? ? yield : body) }, view_context).render\n end",
"def primary_button_small\n \"highl... | [
"0.6304522",
"0.62463456",
"0.6233385",
"0.614853",
"0.59707695",
"0.59572005",
"0.5897954",
"0.58407533",
"0.5785331",
"0.5708677",
"0.5698319",
"0.5623476",
"0.560992",
"0.5607986",
"0.5597446",
"0.5553236",
"0.5540001",
"0.5526852",
"0.5513068",
"0.54736465",
"0.5456871",
... | 0.7353232 | 0 |
Returens styled a tag themes are selected similar to sexy_button method sexy_link_to "Click here", "/my_url", :theme => "mytheme" | def sexy_link_to(name, options={}, html_options={})
default_html_options = {
:class => "sexy-button"
}
if html_options[:theme] or SexyButtons.default_theme != "default"
theme = html_options[:theme] ? html_options.delete(:theme) : SexyButtons.default_theme
default_html_options[:class] << " sexy-button-#{theme}"
end
if html_options[:class]
html_options[:class] << " #{default_html_options[:class]}"
end
link_to(content_tag(:span, name), options, default_html_options.merge(html_options))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def link_trait\n colors = NfgUi::Components::Traits::Theme::COLOR_TRAITS\n\n # Check if we've got any color themes passed through in addition to :link\n if traits.collect { |t| t.in?(colors) }.any? && traits.include?(:link)\n # Grab and remove the theme color from traits so it... | [
"0.63444304",
"0.61986476",
"0.61986476",
"0.61986476",
"0.6049627",
"0.600091",
"0.5945917",
"0.58653927",
"0.5808885",
"0.57608026",
"0.5599434",
"0.5595868",
"0.5587614",
"0.5575896",
"0.5507223",
"0.5499462",
"0.5439119",
"0.5437417",
"0.54294896",
"0.53939366",
"0.538731... | 0.62139946 | 1 |
Force signout to prevent CSRF attacks | def handle_unverified_request
sign_out
super
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sign_out\n send_request('sign_out', :delete) do |req|\n req.body = { auth_token: @auth_token }\n end\n end",
"def sign_out\n @logout = true\n authenticate_api_user\n @logout = false\n revoke_access if @current_user\n head :no_content\n end",
"def signout\n self.curren... | [
"0.7989222",
"0.7957568",
"0.7951285",
"0.79439825",
"0.78757477",
"0.7875546",
"0.7869332",
"0.78595734",
"0.7842295",
"0.7839813",
"0.78157324",
"0.78090745",
"0.77819127",
"0.77761185",
"0.77508295",
"0.7749756",
"0.7738409",
"0.77285844",
"0.7702963",
"0.769139",
"0.76831... | 0.76811224 | 42 |
Formats a displayable position string. | def position_string(position, subpath = nil)
"might_config[#{(position + Array(subpath).join('/').split('/')).join('][')}]"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s format = '%8.4f'\n (\"%-6s\" + \"#{format} \" * 3) % ([name] + pos.to_a) \n end",
"def show_text_with_positioning(*params)\n params = params.first\n params.each { |str|\n if str.kind_of?(String)\n show_text(str)\n else\n# if str < -100\n# puts str.inspect\n# ... | [
"0.6359237",
"0.61843675",
"0.61338556",
"0.61050737",
"0.6100568",
"0.60280055",
"0.5966011",
"0.5937152",
"0.5889965",
"0.58595407",
"0.57922953",
"0.5770392",
"0.5761128",
"0.5750295",
"0.5750295",
"0.5750295",
"0.5744321",
"0.5740237",
"0.5737629",
"0.573316",
"0.57265705... | 0.0 | -1 |
Converts hierarchical hash of URI path fragments to subconfigurations to a flat hash of regular expressions matching URI to subconfiguration. Additional matchers such as verb or header are not included in the regex. this is intended to reduce how much searching is needed to find the configuration for a particular request/response. Ruby has no direct support for hashing by matching a regular expression to a value but the hash idiom is still useful here. | def normalize_route_configuration(uri_path, position, configuration_data)
uri_path = uri_path[1..-1] if uri_path.start_with?('/')
uri_path = uri_path.chomp('/').split('/')
recursive_traverse_uri(regex_to_data = {}, position, uri_path, configuration_data)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recursive_traverse_uri(regex_to_data, position, uri_path, data)\n unless data.respond_to?(:has_key?)\n message = \"Expected a hash at #{position_string(position, uri_path)}; \" +\n \"use the #{STOP_TRAVERSAL_KEY.inspect} key to stop traversal.\"\n raise ConfigError, message\... | [
"0.617355",
"0.54595983",
"0.5395985",
"0.53174806",
"0.53165907",
"0.52271503",
"0.52069646",
"0.51756984",
"0.5164751",
"0.5113807",
"0.5088007",
"0.50873196",
"0.5018372",
"0.49818733",
"0.49596044",
"0.49573418",
"0.49495968",
"0.4917385",
"0.49131975",
"0.49061206",
"0.4... | 0.564768 | 1 |
Builds regular expressions from URI paths by recursively looking for either the 'stop' key or the start of matcher information. When the path for the URI is complete the wildcard 'file' path is converted to a regular expression and inserted into the regex_to_data hash. The data has a regex on the lefthand and a matcher data hash on the righthand. The matcher data may have empty criteria if no matching beyond the URI path is needed. | def recursive_traverse_uri(regex_to_data, position, uri_path, data)
unless data.respond_to?(:has_key?)
message = "Expected a hash at #{position_string(position, uri_path)}; " +
"use the #{STOP_TRAVERSAL_KEY.inspect} key to stop traversal."
raise ConfigError, message
end
data.each do |k, v|
# stop key or 'type:name=value' qualifier stops URI path traversal.
k = k.to_s
if k == STOP_TRAVERSAL_KEY || k.index('=')
# create regular expression from uri_path elements up to this point.
# include a leading forward-slash (/) because uri.path will generally
# have it.
regex_string = '^/' + uri_path.map do |path_element|
case path_element
when '**'
'.*' # example: 'api/**'
else
# element may contain single wildcard character (*)
::Regexp.escape(path_element).gsub("\\*", '[^/]*')
end
end.join('/') + '$'
regex = ::Regexp.compile(regex_string)
# URI path is the outermost qualifier, but there can be literal verb,
# header, query qualifiers as well. create another interesting map of
# (qualifier name to value) to (configuration data). the qualifiers
# can be hierarchical, of course, so we must traverse and flatten
# those also.
#
# examples of resulting uri regex to matcher data:
# request:
# /^api\/create$/ => { { 'verb' => 'POST', 'header' => { 'x_foo' => 'foo' } } => { 'body' => { 'name' => 'foo_name_variable' } } }
# response:
# { { 'verb' => 'GET', 'query' => { 'view' => 'full' } } => { 'body' => { 'name' => 'foo_name_variable' } } }
#
# FIX: don't think there is a need for wildcard qualifiers beyond URI
# path (i.e. wildcard matchers) so they are not currently supported.
qualifiers_to_data = regex_to_data[regex] ||= {}
current_qualifiers = RightSupport::Data::Mash.new
if k == STOP_TRAVERSAL_KEY
# no qualifiers; stopped after URI path
qualifiers_to_data[current_qualifiers] = normalize_route_stop_configuration(position, uri_path + [k], v)
else
recursive_traverse_qualifiers(qualifiers_to_data, current_qualifiers, position, uri_path + [k], v)
end
else
# recursion
recursive_traverse_uri(regex_to_data, position, uri_path + [k], v)
end
end
regex_to_data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def [] files\n # This stores all our matches\n match_hash = {}\n\n # Go through each file, check if the file basename matches the regexp.\n files.each do |f|\n path, file = File.split(f)\n\n if (m = match_against(file))\n replacement = populate_based_on(m)\n match_hash[f] = if p... | [
"0.5646992",
"0.51106364",
"0.5012647",
"0.495653",
"0.48970294",
"0.48935175",
"0.48935175",
"0.48198846",
"0.4756903",
"0.4732165",
"0.4721019",
"0.47018427",
"0.46937996",
"0.4668631",
"0.4665748",
"0.46419212",
"0.46356",
"0.46115673",
"0.46054882",
"0.45934734",
"0.45922... | 0.6595241 | 0 |
Recursively builds one of more hash of qualifiers cumulatively with the parent qualifiers being included in child qualifier hashes. The completed qualifier hash is then inserted into the qualifiers_to_data hash. | def recursive_traverse_qualifiers(qualifiers_to_data, current_qualifiers, position, subpath, data)
unless data.kind_of?(::Hash)
message = "Expected a hash at #{position_string(position, subpath)}; " +
"use the #{STOP_TRAVERSAL_KEY.inspect} key to stop traversal."
raise ConfigError, message
end
# could be multiple qualifiers in a CGI-style string.
current_qualifiers = RightSupport::Data::Mash.new(current_qualifiers)
more_qualifiers = RightSupport::Data::Mash.new
::CGI.unescape(subpath.last).split('&').each do |q|
if matched = TYPE_NAME_VALUE_REGEX.match(q)
case qualifier_type = matched[1]
when 'verb'
if matched[2]
message = "Verb qualifiers cannot have a name: " +
position_string(position, subpath)
raise ConfigError, message
end
verb = matched[3].upcase
unless METADATA_CLASS::VERBS.include?(verb)
message = "Unknown verb = #{verb}: " +
position_string(position, subpath + [k])
raise ConfigError, message
end
more_qualifiers[qualifier_type] = verb
else
unless matched[2]
message = "#{qualifier_type} qualifiers must have a name: " +
position_string(position, subpath)
raise ConfigError, message
end
# qualifier may be nested (for query string or body).
qualifier = ::Rack::Utils.parse_nested_query("#{matched[2]}=#{matched[3]}")
# names and values are case sensitive but header keys are usually
# not case-sensitive so convert the header keys to snake_case to
# match normalized headers from request.
if qualifier_type == 'header'
qualifier = qualifier.inject(RightSupport::Data::Mash.new) do |h, (k, v)|
h[normalize_header_key(k)] = v
h
end
end
::RightSupport::Data::HashTools.deep_merge!(
more_qualifiers[qualifier_type] ||= RightSupport::Data::Mash.new,
qualifier)
end
else
message = "Qualifier does not match expected pattern: " +
position_string(position, subpath)
raise ConfigError, message
end
end
::RightSupport::Data::HashTools.deep_merge!(current_qualifiers, more_qualifiers)
data.each do |k, v|
# only the 'stop' key stops traversal now.
k = k.to_s
if k == STOP_TRAVERSAL_KEY
qualifiers_to_data[current_qualifiers] = normalize_route_stop_configuration(position, subpath, v)
else
# recursion
recursive_traverse_qualifiers(qualifiers_to_data, current_qualifiers, position, subpath + [k], v)
end
end
qualifiers_to_data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_parents(data)\n data.inject({}) do |h, d|\n (1...d.length).each { |i| h[d[i]] = d[0] }; h\n end\nend",
"def build_qualifier\n qualifier = @xml_node.attributes.key?('qualifier') ? @xml_node.attributes['qualifier'].value : 'default'\n Metadata::Qualifier.new(@field, qualifier, @work_type_c... | [
"0.5369198",
"0.49226382",
"0.49199918",
"0.47977513",
"0.4755113",
"0.4751464",
"0.46898848",
"0.4678678",
"0.46642238",
"0.46100482",
"0.46022007",
"0.45711198",
"0.45189276",
"0.45189276",
"0.45154846",
"0.44852683",
"0.4439905",
"0.44324514",
"0.44193676",
"0.44186646",
"... | 0.6605684 | 0 |
Ensures that any header keys are normalized in deep stop configuration. Only header keys are normalized; other fields are casesensitive and otherwise adhere to a standard specific to the API for field names. | def normalize_route_stop_configuration(position, subpath, route_stop_config)
# sanity check.
unwanted_keys = route_stop_config.keys.map(&:to_s) - ALLOWED_KINDS
unless unwanted_keys.empty?
message = 'The route configuration for route configuration at ' +
"#{position_string(position, subpath)} " +
"contained illegal kind specifiers = " +
"#{unwanted_keys.inspect}. Only #{ALLOWED_KINDS} are allowed."
raise ConfigError, message
end
route_stop_config.inject(RightSupport::Data::Mash.new) do |rst, (rst_k, rst_v)|
# sanity check.
unwanted_keys = rst_v.keys.map(&:to_s) - ALLOWED_CONFIG_ACTIONS
unless unwanted_keys.empty?
message = 'The route configuration for route configuration at ' +
"#{position_string(position, subpath + [rst_k])} " +
"contained illegal action specifiers = " +
"#{unwanted_keys.inspect}. Only #{ALLOWED_CONFIG_ACTIONS} are allowed."
raise ConfigError, message
end
rst[rst_k] = rst_v.inject(RightSupport::Data::Mash.new) do |kc, (kc_k, kc_v)|
case kc_k
when METADATA_CLASS::DELAY_SECONDS_KEY
begin
kc_v = Float(kc_v)
rescue ::ArgumentError
location = position_string(position, subpath + [rst_k, kc_k])
message = 'Invalid route configuration delay_seconds value at ' +
"#{location}: #{kc_v.inspect}"
raise ConfigError, message
end
when METADATA_CLASS::TIMEOUTS_KEY
# sanity check.
kc_v = kc_v.inject(RightSupport::Data::Mash.new) do |h, (k, v)|
h[k] = Integer(v)
h
end
unwanted_keys = kc_v.keys - ALLOWED_TIMEOUTS
unless unwanted_keys.empty?
message = 'The route configuration for timeouts at ' +
"#{position_string(position, subpath + [rst_k, kc_k])} " +
"contained illegal timeout specifiers = " +
"#{unwanted_keys.inspect}. Only #{ALLOWED_TIMEOUTS} are allowed."
raise ConfigError, message
end
else
# sanity check.
kc_v = deep_mash(kc_v)
unwanted_keys = kc_v.keys - ALLOWED_VARIABLE_TYPES
unless unwanted_keys.empty?
message = 'The route configuration for variables at ' +
"#{position_string(position, subpath + [rst_k, kc_k])} " +
"contained illegal variable specifiers = " +
"#{unwanted_keys.inspect}. Only #{ALLOWED_VARIABLE_TYPES} are allowed."
raise ConfigError, message
end
if headers = kc_v[:header]
case headers
when ::Array
# significant
kc_v[:header] = headers.inject([]) do |a, k|
a << normalize_header_key(k)
end
when ::Hash
# transform, variables
kc_v[:header] = headers.inject(RightSupport::Data::Mash.new) do |h, (k, v)|
h[normalize_header_key(k)] = v
h
end
else
message = "Expected an array at #{position_string(position, subpath + [rst_k, kc_k, :header])}; " +
"use the #{STOP_TRAVERSAL_KEY.inspect} key to stop traversal."
raise ConfigError, message
end
end
end
kc[kc_k] = kc_v
kc
end
rst
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize_headers(headers)\n return {} unless headers\n\n headers = Hash[\n headers.map { |k, v| [k.gsub(HEADER_HTTP_PREFIX, '').capitalize, v] }\n ] # remove 'HTTP_' prefix in keys\n headers.delete_if { |_... | [
"0.6460256",
"0.627984",
"0.6260675",
"0.6190073",
"0.6190073",
"0.6089346",
"0.60826904",
"0.6017462",
"0.5982509",
"0.5872097",
"0.58389825",
"0.5820656",
"0.58160037",
"0.57783866",
"0.5722722",
"0.5682122",
"0.56752515",
"0.56391686",
"0.5562052",
"0.5548259",
"0.5497888"... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_box
@box = Box.find(params[:box_id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def item_params
params.require(:item).permit(:description, :image)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
We use the users public key and inject into the cloudinit | def public_key
@key ||= File.read("#{ENV['HOME']}/.ssh/id_rsa.pub")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def public_key; end",
"def public_key; end",
"def public_key; end",
"def public_key=(_); end",
"def public_key=(_); end",
"def public_key\n @pub\n end",
"def load_public_key(filename); end",
"def set_keys\n self.auth = gen_key('auth') if auth.blank?\n self.mkey = gen_key('mkey') if mkey... | [
"0.7299193",
"0.7299193",
"0.7299193",
"0.7111034",
"0.7111034",
"0.6714324",
"0.65028286",
"0.6478406",
"0.6438676",
"0.6438676",
"0.642857",
"0.6400828",
"0.63432825",
"0.62697273",
"0.62677157",
"0.62677157",
"0.6263107",
"0.62604535",
"0.6250898",
"0.6237456",
"0.6216868"... | 0.65479213 | 6 |
metodo que realiza el test de lehman peralta para calcular si dos numeros son coprimos. | def lehman_peralta(numero)
num=numero.to_i
n_aleatorios,t_primo,i,exponente,contador=[],[],1,(num-1)/2,0
while i<num
n_aleatorios[i]=rand(1..num-1)
#puts "aleatorio creado: #{n_aleatorios[i]}"
i+=1
end
for j in 1...num
t_primo[j]=(n_aleatorios[j]**exponente)%num
#condicion para que de -1 en caso de que de la operacion con el modulo un numero (num-1).Ej 6%7
if(t_primo[j]>1)
t_primo[j]=t_primo[j]-num
end
end
#puts "t_primo=#{t_primo}"
for j in 1...t_primo.length
#puts "t_primo[j]=#{t_primo[j]}"
if(t_primo[j]==1)
contador+=1
elsif t_primo[j]!=1 && t_primo[j]!=-1
@primo=false
end
end
if contador==t_primo.length-1
@primo=false
end
@primo
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lehman_peralta(numero)\n num=numero.to_i\n n_aleatorios=[]\n t_primo=[]\n i=1\n exponente=(num-1)/2\n contador=0 #contador para contar si todos los modulos son = a 1 y rechazar que sea primo\n while i<num\n n_aleatorios[i]=rand(1..num-1)\n #puts \"aleatorio creado: #{n_aleat... | [
"0.66026986",
"0.619069",
"0.6188151",
"0.6071948",
"0.60295445",
"0.6021743",
"0.6013312",
"0.59738696",
"0.59423876",
"0.59416604",
"0.5933182",
"0.5885064",
"0.58796227",
"0.58419466",
"0.58328027",
"0.5815385",
"0.5811691",
"0.5794687",
"0.57940125",
"0.57831025",
"0.5767... | 0.66051435 | 0 |
metodo que realiza el algoritmo de euclides extendido | def euclides_extendido(a,b)
x,z=[],[]
t_primo=false
#condicion para comprobar si el numero b es mayor que a si es asi se hace un swap
if(b.to_i>a.to_i)
x[1],x[2]=b.to_i,a.to_i
else
x[1],x[2]=a.to_i,b.to_i
end
z[0],z[1]=0,1
i=1
r=x[1]%x[2]
#puts "resto al comienzo: #{r}"
if r==0
t_primo=false
else
while(r>0)
#puts "#{"="*30}"
if(i>=2)
#puts "entre..."
z[i]=(-1*((x[i-1]/x[i]).to_i))*z[i-1]+z[i-2]
x[i+1]=x[i-1]%x[i]
end
r=x[i+1]
mcd=x[i]
if(mcd==1)
t_primo=true
#en caso de que el inverso de negativo, se suma al numero mayor que se paso a la función.
if(z[i-1]<0)
@inverso=z[i-1]+x[1]
else
@inverso=z[i-1]
end
end
i+=1
#puts "#{"="*30}"
end
end
#puts "MCD: #{mcd}"
t_primo
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def euclides_extendido(a,b)\n #condicion para comprobar si el numero b es mayor que a si es asi se hace un swap\n x,z=[],[]\n t_primo=false\n if(b.to_i>a.to_i)\n x[1],x[2]=b.to_i,a.to_i\n else\n x[1],x[2]=a.to_i,b.to_i\n end\n z[0],z[1]=0,1\n i=1\n r=x[1]%x[2]\n #puts \"rest... | [
"0.61725396",
"0.61592084",
"0.6077523",
"0.60632867",
"0.5968282",
"0.59164304",
"0.58163357",
"0.5773673",
"0.56962925",
"0.5623682",
"0.55262685",
"0.5490062",
"0.5481206",
"0.54559857",
"0.5366102",
"0.53089136",
"0.5289243",
"0.5285504",
"0.5272075",
"0.5245709",
"0.5242... | 0.65926135 | 0 |
Renders a file into another form Returns encoded file | def render
return nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_to_render\n file\n end",
"def render_file(filename)\n to_file(filename)\n end",
"def render_file(filename)\n to_file(filename)\n end",
"def render\n ERB.new(File.read(@file)).result(binding)\n end",
"def render_file(path, options = {}, &block)\n\t\t\t\t\t\tout = ren... | [
"0.76901287",
"0.6995774",
"0.6995774",
"0.67369324",
"0.6468528",
"0.6455453",
"0.6396342",
"0.63529676",
"0.63219094",
"0.62080264",
"0.6204338",
"0.6128127",
"0.61214983",
"0.6120207",
"0.6084058",
"0.6083485",
"0.60735524",
"0.6026943",
"0.6003756",
"0.5994993",
"0.597323... | 0.0 | -1 |
Sets up src and other stuff | def initialize(params)
@errors = []
@src = params[:src]
@log = Logger.new(STDOUT)
@type = nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def src; end",
"def src; end",
"def src; end",
"def initialize source_dir, config, js\r\n @javascripts = []\r\n @stylesheets = []\r\n @source_dir = source_dir\r\n @config = config\r\n @html_dir = resolve_html_dir\r\n #@game_config = PlotConfig.new(\"#{source_dir}/con... | [
"0.70513594",
"0.70513594",
"0.70513594",
"0.6861443",
"0.63264835",
"0.6207033",
"0.61594284",
"0.614654",
"0.61052537",
"0.6097857",
"0.60873085",
"0.60570794",
"0.6044152",
"0.6044152",
"0.6044152",
"0.6022998",
"0.5981797",
"0.5958576",
"0.5958576",
"0.59337276",
"0.59213... | 0.0 | -1 |
GET /projects/1 GET /projects/1.json | def show
@project = Project.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @project }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list\n get 'projects'\n end",
"def listprojects\n get('listprojects.json')['projects']\n end",
"def show\n @project = @client.projects.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @project }\n end\n end",
"def projects\n... | [
"0.7868971",
"0.76979554",
"0.7680216",
"0.7611453",
"0.75334454",
"0.75258976",
"0.74926496",
"0.74926496",
"0.74926496",
"0.74926496",
"0.74926496",
"0.74926496",
"0.74926496",
"0.74924207",
"0.7484109",
"0.7479275",
"0.7444873",
"0.74294627",
"0.74224764",
"0.7414947",
"0.... | 0.73410857 | 43 |
GET /projects/new GET /projects/new.json | def new
@project = Project.new
@project.photos.build
respond_to do |format|
format.html # new.html.erb
format.json { render json: @project }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @project = current_user.projects.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end",
"def new\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @... | [
"0.81725097",
"0.8165836",
"0.8165836",
"0.8165836",
"0.8165836",
"0.8165836",
"0.8165836",
"0.8165836",
"0.8165836",
"0.8165836",
"0.8165836",
"0.8165836",
"0.8165836",
"0.8165836",
"0.8165836",
"0.8165836",
"0.8165836",
"0.8165836",
"0.8165836",
"0.8165836",
"0.8165836",
... | 0.0 | -1 |
POST /projects POST /projects.json | def create
@project = Project.new(project_params)
respond_to do |format|
if @project.save
format.html { redirect_to @project, notice: 'Project was successfully created.' }
format.json { render json: @project, status: :created, location: @project }
else
format.html { render action: "new" }
format.json { render json: @project.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.json { render :json => @project, :status => :created, :location => @project }\n format.html { redirect_to(projects_path) }\n else\n format.html { render :action => \"new... | [
"0.7338948",
"0.73139244",
"0.7308003",
"0.7299582",
"0.7227503",
"0.7225945",
"0.71982473",
"0.71170384",
"0.7104803",
"0.7095263",
"0.7070636",
"0.70408624",
"0.70358187",
"0.7024969",
"0.70191896",
"0.7009597",
"0.698481",
"0.697517",
"0.6963753",
"0.6963096",
"0.6948756",... | 0.6879012 | 41 |
PUT /projects/1 PUT /projects/1.json | def update
@project = Project.find(params[:id])
respond_to do |format|
if @project.update_attributes(project_params)
format.html { redirect_to @project, notice: 'Project was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @project.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def project_update(project)\n raise Client::FileboundClientException.new('Id is required', 0) unless project[:projectId].greater_than_zero?\n put('/projects', nil, project)\n end",
"def update\n if @project.update(project_params)\n render json: @project, status: 200\n else\n re... | [
"0.7380123",
"0.7308916",
"0.7181629",
"0.7167707",
"0.7132476",
"0.7125153",
"0.7081923",
"0.7008695",
"0.700572",
"0.70002675",
"0.69908255",
"0.6989358",
"0.6989358",
"0.6989358",
"0.6989358",
"0.6983146",
"0.69805205",
"0.69805205",
"0.6977218",
"0.6970257",
"0.6970257",
... | 0.69316417 | 37 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.