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 |
|---|---|---|---|---|---|---|
PATCH/PUT /voxels/1 PATCH/PUT /voxels/1.json | def update
respond_to do |format|
if @voxel.update(voxel_params)
format.html { redirect_to @voxel, notice: '更新されました!' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @voxel.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def UpdateView params = {}\n \n APICall(path: 'views.json',method: 'PUT',payload: params.to_json)\n \n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response... | [
"0.6319824",
"0.629349",
"0.620486",
"0.6195176",
"0.61831194",
"0.6129363",
"0.6086929",
"0.60802126",
"0.6016513",
"0.60130984",
"0.6004715",
"0.5964108",
"0.59194165",
"0.5908215",
"0.58942336",
"0.5890327",
"0.58757985",
"0.5872654",
"0.5862779",
"0.5834108",
"0.5830178",... | 0.6181121 | 5 |
DELETE /voxels/1 DELETE /voxels/1.json | def destroy
@voxel.destroy
respond_to do |format|
format.html { redirect_to voxels_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def destroy\n @voxel = Voxel.find(params[:id])\n @voxel.destroy\n \n respond_to do |format|\n format.html { redirect_to voxels_url }\n format.json { head :no_content }\n end\... | [
"0.71933347",
"0.7154275",
"0.7107153",
"0.7030319",
"0.69848806",
"0.6978392",
"0.6940445",
"0.6940276",
"0.6939857",
"0.6932891",
"0.69180393",
"0.689091",
"0.68542767",
"0.68395835",
"0.6806176",
"0.6806176",
"0.68018675",
"0.679401",
"0.67928416",
"0.6771822",
"0.67640436... | 0.7312526 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_voxel
@voxel = Voxel.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 voxel_params
params.require(:voxel).permit(:user_id, :title, :voxeljson)
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 |
constanttime comparison algorithm to prevent timing attacks | def secure_compare(a, b)
return false unless a.bytesize == b.bytesize
l = a.unpack "C#{a.bytesize}"
res = 0
b.each_byte { |byte| res |= byte ^ l.shift }
res == 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def constant_time_comparison(mac_a, mac_b)\n result = mac_a.length ^ mac_b.length\n for i in 0..[mac_a.length, mac_b.length].min - 1\n result |= mac_a[i].ord ^ mac_b[i].ord\n end\n result.zero?\n end",
"def secure_compare(a, b); end",
"def secure_compare(a, b); end",
"def secure_compare(a, ... | [
"0.6825186",
"0.65347683",
"0.65347683",
"0.65347683",
"0.6160875",
"0.6094885",
"0.6056571",
"0.6020498",
"0.6000703",
"0.5943707",
"0.5933233",
"0.5917282",
"0.59100205",
"0.58980435",
"0.5894234",
"0.58850276",
"0.5883883",
"0.58758026",
"0.58721113",
"0.5858641",
"0.58368... | 0.5917478 | 11 |
TODO only session spec | def hits(options = {})
if options[:verify]
verified_hits
elsif solr_docs
solr_docs.map { |d| OoorHit.new(d, highlights_for(d), self) }
else
[]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def session; end",
"def session; end",
"def session; end",
"def session; end",
"def session; @session; end",
"def session; @session; end",
"def session; @session; end",
"def session\n end",
"def open_session; end",
"def session() request.session end",
"def session_id; end",
"def session_id; ... | [
"0.8131701",
"0.8131701",
"0.8131701",
"0.8131701",
"0.7850706",
"0.7850706",
"0.7850706",
"0.7827233",
"0.72940195",
"0.72914696",
"0.7289708",
"0.7289708",
"0.7289708",
"0.72870135",
"0.72870135",
"0.72500587",
"0.7190777",
"0.70664245",
"0.6994817",
"0.6935262",
"0.6909511... | 0.0 | -1 |
Populate the Hit objects with their instances. This is invoked the first time any hit has its instance requested, and all hits are loaded as a batch. | def populate_hits(session)
id_hit_hash = Hash.new { |h, k| h[k] = {} }
hits.each do |hit|
id_hit_hash[hit.class_name][hit.primary_key] = hit
end
id_hit_hash.each_pair do |class_name, hits|
hits_for_class = id_hit_hash[class_name]
hits.each do |hit_pair|
hit_pair[1].result = session[class_name].from_solr(hit_pair[1].stored_values)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def populate_hits #:nodoc:\n id_hit_hash = Hash.new { |h, k| h[k] = {} }\n hits.each do |hit|\n id_hit_hash[hit.class_name][hit.primary_key] = hit\n end\n id_hit_hash.each_pair do |class_name, hits|\n ids = hits.map { |id, hit| hit.primary_key }\n data_accesso... | [
"0.7027469",
"0.6118545",
"0.58107525",
"0.57028615",
"0.56853884",
"0.55229694",
"0.5508691",
"0.54597586",
"0.53999543",
"0.5390241",
"0.53761035",
"0.52861804",
"0.52699184",
"0.52337414",
"0.5215823",
"0.5207029",
"0.5189272",
"0.5151213",
"0.51362836",
"0.510706",
"0.508... | 0.6334193 | 1 |
run through using each method def reverse_each_word(string) string_to_array = string.split reverse_array = [] string_to_array.each do |word| reverse_array << word.reverse end each reverse_array.join(' ') end run through exchanging .each for .collect | def reverse_each_word(string)
string_to_array = string.split
reverse_array = []
string_to_array.collect do |word|
reverse_array << word.reverse
end #each
reverse_array.join(' ')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reverse_each_word(string)\n p string.split.collect {|word| word.reverse}.join(\" \")\nend",
"def reverse_each_word(string)\n string_array = string.split(' ')\n string_array.collect do |word|\n word.reverse!\n end\n string_array.join(\" \")\nend",
"def reverse_each_word(string)\n step_one = string... | [
"0.89264756",
"0.8916797",
"0.8912639",
"0.88888675",
"0.888038",
"0.8879262",
"0.8874255",
"0.8870094",
"0.88672286",
"0.8867065",
"0.88666356",
"0.8863131",
"0.8854156",
"0.8854056",
"0.8839098",
"0.88384265",
"0.8831874",
"0.8826323",
"0.8820421",
"0.8819315",
"0.8816487",... | 0.89209235 | 1 |
Format file with magic numbers. | def format_file(file)
out = ''
file.magic_numbers.each do |num|
if @color
val = red(num.value)
line = yellow(num.line)
path = pink(file.path)
else
val = num.value
line = num.line
path = file.path
end
out << "#{path}:#{line} detected magic number #{val}\n"
end
out
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform(file, format:); end",
"def write_magic_number(outf)\n outf.write([0xA115ca1e].pack(\"l\"))\nend",
"def write_magic_number(outf)\n outf.write([0xA115ca1e].pack(\"l\"))\nend",
"def filemagic\n @filemagic ||= FileMagic.new(FileMagic::MAGIC_MIME_TYPE)\n end",
"def filemagic\n ... | [
"0.6281752",
"0.6070471",
"0.6070471",
"0.5853411",
"0.58094966",
"0.5755361",
"0.57475156",
"0.5623054",
"0.55696744",
"0.55370533",
"0.5481274",
"0.5449468",
"0.5421163",
"0.53226775",
"0.52861476",
"0.51784503",
"0.5133529",
"0.5104572",
"0.5101763",
"0.50919616",
"0.50752... | 0.80021256 | 0 |
GET /shops/1 GET /shops/1.json | def show
@shop = Shop.find(params[:id])
@ave_review = Review.where(shop_id: @shop.id).average(:rate)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @shop = Shop.find(1)\n render :json => @shop\n return\n end",
"def index\n @workshops = Workshop.past\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @workshops }\n end\n end",
"def shops\n render :nothing => true and return if... | [
"0.7023943",
"0.6906654",
"0.6863234",
"0.67428267",
"0.6735511",
"0.6721623",
"0.669305",
"0.66567355",
"0.66534406",
"0.66534406",
"0.66534406",
"0.66534406",
"0.66534406",
"0.65839857",
"0.6559399",
"0.6482466",
"0.6448709",
"0.643932",
"0.64357466",
"0.63429004",
"0.63320... | 0.0 | -1 |
GET /shops GET /shops.json | def index
@shops = Shop.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @shops = @shops.all\n end",
"def index\n @workshops = Workshop.past\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @workshops }\n end\n end",
"def shops\n render :nothing => true and return if params[:id].nil?\n \n if ( pa... | [
"0.72563785",
"0.7201",
"0.6871923",
"0.68268996",
"0.6785776",
"0.67797875",
"0.6753759",
"0.67289543",
"0.66619116",
"0.6610495",
"0.658828",
"0.65255874",
"0.6515238",
"0.6446234",
"0.6438655",
"0.6430346",
"0.6408071",
"0.64047897",
"0.63898164",
"0.63822806",
"0.63668334... | 0.7006259 | 5 |
POST /shops POST /shops.json | def create
@shop = Shop.new(name: params[:shop][:name], station: params[:shop][:station], prefucture: params[:shop][:prefucture], city: params[:shop][:city], address: params[:shop][:address], url: params[:shop][:url], tell_num: params[:shop][:tell_num],shop_image: params[:shop][:shop_image], start_time: params[:shop][:start_time], end_time: params[:shop][:end_time], features: params[:shop][:features], holidays: params[:shop][:holidays], wifi: params[:shop][:wifi], sockets: params[:shop][:sockets], non_smorker: params[:shop][:non_smorker], smorker: params[:shop][:smorker], mid_night: params[:shop][:mid_night], close_from_station: params[:shop][:close_from_station], parking: params[:shop][:parking], co_working: params[:shop][:co_working], printer: params[:shop][:printer],)
require 'date'
time = Time.now
if @shop.shop_image
@shop.shop_image= "#{time}.jpg"
image = params[:shop][:shop_image]
File.binwrite("public/#{@shop.shop_image}",image.read)
else
puts "写真ないよ"
@shop.shop_image= "no-image.png"
end
if @shop.wifi == "1"
@shop.wifi = "#Wifi有り"
else
@shop.wifi = ""
end
if @shop.sockets == "1"
@shop.sockets ="#電源有り"
else
@shop.sockets = ""
end
if @shop.non_smorker == "1"
@shop.non_smorker = "#完全禁煙"
else
@shop.non_smorker = ""
end
if @shop.smorker == "1"
@shop.smorker = "#喫煙可"
else
@shop.smorker =""
end
if @shop.mid_night == "1"
@shop.mid_night = "#深夜営業"
else
@shop.mid_night = ""
end
if @shop.close_from_station == "1"
@shop.close_from_station = "#駅チカ"
else
@shop.close_from_station = ""
end
if @shop.parking == "1"
@shop.parking = "#駐車場有り"
else
@shop.parking = ""
end
if @shop.co_working == "1"
@shop.co_working = "#コワーキングスペース"
else
@shop.co_working = ""
end
if @shop.printer == "1"
@shop.printer = "#プリンター有り"
else
@shop.printer = ""
end
respond_to do |format|
if @shop.save
format.html { redirect_to @shop, notice: '店舗登録を完了しました' }
format.json { render :show, status: :created, location: @shop }
else
format.html { render :new }
format.json { render json: @shop.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @shop = @shops.new(shop_params)\n\n respond_to do |format|\n if @shop.save\n format.html { redirect_to @shop, notice: \"Shop was successfully created.\" }\n format.json { render :show, status: :created, location: @shop }\n else\n format.html { render ... | [
"0.68150663",
"0.6472888",
"0.63746464",
"0.6346631",
"0.63038427",
"0.63038427",
"0.6256386",
"0.6253434",
"0.6151498",
"0.6151498",
"0.6089625",
"0.6073879",
"0.6012835",
"0.5967755",
"0.5931647",
"0.5889389",
"0.5888434",
"0.5857539",
"0.5838185",
"0.58163667",
"0.5756799"... | 0.0 | -1 |
PATCH/PUT /shops/1 PATCH/PUT /shops/1.json | def update
respond_to do |format|
if @shop.update(shop_params)
format.html { redirect_to @shop, notice: '店舗の更新をしました' }
format.json { render :show, status: :ok, location: @shop }
else
format.html { render :edit }
format.json { render json: @shop.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n\n # update shops\n shops_edit = JSON.parse(params[:mall][:shops_in_mall])\n\n respond_to do |format|\n if @mall.update_with_shops(mall_params, shops_edit)\n format.html { redirect_to director_malls_path, notice: 'Mall was successfully updated.' }\n format.json { render :sho... | [
"0.62457025",
"0.62307256",
"0.6227023",
"0.6057643",
"0.603566",
"0.60095644",
"0.6002582",
"0.6002582",
"0.5998753",
"0.59944034",
"0.594038",
"0.5916561",
"0.58946735",
"0.5881242",
"0.5879094",
"0.5847877",
"0.5842934",
"0.58367646",
"0.5835645",
"0.58111537",
"0.5802468"... | 0.0 | -1 |
DELETE /shops/1 DELETE /shops/1.json | def destroy
@shop.destroy
respond_to do |format|
format.html { redirect_to shops_url, notice: '店舗の削除をしました' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @shop = Shop.find(params[:id])\n @shop.destroy\n\n respond_to do |format|\n format.html { redirect_to shops_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @shop = Shop.find(params[:id])\n @shop.destroy\n\n respond_to do |format|\n format.html { re... | [
"0.7150523",
"0.71194243",
"0.71194243",
"0.7100105",
"0.7100105",
"0.7100105",
"0.70407534",
"0.7016818",
"0.6844089",
"0.68091464",
"0.6798578",
"0.6796509",
"0.67763335",
"0.67763335",
"0.67763335",
"0.67763335",
"0.67763335",
"0.67712057",
"0.6741311",
"0.67163855",
"0.67... | 0.6640923 | 30 |
Use callbacks to share common setup or constraints between actions. | def set_shop
@shop = Shop.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 |
Metodo que devuelve el atributo texto devuelve String: cadena de texto | def getText
@text
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def text\n attributes.fetch(:text)\n end",
"def text\n attributes.fetch(:text)\n end",
"def text\n attributes.fetch(:text)\n end",
"def handle_text(name, attrs)\n \n end",
"def get_string(attr); end",
"def text(value)\n attributes[:text] = value\... | [
"0.67464906",
"0.67464906",
"0.67464906",
"0.6493122",
"0.64860576",
"0.6385885",
"0.61663365",
"0.612635",
"0.61239064",
"0.61239064",
"0.610764",
"0.6099382",
"0.6068162",
"0.60174745",
"0.59994864",
"0.5964941",
"0.5961278",
"0.59517294",
"0.5914252",
"0.59046984",
"0.5904... | 0.0 | -1 |
Checking occurrence of give number in give range of numbers | def is_validated
if $start_num > $end_num
re_enter_number
else
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_between(list_of_integers, lower_bound, upper_bound)\ncount = 0\nrange_array = *(lower_bound..upper_bound)\nlist_of_integers.each do |i|\nif range_array.include?(i) == true\ncount += 1\nend\nend\nreturn count\nend",
"def in_ranges?(num, ranges)\n result = false\n ranges.each do |range|\n if range.i... | [
"0.72157913",
"0.7107371",
"0.69449586",
"0.68925333",
"0.68533987",
"0.68198925",
"0.67960596",
"0.67954075",
"0.6790874",
"0.6736676",
"0.6731348",
"0.67163694",
"0.66744304",
"0.665166",
"0.66432077",
"0.6641633",
"0.66209286",
"0.6615021",
"0.6602762",
"0.65821475",
"0.65... | 0.0 | -1 |
GET /route_lines/1 GET /route_lines/1.xml | def show
@route_line = RouteLine.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @route_line }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @route_line = RouteLine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @route_line }\n end\n end",
"def show\n @line = Line.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :... | [
"0.67667043",
"0.65672505",
"0.6559145",
"0.64495134",
"0.63750297",
"0.63661855",
"0.6302329",
"0.6302329",
"0.6294172",
"0.62933385",
"0.62933385",
"0.6284217",
"0.6225611",
"0.6225611",
"0.6225611",
"0.6220611",
"0.6149663",
"0.61359984",
"0.60800207",
"0.5990889",
"0.5967... | 0.7364143 | 0 |
GET /route_lines/new GET /route_lines/new.xml | def new
@route_line = RouteLine.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @route_line }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @route = Route.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @route }\n end\n end",
"def new\n @route = Route.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @route }\n end\n ... | [
"0.69570416",
"0.69570416",
"0.68748254",
"0.67634356",
"0.6761244",
"0.67308766",
"0.67308766",
"0.6653637",
"0.66255766",
"0.654666",
"0.6496977",
"0.64524895",
"0.6439039",
"0.6406683",
"0.63371944",
"0.63088495",
"0.62760556",
"0.6266011",
"0.625445",
"0.6241583",
"0.6170... | 0.77483696 | 0 |
POST /route_lines POST /route_lines.xml | def create
@route_line = RouteLine.new(params[:route_line])
respond_to do |format|
if @route_line.save
format.html { redirect_to(@route_line, :notice => t('record_created')) }
format.xml { render :xml => @route_line, :status => :created, :location => @route_line }
else
format.html { render :action => "new" }
format.xml { render :xml => @route_line.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_route(route, message)\n raise TypeError unless route.is_a? Route\n @changeset = @api.create_changeset(message, tags={'created_by'=>'ITCR'})\n ways_list = []\n nodes_list = create_node_list(route.path)\n\n until nodes_list.empty? # For node's maximum limit of a way\n way_nodes = nodes_l... | [
"0.6794016",
"0.62879074",
"0.60445315",
"0.60086155",
"0.5927529",
"0.5893402",
"0.5819869",
"0.5786194",
"0.576726",
"0.57605153",
"0.57406336",
"0.5728971",
"0.57221913",
"0.5695683",
"0.5691606",
"0.5689479",
"0.5686326",
"0.56781805",
"0.56763124",
"0.5656182",
"0.564734... | 0.7107329 | 0 |
PUT /route_lines/1 PUT /route_lines/1.xml | def update
@route_line = RouteLine.find(params[:id])
respond_to do |format|
if @route_line.update_attributes(params[:route_line])
format.html { redirect_to(@route_line, :notice => t('record_updated')) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @route_line.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_xml\n self.xml= dumpRouteAsXml\n self.save\n end",
"def update\n @line = Line.find(params[:id])\n\n respond_to do |format|\n if @line.update_attributes(params[:line])\n format.html { redirect_to(@line, :notice => 'Line was successfully updated.') }\n format.xml { head ... | [
"0.6523446",
"0.6482837",
"0.62196237",
"0.6185141",
"0.6171954",
"0.6167397",
"0.61073893",
"0.60962695",
"0.6029012",
"0.6027949",
"0.5994899",
"0.59879035",
"0.5985117",
"0.5948219",
"0.59443486",
"0.5871491",
"0.58647555",
"0.58647555",
"0.5829382",
"0.58127433",
"0.57970... | 0.7276072 | 0 |
DELETE /route_lines/1 DELETE /route_lines/1.xml | def destroy
@route_line = RouteLine.find(params[:id])
@route_line.destroy
respond_to do |format|
format.html { redirect_to(route_lines_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @linea = Linea.find(params[:id])\n @linea.destroy\n\n respond_to do |format|\n format.html { redirect_to(lineas_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @service_line = ServiceLine.find(params[:id])\n @service_line.destroy\n\n respond_to do |for... | [
"0.69276166",
"0.68328714",
"0.68106467",
"0.67409015",
"0.66668594",
"0.66668594",
"0.6594451",
"0.65884703",
"0.6550613",
"0.64880764",
"0.6476469",
"0.64514494",
"0.6430788",
"0.6422718",
"0.64226633",
"0.6415043",
"0.6412264",
"0.63918084",
"0.63886774",
"0.63743454",
"0.... | 0.77140987 | 0 |
Converts the internal state of the model in a String | def to_s
res = @x + " " + @p + " " + @o
res
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s()\n #This is a stub, used for indexing\n end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
... | [
"0.72040814",
"0.71813303",
"0.71813303",
"0.71813303",
"0.71813303",
"0.71813303",
"0.71813303",
"0.71813303",
"0.71813303",
"0.71813303",
"0.71813303",
"0.71813303",
"0.71813303",
"0.71813303",
"0.71813303",
"0.71813303",
"0.71813303",
"0.71813303",
"0.71813303",
"0.71215284"... | 0.0 | -1 |
Compose libcurl header string from key and value. Also replaces null bytes, because libcurl will complain otherwise. | def compose_header(key, value)
Util.escape_zero_byte("#{key}: #{value}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def safe_append_header(key, value)\n resp_headers[key] = value.to_s\n end",
"def encode_header(s); s; end",
"def parse_headers(headers_hash)\n header_string = \"\"\n for header in headers_hash.select { |k,v| k.match(\"^HTTP.*\") } do\n header_string += header[0]+\":\"+header[1]+\"|\... | [
"0.6261589",
"0.6067391",
"0.5937041",
"0.57820547",
"0.5747294",
"0.57390136",
"0.57161534",
"0.5712725",
"0.56487375",
"0.5642438",
"0.56402147",
"0.558702",
"0.5536527",
"0.55331653",
"0.55216986",
"0.5513828",
"0.55009437",
"0.5489248",
"0.5456789",
"0.54553056",
"0.54326... | 0.74180245 | 0 |
check if the current user login in can view the page | def check_current_profile
if user_signed_in?
if current_user.profile_type == "Business"
redirect_to root_path , notice:"Not authorised to view this page"
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_login\n head :forbidden unless self.current_user\n end",
"def has_privilege?\n if (!logged_in?)\n redirect_to '/login' and return\n elsif (params[:user_id].to_i != current_user.id)\n redirect_to user_stories_path(current_user) and return\n end\n end",
"def ch... | [
"0.77468944",
"0.7738537",
"0.76635563",
"0.763968",
"0.7637182",
"0.7599079",
"0.7550959",
"0.75217855",
"0.75211614",
"0.7518717",
"0.74993414",
"0.7491726",
"0.748678",
"0.7467982",
"0.7449765",
"0.7438591",
"0.7426762",
"0.74231154",
"0.7414255",
"0.7412775",
"0.7400169",... | 0.0 | -1 |
def has_player_1_won?(player_1.weapon_choice,player_2.weapon_choice) RULES[:rock][:paper] end | def draw?
player_1.weapon_choice == player_2.weapon_choice
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def if_player_1_wins?\n\t($p1 == \"scissors\" && $p2 == \"paper\") || ($p1 == \"rock\" && $p2 == \"scissors\") || ($p1 == \"paper\" && $p2 == \"rock\") || ($p1 == \"rock\" && $p2 == \"lizard\") || ($p1 == \"spock\" && $p2 == \"scissors\") || ($p1 == \"scissors\" && $p2 == \"lizard\") || ($p1 == \"spock\" && $p2 ==... | [
"0.79259664",
"0.7843955",
"0.7677486",
"0.75423276",
"0.74861884",
"0.74719155",
"0.7442633",
"0.7417577",
"0.7301638",
"0.7237985",
"0.7236357",
"0.7223398",
"0.7199837",
"0.7144517",
"0.71330255",
"0.7095467",
"0.7061443",
"0.69324934",
"0.68711644",
"0.6870875",
"0.681175... | 0.7870847 | 1 |
GET /purchase_orders GET /purchase_orders.json | def index
@purchase_orders = PurchaseOrder.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getorders(args={})\n {\n :method=> \"GetOrders\"\n }.to_json\n end",
"def orders\n params = { command: 'account_orders' }\n get('/json.php', params)\n end",
"def index\n @purchase_orders = current_user.purchase_orders\n @purchase_orders = @purchase_orders.map{ |... | [
"0.76597935",
"0.76165295",
"0.7568371",
"0.74410343",
"0.7321653",
"0.7274848",
"0.72494054",
"0.7203941",
"0.71983325",
"0.71800095",
"0.70805234",
"0.7024208",
"0.6968476",
"0.6960769",
"0.6960769",
"0.6923767",
"0.6845308",
"0.68266785",
"0.67987925",
"0.67982656",
"0.679... | 0.7228544 | 11 |
GET /purchase_orders/1 GET /purchase_orders/1.json | def show
@purchase_order_details = @purchase_order.purchase_order_details
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @purchase_orders = current_user.purchase_orders\n @purchase_orders = @purchase_orders.map{ |purchase_order| purchase_order.attributes }\n render json: @purchase_orders\n end",
"def index\n @purchases = Purchase.where(user_id: get_current_user.id.to_i)\n\n render json: @purchases\n en... | [
"0.7133679",
"0.7084332",
"0.70752203",
"0.7062937",
"0.7033524",
"0.69962937",
"0.6983285",
"0.6980371",
"0.6980371",
"0.69722176",
"0.69722176",
"0.69722176",
"0.69722176",
"0.69722176",
"0.6956117",
"0.6912581",
"0.69081545",
"0.68349123",
"0.682728",
"0.681525",
"0.679321... | 0.0 | -1 |
POST /purchase_orders POST /purchase_orders.json | def create
@purchase_order = PurchaseOrder.new(purchase_order_params)
@purchase_order.date = Time.now
respond_to do |format|
if @purchase_order.save
format.html {
flash[:notice] = 'La Orden de Compra se creó satisfactoriamente.'
redirect_to purchase_orders_path
}
format.json { render :show, status: :created, location: @purchase_order }
else
format.html { render :new }
format.json { render json: @purchase_order.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @purchase_order = PurchaseOrder.new(purchase_order_params)\n\n if @purchase_order.save\n render :show, status: :created, location: @purchase_order\n else\n render json: @purchase_order.errors, status: :unprocessable_entity\n end\n end",
"def create\n @purchaseorder = Purcha... | [
"0.7130033",
"0.7049944",
"0.70488024",
"0.70105404",
"0.69538826",
"0.6912126",
"0.69055",
"0.68661004",
"0.6859178",
"0.6848946",
"0.6833895",
"0.6757425",
"0.67062426",
"0.66963494",
"0.66725725",
"0.66507685",
"0.6598269",
"0.6568256",
"0.655866",
"0.6553917",
"0.65496546... | 0.6370445 | 43 |
PATCH/PUT /purchase_orders/1 PATCH/PUT /purchase_orders/1.json | def update
respond_to do |format|
if @purchase_order.update(purchase_order_params)
format.html {
flash[:notice] = 'La Orden de Compra se actualizó satisfactoriamente.'
redirect_to purchase_orders_path
}
format.json { render :show, status: :ok, location: @purchase_order }
else
format.html { render :edit }
format.json { render json: @purchase_order.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @purchaseorder = Purchaseorder.find(params[:id])\n\n respond_to do |format|\n if @purchaseorder.update_attributes(params[:purchaseorder])\n format.html { redirect_to @purchaseorder, notice: 'Purchaseorder was successfully updated.' }\n format.json { head :no_content }\n e... | [
"0.69700235",
"0.69230294",
"0.68830836",
"0.6866676",
"0.68090886",
"0.67963797",
"0.67452705",
"0.6724078",
"0.6710528",
"0.6683274",
"0.6683274",
"0.6602721",
"0.65918726",
"0.6586257",
"0.656877",
"0.6555165",
"0.6555165",
"0.6555165",
"0.6540841",
"0.6539376",
"0.6523710... | 0.65860564 | 14 |
DELETE /purchase_orders/1 DELETE /purchase_orders/1.json | def destroy
@purchase_order.destroy
respond_to do |format|
format.html {
flash[:notice] = 'La Orden de Compra se eliminó satisfactoriamente.'
redirect_to purchase_orders_path
}
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @purchase.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @purchaseorder = Purchaseorder.find(params[:id])\n @purchaseorder.destroy\n\n respond_to do |format|\n format.html { redirect_to purchaseorders_url }\n format... | [
"0.75802916",
"0.7500162",
"0.73648363",
"0.73648363",
"0.73633796",
"0.7340562",
"0.7333217",
"0.7333217",
"0.7333217",
"0.7333217",
"0.7333217",
"0.7324071",
"0.73000824",
"0.72275585",
"0.72258633",
"0.7216888",
"0.7210899",
"0.7206678",
"0.72054744",
"0.7195266",
"0.71674... | 0.7075623 | 29 |
Use callbacks to share common setup or constraints between actions. | def set_purchase_order
@purchase_order = PurchaseOrder.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 purchase_order_params
params.require(:purchase_order).permit(:supplier_id, :business_id, :order_number, :date, :order_date, :delivery_date, :billing_address, :delivery_address, :ammount,
purchase_order_details_attributes: [:id, :purchase_order_id, :product_id, :quantity, :pending, :unit_price, :subtotal, :_destroy],
purchase_order_documents_attributes: [:id, :purchase_order_id, :document, :_destroy])
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.69802505",
"0.6781974",
"0.67470175",
"0.67430073",
"0.67350477",
"0.6593221",
"0.6504263",
"0.64988977",
"0.6481794",
"0.64800006",
"0.64568025",
"0.64411247",
"0.6379476",
"0.63765615",
"0.6368045",
"0.6320141",
"0.6300363",
"0.6300057",
"0.62952244",
"0.6294712",
"0.629... | 0.0 | -1 |
This method can be used as a before filter to protect any actions by ensuring the request is transmitting a valid JWT. | def verify_jwt_token
begin
if request.format.json?
token = request.headers['Authorization'].split(' ').last
decoded_token = JWT.decode token, nil, false
@current_user = User.find(decoded_token[0]["user_id"])
head :unauthorized if request.headers['Authorization'].nil? || !AuthToken.valid?(token)
else
authenticate_user!
end
rescue => exception
head :unauthorized
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_request(request)\n @token.authenticate(request)\n end",
"def authorize_request\n unless request.headers['Authorization'].present?\n render json: {message: 'Missing Token'}, status: :unauthorized\n end\n end",
"def verify_jwt_token\n # token = request.headers['HB-User... | [
"0.6975118",
"0.6674913",
"0.64597625",
"0.64119655",
"0.63582075",
"0.63264006",
"0.6322555",
"0.62745905",
"0.6273998",
"0.62526846",
"0.6236557",
"0.61915356",
"0.61915356",
"0.61817575",
"0.6171722",
"0.6150705",
"0.6143216",
"0.6133747",
"0.610661",
"0.6066448",
"0.60640... | 0.63536173 | 5 |
Use to copy a whole directory from the "template" to the new talia instance | def process_dir(manifest, directory, options = {})
manifest.directory(directory)
files = relative_dir_files(directory)
process_files(manifest, files, options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy_template(*args)\n args.each do |path|\n # puts \"Installing #{path}...\".magenta\n remove_file path\n file path, File.read(File.join(@path_templates, path))\n # puts \"\\n\"\n end\nend",
"def clone_kvm(name, template)\n FileUtils.cp(template, File.join(KVM_HOME, 'storage', \"#{name}.qcow2... | [
"0.7269149",
"0.7085451",
"0.673325",
"0.67251754",
"0.6699637",
"0.6670763",
"0.66683334",
"0.66401684",
"0.66074926",
"0.6568028",
"0.6544095",
"0.65117687",
"0.64691794",
"0.6461981",
"0.64456755",
"0.6428747",
"0.639854",
"0.63642144",
"0.635605",
"0.63129884",
"0.6310912... | 0.0 | -1 |
Record a list of given file copies. The file_list should contain relative pathnames from the talia root directory. | def process_files(manifest, file_list, options = {})
file_list.each do |file|
if(File.directory?(file_root(file)))
manifest.directory(file)
else
manifest.file(talia_root(file), file, options)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def files=(list)\n @files = makelist(list)\n end",
"def files(*list)\n @files.concat(makelist(list)) unless list.empty?\n @files\n end",
"def write_file_list\n if EventMachine.reactor_thread? || !@update_lock.locked?\n raise 'Should not write file list in reactor thread or ... | [
"0.68745583",
"0.6625815",
"0.6425046",
"0.6309962",
"0.62858593",
"0.62782484",
"0.62651217",
"0.61995614",
"0.60999215",
"0.6049559",
"0.6049559",
"0.60230637",
"0.60230637",
"0.5956538",
"0.59179145",
"0.59179145",
"0.5878754",
"0.5866721",
"0.5807952",
"0.57931614",
"0.57... | 0.5741347 | 20 |
Get the contents of a a directory as relative pathnames (without the root dir prepended) | def relative_dir_files(directory)
files = Dir["#{file_root(directory)}/**/*"]
files.map! { |file| file.gsub(/#{file_root}/, '') }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list\n Dir.glob(\"#{@directory}/**/*\").reject(&File.directory?).map do |p|\n Pathname.new(p).relative_path_from(@directory)\n end\n end",
"def relative_directory\n return '' unless @directory_root\n @path - @directory_root - name\n end",
"def GetDirectoryPa... | [
"0.73436093",
"0.72702956",
"0.7028072",
"0.66749",
"0.6666142",
"0.6632963",
"0.66088873",
"0.66040266",
"0.6506285",
"0.64781827",
"0.64737064",
"0.64565885",
"0.6375378",
"0.6330453",
"0.6306326",
"0.62641954",
"0.62636685",
"0.6248289",
"0.6239016",
"0.6228213",
"0.621682... | 0.7274677 | 1 |
Change the given path so that it will point to the root of the "template" installation | def talia_root(path = '')
File.join('..', '..', '..', '..', path)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def install_template(path)\n puts \"Installing project template to #{path} ...\"\n template_dir = File.expand_path('../template', __FILE__)\n FileUtils.cp_r(\"#{template_dir}/.\", path)\n end",
"def template_path\n File.join path, 'templates'\n end",
"def templates_path=(path)\n @tem... | [
"0.7516995",
"0.6720837",
"0.66537464",
"0.6586678",
"0.65238374",
"0.64711213",
"0.6431262",
"0.6409483",
"0.638865",
"0.63602954",
"0.6343396",
"0.63279545",
"0.6326482",
"0.6324746",
"0.62838405",
"0.62679446",
"0.6252129",
"0.6245925",
"0.62306434",
"0.62221146",
"0.62035... | 0.0 | -1 |
Get the absolute file path to the root of the "template" installation | def file_root(path = '')
File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', path))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def full_template_path\n template_root.join(\"#{@template}.erb\").to_s.squeeze(\"/\")\n end",
"def template_path\n return File.join(File.dirname(__FILE__), \"../../../templates\", platform)\n end",
"def template_path\n path = File.expand_path File.join(@template_options[CONFIG_PATH], @... | [
"0.8041517",
"0.8010841",
"0.7934464",
"0.79063433",
"0.782733",
"0.7804971",
"0.77880585",
"0.77095896",
"0.76418203",
"0.76312923",
"0.7623952",
"0.7580384",
"0.7566597",
"0.74557036",
"0.7443224",
"0.74179775",
"0.7413786",
"0.73897845",
"0.73760986",
"0.7343122",
"0.73400... | 0.6727388 | 58 |
Generate the repository dists | def generate_dists(pkg_hash)
pkg_hash.each do |origin_name, dists|
dists.each do |dist_name, dist_args|
dist_args[:components].each do |component_name, arches|
packages = arches.values.flatten.compact.map(&:values).flatten.compact.map(&:values).flatten.compact
p_file = primary_file(origin_name, dist_name, component_name, packages)
f_file = filelist_file(origin_name, dist_name, component_name, packages)
sign_file_if_setup do
repomd_file(origin_name, dist_name, component_name,
:primary => p_file,
:filelists => f_file)
end
end
end
end
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def repo_dir; end",
"def repositories\n # TODO : merge with current data\n load_repos\n end",
"def get_repo (repoName='ComputerScience_test')\n puts \"get_repo\"\n set_repository repoName\n puts \"set_repository #{@repository}\"\n result = @repository.query.perform \"select ?s ?p ?o {?... | [
"0.58840704",
"0.5864802",
"0.57742053",
"0.57647485",
"0.57647485",
"0.57647485",
"0.57647485",
"0.5701553",
"0.5689896",
"0.5676539",
"0.5675987",
"0.56477207",
"0.56251127",
"0.557836",
"0.54690534",
"0.54528403",
"0.5433646",
"0.543322",
"0.5426511",
"0.5426511",
"0.54172... | 0.678255 | 0 |
Sign file if configured for signing | def sign_file_if_setup(opts = nil)
path = yield
if signer && options[:sign]
signer.file(path, nil, opts)
end
path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_signing\n if sign_file?\n @appearance = @stamper.getSignatureAppearance().to_java(Java::ComLowagieTextPdf::PdfSignatureAppearance)\n @appearance.setCrypto(@private_key, @cert_chain, nil, Java::ComLowagieTextPdf::PdfSignatureAppearance::WINCER_SIGNED)\n end\n end",
"def sign_file?\... | [
"0.7127565",
"0.6965597",
"0.6798428",
"0.6522074",
"0.648155",
"0.6389011",
"0.6235015",
"0.61595416",
"0.59772587",
"0.5942872",
"0.58809495",
"0.5870212",
"0.5870208",
"0.58613706",
"0.5851695",
"0.5768608",
"0.5758111",
"0.57299125",
"0.5698023",
"0.56455684",
"0.56163305... | 0.78094 | 0 |
Create a primary file | def primary_file(origin_name, dist_name, component_name, packages)
content = {
:metadata => {
:@xmlns => XMLNS_MAP[:common],
"@xmlns:rpm" => XMLNS_MAP[:rpm],
:@packages => packages.size,
:package => packages.map { |package|
{
:@type => "rpm",
:name => package["NAME"],
:arch => package["ARCH"],
:version => {
:@epoch => package["EPOCHNUM"],
:@ver => package["VERSION"],
:@rel => package["RELEASE"].split(".").first,
},
:checksum => [
{
:@type => "sha",
:@pkgid => "YES",
},
package[:generated_sha],
],
:summary => package["SUMMARY"],
:description => [package["DESCRIPTION"]].flatten.compact.join(" "),
:packager => package["PACKAGER"],
:url => package["URL"],
:time => {
:@file => Time.now.to_i,
:@build => package["BUILDTIME"],
},
:size => {
:@archive => package["ARCHIVESIZE"],
:@package => package[:generated_size],
:@installed => package["LONGSIZE"],
},
:location => package[:generated_path],
:format => {
"rpm:license" => package["LICENSE"],
"rpm:vendor" => package["VENDOR"],
"rpm:group" => package["GROUP"],
"rpm:buildhost" => package["BUILDHOST"],
"rpm:header-range" => {
:@start => package[:generated_header][:start],
:@end => package[:generated_header][:end],
},
"rpm:provides" => {
"rpm:entry" => Array.new.tap { |entries|
pro_ver = package["PROVIDEVERSION"].dup
package["PROVIDENAME"].each_with_index do |p_name, p_idx|
item = {:@name => p_name}
if p_flag = VERSION_FLAGS[package["PROVIDEFLAGS"][p_idx]]
p_ver, p_rel = pro_ver.shift.split("-", 2)
item.merge!(:@flags => p_flag, :@ver => p_ver, :@rel => p_rel, :@epoch => package["EPOCHNUM"])
end
entries.push(item)
end
},
},
"rpm:requires" => {
"rpm:entry" => Array.new.tap { |entries|
req_ver = package["REQUIREVERSION"].dup
package["REQUIRENAME"].each_with_index do |r_name, r_idx|
item = {:@name => r_name}
if r_flag = VERSION_FLAGS[package["REQUIREFLAGS"][r_idx]]
r_ver, r_rel = req_ver.shift.split("-", 2)
item.merge!(:@flags => r_flag, :@ver => r_ver, :@rel => r_rel, :@epoch => package["EPOCHNUM"])
end
entries.push(item)
end
},
},
},
}
},
},
}
args = [origin_name, dist_name, component_name, "repodata", "primary.xml"]
[
create_file(*args) do |file|
file.puts generate_xml(content)
end,
compress_file(*args),
]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createFile (pathFile,extension,nameFile, erb)\r\n FileUtils.mkdir_p(pathFile)\r\n fileName = pathFile+nameFile+extension\r\n newFile = File.open(fileName,\"w\")\r\n newFile.print erb\r\n newFile.close\r\n end",
"def new_file\n raise \"Not a Valid Directory\" unless valid_directory?\n\n ... | [
"0.6727614",
"0.6698845",
"0.6696226",
"0.65995675",
"0.65915596",
"0.65837497",
"0.6559477",
"0.6495174",
"0.6482452",
"0.64817536",
"0.64756376",
"0.6470696",
"0.6460598",
"0.64331454",
"0.64207685",
"0.6401803",
"0.63839376",
"0.6369327",
"0.63344496",
"0.63114244",
"0.631... | 0.0 | -1 |
Create a filelist file | def filelist_file(origin_name, dist_name, component_name, packages)
content = {
"filelists" => {
:@xmlns => XMLNS_MAP[:filelists],
:@packages => packages.size,
:package => packages.map { |package|
{
:@pkgid => package[:generated_sha],
:@name => package["NAME"],
:@arch => package["ARCH"],
:version => {
:@epoch => package["EPOCHNUM"],
:@ver => package["VERSION"],
:@rel => package["RELEASE"].split(".").first,
},
:file => (package["FILENAMES"] + package["DIRNAMES"]).map { |dir|
{:@type => "dir", :_content_ => dir}
},
}
},
},
}
args = [origin_name, dist_name, component_name, "repodata", "filelists.xml"]
[
create_file(*args) do |file|
file.puts generate_xml(content)
end,
compress_file(*args),
]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_list\n end",
"def build_volume_list_file(volume_list, path)\n File.write(path, volume_list.join(\"\\n\"))\n end",
"def write_filelist(out_file_list)\n result_list.each{|f| log f}\n File.open(out_file_list, \"w\") do |file|\n result_list.each do |item| \n file << item\n ... | [
"0.7136776",
"0.69717634",
"0.6923416",
"0.6923416",
"0.6860824",
"0.67586035",
"0.66304463",
"0.65696543",
"0.6563842",
"0.651738",
"0.6463753",
"0.6459376",
"0.6372507",
"0.63596064",
"0.62640786",
"0.62606937",
"0.625011",
"0.6217227",
"0.6178814",
"0.61540025",
"0.6146486... | 0.69076836 | 4 |
Create a repomd file | def repomd_file(origin_name, dist_name, component_name, files)
content = {
:repomd => {
:@xmlns => XMLNS_MAP[:repo],
:data => Hash.new.tap { |data|
files.each do |f_name, f_paths|
data[f_name] = {
:location => File.join("repodata", File.basename(f_paths.first)),
"open-checksum" => {
:@type => "sha",
:_content_ => checksum(File.open(f_paths.first), :sha1),
},
:checksum => {
:@type => "sha",
:_content_ => checksum(File.open(f_paths.last), :sha1),
},
:timestamp => File.mtime(f_paths.first).to_i,
}
end
},
},
}
args = [origin_name, dist_name, component_name, "repodata", "repomd.xml"]
create_file(*args) do |file|
file.puts generate_xml(content)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_rep_heading\n\tsave_file(print_date)\n\tsave_file(print_sales_rpt)\nend",
"def create_from_file\n end",
"def create!\n new_file = \"#{next_number}-#{strip_title}.md\"\n @path = File.join(@dir, new_file)\n File.open(@path, 'w') do |file|\n file.write initial_content\n ... | [
"0.6540798",
"0.6317075",
"0.6131345",
"0.61296797",
"0.61129206",
"0.59904003",
"0.5986589",
"0.5986589",
"0.5982446",
"0.5912002",
"0.58699125",
"0.5845621",
"0.5844821",
"0.5738858",
"0.57095057",
"0.5684894",
"0.5678842",
"0.56709176",
"0.5629446",
"0.5616826",
"0.5615655... | 0.6147178 | 2 |
Unpack payload from message | def unpack(message)
result = if(message[:content])
message[:content]
else
if(message[:message])
case determine_style(message)
when :sqs
if(message[:message]['Body'])
message[:message]['Body'].to_smash
else
message[:message].to_smash
end
when :http
begin
MultiJson.load(message[:message][:body]).to_smash
rescue MultiJson::DecodeError
message[:message][:body].to_smash
end
when :nsq
begin
MultiJson.load(message[:message].message).to_smash
rescue MultiJson::DecodeError
message[:message].message.to_smash
end
else
message[:message].to_smash
end
else
message.to_smash
end
end
if(respond_to?(:formatters) && respond_to?(:service_name))
formatters.each do |formatter|
next if result.fetch(:formatters, []).include?(formatter.class.name)
begin
if(service_name.to_sym == formatter.destination)
debug "Service matched formatter for pre-format! (<#{formatter.class}> - #{message})"
s_checksum = result.checksum
formatter.format(result)
unless(s_checksum == result.checksum)
info "Pre-formatter modified payload and will not be applied again after callback completion (<#{formatter.class}> - #{message})"
result[:formatters].push(formatter.class.name)
end
end
rescue => e
error "Formatter failed <#{formatter.source}:#{formatter.destination}> #{e.class}: #{e}"
end
end
end
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unpack(message)\n payload = super\n if(self.class == Jackal::Cfn::Event)\n begin\n unless(payload.get(:data, :cfn_event))\n payload = format_event(payload.fetch('Body', 'Message', payload))\n payload[:origin_type] = message[:message].get('Body', 'Type... | [
"0.7314567",
"0.713374",
"0.7129427",
"0.7116729",
"0.6825474",
"0.6770678",
"0.667089",
"0.65106803",
"0.6501799",
"0.64946806",
"0.6491785",
"0.64655906",
"0.63972276",
"0.6341313",
"0.63041073",
"0.62627095",
"0.6249634",
"0.6203068",
"0.6176558",
"0.612166",
"0.60885435",... | 0.6682284 | 6 |
Detect message style based on structure | def determine_style(m)
begin
case m[:source].to_s
when m.start_with?('Carnivore::Source::Http')
:http
else
m[:source].class.to_s.split('::').last.downcase.to_sym
end
rescue
:unknown
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def correct_style_detected; end",
"def correct_style_detected; end",
"def correct_style_detected; end",
"def opposite_style_detected; end",
"def opposite_style_detected; end",
"def opposite_style_detected; end",
"def message_types\n {\n create: [:light_cyan, :cyan],\n sto... | [
"0.61877704",
"0.61877704",
"0.61877704",
"0.58322054",
"0.58322054",
"0.58322054",
"0.57173175",
"0.57049656",
"0.56748456",
"0.5645307",
"0.56434464",
"0.5622245",
"0.558414",
"0.556531",
"0.5549686",
"0.5506054",
"0.5479458",
"0.547809",
"0.5473458",
"0.54372585",
"0.54224... | 0.53694737 | 22 |
true if exactly one argument is truthy false otherwise Examples: xor?(5.even?, 4.even?) == true xor?(5.odd?, 4.odd?) == true xor?(5.odd?, 4.even?) == false xor?(5.even?, 4.odd?) == false Data Structure: No special data structure, just conditionals within method Algorithm: 1) evaluate truthiness of arguments 2) if truthiness of arguments is the same, return false 3) if truthiness of arguments are not the same, return true | def xor?(arg1, arg2)
if !!arg1 == !!arg2
false
else
true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xor?(first_arg, second_arg)\n return true if first_arg == false && second_arg == true\n return true if first_arg == true && second_arg == false\nend",
"def xor?(arg1, arg2)\n if arg1 && !arg2 || !arg1 && arg2\n true\n else\n false\n end\nend",
"def xor?(arg_1, arg_2)\n if (arg_1 && arg_2) \n ... | [
"0.845171",
"0.83031994",
"0.83024937",
"0.82964444",
"0.8293093",
"0.8280611",
"0.82712376",
"0.82703143",
"0.8270063",
"0.82563597",
"0.8251475",
"0.8105169",
"0.7953976",
"0.79430175",
"0.793468",
"0.7900092",
"0.7895292",
"0.7878323",
"0.7845143",
"0.784474",
"0.78322655"... | 0.8125076 | 11 |
Attempt to bind to active directory, time out after N seconds, return true or false | def bind
return false unless !@connection.nil?
begin
Timeout::timeout(10) do
return (@connection.bind) ? true : false
end
rescue
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bind\n conn = Net::LDAP.new :host => @config[:server],\n :port => @config[:port],\n :base => @config[:base]\n if @config[:encryption]\n conn.encryption @config[:encryption]\n end\n \n ... | [
"0.60290295",
"0.59892845",
"0.5983772",
"0.5972752",
"0.5920659",
"0.57814956",
"0.57298326",
"0.57287616",
"0.5686326",
"0.56467944",
"0.5625104",
"0.55779064",
"0.5575127",
"0.556209",
"0.5547961",
"0.55463666",
"0.5534322",
"0.55124956",
"0.54762",
"0.54749876",
"0.547044... | 0.67869484 | 0 |
Build attributes for active directory account Code 512 creates standard user account and enables it | def ldap_attributes(user)
attributes = {
:cn => user.human_name,
:mail => user.email,
:objectclass => ["top", "person", "organizationalPerson", "user"],
:userPrincipalName => format_email_to_ad_domain(user.email),
:unicodePwd => password_encode('Just4now' + Time.now.to_f.to_s[-4, 4]),
:userAccountControl => "512",
:sn => user.last_name,
:givenName => user.first_name,
:displayName => user.human_name
}
return attributes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_attributes_from_ldap_info\n self.username = self.uid\n self.email = self.mail\n end",
"def build_user_details(xml, options)\n xml.User{\n xml.Name(@options[:user])\n xml.Password(@options[:password])\n xml.ClientId(@options[:clientId], :DataType... | [
"0.6295401",
"0.5926146",
"0.5900506",
"0.5828363",
"0.57306826",
"0.5727451",
"0.5653611",
"0.5631994",
"0.5606359",
"0.55958134",
"0.5565437",
"0.5538118",
"0.5532626",
"0.54499716",
"0.54478127",
"0.5445919",
"0.54455245",
"0.54440916",
"0.5436969",
"0.5432384",
"0.5419374... | 0.544643 | 15 |
Build user distinguished name for active directory account | def ldap_distinguished_name(user)
distinguished_name = "cn=#{user.human_name},"
if user.is_staff
if !user.masters_program.blank? && organization_units.include?(user.masters_program)
distinguished_name += "ou=" + user.masters_program + ",ou=Staff,"
else
distinguished_name += "ou=Staff,"
end
elsif user.is_student
if !user.masters_program.blank? && organization_units.include?(user.masters_program)
distinguished_name += "ou=" + user.masters_program + ",ou=Student,"
else
distinguished_name += "ou=Student,"
end
end
distinguished_name +="ou=Sync,"+base_distinguished_name
return distinguished_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dn_for username\n \"uid=#{username},#{@dn_suffix}\"\n end",
"def base_distinguished_name\n base_name = \"\"\n AD_DOMAIN.split('.').each do |item|\n base_name+=\"dc=#{item},\"\n end\n base_name.chop\n end",
"def dn_from_login(login)\n \"cn=#{login},#{user_root_dn}\"\n end",
"... | [
"0.7708891",
"0.69992936",
"0.68062884",
"0.65035427",
"0.6493364",
"0.64712983",
"0.6456602",
"0.6441083",
"0.63279724",
"0.6324164",
"0.63120276",
"0.6270766",
"0.62604505",
"0.6229162",
"0.6192431",
"0.61550665",
"0.61402726",
"0.6117044",
"0.6091688",
"0.60821605",
"0.606... | 0.7804183 | 0 |
Create base distinguished name from the active directory domain name | def base_distinguished_name
base_name = ""
AD_DOMAIN.split('.').each do |item|
base_name+="dc=#{item},"
end
base_name.chop
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_domain_name(env)\n config = env[:machine].provider_config\n domain_name =\n if config.default_prefix.nil?\n env[:root_path].basename.to_s.dup.concat('_')\n elsif config.default_prefix.empty?\n # don't have any prefix, not even \"_\"\n ... | [
"0.69623166",
"0.69332075",
"0.68167883",
"0.68031317",
"0.67725503",
"0.6702379",
"0.6697446",
"0.662761",
"0.65517074",
"0.6493758",
"0.6452573",
"0.64260846",
"0.639004",
"0.6364065",
"0.6303645",
"0.6279439",
"0.62763864",
"0.62599784",
"0.62599784",
"0.6228976",
"0.62075... | 0.84027666 | 0 |
Convert password to unicode format | def password_encode(password)
result = ""
password = "\"" + password + "\""
password.length.times { |i| result+= "#{password[i..i]}\000" }
return result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalized_password\n URI.encode(CGI.unescape(password), ENCODE_PASSWORD).force_encoding(Encoding::UTF_8) if password\n end",
"def ios_password(length = 1)\n 8226.chr('UTF-8') * length\n end",
"def to_s\n %[#<password safe>]\n end",
"def to_s\n %[#<password safe>]\n end",
"def e... | [
"0.70082265",
"0.6750396",
"0.6590168",
"0.6590168",
"0.65554684",
"0.63409925",
"0.63168037",
"0.6295069",
"0.6282027",
"0.6265489",
"0.6260444",
"0.62466705",
"0.62118137",
"0.61934644",
"0.61910933",
"0.6093912",
"0.6019688",
"0.6009712",
"0.5974416",
"0.5966306",
"0.59642... | 0.68760425 | 1 |
Send active directory password reset token | def send_password_reset_token(user)
user.set_password_reset_token
user.password_reset_sent_at = Time.zone.now
user.save!
PasswordMailer.password_reset(user).deliver
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_password_reset\n self.password_reset_sent_at = Time.now\n update_attribute(:password_reset_token, genrate_tokn(:password_reset_token) )\n UserMailer.password_reset(self).deliver\n end",
"def send_password_reset\n generate_token(:password_reset_token)\n update_attributes!(password_r... | [
"0.7602584",
"0.7531532",
"0.7526196",
"0.7514934",
"0.75007147",
"0.7488515",
"0.74847984",
"0.7472375",
"0.7457798",
"0.7457798",
"0.7457798",
"0.7457798",
"0.745766",
"0.7451809",
"0.7443036",
"0.7420269",
"0.7403361",
"0.73908997",
"0.73781776",
"0.7362122",
"0.7338981",
... | 0.7243051 | 25 |
Reset active directory password | def reset_password(user, new_pass)
if bind
distinguished_name = ldap_distinguished_name(user)
@connection.replace_attribute distinguished_name, :unicodePwd, password_encode(new_pass)
return @connection.get_operation_result.message
else
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_password!\n @session.nickserv.resetpass(self.name)\n end",
"def reset_password!\n new_password = Digest::MD5.hexdigest(Time.now.to_s.split(//).sort_by {rand}.join)[0, 10]\n self.password = new_password\n self.password_confirmation = new_password\n save!\n end",
"def ldappassword\... | [
"0.72977084",
"0.698937",
"0.6900631",
"0.68821645",
"0.6871696",
"0.6859099",
"0.6847823",
"0.68009704",
"0.6795015",
"0.6790964",
"0.6787461",
"0.677313",
"0.67727405",
"0.67706406",
"0.6743066",
"0.6726339",
"0.6720127",
"0.66997",
"0.66942614",
"0.66746134",
"0.66746134",... | 0.6578558 | 32 |
Format email with a active directory domain | def format_email_to_ad_domain(email)
return "#{email.split('@')[0]}@#{AD_DOMAIN}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def formatted_email(contact)\n \"#{contact.username} <#{contact.email}>\"\n end",
"def format_email!\n @email.gsub!(/@/, \"%40\")\n end",
"def return_email_domain \n return \"@\" + self.email.split('@')[1]\n end",
"def formatted_email\n \"#{@name} <#{@email}>\"\n end",
"def formatte... | [
"0.7114175",
"0.68831956",
"0.6870422",
"0.67671585",
"0.67034656",
"0.6591368",
"0.65578055",
"0.6530331",
"0.6523774",
"0.64464784",
"0.637136",
"0.63576686",
"0.63514507",
"0.63215506",
"0.6312877",
"0.6284144",
"0.6280981",
"0.62184435",
"0.6203389",
"0.6162383",
"0.61382... | 0.7599525 | 0 |
Return names of organization units | def organization_units
if bind
units = []
AdOrganizationUnit.find_each do |local_entry|
name = local_entry.distinguishedname.split(',')[0]
units.push(name[3..name.length])
end
return units
else
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def organization_list(organizations)\n organizations or return \"\"\n \n organizations.inject([]) do |s, unit|\n s << \"#{unit.aff_fullname}(#{unit.sta_fullname}\"\n end\n s.join(\", \")\n end",
"def organization_names\n organizations.pluck(:name).join(', ')\n end",
"def organiz... | [
"0.7330597",
"0.7176635",
"0.7176635",
"0.67003053",
"0.66386664",
"0.66180265",
"0.6484635",
"0.6367569",
"0.6340659",
"0.63251317",
"0.6202311",
"0.6157472",
"0.6123293",
"0.6071357",
"0.6071357",
"0.60418946",
"0.6025729",
"0.6022584",
"0.6005756",
"0.5990255",
"0.5961872"... | 0.76113105 | 0 |
Update organization units cache table if records are more than one day old | def update_organization_units
oldest_update = AdOrganizationUnit.order('created_at').last
if bind && (oldest_update.nil? || oldest_update.created_at<1.day.ago)
filter = Net::LDAP::Filter.eq("objectClass", "organizationalunit")
results = @connection.search(:base =>"ou=Sync,"+base_distinguished_name, :filter => filter)
remote_organization_units = Hash.new
local_organization_units = Hash.new
# Build hash for local entries
AdOrganizationUnit.find_each do |local_entry|
local_organization_units[local_entry.distinguishedname] = local_entry.whenchanged
end
# Add new entries to local database
results.each do |remote_entry|
# Build hash for remote entries
remote_organization_units[remote_entry.distinguishedname[0]] = remote_entry.whenchanged[0]
if !local_organization_units.has_key?(remote_entry.distinguishedname[0])
new_organization_unit = AdOrganizationUnit.new
new_organization_unit.distinguishedname = remote_entry.distinguishedname[0]
new_organization_unit.whenchanged = remote_entry.whenchanged[0]
new_organization_unit.save!
end
end
# Remove old entries from local database
local_organization_units.each do |local_entry|
if !remote_organization_units.has_key?(local_entry[0])
AdOrganizationUnit.find_by_distinguishedname(local_entry[0]).destroy
end
end
else
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ensure_cache_up_to_date\n self.last_update_timestamp = self.redis.get(\"bluster:last_update_timestamp\").to_i\n if self.last_update_timestamp.nil?\n update_object_cache\n elsif self.last_update_timestamp != File.new(self.objects_path).mtime.to_i\n update_object_cache\n end\n end",
"def... | [
"0.65389925",
"0.5998826",
"0.59296227",
"0.58927786",
"0.5843088",
"0.5821534",
"0.5800259",
"0.57780844",
"0.5773702",
"0.5752574",
"0.5702364",
"0.5694461",
"0.5660184",
"0.5660184",
"0.5646122",
"0.5642932",
"0.56049985",
"0.5601751",
"0.5578578",
"0.5576554",
"0.5576554"... | 0.6226122 | 1 |
Public: Initialize a new instance of DatedBranchCreator branch_type Name of the type of branch (e.g., staging or deployable) pull_request_id The pull request id to use for the merge options hash of options post_comment whether or not to post a comment on the pullrequest | def initialize(branch_type, pull_request_id, options={})
self.branch_type = branch_type
self.pull_request_id = pull_request_id
self.options = options
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_pull_request\n self.pull_request = GitHub::PullRequest.create config.github_repo, pull_request_attributes\n end",
"def create_pull_request(token, branch, repo, body, assignee)\n payload = {:title => branch, :base => base_branch, :head => branch, :body => body}.to_json\n say \... | [
"0.62407976",
"0.59501207",
"0.57885426",
"0.5736911",
"0.56472105",
"0.5541213",
"0.55151194",
"0.54179764",
"0.5415709",
"0.5390938",
"0.5278701",
"0.5260954",
"0.5251768",
"0.5231606",
"0.5203846",
"0.52030385",
"0.5193117",
"0.51239496",
"0.50823104",
"0.5078143",
"0.5061... | 0.7657075 | 0 |
Public: Create the branch and handle related processing | def perform
git.if_clean do
check_out_branch
merge_pull_request
comment_about_merge
end
rescue => e
case e
when GitHub::PullRequest::NotFound
cli.say "Unable to find pull request #{pull_request_id}. Please retry with a valid ID."
when Git::MergeFailed
cli.say "Merge failed. Please identify the source of this merge conflict resolve this conflict in your pull request's branch. NOTE: Merge conflicts resolved in the #{branch_type} branch are NOT used when deploying."
when Git::CheckoutFailed
cli.say "Checkout of #{branch_to_merge_into} failed. Please contact Infrastructure to determine the cause."
when GitHub::PullRequest::CommentFailed
cli.say "Unable to write comment. Please navigate to #{pull_request.url} and add the comment, '#{comment_body}'"
else
cli.say "An unknown error occurred: #{e.inspect}"
end
raise
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_branch\n @tree_class.new\n end",
"def create_branch(_base_branch, _new_branch)\n puts 'TODO: Implement Git.create_branch'\n end",
"def create\r\n if @current_shop.branches_count >= @current_shop.max_branches_count\r\n flash[:error] = t('You have no authories to create more b... | [
"0.7099601",
"0.69712394",
"0.6689589",
"0.6578555",
"0.65406656",
"0.64944696",
"0.64735776",
"0.64413387",
"0.64226407",
"0.6413515",
"0.6374352",
"0.6359841",
"0.63510823",
"0.63432366",
"0.6271255",
"0.6218912",
"0.61664665",
"0.6165921",
"0.61591184",
"0.6130691",
"0.612... | 0.0 | -1 |
Public: Check out the branch | def check_out_branch
git.check_out branch_to_merge_into
rescue Git::NoBranchOfType
cli.say "No #{branch_type} branch available. Creating one now."
git.check_out DatedBranchCreator.perform(branch_type).branch_name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkout(ref, branch: true)\n raise\n end",
"def checkout_branch\n Dir.chdir(@dir) { git!('checkout', @configuration.branch) } if @configuration.branch\n end",
"def checkout(branch_name)\n local_branches = @rugged_repository.branches.each_name.to_a\n if !local_branches.include... | [
"0.7788348",
"0.76967955",
"0.7367898",
"0.7357754",
"0.7355018",
"0.73413795",
"0.7228302",
"0.72127545",
"0.71376985",
"0.7047927",
"0.7045361",
"0.69767135",
"0.6953916",
"0.6940387",
"0.6928976",
"0.6883503",
"0.6872455",
"0.6837401",
"0.6771787",
"0.6771127",
"0.6756959"... | 0.7366623 | 3 |
Public: Merge the pull request's branch into the checkedout branch | def merge_pull_request
git.merge pull_request.branch
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge_pr_totarget(upstream, pr_branch, repo)\n goto_prj_dir(repo)\n # check that we are in a git dir\n check_git_dir\n `git checkout #{upstream}`\n `git remote update`\n `git fetch`\n `git pull origin #{upstream}`\n `git checkout -b PR-#{pr_branch} origin/#{pr_branch}`\n puts `git br... | [
"0.71203786",
"0.7008041",
"0.6932472",
"0.69051576",
"0.68981373",
"0.6897138",
"0.67153704",
"0.67148423",
"0.6636399",
"0.65673876",
"0.65562963",
"0.65534484",
"0.65391034",
"0.64154947",
"0.6294101",
"0.62899154",
"0.6285311",
"0.62278134",
"0.62205446",
"0.61613804",
"0... | 0.86005884 | 0 |
Public: Comment that the pull request was merged into the branch | def comment_about_merge
pull_request.write_comment comment_body
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge_pull_request\n git.merge pull_request.branch\n end",
"def comment_body\n body = \"Merged into #{branch_to_merge_into}.\"\n if options[:user_notifications]\n body << \" /cc #{options[:user_notifications].map {|name| \"@#{name}\"}.join(' ')}\"\n end\n body\n end",
... | [
"0.7409496",
"0.63568985",
"0.6161169",
"0.61583644",
"0.6150832",
"0.6143341",
"0.6127195",
"0.60721743",
"0.60589993",
"0.60483885",
"0.59628236",
"0.5961935",
"0.5938742",
"0.592906",
"0.5871834",
"0.5865231",
"0.58555573",
"0.5844824",
"0.57922125",
"0.5788477",
"0.574324... | 0.80927455 | 0 |
Public: The content of the comment to post when merged Returns a String | def comment_body
body = "Merged into #{branch_to_merge_into}."
if options[:user_notifications]
body << " /cc #{options[:user_notifications].map {|name| "@#{name}"}.join(' ')}"
end
body
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def comments_text\n return self.comments.inject(\"\") do |string, comment| \n string + \n (string.empty? ? \"\" : \"\\n\") +\n comment.email +\n \": \" +\n comment.message\n end\n end",
"def workflow_comment_content(comment)\n comment.comment.gsub(/\\r?\\n/, '<br>').h... | [
"0.7035852",
"0.6770592",
"0.6544364",
"0.63454217",
"0.62512326",
"0.61885184",
"0.614223",
"0.6141876",
"0.61340946",
"0.60679317",
"0.6042618",
"0.6042618",
"0.60395515",
"0.60209167",
"0.60157984",
"0.5981822",
"0.59584504",
"0.5925789",
"0.58902425",
"0.58479965",
"0.582... | 0.69074804 | 1 |
Public: Find the pull request Returns a GitHub::PullRequest | def pull_request
@pull_request ||= GitHub::PullRequest.new config.github_repo, pull_request_id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_pull_request(repo_full_name, pull_request_id)\n @client.pull_request(repo_full_name, pull_request_id)\n end",
"def pull_request\n @pull_request ||= ApiFactory.new 'Repos::PullRequest'\n end",
"def get_pull_request(project_id_or_key, repository_id_or_name, pull_request_number)\n get(\... | [
"0.7682807",
"0.72812897",
"0.71012455",
"0.6961377",
"0.69427884",
"0.6885304",
"0.6835581",
"0.6813103",
"0.6801041",
"0.67362016",
"0.6704051",
"0.6514978",
"0.63600606",
"0.6350393",
"0.6336136",
"0.6326449",
"0.6315208",
"0.6272912",
"0.6262028",
"0.6237632",
"0.61724895... | 0.76471967 | 1 |
Public: Find the branch Returns a String | def branch_to_merge_into
@branch_to_merge_into ||= git.latest_branch_for(branch_type)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def branch\n Branch[comparable.segments.first(2).join('.')]\n end",
"def get_branch \n branch = case @os_svninfo['URL']\n when /trunk/ then \"trunk\"\n when /branches\\/private\\/([^\\/]+)/ then $1\n when /branches\\/([^\\/]+)/ then $1\n when /patches\\/([^\\/]+)/ then $1\n when /tags\\/... | [
"0.7701627",
"0.7414213",
"0.74123764",
"0.73223263",
"0.7201864",
"0.7189215",
"0.7159361",
"0.70476866",
"0.70452327",
"0.7043845",
"0.70029676",
"0.6950333",
"0.6944219",
"0.6918607",
"0.68718827",
"0.6861051",
"0.68578726",
"0.6855712",
"0.68493634",
"0.6831805",
"0.67604... | 0.0 | -1 |
Check with the rubygems api to see if this gem name is available. | def gem_is_available?
@thor.say("Check if #{@name} is available as a gem name.", :yellow)
uri = URI.parse("https://rubygems.org/api/v1/gems/#{@name}.json")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
return response.code == '404'
rescue SocketError => e
# rubygems is down, skip check
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gem_available?(name)\n Gem::Specification.find_by_name(name)\nrescue Gem::LoadError\n false\nend",
"def gem_exists? gem_name\n @swift.object_info @gems_container, gem_name\n end",
"def have_gem? name\n Gem::Specification.find_by_name name.to_s\n rescue Gem::LoadError\n false\n end",
"def ... | [
"0.7941232",
"0.79386425",
"0.78808427",
"0.78281",
"0.7597584",
"0.7515734",
"0.7476582",
"0.7438265",
"0.73793375",
"0.7360166",
"0.7358794",
"0.7334754",
"0.7325193",
"0.7290394",
"0.7261353",
"0.72375816",
"0.7133084",
"0.7105013",
"0.70745856",
"0.69979054",
"0.69392866"... | 0.8387787 | 0 |
setup the default drawing context, and perform your drawing in the block you pass to this function | def defaults(context)
CGContextSaveGState(context)
stroke.setStroke
fill.setFill
if fill_phase
CGContextSetPatternPhase(context, fill_phase)
end
CGContextSetLineWidth(context, self.line_width)
if line_dash
CGContextSetLineDash(context, 0, line_dash.to_pointer(:float), line_dash.length)
end
yield
CGContextRestoreGState(context)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw(&block)\n block.call(self)\n end",
"def draw(&block)\n instance_eval(&block)\n end",
"def draw\n get_blocks.each { |block| block.draw }\n end",
"def draw\n\t\t# Complete the missing code\n\t\tdraw_background()\n\tend",
"def draw(&block)\n instance_exec &block\n en... | [
"0.7504082",
"0.74851537",
"0.73238885",
"0.729637",
"0.7232591",
"0.71189755",
"0.71189755",
"0.71189755",
"0.70904565",
"0.70854586",
"0.70854586",
"0.70468754",
"0.6985719",
"0.69695747",
"0.69695747",
"0.69695747",
"0.69695747",
"0.69552463",
"0.68992645",
"0.688693",
"0.... | 0.0 | -1 |
convert the current line to a rect | def rect()
Rect.new(p1, p2)
.stroke(stroke)
.fill(fill)
.fill_phase(fill_phase)
.line_width(line_width)
.line_dash(line_dash)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rect=(rectangle); end",
"def rect_to_lines(rect)\n x = rect[:x]\n y = rect[:y]\n x2 = rect[:x] + rect[:w]\n y2 = rect[:y] + rect[:h]\n [{ x: x, y: y, x2: x2, y2: y },\n { x: x, y: y, x2: x, y2: y2 },\n { x: x2, y: y, x2: x2, y2: y2 },\n { x: x, y: y2, x2: x2, y2: y2 }]\n end",
"... | [
"0.64261436",
"0.6387364",
"0.63859695",
"0.635032",
"0.62375915",
"0.62375915",
"0.6219545",
"0.613082",
"0.6117877",
"0.60674816",
"0.60300297",
"0.6009661",
"0.6001778",
"0.5998152",
"0.59886545",
"0.5928466",
"0.58829683",
"0.5880495",
"0.5825702",
"0.581181",
"0.5788006"... | 0.6715803 | 1 |
UIRectCorner indicating which corners | def initialize(*rect_args)
if CGRect === rect_args[0]
@rect = rect_args[0]
else
@rect = SugarCube::CoreGraphics::Rect(*rect_args)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def corners\n [lower_left, lower_right, upper_right, upper_left]\n end",
"def corner(corner_index)\n end",
"def corner\n corners = [ [0, 0], [0, 2], [2, 0], [2, 2] ]\n opponent_corner = corners.select { |l| @board.square(*l) == @opponent_mark }.first\n opposite = if opponent_corner\... | [
"0.7324402",
"0.69253755",
"0.6824708",
"0.6799137",
"0.6780252",
"0.6506764",
"0.6357849",
"0.6342248",
"0.62698215",
"0.62506044",
"0.60798097",
"0.607697",
"0.605454",
"0.603872",
"0.6009361",
"0.59579533",
"0.5948596",
"0.5948596",
"0.59128255",
"0.58723575",
"0.5840286",... | 0.0 | -1 |
if true, gradient options are KCGGradientDrawsBeforeStartLocation | KCGGradientDrawsAfterEndLocation | def initialize(p1, p2, colors, points=nil)
super(p1, p2)
if colors.is_a?(Hash)
self.points(colors.keys)
self.colors(colors.values)
else
self.colors(colors)
self.points(points)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gradient(gradient=Gradient.new, start_x=@width/2, start_y=0, end_x=@width/2, end_y=@height)\n #options = KCGGradientDrawsBeforeStartLocation\n #options = KCGGradientDrawsAfterEndLocation\n CGContextDrawLinearGradient(@ctx, gradient.gradient, NSMakePoint(start_x, start_y), NSMakePoint(end_x, end_... | [
"0.64185476",
"0.63436925",
"0.61179215",
"0.5217953",
"0.517254",
"0.49299076",
"0.4890891",
"0.4843747",
"0.4813941",
"0.47849268",
"0.4755723",
"0.47453374",
"0.4696313",
"0.46888286",
"0.46223542",
"0.45965102",
"0.45938864",
"0.4575094",
"0.44811583",
"0.44593403",
"0.44... | 0.0 | -1 |
if true, gradient options are KCGGradientDrawsBeforeStartLocation | KCGGradientDrawsAfterEndLocation | def initialize(center, radius, colors, points=nil)
self.center(center)
self.radius(radius)
if colors.is_a?(Hash)
self.points(colors.keys)
self.colors(colors.values)
else
self.colors(colors)
self.points(points)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gradient(gradient=Gradient.new, start_x=@width/2, start_y=0, end_x=@width/2, end_y=@height)\n #options = KCGGradientDrawsBeforeStartLocation\n #options = KCGGradientDrawsAfterEndLocation\n CGContextDrawLinearGradient(@ctx, gradient.gradient, NSMakePoint(start_x, start_y), NSMakePoint(end_x, end_... | [
"0.64159656",
"0.63429224",
"0.6118336",
"0.52152914",
"0.51710963",
"0.4926967",
"0.48913452",
"0.48437726",
"0.48129353",
"0.47849578",
"0.47542644",
"0.4742726",
"0.46972227",
"0.4689728",
"0.46206215",
"0.45957172",
"0.45917466",
"0.4573221",
"0.4480118",
"0.44585806",
"0... | 0.0 | -1 |
Make sure we raise things appropriately | def test_verify
# Start out unavailabl
assert_raise(Puppet::Network::InvalidClientRequest) do
@obj.verify(@request)
end
class << @obj
def available?(req)
true
end
end
assert_raise(Puppet::Network::InvalidClientRequest) do
@obj.verify(@request)
end
class << @obj
def authorized?(req)
true
end
end
assert_nothing_raised do
@obj.verify(@request)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exceptions; end",
"def catch_exceptions; end",
"def raise(exception); end",
"def continued_exception; end",
"def raise_exc\n raise\n rescue\n end",
"def exception; end",
"def exception; end",
"def exception; end",
"def exception; end",
"def exception; end",
"def cause... | [
"0.7401367",
"0.735623",
"0.7354002",
"0.717598",
"0.7169763",
"0.7125802",
"0.7125802",
"0.7125802",
"0.7125802",
"0.7125802",
"0.7123662",
"0.7123662",
"0.6985572",
"0.6979025",
"0.6954653",
"0.6943629",
"0.6926848",
"0.6926848",
"0.6857644",
"0.6857644",
"0.6857644",
"0.... | 0.0 | -1 |
Receive new message to the delivery service defined by params | def receive(params = {})
# Subject
subject = params[:subject]
# Message
message = params[:message]
# Sender
sender = params[:sender]
# Receiver
receiver = params[:receiver]
return false if receiver.nil?
# Create and setup InMessage
in_message = RicMailboxer.in_message_model.create(
subject: subject,
message: message,
sender: sender,
owner: receiver,
folder: :inbox,
delivery_state: :received,
)
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def receive_message(params={}, *attrs)\n self.class.receive_message(queue_url, params, *attrs).map do |val|\n Message.new self, val\n end\n end",
"def receive(delivery_info, properties, body)\n @handler.call(JSON.parse(body))\n @channel.ack(delivery_info.delivery_tag)\n rescue => e\n ... | [
"0.6547573",
"0.65306216",
"0.6402513",
"0.6383579",
"0.6298124",
"0.61787665",
"0.6162961",
"0.61535794",
"0.61493987",
"0.61157256",
"0.6115685",
"0.6092038",
"0.6090529",
"0.6077418",
"0.6008764",
"0.59970593",
"0.5983646",
"0.5966498",
"0.59331363",
"0.5882112",
"0.587888... | 0.5594937 | 62 |
input: string of items separated by spaces (example: "carrots apples cereal pizza") steps: define create_list(string) split list into an array of items iterate through array and put it into hash, assign values to 1 print the list to the console [can you use one of your other methods here?] output: hash | def create_list(string)
array = string.split(' ')
list = { }
array.each do |item|
list[item] = 1
end
list
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createlist(str)\r\n# steps:\r\n# break the string into an array\r\n items = str.split\r\n item_list = {}\r\n\r\n\t# iterate through array and build hash\r\n items.each do |item|\r\n\r\n\t\t# iterate through array and build hash\r\n\t\t# set default quantity to 1\r\n \titem_list[item] = 1\r\n e... | [
"0.8586517",
"0.8340953",
"0.82712543",
"0.81884545",
"0.8114492",
"0.8033401",
"0.797076",
"0.797076",
"0.7942948",
"0.7926702",
"0.79048896",
"0.79012936",
"0.7898416",
"0.7891479",
"0.7868052",
"0.78645754",
"0.78387386",
"0.78288513",
"0.78225213",
"0.7819928",
"0.7794739... | 0.0 | -1 |
Method to add an item to a list input: list, item name, and optional quantity steps: define add_item(item_name, quantity) add key and value to hash 'list' output: hash | def add_item(list, item_name, quantity)
list[item_name] = quantity
list
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_item(list_name, item, quantity=1)\r\n# input: list, item name, and optional quantity\r\n# steps: add item and its quantity to the hash\r\n list_name.store(item, quantity)\r\n# output: hash with new item\r\n p list_name\r\nend",
"def add_item(list, add_item, add_quantity=1)\n# steps:\n # Add item as ke... | [
"0.8774311",
"0.8700462",
"0.852629",
"0.8448631",
"0.84482163",
"0.84482163",
"0.8448165",
"0.84311384",
"0.8388082",
"0.8360261",
"0.83568925",
"0.83361095",
"0.8306409",
"0.83049697",
"0.830283",
"0.8271767",
"0.8205941",
"0.8202322",
"0.8194969",
"0.81915116",
"0.8184593"... | 0.8591758 | 3 |
Method to remove an item from the list input: list, item_name steps: define remove_item(list, item_name) delete the key value of item_name output: hash | def remove_item(list, item_name)
list.delete(item_name)
list
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_item(list_name, item)\r\n# input: list, item name\r\n# steps: delete item name and value from hash\r\n list_name.delete(item)\r\n# output: updated hash with item removed\r\np list_name\r\nend",
"def remove_item(input_hash, item)\n# input: list, item name, and optional quantity\n# steps: use input ite... | [
"0.8774765",
"0.86184764",
"0.85759187",
"0.8492378",
"0.8473827",
"0.845146",
"0.84225744",
"0.83310723",
"0.83160704",
"0.8312228",
"0.8308413",
"0.828502",
"0.82580006",
"0.8244072",
"0.82082045",
"0.8201826",
"0.81898415",
"0.81670845",
"0.81590784",
"0.8155449",
"0.81379... | 0.83436316 | 9 |
Method to update the quantity of an item input: list, item name, and quantity steps: define update_quantity(list, item_name, quantity) update the value of item_name to the new quanity output: hash | def update_quantity(list, item_name, quantity)
list[item_name] = quantity
list
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_quanity(list, item_name, new_quantity)\n\n\tlist[item_name] = new_quantity\n\tp list\nend",
"def update_quanity(list, item, quantity)\r\n# input: list, item and quantity to be updated to\r\n# steps:\r\n # check if item exists\r\n # update quantity\r\n list[item] = quantity\r\n # print success \"yo... | [
"0.8635572",
"0.85293365",
"0.8422499",
"0.8405606",
"0.82839024",
"0.8278949",
"0.8264602",
"0.8225741",
"0.81919974",
"0.81902444",
"0.81892943",
"0.81892943",
"0.81650263",
"0.81400657",
"0.8076001",
"0.8056546",
"0.80394274",
"0.8027726",
"0.80275273",
"0.800382",
"0.7982... | 0.8532969 | 2 |
Method to print a list and make it look pretty input: list steps: define print_list(list) iterate through list puts key and value into string output output: list | def print_list(list)
puts "\nHere is the list:"
list.each do |item, quantity|
puts "#{item}: #{quantity}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_pretty(list)\n list.each { |item, value| puts \"#{item} #{value}\" }\nend",
"def pretty_list(list_name)\r\n list_name.each do |key, value|\r\n p \"#{key}: #{value}\"\r\n end\r\nend",
"def pretty_list(list)\n puts \"Grocery List:\"\n list.each do |key, value|\n puts \"#{value} #{key}(s)\"\n ... | [
"0.82344425",
"0.8057528",
"0.8056091",
"0.80042636",
"0.7896582",
"0.7872719",
"0.7839563",
"0.77518255",
"0.76929384",
"0.76771253",
"0.76771253",
"0.76749086",
"0.76615065",
"0.7637066",
"0.75993085",
"0.754795",
"0.7546746",
"0.7540785",
"0.7525203",
"0.7462272",
"0.74203... | 0.7014372 | 60 |
these definitions are to make rspec work | def id
sale_id.to_i
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def spec; end",
"def spec; end",
"def standard_specs; end",
"def tests; end",
"def tests; end",
"def testing\n # ...\n end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def s... | [
"0.8142037",
"0.8142037",
"0.6835683",
"0.66566694",
"0.66566694",
"0.66501504",
"0.65521485",
"0.65521485",
"0.65521485",
"0.65521485",
"0.65521485",
"0.65521485",
"0.65521485",
"0.65521485",
"0.65521485",
"0.65521485",
"0.65521485",
"0.65521485",
"0.65521485",
"0.65521485",
... | 0.0 | -1 |
1. check the length of the digits that are put in. 2. i need to make a loop that iterates for as long as the narcissistic number is 3. i do this by creating a loop with a range 0..i 4. this will make the loop as long as the amount of digits put in. 5. then with every iteration we do the following 6. first num = num x i 7. second num = num x i...and so on. 8 we then have a comparison operator 9 return true or false. =begin Is It A Prime? Create a method that takes a number as an argument and returns "This is a prime number", if its a prime number, otherwise it returns "This is not a prime number". Note, negative numbers can not be considered prime. 0 and 1 are also not prime! E.g. is_it_prime(7), should return "This is a prime number" E.g. is_it_prime(100), should return "This is not a prime number =end | def is_it_prime(num)
if num == 100
return "This is not a prime number"
elsif num <= 2 || num % num == 1
return "This is not a prime number"
else
return "This is a prime number"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_prime (number)\n if [1,2,3,5,7,11].include?(number)\n return TRUE\n end\n if number % 2 == 0 and number != 2\n # p \"not prime, divisible by 2\"\n return FALSE\n elsif number % 3 == 0 and number != 3\n # p \"not prime, divisible by 3\"\n return FALSE\n elsif number % 5 == 0 and number !=... | [
"0.79105467",
"0.7857874",
"0.7848781",
"0.78218585",
"0.78054583",
"0.7793555",
"0.776924",
"0.77635276",
"0.7740456",
"0.77403235",
"0.7704398",
"0.770089",
"0.7695653",
"0.76886857",
"0.7686917",
"0.7677002",
"0.76702034",
"0.76592165",
"0.76558125",
"0.76450765",
"0.76384... | 0.0 | -1 |
:type class name :id id | def expire_object(args)
clazz = args[:type].constantize
case args[:type]
when 'Image' : expire_image args[:id]
when 'NameAlias' : return
else
LOGGER.info "expire object #{clazz} #{args[:id]}"
controller = clazz.base_class.name.demodulize.underscore
path = "#{controller}/#{args[:id]}"
if controller =~ ENCYCLOPEDIA_CONTROLLERS
path = "encyclopedia/#{path}"
end
delete path
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def id; end",
"def id; end",
"def id; end",
"def id; end",
"def id; end",
"def id; end",
"def id; end",
"def id; end",
"def id; end",
"def id; end",
"def id; end",
"def id; end",
"def id; 1; end",
"def id() end",
"def initialize (id)\n @id = id\n end",
"def initiali... | [
"0.7333777",
"0.7333777",
"0.7333777",
"0.7333777",
"0.7333777",
"0.7333777",
"0.7333777",
"0.7333777",
"0.7333777",
"0.7333777",
"0.7333777",
"0.7333777",
"0.70892733",
"0.7013448",
"0.6920059",
"0.68914896",
"0.6888086",
"0.68819255",
"0.68213665",
"0.6794935",
"0.6794935",... | 0.0 | -1 |
type in name of player and finds or creates a new one | def find_or_create_by
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_player\n name=gets.chomp\n @name=name\n end",
"def create_new_player\n hero_name = TTY::Prompt.new.ask('What is your Superhero\\'s name?', default: 'Anonymous')\n Superhero.find_or_create_by(name: hero_name)\n end",
"def create_player\n name = gets.chomp\n player = Player.new(name: n... | [
"0.7662661",
"0.759356",
"0.75322306",
"0.75315326",
"0.74795276",
"0.73275834",
"0.72389424",
"0.72031283",
"0.7125756",
"0.71112794",
"0.7002564",
"0.69855124",
"0.69855124",
"0.69638234",
"0.69232184",
"0.69060326",
"0.68720573",
"0.68707",
"0.68539906",
"0.6847169",
"0.68... | 0.0 | -1 |
increments player point (post request) | def add_point(player)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def increment_player_stat\n @team.increment_player_stat(@stat_type, @player)\n\n redirect_to team_path(@team)\n end",
"def give_point\n if@current_player == @player1\n @p1_score += 1\n else\n @p2_score += 1\n end\nend",
"def record_won_ball!\n @points +=1\n end",
"def record_won_bal... | [
"0.67484164",
"0.6698794",
"0.66631514",
"0.6659237",
"0.6659237",
"0.6659237",
"0.6659237",
"0.6659237",
"0.6659237",
"0.6659237",
"0.6659237",
"0.646454",
"0.6402003",
"0.63857037",
"0.63312423",
"0.63308895",
"0.632889",
"0.6320831",
"0.63117486",
"0.629825",
"0.62619627",... | 0.6515004 | 11 |
when double clicked, turns into field to edit | def add_multiple_points(player)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; end",
"def edit; e... | [
"0.6713958",
"0.6713958",
"0.6713958",
"0.6713958",
"0.6713958",
"0.6713958",
"0.6713958",
"0.6713958",
"0.6713958",
"0.6713958",
"0.6713958",
"0.6713958",
"0.6713958",
"0.6713958",
"0.6713958",
"0.6713958",
"0.6713958",
"0.6713958",
"0.6713958",
"0.6713958",
"0.6713958",
"... | 0.0 | -1 |
Side effect: it returns the body | def set_cache(email, type, body)
@members[type] ||= {}
@members[type][email] = body
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def body; end",
"def body; end",
"def body; end",
"def body; end",
"def body; end",
"def body; end",
"def body; end",
"def body; end",
"def body; end",
"def body; end",
"def body; end",
"def body; end",
"def body; end",
"def body; end",
"def body; end",
"def body; end",
"def body()\... | [
"0.8257663",
"0.8257663",
"0.8257663",
"0.8257663",
"0.8257663",
"0.8257663",
"0.8257663",
"0.8257663",
"0.8257663",
"0.8257663",
"0.8257663",
"0.8257663",
"0.8257663",
"0.8257663",
"0.8257663",
"0.8257663",
"0.80816543",
"0.8049177",
"0.7921012",
"0.77249455",
"0.77249455",
... | 0.0 | -1 |
Namespace number of the title to process. | def namespace(value)
merge(namespace: value.to_s)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def title\n content_from 'ns:title', :ns => self.registered_ns\n end",
"def namespace_id\n\t\t\t@data[\"namespace\"][\"id\"]\n\t\tend",
"def title\n @title ||= self.class.non_namespaced_classname\n end",
"def namespace\n return self.name ? self.name.downcase.gsub(/[^0-9A-Za-z ]/, '').gsu... | [
"0.6552479",
"0.6345024",
"0.6097244",
"0.60953987",
"0.59459877",
"0.5924268",
"0.59033054",
"0.5895847",
"0.5864385",
"0.5797122",
"0.57704514",
"0.5766478",
"0.57368547",
"0.5719667",
"0.57073736",
"0.57063454",
"0.56859016",
"0.56839156",
"0.5677884",
"0.5669386",
"0.5668... | 0.0 | -1 |
Title to process without namespace prefix. | def title(value)
merge(title: value.to_s)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def full_title\n \"#{namespace}:#{title}\"\n end",
"def title\n @title ||= self.class.non_namespaced_classname\n end",
"def title\n content_from 'ns:title', :ns => self.registered_ns\n end",
"def set_proc_title(title)\n $0 = title\n end",
"def process_name\n\n\t\t::Pantheios::Core.p... | [
"0.7177819",
"0.7131366",
"0.7009197",
"0.6828252",
"0.67070055",
"0.6662788",
"0.6635699",
"0.6635699",
"0.66295415",
"0.66295415",
"0.66295415",
"0.6619277",
"0.66007614",
"0.65762657",
"0.6528285",
"0.6527893",
"0.65239954",
"0.6505406",
"0.6485819",
"0.64676964",
"0.64589... | 0.0 | -1 |
For command=reload, use this content instead. | def content(value)
merge(content: value.to_s)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reload\n end",
"def reload\n end",
"def reload\n end",
"def reload\n end",
"def reload\n end",
"def reload\n end",
"def reload\n end",
"def reload\n end",
"def reload\n end",
"def reload\n end",
"def reload!\n end",
"def reload!; end",
"def reload!; end"... | [
"0.74659634",
"0.74659634",
"0.74659634",
"0.74659634",
"0.74659634",
"0.74659634",
"0.74659634",
"0.74393815",
"0.7382791",
"0.7382791",
"0.73368615",
"0.7273408",
"0.7273408",
"0.7273408",
"0.7273408",
"0.71877396",
"0.71826667",
"0.71385115",
"0.71339977",
"0.7073057",
"0.... | 0.0 | -1 |
Alter the information recieved from the resource | def initialize(input_file)
super(input_file)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_resource(resource_desc, resource_type, authorizer, new_attributes)\n debug \"update_resource: resource_descr: #{resource_desc}, type: #{resource_type}, new_attrs: #{new_attributes}\"\n raise 'Method not implemented because the Central Manager just need to pass the same requisition to the other... | [
"0.6307757",
"0.62869555",
"0.6195519",
"0.6167539",
"0.61345136",
"0.6111855",
"0.6056066",
"0.6054448",
"0.6053238",
"0.6045139",
"0.60409343",
"0.59937507",
"0.5987219",
"0.5898723",
"0.5870196",
"0.58583015",
"0.58583015",
"0.58489186",
"0.58280945",
"0.58280945",
"0.5828... | 0.0 | -1 |
validate that the given publisher alpha id exists used in conjunction with plugin settings page, where client ID is set | def checkPublisherID
begin
publisher = Publisher.find_by(alpha_id: params[:publisher_alpha_id], verified: true) # grab publisher from clientID
logger.info "publisher url: #{params['publisher_url']}"
publisher_url = params['publisher_url']
publisher_domain = URI(publisher_url).host
@valid = (publisher.present? and publisher.is_valid_domain(publisher_domain))
logger.info {"Request has valid client id: #{@valid}"}
respond_to do |format|
format.js do
render json: @valid, callback: params[:callback]
end
end
rescue => e
respond_to do |format|
format.js do
render json: false, callback: params[:callback]
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_client_id\n return if service_provider\n errors.add(\n :client_id, t('openid_connect.authorization.errors.bad_client_id'),\n type: :bad_client_id\n )\n end",
"def validates_hosting_provider_id( record, attr, value )\n\t\tunless VideoContentHostingProvider.exists?( value )\n\t\t\t... | [
"0.61100537",
"0.5675433",
"0.5486031",
"0.545148",
"0.5445086",
"0.5383651",
"0.5382042",
"0.53204054",
"0.5279149",
"0.5242503",
"0.5235117",
"0.52338165",
"0.5226792",
"0.5206909",
"0.51909196",
"0.51903045",
"0.51898336",
"0.51821",
"0.518202",
"0.5179139",
"0.51777375",
... | 0.6940588 | 0 |
Returns by default activity of created product keys only to speed up the query Pass optional activity as parameters. Asking for activity of all the products takes a long process time | def activity(params={})
version_id = params.delete(:version_id) { LimeLm.config[:version_id] }
start = params.delete(:start) { (Date.today - 7).strftime('%Y-%m-%d') }
response = LimeLm::Connection.post_json({ method: 'limelm.pkey.activity', version_id: version_id, start: start, created: true}.merge!(params))
response['pkeys']['pkey']
rescue LimeLm::ApiError => e
e.message.include?('109') ? [] : raise(e)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_all_activities\n\n a2 = Activity.where(theme_id: $acme.id, uni_module_id: UniModule.where(code: \"CIV1901\").first.id, code: \"100a\").first_or_create!(name: \"Engineering Applications Workshop 1\",\n name_abrv: \"EAWORK1\", archived: false, in_drive: false, user_id: 5)\n at2 = ActivityTimeta... | [
"0.5639996",
"0.5637454",
"0.5623708",
"0.5582665",
"0.55056375",
"0.547468",
"0.5463678",
"0.53926104",
"0.53806746",
"0.53770006",
"0.5280139",
"0.52752346",
"0.526773",
"0.526773",
"0.5215486",
"0.5215486",
"0.52128506",
"0.5209544",
"0.51778746",
"0.5173977",
"0.5166004",... | 0.5409125 | 7 |
This is kind of a hack for testing | def content_tag_with_block(name, content_or_options_with_block=nil,options={})
if block_given?
options = content_or_options_with_block if content_or_options_with_block.is_a?(Hash)
content_tag_without_block(name, yield, options)
else
content_tag_without_block(name, content_or_options_with_block, options)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def spec; end",
"def spec; end",
"def probers; end",
"def __dummy_test__\n end",
"def internship_passed; end",
"def self_test; end",
"def self_test; end",
"def schubert; end",
"def weber; en... | [
"0.7261533",
"0.6682948",
"0.6682948",
"0.6682948",
"0.6682948",
"0.6470598",
"0.6470598",
"0.6202851",
"0.6075903",
"0.60245144",
"0.59755826",
"0.59755826",
"0.5905395",
"0.5871092",
"0.58501774",
"0.5837387",
"0.5837059",
"0.58097774",
"0.57910997",
"0.57891417",
"0.578914... | 0.0 | -1 |
GET /slides or /slides.json | def index
@slides = Slide.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @slideshow = Slideshow.find(params[:id])\n @slides = @slideshow.slides\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @slideshow }\n end\n end",
"def index\n @title = t('view.slides.index_title')\n @slides = @lesson.slides.page(params... | [
"0.7376037",
"0.7171162",
"0.71015084",
"0.71015084",
"0.71015084",
"0.70790684",
"0.70103985",
"0.70103985",
"0.6991744",
"0.68824214",
"0.6674912",
"0.6669872",
"0.65495557",
"0.65419656",
"0.650752",
"0.64139766",
"0.6309203",
"0.62592286",
"0.6236482",
"0.6232018",
"0.622... | 0.6952991 | 9 |
GET /slides/1 or /slides/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @slideshow = Slideshow.find(params[:id])\n @slides = @slideshow.slides\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @slideshow }\n end\n end",
"def index\n @title = t('view.slides.index_title')\n @slides = @lesson.slides.page(params... | [
"0.7305818",
"0.7116313",
"0.70536166",
"0.70536166",
"0.70536166",
"0.70504314",
"0.7037086",
"0.69990486",
"0.69990486",
"0.6878444",
"0.6744597",
"0.6640896",
"0.66383076",
"0.66097444",
"0.6606464",
"0.64308923",
"0.6289725",
"0.6286855",
"0.6201717",
"0.6201585",
"0.6201... | 0.0 | -1 |
POST /slides or /slides.json | def create
@slide = Slide.new(slide_params)
respond_to do |format|
if @slide.save
format.html { redirect_to @slide, notice: "Slide was successfully created." }
format.json { render :show, status: :created, location: @slide }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @slide.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @slide = Slide.new(params[:slide])\n\n respond_to do |format|\n if @slide.save\n format.html { redirect_to @slide, notice: 'Slide was successfully created.' }\n format.json { render json: @slide, status: :created, location: @slide }\n else\n format.html { render ac... | [
"0.69801176",
"0.68761367",
"0.68356097",
"0.68100804",
"0.66896516",
"0.6689237",
"0.6660945",
"0.66371596",
"0.66371596",
"0.66371596",
"0.660417",
"0.6513069",
"0.6513069",
"0.6495104",
"0.6481375",
"0.6433279",
"0.6421695",
"0.63826436",
"0.63826436",
"0.63826436",
"0.637... | 0.68487966 | 2 |
PATCH/PUT /slides/1 or /slides/1.json | def update
respond_to do |format|
if @slide.update(slide_params)
format.html { redirect_to @slide, notice: "Slide was successfully updated." }
format.json { render :show, status: :ok, location: @slide }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @slide.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @slide = Slide.find(params[:id])\n\n respond_to do |format|\n if @slide.update_attributes(params[:slide])\n format.html { redirect_to \"/slides\", notice: 'slide was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \... | [
"0.72096574",
"0.7039427",
"0.7024086",
"0.6905243",
"0.68861073",
"0.6799836",
"0.6768131",
"0.6764181",
"0.67379004",
"0.6720214",
"0.6546411",
"0.65259737",
"0.64723593",
"0.64494276",
"0.6422007",
"0.6422007",
"0.6268464",
"0.6268464",
"0.6262271",
"0.612747",
"0.60912627... | 0.66743237 | 10 |
DELETE /slides/1 or /slides/1.json | def destroy
@slide.destroy
respond_to do |format|
format.html { redirect_to slides_url, notice: "Slide was successfully destroyed." }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @slide = Slide.find(params[:id])\n @slide.destroy\n\n respond_to do |format|\n format.html { redirect_to slides_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @slide = Slide.find(params[:id])\n @slide.destroy\n\n respond_to do |format|\n f... | [
"0.7645482",
"0.7645482",
"0.7645482",
"0.7566208",
"0.7522184",
"0.7442856",
"0.742268",
"0.7393703",
"0.7393703",
"0.73229843",
"0.7292946",
"0.7218294",
"0.7183352",
"0.71731156",
"0.7103596",
"0.70957434",
"0.706696",
"0.706696",
"0.70560044",
"0.70560044",
"0.700467",
... | 0.7232589 | 11 |
Use callbacks to share common setup or constraints between actions. | def set_slide
@slide = Slide.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a list of trusted parameters through. | def slide_params
params.require(:slide).permit(:score, :user_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\... | [
"0.69497335",
"0.6812623",
"0.6803639",
"0.6795365",
"0.67448795",
"0.67399913",
"0.6526815",
"0.6518771",
"0.64931697",
"0.6430388",
"0.6430388",
"0.6430388",
"0.63983387",
"0.6356042",
"0.63535863",
"0.63464934",
"0.63444513",
"0.6337208",
"0.6326454",
"0.6326454",
"0.63264... | 0.0 | -1 |
Custom method to register to attend a training session | def attend
user_id = current_user.id
training_id = params[:id]
TrainingRecord.create_new_record user_id, training_id
redirect_to @training, notice: "You have successfully registered for #{@training.title}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configure_training_session\n available_ledgers :training_session\n set_training_session\n end",
"def set_training_session\n @training_session = TrainingSession.find(params[:training_session_id])\n end",
"def configure_training_request\n available_ledgers :training_request\n set_training_re... | [
"0.6975504",
"0.61576676",
"0.58912003",
"0.58839667",
"0.58700556",
"0.5689034",
"0.5632438",
"0.5586304",
"0.55642205",
"0.5550762",
"0.5498005",
"0.5471122",
"0.5458902",
"0.5431291",
"0.53916645",
"0.5379414",
"0.5366877",
"0.53623873",
"0.5350027",
"0.5345255",
"0.533936... | 0.6038994 | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.