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 |
|---|---|---|---|---|---|---|
hour: 30/hr min: 6/min | def clock_angle(hour, minutes)
h = (hour % 12) * 30 + (minutes.to_f / 60) * 30
minute = minutes * 6
[(h - minute).abs, 360 - (h - minute).abs].min
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hour() end",
"def hours() 60 * minutes end",
"def rational_hour(seconds); end",
"def get_hour\n self.hr.strftime(\"%H\").to_i + self.hr.strftime(\"%M\").to_d/60\n end",
"def time_hour; Time.now.hour; end",
"def format_time_from_hour hour\n hrs = hour.to_i\n min = ((hour - hrs) * 60.0 + 0.5)... | [
"0.75423753",
"0.7453264",
"0.7431016",
"0.7131477",
"0.69997126",
"0.69784516",
"0.69754326",
"0.69168025",
"0.68943095",
"0.6868455",
"0.68495584",
"0.6845292",
"0.6817291",
"0.6796445",
"0.6794814",
"0.67586344",
"0.67505646",
"0.6736605",
"0.6700932",
"0.66988474",
"0.668... | 0.0 | -1 |
Returns the value for the given name stored in the S3Object's metadata: bucket.objects['myobject'].metadata['purpose'] returns nil if the given metadata key has not been set | def [] name
to_h[name.to_s]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aws_S3_object_get_and_read(bucket, name)\n log \"AWS: getting S3Object 'name'\"\n object = aws_call('aws_S3_object_get', bucket: bucket, name: name)\n if aws_call('aws_obj_exists?', obj: object)\n log \"AWS: reading S3Object '#{object.key}'\"\n return aws_call('aws_S3_object_read', object: o... | [
"0.66533184",
"0.62448925",
"0.6151701",
"0.6122699",
"0.61079687",
"0.6071108",
"0.5996848",
"0.5821205",
"0.5781572",
"0.5750607",
"0.5730542",
"0.5709119",
"0.5682097",
"0.5656706",
"0.56445724",
"0.56240183",
"0.56022084",
"0.55683345",
"0.55645674",
"0.553961",
"0.553893... | 0.0 | -1 |
Changes the value of the given name stored in the S3Object's metadata: object = bucket.object['myobject'] object.metadata['purpose'] = 'research' object.metadata['purpose'] => 'research' | def []= name, value
raise "cannot change the metadata of an object version; "+
"use S3Object#write to create a new version with different metadata" if
@version_id
metadata = to_h.dup
metadata[name.to_s] = value
object.copy_from(object.key,
:metadata => metadata)
value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_metadata\n s3_obj.metadata[\"filename\"] = file_name\n s3_obj.metadata[\"bindery-pid\"] = persistent_id\n end",
"def object_uploaded_with_metadata?(\r\n s3_client,\r\n bucket_name,\r\n object_key,\r\n metadata\r\n)\r\n response = s3_client.put_object(\r\n bucket: bucket_name,\r\n body: ... | [
"0.72068065",
"0.6297951",
"0.6294349",
"0.62638694",
"0.61404026",
"0.61331016",
"0.59943455",
"0.5990066",
"0.5969343",
"0.59573895",
"0.5951588",
"0.59445983",
"0.59445983",
"0.59445983",
"0.59445983",
"0.59445983",
"0.59445983",
"0.59445983",
"0.59445983",
"0.59445983",
"... | 0.73467493 | 0 |
the active_scaffold_export template path | def template_search_path_with_export(frontend = self.frontend)
frontends_path = "../../vendor/plugins/#{ActiveScaffold::Config::Core.export_plugin_directory}/frontends"
search_path = template_search_path_without_export
search_path << "#{frontends_path}/#{frontend}/views" if frontend.to_sym != :default
search_path << "#{frontends_path}/default/views"
return search_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def template_path() 'demo/admin/billing.erb' end",
"def scaffold_path(template_name)\n File.join(scaffold_template_dir, template_name+'.rhtml')\n end",
"def scaffold_path(template_name)\n self.class.scaffold_path(template_name)\n end",
"def pathTemplates\n \"./templates/\"\nend",
"def ... | [
"0.74903905",
"0.734632",
"0.72725904",
"0.7223041",
"0.7079919",
"0.7075234",
"0.6995853",
"0.69882",
"0.6979815",
"0.6909299",
"0.6866169",
"0.6863346",
"0.6862625",
"0.6862625",
"0.6861741",
"0.6815541",
"0.68019444",
"0.67756975",
"0.6763028",
"0.6740524",
"0.6726306",
... | 0.71023506 | 4 |
GET /testreplyposts GET /testreplyposts.json | def index
@testreplyposts = Testreplypost.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @replies = Reply.all\n\n render json: @replies\n end",
"def index\n @replies = Reply.all\n\n render json: @replies\n end",
"def index\n @post_replies = PostReply.all\n end",
"def index\n @replies = Reply.all\n\n respond_to do |format|\n format.html # index.html.erb\n ... | [
"0.6933231",
"0.6933231",
"0.6866066",
"0.6685794",
"0.64412427",
"0.6249165",
"0.6249165",
"0.6249165",
"0.6249165",
"0.6245159",
"0.62433976",
"0.6109161",
"0.61003816",
"0.6083092",
"0.6075278",
"0.6071272",
"0.6064191",
"0.6064191",
"0.6043861",
"0.6036293",
"0.6035207",
... | 0.72688186 | 0 |
GET /testreplyposts/1 GET /testreplyposts/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @testreplyposts = Testreplypost.all\n end",
"def index\n @replies = Reply.all\n\n render json: @replies\n end",
"def index\n @replies = Reply.all\n\n render json: @replies\n end",
"def index\n @post_replies = PostReply.all\n end",
"def index\n @replies = Reply.all\n\n ... | [
"0.7142281",
"0.7047063",
"0.7047063",
"0.7031367",
"0.6898149",
"0.67412645",
"0.6633324",
"0.65961087",
"0.65614223",
"0.65614223",
"0.6478262",
"0.6478262",
"0.6478262",
"0.6478262",
"0.6399445",
"0.63662386",
"0.6351225",
"0.6311222",
"0.63002867",
"0.6222892",
"0.6176492... | 0.0 | -1 |
POST /testreplyposts POST /testreplyposts.json | def create
@testreplypost = Testreplypost.new(testreplypost_params)
respond_to do |format|
if @testreplypost.save
format.html { redirect_to @testreplypost, notice: 'Testreplypost was successfully created.' }
format.json { render :show, status: :created, location: @testreplypost }
else
format.html { render :new }
format.json { render json: @testreplypost.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testreplypost_params\n params.require(:testreplypost).permit(:text, :testpost_id)\n end",
"def reply_to_post\n puts params[:reply]\n @post = Post.find(params[:reply][:post_id])\n @reply = @post.replies.build(params[:reply])\n @reply.user_id = current_user.id\n\n respond_to do |format|\... | [
"0.66744643",
"0.656458",
"0.6517219",
"0.649634",
"0.6437977",
"0.6415763",
"0.6371864",
"0.62719953",
"0.62571985",
"0.62467",
"0.61737525",
"0.6069886",
"0.6069743",
"0.60460824",
"0.60460824",
"0.60304666",
"0.601452",
"0.5977733",
"0.59768456",
"0.5963004",
"0.59563494",... | 0.71013653 | 0 |
PATCH/PUT /testreplyposts/1 PATCH/PUT /testreplyposts/1.json | def update
respond_to do |format|
if @testreplypost.update(testreplypost_params)
format.html { redirect_to @testreplypost, notice: 'Testreplypost was successfully updated.' }
format.json { render :show, status: :ok, location: @testreplypost }
else
format.html { render :edit }
format.json { render json: @testreplypost.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @reply = Reply.find(params[:id])\n\n if @reply.update(params[:reply])\n head :no_content\n else\n render json: @reply.errors, status: :unprocessable_entity\n end\n end",
"def update\n @reply = Reply.find(params[:id])\n\n if @reply.update(reply_params)\n head :no_con... | [
"0.66724545",
"0.66275835",
"0.6596491",
"0.6552887",
"0.6512274",
"0.6491278",
"0.64508295",
"0.64259106",
"0.6374485",
"0.634269",
"0.6328409",
"0.63281196",
"0.63281196",
"0.63281196",
"0.63281196",
"0.63281196",
"0.6322378",
"0.6317303",
"0.62884116",
"0.62517685",
"0.620... | 0.650168 | 5 |
DELETE /testreplyposts/1 DELETE /testreplyposts/1.json | def destroy
@testreplypost.destroy
respond_to do |format|
format.html { redirect_to testreplyposts_url, notice: 'Testreplypost was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @reply = Reply.find(params[:id])\n @reply.destroy\n @post = @reply.post\n\n respond_to do |format|\n format.html { redirect_to @post }\n format.json { head :ok }\n end\n end",
"def destroy\n @reply = Reply.find(params[:id])\n @reply.destroy\n\n head :no_content\n ... | [
"0.7447253",
"0.71885616",
"0.71482754",
"0.7132503",
"0.7129506",
"0.7111269",
"0.70858586",
"0.7062502",
"0.70077604",
"0.69489765",
"0.69489765",
"0.69489765",
"0.69489765",
"0.69489765",
"0.6944151",
"0.69347095",
"0.690423",
"0.690423",
"0.6890433",
"0.68859076",
"0.6880... | 0.7330937 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_testreplypost
@testreplypost = Testreplypost.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 testreplypost_params
params.require(:testreplypost).permit(:text, :testpost_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
This function gives out the title page when people use this system | def instruction
@spliter = '-----------CSAIR-------------------------'
puts @spliter
puts 'Welcome to the CSair interface'
puts 'You can use the following instruction to interact with the databse'
puts 'Case is not sensitive in this interface'
puts 'GetCity [CITY CODE] will return the information of the city'
puts 'GetInfo will return the information of CSAIR'
puts 'Browser will return the picture which has all the routes of CSAIR'
puts 'GetAllCity will return a list of cities that CSAIR fly to.'
puts 'EditCity will bring you to edit mode where you can edit a city'
puts 'Editroute will bring you to the edit mode where you can edit a route.'
puts 'Save will save the current graph onto the data file.'
puts 'Load will reload the graph from the data file. Current progress will be lost.'
puts 'Merge [file_path] will let you read and merge the file into our current graph'
puts 'Checkroutes [metro1] [metro2]......[metro.n] will check the routes and give you some feekbacks'
puts 'Shortest [City Code1] [city Code2] will return the path from city 1 to city 2.'
puts 'Test and ExitTest will enter or exit the testing mode'
puts 'Help will print this menu again.'
puts @spliter
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def page_title\n \n page_title = @renderer.title title()\n \n puts \"[Cutlist.page_title]: #{page_title}\" if $cutlister_debug\n \n page_title\n \n end",
"def title_help \n\n\t\t#Define general page title\n\t\tbase_title = \"Rex Ruby on Rails Learning | PagesHelper\"\n\t\tif(@title.nil?)\n\... | [
"0.7978431",
"0.78991604",
"0.7844771",
"0.7832088",
"0.78234446",
"0.78141314",
"0.78130203",
"0.78106415",
"0.77787006",
"0.7764507",
"0.77505845",
"0.7722555",
"0.77165514",
"0.7715816",
"0.76970947",
"0.7695327",
"0.7684538",
"0.7671375",
"0.7651759",
"0.76508695",
"0.764... | 0.0 | -1 |
This function is a main interface, cal this function and the interface will show up. | def wait_for_input(my_graph)
while true
input = gets
words = input.split
if (words.length == 0)
next
end
command = words[0].upcase
case command
when 'EXIT'
break
when 'BROWSER'
open_browser(my_graph)
when 'GETINFO'
my_graph.analysis_data
when 'GETALLCITY'
list_city(my_graph)
when 'GETCITY'
if (words.length >= 2)
get_city_info(words[1].upcase, my_graph)
else
puts 'You need to give me the city!'
end
when 'EDITCITY'
edit_city(my_graph)
when 'EDITROUTE'
edit_route(my_graph)
when 'HELP'
instruction
when 'SAVE'
save_file(my_graph)
when 'LOAD'
my_graph = load_file(my_graph)
when 'MERGE'
merge_file(my_graph, words[1])
when 'CHECKROUTES'
words.shift
check_routes(my_graph, words)
when 'TEST'
my_graph = Graph.new('../data/test.json')
puts 'Into Test mode'
when 'EXITTEST'
my_graph = Graph.new('../data/map_data.json')
puts 'Exit test mode'
when 'SHORTEST'
if words.length >=3
if words[1]==words[2]
puts 'I know without even thinking about it. It is 0'
else
calculate_shortest(my_graph, words[1].upcase, words[2].upcase)
end
else
puts 'The number of cities you provide is not enough.'
end
else
puts 'Commends not recognisable.'
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def interface; end",
"def interface; end",
"def main\n\n end",
"def main\n end",
"def implementation; end",
"def implementation; end",
"def main; end",
"def main\n\nend",
"def how_it_works\r\n end",
"def included_interfaces; end",
"def call\n\n\tend",
"def call\n\n\tend",
"def run; end",... | [
"0.7633816",
"0.7633816",
"0.74329346",
"0.72500783",
"0.7136535",
"0.7136535",
"0.7109532",
"0.67322654",
"0.6708031",
"0.6645193",
"0.6634692",
"0.6634692",
"0.66224253",
"0.66224253",
"0.66224253",
"0.66224253",
"0.66224253",
"0.66224253",
"0.66224253",
"0.66224253",
"0.66... | 0.0 | -1 |
GET /commodities GET /commodities.json | def index
@commodities = Commodity.all
respond_to do |format|
format.html # index.html.erb
@commoditis = Array.new
format.json {
@commodities = @commodities.select{|commodity|
commoditi = Hash.new
commodity.attributes.each do |key, value|
commoditi[key] = value
end
commoditi[:links] = CommonActions.object_crud_paths(commodity_path(commodity), edit_commodity_path(commodity),
commodity_path(commodity))
@commoditis.push(commoditi)
}
render json: {:aaData => @commoditis}
}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @commodities = Commodity.all\n if params[:search].present?\n @commodities = @commodities.query(params[:search].to_s)\n end\n @commodities = @commodities.page(params[:page])\n respond_to do |format|\n format.html\n format.js {} \n format.json { \n render json: ... | [
"0.744353",
"0.7191632",
"0.7021728",
"0.7021728",
"0.62893605",
"0.6219271",
"0.6219271",
"0.61971575",
"0.61916363",
"0.60515165",
"0.60473996",
"0.60470873",
"0.6032051",
"0.602139",
"0.6019676",
"0.6001457",
"0.5991329",
"0.5917073",
"0.5911838",
"0.5896755",
"0.5879311",... | 0.7156523 | 2 |
GET /commodities/1 GET /commodities/1.json | def show
@commodity = Commodity.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @commodity }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @commodities = Commodity.all\n if params[:search].present?\n @commodities = @commodities.query(params[:search].to_s)\n end\n @commodities = @commodities.page(params[:page])\n respond_to do |format|\n format.html\n format.js {} \n format.json { \n render json: ... | [
"0.71551454",
"0.69652677",
"0.689434",
"0.6624344",
"0.6624344",
"0.6546328",
"0.6453164",
"0.62858075",
"0.62366587",
"0.61024487",
"0.6100771",
"0.6013886",
"0.5983782",
"0.5970167",
"0.5938198",
"0.5938198",
"0.5905315",
"0.58970386",
"0.5895779",
"0.5863152",
"0.5861469"... | 0.7433827 | 1 |
GET /commodities/new GET /commodities/new.json | def new
@commodity = Commodity.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @commodity }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @commodity = Commodity.new(commodity_params)\n\n respond_to do |format|\n if @commodity.save\n format.html { redirect_to commodities_url, notice: 'Commodity was successfully created.' }\n format.json { render json: @commodity, status: :created, location: @commodity }\n el... | [
"0.7340427",
"0.7268655",
"0.72582453",
"0.71029323",
"0.68209285",
"0.6761093",
"0.67424864",
"0.6718772",
"0.67086834",
"0.670618",
"0.6700866",
"0.6700866",
"0.6700866",
"0.6700866",
"0.6700866",
"0.6700866",
"0.6700866",
"0.6700866",
"0.6700866",
"0.6700866",
"0.66807693"... | 0.78646743 | 1 |
POST /commodities POST /commodities.json | def create
@commodity = Commodity.new(commodity_params)
respond_to do |format|
if @commodity.save
format.html { redirect_to commodities_url, notice: 'Commodity was successfully created.' }
format.json { render json: @commodity, status: :created, location: @commodity }
else
format.html { render action: "new" }
format.json { render json: @commodity.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @commodity = Commodity.new(params[:commodity])\n\n respond_to do |format|\n if @commodity.save\n format.html { redirect_to @commodity, notice: 'Commodity was successfully created.' }\n format.json { render json: @commodity, status: :created, location: @commodity }\n else\... | [
"0.70077825",
"0.6577053",
"0.64613676",
"0.6373147",
"0.6214883",
"0.6214883",
"0.6092892",
"0.6036907",
"0.5939506",
"0.58917487",
"0.58812815",
"0.5603079",
"0.5579009",
"0.5560071",
"0.55228204",
"0.5505408",
"0.54937017",
"0.54700327",
"0.54653186",
"0.5463377",
"0.54466... | 0.7094458 | 0 |
PUT /commodities/1 PUT /commodities/1.json | def update
@commodity = Commodity.find(params[:id])
respond_to do |format|
if @commodity.update_attributes(commodity_params)
format.html { redirect_to commodities_url, notice: 'Commodity was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @commodity.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @commodity = Commodity.find(params[:id])\n\n respond_to do |format|\n if @commodity.update_attributes(params[:commodity])\n format.html { redirect_to @commodity, notice: 'Commodity was successfully updated.' }\n format.json { head :no_content }\n else\n format.html... | [
"0.698199",
"0.6865258",
"0.6549405",
"0.625449",
"0.61144966",
"0.6061187",
"0.6029585",
"0.59958655",
"0.5914688",
"0.5914688",
"0.5864249",
"0.57738084",
"0.5706487",
"0.569667",
"0.5666119",
"0.56512976",
"0.56425893",
"0.56246763",
"0.56246763",
"0.5579705",
"0.5577149",... | 0.6982537 | 0 |
DELETE /commodities/1 DELETE /commodities/1.json | def destroy
@commodity = Commodity.find(params[:id])
@commodity.destroy
respond_to do |format|
format.html { redirect_to commodities_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @commodity.destroy\n respond_to do |format|\n format.html { redirect_to commodities_url, flash: {success: '操作成功.' } }\n format.json { head :no_content }\n end\n end",
"def destroy\n @commodity = Commodity.find(params[:id])\n @commodity.num = 0\n\n respond_to do |format|... | [
"0.73369837",
"0.70824623",
"0.68722385",
"0.67435133",
"0.6578203",
"0.655855",
"0.6527886",
"0.6525086",
"0.651146",
"0.65054107",
"0.6503747",
"0.64894783",
"0.6469133",
"0.64428556",
"0.6442285",
"0.643782",
"0.64324564",
"0.6415179",
"0.6380721",
"0.6375529",
"0.637437",... | 0.7840331 | 1 |
def set_name=(name) > method to change names | def name=(n) #rubyist
@name = n #@name = name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name_setter(new_name)\n @name = new_name\n end",
"def set_name(name)\n @name = name\n end",
"def change_name=(name)\n @name = name\n end",
"def set_name=(name)\n @name = name\n end",
"def name= val # Setter - set a value\n @name = val \n end",
"def name=(name)\n end",
"de... | [
"0.87736195",
"0.8531453",
"0.8516591",
"0.8483499",
"0.8369841",
"0.8342851",
"0.83335775",
"0.83268005",
"0.83268005",
"0.83268005",
"0.83268005",
"0.83268005",
"0.8322407",
"0.82996196",
"0.8286663",
"0.82865596",
"0.8284237",
"0.8280601",
"0.8254604",
"0.8242691",
"0.8242... | 0.80257875 | 40 |
Setting up the board. Loading it with all the squares and pieces. | def initialize
@config = Outpost::Config.setup
@squares = Outpost::Squares::Create.squares self
reset_cycled_colors
@pieces = Outpost::Piece::Create.pieces self
setup_pieces
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_board\n gameboard.build_board\n build_white_side\n build_black_side\n end",
"def setup(board)\n ('a'..'h').each_with_index do |column, index|\n # Set up the home rows\n [[1, :white], [8, :black]].each do |row, color|\n piece = HOME_ROW[index].new(color)\n ... | [
"0.79345536",
"0.78686476",
"0.7808432",
"0.77550375",
"0.7427124",
"0.7330495",
"0.7277026",
"0.7237489",
"0.72195303",
"0.7177677",
"0.71415424",
"0.7132579",
"0.7094089",
"0.70628107",
"0.7054558",
"0.70445156",
"0.7012075",
"0.6981629",
"0.6968954",
"0.6940081",
"0.693755... | 0.6510795 | 57 |
The definition of the files for this board. By default it will be files 'a' .. 'h'. You can change this by initializing the board with a different range. | def files
Outpost::Config.instance.files
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def files\n @files ||= FILE_RANGE.map(&:to_sym)\n end",
"def files\n ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']\n end",
"def files; end",
"def files; end",
"def files; end",
"def files; end",
"def files; end",
"def files; end",
"def filenames; end",
"def files\n @files ||= {}... | [
"0.6911375",
"0.6479326",
"0.63325906",
"0.63325906",
"0.63325906",
"0.63325906",
"0.63325906",
"0.63325906",
"0.59922475",
"0.5983024",
"0.59214914",
"0.5846886",
"0.5822537",
"0.5822537",
"0.58013374",
"0.57564443",
"0.5743453",
"0.5742581",
"0.5742581",
"0.56999034",
"0.56... | 0.54791164 | 48 |
The definition of the ranks for this board. By default it will be files 1 .. 8. You can change this by initializing the board with a different range. | def ranks
Outpost::Config.instance.ranks
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ranks\n @ranks ||= RANK_RANGE.map(&:to_i)\n end",
"def rank=(value)\n @rank = value\n end",
"def ranked_board\n # pre-process to remove sunken ships\n string = remove_sunken_ships board_to_string\n self.board = string_to_board(string)\n set_base_ran... | [
"0.7753274",
"0.64954853",
"0.6490504",
"0.6442089",
"0.64249766",
"0.64249766",
"0.6338014",
"0.6267029",
"0.62390393",
"0.6190477",
"0.6189208",
"0.61687887",
"0.61215717",
"0.6021965",
"0.60004365",
"0.5976181",
"0.5976181",
"0.59745973",
"0.59647113",
"0.5960863",
"0.5947... | 0.7009478 | 1 |
The definition of the colors for this board. By default it will be files [ :black, :white ]. You can change this by initializing the board with a different array of colors. This definition will be used to generate the board. | def colors
Outpost::Config.instance.colors
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def possible_colors\n %w(R G B Y)\n end",
"def colors() = @colors ||= %i[blue green purple magenta cyan yellow red]",
"def colors; end",
"def colors\n @colors\n end",
"def colors\n @colors ||= parse_colors(color_properties)\n end",
"def default_color_train\n %w{#5D1880 #90571... | [
"0.7186013",
"0.7010046",
"0.6751224",
"0.65643",
"0.655004",
"0.65293586",
"0.6525539",
"0.64489794",
"0.64155155",
"0.64125454",
"0.6408897",
"0.6383208",
"0.6355099",
"0.6337689",
"0.62762755",
"0.6272677",
"0.62364525",
"0.61797535",
"0.61742854",
"0.61660475",
"0.6145383... | 0.6244303 | 16 |
This helper will give you a way to cycle the colors | def cycled_colors
@cycled_colors ||= colors.cycle
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cycle colors=[], delay=0.5\n unless colors.all? {|c| COLORS.include? c}\n raise \"Invalid color\"\n end\n\n reset\n\n @thread = Thread.new do\n i = 0\n loop do\n set_color_raw colors[i]\n i = (i+1) % colors.length\n sleep delay\n end\n ... | [
"0.76274145",
"0.71802366",
"0.71802366",
"0.69707036",
"0.6750518",
"0.6687178",
"0.66343486",
"0.66284937",
"0.6518931",
"0.6429232",
"0.6398278",
"0.63675666",
"0.63319075",
"0.625633",
"0.62457186",
"0.6207914",
"0.6201747",
"0.61980814",
"0.61974007",
"0.61866844",
"0.61... | 0.77058166 | 0 |
Parse the JSON from all VMs and templates. Then return an array of objects (without duplicates) | def read_vms_info
vms_arr = json([]) do
execute_prlctl('list', '--all','--info', '--json')
end
templates_arr = json([]) do
execute_prlctl('list', '--all','--info', '--json', '--template')
end
vms_arr | templates_arr
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_vms\n args = %w[list --all --no-header --json -o name,uuid]\n vms_arr = json { execute_prlctl(*args) }\n templates_arr = json { execute_prlctl(*args, '--template') }\n\n vms = vms_arr | templates_arr\n Hash[vms.map { |i| [i.fetch('name'), i.fetch('uuid')] }]\n ... | [
"0.71686256",
"0.6681401",
"0.5961826",
"0.59298587",
"0.5920288",
"0.58270335",
"0.56836045",
"0.56644773",
"0.56527555",
"0.548605",
"0.5467821",
"0.5452085",
"0.54150885",
"0.53878874",
"0.5383206",
"0.5383206",
"0.53668404",
"0.5338923",
"0.53160316",
"0.52626276",
"0.520... | 0.6927358 | 1 |
Catch all for the method | def liquid_method_missing(method)
return nil unless @context&.strict_variables
raise Liquid::UndefinedDropMethod, "undefined method #{method}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def catch_exceptions; end",
"def handlers; end",
"def handlers; end",
"def handlers; end",
"def exception_handler; end",
"def catch\n puts \"This is an instance method\"\n end",
"def exceptions\n end",
"def _catch_warden(&block); end",
"def catch _obj, _args\n \"_obj catch _args;\" \n... | [
"0.66361105",
"0.6541664",
"0.6541664",
"0.6541664",
"0.6419963",
"0.633928",
"0.6312632",
"0.62578744",
"0.622142",
"0.61746883",
"0.6156518",
"0.6156518",
"0.61089617",
"0.58741623",
"0.58619577",
"0.5850803",
"0.5776226",
"0.5769317",
"0.5757386",
"0.574312",
"0.5719776",
... | 0.0 | -1 |
called by liquid to invoke a drop | def invoke_drop(method_or_key)
if self.class.invokable?(method_or_key)
send(method_or_key)
else
liquid_method_missing(method_or_key)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drop\n do_callback(:before_drop)\n collection.drop\n do_callback(:after_drop)\n end",
"def invoke_drop(m)\n self.class.invokable?(m) ? send(m) : liquid_method_missing(m)\n end",
"def page_drop; end",
"def drop\n Statements::DropFunction.new(context: self)\n end",... | [
"0.69509137",
"0.69160455",
"0.68819594",
"0.68675953",
"0.67259324",
"0.6557238",
"0.651733",
"0.64635915",
"0.6451933",
"0.64483213",
"0.640781",
"0.640496",
"0.63689774",
"0.6352947",
"0.63290507",
"0.6328251",
"0.6314846",
"0.6280054",
"0.6230457",
"0.6171241",
"0.6119198... | 0.6383377 | 12 |
this method is implemented by middlemanblog and we can't stub it directly because the helpers module doesn't implement it on it's own | def blog(which_blog)
blog_object
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def helpers; end",
"def helpers; end",
"def helpers; end",
"def private; end",
"def define_helpers; end",
"def weber; end",
"def around_hooks; end",
"def wrapper; end",
"def custom; end",
"def custom; end",
"def private_method\n end",
"def macro; raise NotImplementedError; end",
"def m... | [
"0.6794805",
"0.6794805",
"0.6794805",
"0.63869816",
"0.6282601",
"0.61621547",
"0.6104847",
"0.6007047",
"0.58904284",
"0.58904284",
"0.5838433",
"0.5801471",
"0.5801471",
"0.5801471",
"0.57658535",
"0.57658535",
"0.5663216",
"0.5654853",
"0.5654853",
"0.5654853",
"0.5654853... | 0.0 | -1 |
Renders a constituency and the current incumbent given a constituency id. | def current
@constituency, @seat_incumbency = Parliament::Utils::Helpers::FilterHelper.filter(@request, 'ConstituencyGroup', 'SeatIncumbency')
@constituency = @constituency.first
@seat_incumbency = @seat_incumbency.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @constituency = Constituency.find(params[:id])\n\n respond_to do |format|\n if @constituency.update_attributes(params[:constituency])\n flash[:notice] = 'Constituency was successfully updated.'\n format.html { redirect_to(@constituency) }\n format.xml { head :ok }\n ... | [
"0.6155001",
"0.6058926",
"0.5584382",
"0.5560938",
"0.5481249",
"0.5457177",
"0.5403604",
"0.5355283",
"0.5161771",
"0.51590693",
"0.5157324",
"0.513538",
"0.5094399",
"0.4992046",
"0.49698243",
"0.4960046",
"0.49599808",
"0.49533534",
"0.49407077",
"0.49370998",
"0.49298185... | 0.46784168 | 63 |
Gets file name from command line. | def print_all(f) #function definition is used to read from file and prints the file.
puts f.read
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filename\n return @args[:fname]\n end",
"def filename\n return @args[\"fname\"]\n end",
"def get_filename\n filename = gets.chomp\n end",
"def get_file()\n puts(\"Please enter a file path: \")\n for arg in ARGV\n \tname = arg\n end\n print meta_data(name)\n name\nend",
"def get_filena... | [
"0.77927077",
"0.7779101",
"0.7300655",
"0.7148661",
"0.6960506",
"0.69362074",
"0.67874384",
"0.6714737",
"0.66138756",
"0.6603715",
"0.6600954",
"0.6587218",
"0.656159",
"0.65416855",
"0.65361786",
"0.6511452",
"0.65007526",
"0.64964217",
"0.6486411",
"0.64616",
"0.6460324"... | 0.0 | -1 |
GET /videos GET /videos.json | def index
@videos = Video.order('created_at DESC').page params[:page]
respond_to do |format|
format.html # index.html.erb
format.json { render json: @videos }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def videos options={}\n response = client.get(\"/#{id}/videos\", options)\n end",
"def index\n @videos = Video.all\n render json: @videos\n end",
"def list\n @videos = Video.all\n\n respond_to do |format|\n format.html # list.html.erb\n format.json { render json: @videos }\n e... | [
"0.8300022",
"0.7734552",
"0.77048963",
"0.75849354",
"0.74897736",
"0.74893093",
"0.74893093",
"0.74893093",
"0.74893093",
"0.74756104",
"0.73633087",
"0.7358063",
"0.7357167",
"0.72600365",
"0.7200847",
"0.7194637",
"0.71250415",
"0.71250415",
"0.71250415",
"0.71250415",
"0... | 0.730496 | 13 |
GET /videos/list GET /videos/list.json | def list
@videos = Video.all
respond_to do |format|
format.html # list.html.erb
format.json { render json: @videos }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def videos options={}\n response = client.get(\"/#{id}/videos\", options)\n end",
"def index\n @videos = Video.all\n render json: @videos\n end",
"def video_list(login = nil, authenticated = false, page=1)\n result = []\n response = nil\n if authenticated\n response = auth_... | [
"0.8083367",
"0.7769143",
"0.7755607",
"0.7634245",
"0.763365",
"0.763365",
"0.763365",
"0.763365",
"0.76053154",
"0.7463178",
"0.7461059",
"0.7452215",
"0.7430447",
"0.73788255",
"0.7368817",
"0.7312249",
"0.7265401",
"0.7265401",
"0.7265401",
"0.7265401",
"0.7265401",
"0.... | 0.842482 | 0 |
GET /videos/1 GET /videos/1.json | def show
@video = Video.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @video }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def videos options={}\n response = client.get(\"/#{id}/videos\", options)\n end",
"def index\n @videos = Video.all\n render json: @videos\n end",
"def list\n @videos = Video.all\n\n respond_to do |format|\n format.html # list.html.erb\n format.json { render json: @videos }\n e... | [
"0.77855194",
"0.7450134",
"0.7386234",
"0.73703194",
"0.7363398",
"0.73398286",
"0.7338815",
"0.7338815",
"0.7338815",
"0.7338815",
"0.7308188",
"0.722379",
"0.72142017",
"0.72013223",
"0.7160676",
"0.7117048",
"0.7104133",
"0.7104133",
"0.7077088",
"0.7041828",
"0.7010378",... | 0.73798877 | 9 |
GET /videos/new GET /videos/new.json | def new
@video = Video.new
@licenses = License.all
@galleries = Gallery.all
if @licenses.empty?
redirect_to "/licenses/new", :notice => "You need to create at least one license"
return
end
respond_to do |format|
format.html # new.html.erb
format.json { render json: @video }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n \n @video = Video.new\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @video }\n end\n end",
"def new\n @video = Video.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @video }\n... | [
"0.8016282",
"0.7963612",
"0.7884851",
"0.78837156",
"0.78837156",
"0.78837156",
"0.78837156",
"0.78837156",
"0.78837156",
"0.78837156",
"0.78837156",
"0.78837156",
"0.78837156",
"0.7604804",
"0.753364",
"0.75278044",
"0.7379394",
"0.72565913",
"0.7214344",
"0.71995765",
"0.7... | 0.0 | -1 |
POST /videos POST /videos.json | def create
@video = Video.new(params[:video])
@licenses = License.all
@galleries = Gallery.all
respond_to do |format|
if @video.save
format.html { redirect_to @video, notice: 'Video was successfully created.' }
format.json { render json: @video, status: :created, location: @video }
else
format.html { render action: "new" }
format.json { render json: @video.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @video = Video.new(video_params)\n @video.save!\n render json: @video\n end",
"def create\n @video = @room.videos.new(video_params)\n respond_to do |format|\n if @video.save\n format.html { redirect_to upload_video_path(@video), notice: 'Video was successfully created.' }... | [
"0.7559166",
"0.72561485",
"0.72147936",
"0.72094315",
"0.7070432",
"0.70647645",
"0.70605457",
"0.70605457",
"0.70605457",
"0.70605457",
"0.69911706",
"0.69875956",
"0.69875956",
"0.69875956",
"0.69875956",
"0.69875956",
"0.69389236",
"0.69220686",
"0.69220686",
"0.6870992",
... | 0.6657436 | 34 |
PUT /videos/1 PUT /videos/1.json | def update
@video = Video.find(params[:id])
@licenses = License.all
@galleries = Gallery.all
respond_to do |format|
if @video.update_attributes(params[:video])
format.html { redirect_to @video, notice: 'Video was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @video.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @video.update(video_params)\n render json: @video\n end",
"def update\n Video.find(params[:id]).update(video_params)\n redirect_to \"/videos/#{params[:id]}\"\n end",
"def edit_video(video_id, title, description, method = HTTP_PUT)\n request_xml = %{\n <?xml version=\"1.0\... | [
"0.7424246",
"0.7119715",
"0.7058636",
"0.69604856",
"0.69604856",
"0.693999",
"0.6919837",
"0.6919837",
"0.6919837",
"0.6919837",
"0.6919837",
"0.6919837",
"0.6919837",
"0.6880118",
"0.68631864",
"0.6855068",
"0.6789322",
"0.67666703",
"0.6766564",
"0.6766564",
"0.6766564",
... | 0.64547807 | 54 |
DELETE /videos/1 DELETE /videos/1.json | def destroy
@video = Video.find(params[:id])
@video.destroy
respond_to do |format|
format.html { redirect_to videos_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @video = Video.find(params[:id])\n @video.destroy\n\n respond_to do |format|\n format.html { redirect_to videos_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @video = Video.find(params[:id])\n @video.destroy\n\n respond_to do |format|\n format.ht... | [
"0.7782917",
"0.7782917",
"0.7768144",
"0.7723812",
"0.77067566",
"0.7692495",
"0.7692495",
"0.7692495",
"0.7682142",
"0.7642714",
"0.76279795",
"0.760256",
"0.75952363",
"0.75657415",
"0.7548429",
"0.7516953",
"0.748994",
"0.748994",
"0.748994",
"0.7489848",
"0.7488452",
"... | 0.77617705 | 14 |
Use callbacks to share common setup or constraints between actions. | def set_catalog
@catalog = present(Catalog::Show).model
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 |
if use init, every each call client, this client are same | def init(url = 'localhost:3000', app = 'weapp')
@url = url
@app = app
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_client; end",
"def initialize(client)\n self.client=client\n\n\tend",
"def post_init\n puts \"#{self.class}/#{self} client post_init runs\"\n end",
"def initialize\n @clients = []\n end",
"def initialize(client)\n\t self.client=client\n end",
"def client; end",
"def client; en... | [
"0.8025852",
"0.73622066",
"0.725011",
"0.722477",
"0.705553",
"0.6890761",
"0.6890761",
"0.68437535",
"0.68437535",
"0.6681286",
"0.66677153",
"0.665912",
"0.6658834",
"0.6629339",
"0.660935",
"0.66060644",
"0.6593374",
"0.6584792",
"0.65449494",
"0.6541615",
"0.65325975",
... | 0.0 | -1 |
source can take any of the following as arguments A single string argument Multiple string arguments An array or strings A delayed evaluator that evaluates to a string or array of strings All strings must be parsable as URIs. source returns an array of strings. | def source(*args)
arg = parse_source_args(args)
ret = set_or_return(:source,
arg,
{ callbacks: {
validate_source: method(:validate_source),
} })
if ret.is_a? String
Array(ret)
else
ret
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def source(*args)\n arg = parse_source_args(args)\n ret = set_or_return(:source,\n arg,\n { :callbacks => {\n :validate_source => method(:validate_source),\n } })\n if ret.is_a? St... | [
"0.791088",
"0.6675598",
"0.6345544",
"0.6165359",
"0.60313857",
"0.6004425",
"0.59468085",
"0.59468085",
"0.59468085",
"0.59468085",
"0.59468085",
"0.58789057",
"0.58679634",
"0.58420074",
"0.5757213",
"0.5739514",
"0.5690611",
"0.56784505",
"0.56784505",
"0.5676527",
"0.565... | 0.7801762 | 1 |
Disable or enable ETag and Last Modified conditional GET. Equivalent to use_etag(true_or_false) use_last_modified(true_or_false) | def use_conditional_get(true_or_false)
use_etag(true_or_false)
use_last_modified(true_or_false)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(path, headers = {})\n cached_response = fetch_cached_response(path)\n if cached_response\n headers = headers.merge 'If-None-Match' => cached_response['Etag']\n end\n response = super(path, headers)\n case response\n when Net::HTTPNotModified then cached_response\n ... | [
"0.6482948",
"0.6287235",
"0.6280377",
"0.6072988",
"0.60519505",
"0.5913605",
"0.5906597",
"0.590059",
"0.58755744",
"0.58405143",
"0.5829607",
"0.58241147",
"0.5783479",
"0.57205737",
"0.567177",
"0.5611315",
"0.55969965",
"0.55632925",
"0.55285174",
"0.5520176",
"0.5505413... | 0.8406503 | 1 |
returns true if a handler is set for the HTTP method in param it is an alternative to get_handler which would return a true value if there is a default handler | def has_handler?(method)
send(method) && true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def respond_to_missing?(method_name)\n @original_handler.respond_to?(method_name)\n end",
"def has_handler_for?(handler_method)\n @jr_handlers ||= {}\n @jr_handlers.has_key?(handler_method)\n end",
"def get?\r\nHTTP_METHOD_LOOKUP[request_method] == :get\r\nend",
"def handleRequest?(path)... | [
"0.71880573",
"0.70673895",
"0.70315045",
"0.6960397",
"0.6888432",
"0.66511524",
"0.6429777",
"0.63968956",
"0.6372571",
"0.63350034",
"0.6328482",
"0.6309252",
"0.6307925",
"0.63055146",
"0.63052446",
"0.62920165",
"0.6265385",
"0.62626976",
"0.6252423",
"0.6249509",
"0.624... | 0.76993495 | 0 |
sets a handler for the HTTP method in param to val | def set_handler(method, val)
send("#{method}=", val)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def http_method(value = nil)\n if value\n @http_method = value\n else\n @http_method\n end\n end",
"def http_method(v)\n endpoint_info[:http_method] = v\n end",
"def http_method= new_verb\n @http_method = new_verb.to_s.upcase\n end",
"def http_metho... | [
"0.71939635",
"0.7159462",
"0.6982221",
"0.6982221",
"0.69335437",
"0.6730909",
"0.6562484",
"0.6323994",
"0.617905",
"0.617905",
"0.61646706",
"0.61485004",
"0.61454594",
"0.6113104",
"0.6094643",
"0.60380816",
"0.6008632",
"0.6005134",
"0.5914227",
"0.5892399",
"0.5888219",... | 0.7760868 | 0 |
Returns an array of pairs of array with [HTTPverbs, handler] an extra item is the :default handler NB: could also be a hash, but I'm fine with it | def handlers
HTTP_METHODS.map do |sym|
[sym, send(sym)]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verbs\n (@verb.downcase.presence || 'get').split('|')\n end",
"def http_methods(_path)\n []\n end",
"def handlers\n @handlers ||= Hash.new do |hash, key|\n if key.nil?\n raise NoHandler\n else\n raise InvalidHandler, key\n end\n end\n... | [
"0.65251577",
"0.63290566",
"0.609211",
"0.6043446",
"0.5937355",
"0.5895904",
"0.5859775",
"0.5852079",
"0.58322763",
"0.58017915",
"0.58015114",
"0.57037044",
"0.57037044",
"0.57037044",
"0.56874067",
"0.566724",
"0.5663021",
"0.56479955",
"0.56331813",
"0.55932385",
"0.559... | 0.7637699 | 0 |
returns an array like handlers but restricted to the not nil values | def handlers_set
handlers.reject{|sym, handler| handler.nil?}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handlers\n @handlers ||= Hash.new do |hash, key|\n if key.nil?\n raise NoHandler\n else\n raise InvalidHandler, key\n end\n end\n end",
"def handlers\n @handlers ||= Set.new\n end",
"def __handlers\n @__handlers ||= Hash.new([])\n ... | [
"0.6487597",
"0.62378854",
"0.61714274",
"0.61482465",
"0.6014034",
"0.57429856",
"0.57349545",
"0.5681223",
"0.5636645",
"0.5546216",
"0.5546216",
"0.5546216",
"0.55271155",
"0.55175674",
"0.55102974",
"0.54561996",
"0.544601",
"0.5399749",
"0.5366708",
"0.5335934",
"0.53336... | 0.7042405 | 0 |
Returns true if there is no handler set for this dispatcher | def no_handler?
handlers_set.empty?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handlers?\n registered_handlers.length > 0\n end",
"def has_handler?(method)\n send(method) && true\n end",
"def empty?\n @dispatchers.empty?\n end",
"def handled?\n handled\n end",
"def handled?\n\t\treturn ! @status.nil?\n\tend",
"def handler_enabled?\n ... | [
"0.77711904",
"0.7221516",
"0.7161389",
"0.69499964",
"0.6823033",
"0.67305195",
"0.6703453",
"0.64089286",
"0.6389181",
"0.6150591",
"0.6085799",
"0.60730803",
"0.60704345",
"0.606162",
"0.6032549",
"0.6016277",
"0.60115904",
"0.59596235",
"0.5940822",
"0.59036714",
"0.58757... | 0.881674 | 0 |
run_command(cmd, arg1, arg2, ...) safely runs a command without using a Unix command shell. This means any wildcards, quotes, redirections, and so on in the command name or arguments are not interpreted by a shell, and are passed directly to the command being run. Accepts a block of code to run, and sets $? to the return status of the process. Dies if the command cannot be executed. | def run_command(cmd, *args)
raise ArgumentError.new('missing required cmd to run') if cmd.nil?
rd, wr = IO.pipe
if fork
wr.close
if block_given?
rd.each { |line| yield(line) }
else
rd.read
end
rd.close
Process.wait
return $?
else
rd.close
$stdin.close
$stdout.reopen(wr)
$stderr.reopen(wr)
exec cmd, *args
raise "exec #{cmd} failed"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_command(command, options = {})\n status = run(command, options)\n fail \"#{command} failed\" unless status\nend",
"def run_command(command, options = {})\n status = run(command, options)\n fail \"#{command} failed\" unless status\nend",
"def run_cmd(cmd)\n print_e(\"Run: #{cmd}\")\n exit_code... | [
"0.6740893",
"0.6740893",
"0.6527088",
"0.6480377",
"0.64657855",
"0.6446945",
"0.6399366",
"0.6376634",
"0.6336044",
"0.63311404",
"0.6326178",
"0.63043284",
"0.630221",
"0.62911665",
"0.6291144",
"0.6273557",
"0.6254009",
"0.6254009",
"0.61839235",
"0.61666405",
"0.61283475... | 0.64201325 | 6 |
Strong params (Buenas Practicas) Refactor code and security params | def strong_article_params
params.require(:article).permit(:title,:status,:content,category_elements: [])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def secure_params(require_param, permit_keys)\n params.require(require_param).permit(*permit_keys)\n end",
"def secure_params\n return @secure_params if @secure_params\n\n @implementation_class = implementation_class\n resname = @implementation_class.name.ns_underscore.gsub('__', '_').singularize.to... | [
"0.6920249",
"0.68722063",
"0.6868638",
"0.68449163",
"0.68334746",
"0.6697007",
"0.6668872",
"0.66526383",
"0.6612213",
"0.65737164",
"0.6543004",
"0.6520707",
"0.6517135",
"0.647815",
"0.6474019",
"0.6464357",
"0.6429797",
"0.642566",
"0.63946843",
"0.634887",
"0.6345376",
... | 0.0 | -1 |
Checks that the model given as a string exists | def model_exists?
if model.present?
begin
model.constantize
rescue NameError
errors.add :model, "#{model} is not a valid model"
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def model_exists?(model_type, name)\n get_model(model_type, name) != nil\n end",
"def model_exists?(model)\n File.exists? File.join(RAILS_ROOT,'app/models', model + '.rb')\n end",
"def model_exists?(model)\n File.exists? File.join(RAILS_ROOT,'app/models', model + '.rb')\nend",
"def model_exists?... | [
"0.7527053",
"0.7440013",
"0.7321153",
"0.71498436",
"0.69572294",
"0.6877183",
"0.68527615",
"0.666068",
"0.664825",
"0.6614182",
"0.65156555",
"0.64835036",
"0.6479785",
"0.64507276",
"0.64369017",
"0.64369017",
"0.643171",
"0.6349107",
"0.6253727",
"0.6243179",
"0.6229256"... | 0.7787579 | 0 |
def collection get_collection_ivar || set_collection_ivar(end_of_association_chain.paginate(:page => params[:page], :per_page => per_page)) end | def per_page
6
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def paginate_collection!\n set_collection get_collection.page(params[:page]).per(self.class.per_page)\n end",
"def page_collection!\n return unless paginate\n\n page = params[:page].to_i\n page = 1 if page.zero?\n page_size = params[:page_size].to_i\n page_size = DEFAULT_PAGE_SIZE if... | [
"0.8350211",
"0.7644634",
"0.7447002",
"0.742697",
"0.7368124",
"0.723076",
"0.7190033",
"0.70924854",
"0.70822847",
"0.7052436",
"0.69765174",
"0.6965738",
"0.69570506",
"0.6946383",
"0.6890084",
"0.6862361",
"0.6753844",
"0.6737098",
"0.6735109",
"0.6734916",
"0.66923046",
... | 0.0 | -1 |
The relative path to the file | def path
real_path = Pathname.new(root).realpath.to_s
full_path.sub(%r{^#{real_path}/}, '')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relative_path\n @relative_path ||= File.join(@dir, @name)\n end",
"def relative_path\n must_be File\n Pathname.new(self.full_path).relative_path_from(Pathname.new(Dir.pwd)).to_s\n end",
"def relative_path; end",
"def relative_path; end",
"def relative_path; end",
"def relative_path; en... | [
"0.81655407",
"0.81536263",
"0.8112074",
"0.8112074",
"0.8112074",
"0.8112074",
"0.8112074",
"0.80664766",
"0.7969286",
"0.79668343",
"0.7916978",
"0.7881229",
"0.784363",
"0.78282386",
"0.78060204",
"0.78033465",
"0.77767164",
"0.77248824",
"0.77170414",
"0.7669392",
"0.7634... | 0.0 | -1 |
Processes the file with HamlLint and outputs to the configured IO | def process
ReportAdapter.new(report: runner.run(run_options), root: root).each do |issue|
io.print issue.to_json
io.print "\0"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_report(report)\n super\n\n File.write(ConfigurationLoader::AUTO_GENERATED_FILE, config_file_contents)\n log.log \"Created #{ConfigurationLoader::AUTO_GENERATED_FILE}.\"\n log.log \"Run `haml-lint --config #{ConfigurationLoader::AUTO_GENERATED_FILE}`\" \\\n \", or add `inherit... | [
"0.6078255",
"0.5819208",
"0.57192457",
"0.5710995",
"0.561803",
"0.558675",
"0.5581003",
"0.557709",
"0.5574326",
"0.55721617",
"0.55469596",
"0.5520805",
"0.55186105",
"0.5500178",
"0.54884994",
"0.54596806",
"0.54511625",
"0.5404621",
"0.5363552",
"0.53429085",
"0.53429085... | 0.0 | -1 |
Instantiates the reporter to generate the HamlLint report | def reporter
@reporter ||= ::HamlLint::Reporter::HashReporter.new(
::HamlLint::Logger.new(StringIO.new)
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def runner\n @runner ||= ::HamlLint::Runner.new\n end",
"def display_report(report)\n super\n\n File.write(ConfigurationLoader::AUTO_GENERATED_FILE, config_file_contents)\n log.log \"Created #{ConfigurationLoader::AUTO_GENERATED_FILE}.\"\n log.log \"Run `haml-lint --config #{Confi... | [
"0.677621",
"0.65861124",
"0.61029667",
"0.6087162",
"0.60562736",
"0.5987778",
"0.59489644",
"0.5836281",
"0.5832875",
"0.5822366",
"0.5787985",
"0.570662",
"0.56942123",
"0.56863564",
"0.5663181",
"0.5639901",
"0.5637486",
"0.5603447",
"0.5535068",
"0.55140877",
"0.5497244"... | 0.80870014 | 0 |
The options to pass to the HamlLint runner | def run_options
{
config: linter_config,
excluded_linters: [],
files: [full_path],
included_linters: linter_config['linters'].keys,
reporter: reporter
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def runner\n @runner ||= ::HamlLint::Runner.new\n end",
"def parse_yardopts_options(*args); end",
"def options\n original_options = super\n defaults = Thor::CoreExt::HashWithIndifferentAccess.new(\n {\n width: 72,\n count: 200,\n },\n )\n\n config... | [
"0.6638811",
"0.59874463",
"0.5959365",
"0.59330416",
"0.5916479",
"0.5874756",
"0.58663785",
"0.5844878",
"0.58249307",
"0.57829326",
"0.5756373",
"0.5756373",
"0.5756373",
"0.5756373",
"0.5756373",
"0.5756373",
"0.5756373",
"0.5756373",
"0.5756373",
"0.5756373",
"0.5756373"... | 0.58413553 | 8 |
The runner to use for analyzing the source file | def runner
@runner ||= ::HamlLint::Runner.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def analyze\n Core::Runner.base_path = @path\n Core::Runner.config_path = @options['config']\n @runner = Core::Runner.new\n\n analyze_source_codes\n analyze_vcs\n end",
"def runner; end",
"def run\n files_to_inspect.each do |path|\n SourceFile.new(\n linte... | [
"0.7367677",
"0.72162795",
"0.7002248",
"0.6951728",
"0.6951682",
"0.6951682",
"0.6951682",
"0.6951682",
"0.6951682",
"0.69311816",
"0.6601783",
"0.6601783",
"0.65434337",
"0.65094286",
"0.6436024",
"0.64005965",
"0.6399625",
"0.6354438",
"0.62435997",
"0.6235248",
"0.6220763... | 0.6266454 | 18 |
GET /bbs GET /bbs.json | def index
@bbs = Bb.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @bb = Bb.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bb }\n end\n end",
"def show\n @weibo = Weibo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @w... | [
"0.7061532",
"0.6372534",
"0.63676804",
"0.62977475",
"0.6288213",
"0.62540007",
"0.6250688",
"0.61445594",
"0.61312085",
"0.6126052",
"0.61097634",
"0.6059838",
"0.6042345",
"0.6031007",
"0.60165703",
"0.60161185",
"0.5978962",
"0.59534454",
"0.5938299",
"0.5935922",
"0.5931... | 0.6912775 | 1 |
GET /bbs/1 GET /bbs/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @bb = Bb.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bb }\n end\n end",
"def index\n @bbs = Bb.all\n end",
"def show\n @weibo = Weibo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html... | [
"0.71855927",
"0.6808038",
"0.6551085",
"0.6516438",
"0.64267075",
"0.63805646",
"0.6335485",
"0.62698764",
"0.61947685",
"0.6191861",
"0.61855793",
"0.61830115",
"0.6153444",
"0.61476344",
"0.61445636",
"0.611823",
"0.61085",
"0.60997295",
"0.6036686",
"0.60331",
"0.6003123"... | 0.0 | -1 |
POST /bbs POST /bbs.json | def create
@bb = Bb.new(bb_params)
respond_to do |format|
if @bb.save
format.html { redirect_to @bb, notice: 'Bb was successfully created.' }
format.json { render :show, status: :created, location: @bb }
else
format.html { render :new }
format.json { render json: @bb.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @bb = Bb.new(params[:bb])\n\n respond_to do |format|\n if @bb.save\n format.html { redirect_to @bb, notice: 'Bb was successfully created.' }\n format.json { render json: @bb, status: :created, location: @bb }\n else\n format.html { render action: \"new\" }\n ... | [
"0.6819664",
"0.64434904",
"0.6243959",
"0.6234521",
"0.61542755",
"0.60390276",
"0.60334337",
"0.603039",
"0.6004649",
"0.59964174",
"0.59896815",
"0.59720916",
"0.593884",
"0.59021103",
"0.5866441",
"0.58390075",
"0.58284444",
"0.5801121",
"0.5784998",
"0.5768846",
"0.57652... | 0.6746908 | 1 |
PATCH/PUT /bbs/1 PATCH/PUT /bbs/1.json | def update
respond_to do |format|
if @bb.update(bb_params)
format.html { redirect_to @bb, notice: 'Bb was successfully updated.' }
format.json { render :show, status: :ok, location: @bb }
else
format.html { render :edit }
format.json { render json: @bb.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @bb = Bb.find(params[:id])\n\n respond_to do |format|\n if @bb.update_attributes(params[:bb])\n format.html { redirect_to @bb, notice: 'Bb was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n form... | [
"0.68290186",
"0.656573",
"0.6504054",
"0.6491519",
"0.6398294",
"0.637623",
"0.6365852",
"0.6364217",
"0.6346069",
"0.6337392",
"0.6309472",
"0.6288787",
"0.6247065",
"0.6217227",
"0.6213658",
"0.6207322",
"0.61985016",
"0.6191008",
"0.6168963",
"0.61643785",
"0.6120079",
... | 0.6563021 | 2 |
DELETE /bbs/1 DELETE /bbs/1.json | def destroy
@bb.destroy
respond_to do |format|
format.html { redirect_to bbs_url, notice: 'Bb was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @bb = Bb.find(params[:id])\n @bb.destroy\n\n respond_to do |format|\n format.html { redirect_to bbs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @b = B.find(params[:id])\n @b.destroy\n\n respond_to do |format|\n format.html { redirect_to... | [
"0.72713745",
"0.700241",
"0.69206923",
"0.68334067",
"0.6804754",
"0.67955065",
"0.6783016",
"0.6760925",
"0.6735975",
"0.6682564",
"0.66667366",
"0.66650814",
"0.66561687",
"0.6645461",
"0.663072",
"0.6581821",
"0.658068",
"0.657236",
"0.656462",
"0.6540489",
"0.6531784",
... | 0.71378064 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_bb
@bb = Bb.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 bb_params
params.require(:bb).permit(:name, :mem_no)
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 |
We use these mock accounts to ensure that the ones which are available in development are valid, to test omniauth actions and verify that a mock account is available for every supported omniauth provider. These must be identical to the ones in /config/environments/development.rb Remember to keep them in sync with development.rb | def mock_auth_accounts
OmniAuth.config.mock_auth[:facebook] =
OmniAuth::AuthHash.new(
provider: 'facebook',
uid: 'facebook-test-uid-1',
info: {
name: 'facebook user',
email: 'user-facebook@example.com',
username: 'user_facebook'
},
credentials: {
token: 'fb_mock_token',
secret: 'fb_mock_secret'
}
)
OmniAuth.config.mock_auth[:google] =
OmniAuth::AuthHash.new(
provider: 'google',
uid: 'google-test-uid-1',
info: {
name: 'google user',
email: 'user-google@example.com',
username: 'user_google'
},
credentials: {
token: 'google_mock_token',
secret: 'google_mock_secret'
}
)
OmniAuth.config.mock_auth[:suse] =
OmniAuth::AuthHash.new(
provider: 'suse',
uid: 'suse-test-uid-1',
info: {
name: 'suse user',
email: 'user-suse@example.com',
username: 'user_suse'
},
credentials: {
token: 'suse_mock_token',
secret: 'suse_mock_secret'
}
)
OmniAuth.config.mock_auth[:github] =
OmniAuth::AuthHash.new(
provider: 'github',
uid: 'github-test-uid-1',
info: {
name: 'github user',
email: 'user-github@example.com',
username: 'user_github'
},
credentials: {
token: 'github_mock_token',
secret: 'github_mock_secret'
}
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mock_auth\n OmniAuth.config.mock_auth[:facebook] = OmniAuth::AuthHash.new({\n provider: 'facebook',\n uid: '123545',\n person_id: '1',\n credentials: {\n token: 'token',\n expires_at: Time.now + 10000000\n },\n info: {\n first_name: 'first_name',\n l... | [
"0.69900966",
"0.6871177",
"0.65068924",
"0.6486989",
"0.64714503",
"0.63960737",
"0.6280759",
"0.62422264",
"0.62377244",
"0.6116393",
"0.6083275",
"0.599791",
"0.5968223",
"0.59553987",
"0.5878758",
"0.5878758",
"0.58665687",
"0.5865046",
"0.5829651",
"0.5829651",
"0.582272... | 0.8128238 | 0 |
best_solution is a thin wrapper of this method, most of the testing is in test_best_solution | def test_resolve_dependencies
Dir.mktmpdir('testbase') do |testbase|
tpkg = Tpkg.new(:base => testbase, :sources => @pkgfiles)
result = tpkg.resolve_dependencies([{:name => 'a', :type => :tpkg}], {:tpkg => {}, :native => {}}, ['a'])
assert(result.has_key?(:solution))
solution = result[:solution]
# We should end up with a-1.0, b-1.0 (the specific one, not the generic
# one), c-1.2 and d-1.2
assert_equal(4, solution.length)
good = ['a-1.0-1.tpkg', "b-1.0-1-#{Metadata.clean_for_filename(tpkg.os.os)}.tpkg", 'c-1.2-1.tpkg', 'd-1.2-1.tpkg']
solution.each { |pkg| assert(good.any? { |g| pkg[:source].include?(g) }) }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def best_solution\n # Sort existing solutions by expected makespan.\n @solutions.sort_by!(&:expected_makespan)\n # First solution is the best one.\n @solutions.first\n end",
"def solution\n solve unless solved?\n @solution\n end",
"def run\n solve\n { price: ... | [
"0.78100836",
"0.73309666",
"0.69790393",
"0.6855173",
"0.6781733",
"0.67695904",
"0.67695904",
"0.6742616",
"0.6730781",
"0.6727398",
"0.6652725",
"0.66474867",
"0.6629942",
"0.66260386",
"0.65989566",
"0.6551165",
"0.6541718",
"0.6539794",
"0.6536312",
"0.6529831",
"0.65157... | 0.0 | -1 |
This method is only used by resolve_dependencies, so the testing here is minimal. | def test_check_solution
Dir.mktmpdir('testbase') do |testbase|
tpkg = Tpkg.new(:base => testbase, :sources => @pkgfiles)
solution = nil
requirements = [{:name => 'c', :minimum_version => '1.3', :type => :tpkg}, {:name => 'd', :minimum_version => '1.3', :type => :tpkg}]
packages = {:tpkg => {}, :native => {}}
requirements.each do |req|
packages[req[:type]][req[:name]] = tpkg.available_packages_that_meet_requirement(req)
end
core_packages = ['c']
number_of_possible_solutions_checked = 0
result = nil
# Check a valid solution
solution = {:pkgs => packages[:tpkg].values.flatten}
assert_nothing_raised { result = tpkg.check_solution(solution, requirements, packages, core_packages, number_of_possible_solutions_checked) }
assert(result.has_key?(:solution))
assert_equal(packages[:tpkg].values.flatten, result[:solution])
# Check an invalid solution
xpkgfile = make_package(:output_directory => @tempoutdir, :change => { 'name' => 'x' }, :dependencies => {'y' => {}}, :remove => ['operatingsystem', 'architecture'])
metadata = Tpkg::metadata_from_package(xpkgfile)
xpkg = {:metadata => metadata}
solution[:pkgs] << xpkg
assert_nothing_raised { result = tpkg.check_solution(solution, requirements, packages, core_packages, number_of_possible_solutions_checked) }
assert(!result.has_key?(:solution))
assert(result.has_key?(:number_of_possible_solutions_checked))
assert(result[:number_of_possible_solutions_checked] > 0)
FileUtils.rm_f(xpkgfile)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def direct_dependencies; end",
"def dependencies; end",
"def dependencies; end",
"def dependencies; end",
"def dependencies=(_arg0); end",
"def resolve_dependency(_completed_operation)\n true\n end",
"def dependency_respects_ordering?; @dependency_respects_ordering; end",
"def test_re... | [
"0.6963175",
"0.67176896",
"0.67176896",
"0.67176896",
"0.64337474",
"0.6221749",
"0.62179136",
"0.62102306",
"0.61282843",
"0.61282843",
"0.6089024",
"0.6072091",
"0.5983655",
"0.5983655",
"0.59614426",
"0.59603727",
"0.5899887",
"0.58741355",
"0.5850722",
"0.58308715",
"0.5... | 0.0 | -1 |
Delete all entities which match all attributes attributes: Hash of attributes to match Returns: Integer count of entities deleted. | def delete_all(attributes = {})
raise NotImplementedError.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_all\n self.store.delete_keys(find_keys)\n end",
"def delete_all(conditions = \"\")\n collection.remove(XGen::SQL::Parser.parse_where(conditions, true) || {})\n end",
"def delete(*args)\n if args.blank?\n raise \"Using delete with no args is not allowed. Please... | [
"0.6635313",
"0.639678",
"0.63617414",
"0.6349998",
"0.61776924",
"0.6144484",
"0.6132015",
"0.60949475",
"0.60592246",
"0.6057224",
"0.6045857",
"0.60256195",
"0.60182184",
"0.59771925",
"0.5975894",
"0.59724146",
"0.5940667",
"0.5931897",
"0.5931067",
"0.5914326",
"0.584031... | 0.7103051 | 0 |
configure the bundle to be explicit | def bundle(bundle_name, type, *filelist)
raise "Invalid bundle type, must be one of #{VALID_TYPES.inspect}" unless VALID_TYPES.include?(type)
# verify ordered files exist
basedir = type_to_path(type)
filelist.each do|name|
path = File.join(basedir, bundle_name.to_s, name)
path << ".#{type.to_s}" unless path.match(/\.#{type.to_s}$/)
raise "Missing reference to file: #{name} at #{path}" unless File.exist?(path)
# add a reference
@bundles[type] ||= {}
@bundles[type][bundle_name] ||= []
@bundles[type][bundle_name] << {:name => name, :path => path}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bundle_install_options\n super + [\"--deployment\"]\n end",
"def bundle()\n puts \"TODO\"\n end",
"def bundle()\n merge(notbundle: 'true')\n end",
"def run_bundle; end",
"def run_bundle ; end",
"def run_bundle ; end",
"def is_bundle=(value)\n @... | [
"0.6550137",
"0.65347403",
"0.632019",
"0.6276555",
"0.62735474",
"0.62735474",
"0.6103117",
"0.60947675",
"0.59797347",
"0.59339964",
"0.5825996",
"0.5825418",
"0.5805666",
"0.57763594",
"0.57730204",
"0.5745918",
"0.5724572",
"0.57109284",
"0.5654736",
"0.5654736",
"0.56384... | 0.0 | -1 |
convenience method, just returns the single user | def fetch_user(id)
fetch( :user, id ).last_result_item
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user(user_id)\n return User.find(user_id)\n end",
"def user\n return User.current unless user_id\n user = User.get_from_cache(user_id)\n user || User.first({:id => user_id})\n end",
"def get_user()\n user = User.first(:id => self.user_id)\n if !user\n user = User.new\n ... | [
"0.8314722",
"0.81571144",
"0.807154",
"0.79991573",
"0.7980551",
"0.7950126",
"0.7905087",
"0.7904401",
"0.7870491",
"0.78532445",
"0.7846037",
"0.7824632",
"0.7806468",
"0.7765938",
"0.7704619",
"0.76927525",
"0.767816",
"0.7677772",
"0.7640682",
"0.76257837",
"0.7605529",
... | 0.0 | -1 |
The default stitching is a board of square tiles Inherit & overwrite these as necessary | def stitching(x, y)
# Return only what's already been generated (that is, what's above and to the left).
return [:normal, [
([x - 1, y] if x > 0),
([x - 1, y - 1] if x > 0 and y > 0),
([x, y - 1] if y > 0),
([x + 1, y - 1] if y > 0 and x < @field_width - 1)
].compact]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def place_knights\r\n $board[1][0] = Knight.new('white')\r\n\t\t$board[6][0] = Knight.new('white')\r\n\t\t$board[1][7] = Knight.new('black')\r\n\t\t$board[6][7] = Knight.new('black')\r\n end",
"def reset(cols, rows)\n\t\t@holeSize = 3 + rand(2)\n\t\t@holeHeight = rows / 4 + rand * (rows / 2)\n\t\t@tubePositi... | [
"0.61197764",
"0.60431886",
"0.59968626",
"0.5990148",
"0.5925573",
"0.59176254",
"0.5896609",
"0.58956623",
"0.5866875",
"0.5858822",
"0.58477473",
"0.5846091",
"0.583172",
"0.5825306",
"0.57986695",
"0.5786398",
"0.57670075",
"0.57513285",
"0.57303077",
"0.5724194",
"0.5711... | 0.6045129 | 1 |
Public Methods Process => Validate, setup all appropriate request data, and register contexts => Return self | def process
raise RequestValidationError unless validate
@roles = get_roles
@user = get_or_create_user
@resource = get_resource
@assignment = get_assignment
@space = get_space
@space_user = get_or_create_space_user
register
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process\n klass.new(request).process\n end",
"def perform\n\n r = validate\n return r unless r.success?\n\n process_hook\n\n end",
"def run(*params)\n setup!(*params) # where do we assign/find the model?\n\n [process(*params), @valid].reverse\n end",
"def pr... | [
"0.64535993",
"0.60113144",
"0.60081416",
"0.5862405",
"0.5718233",
"0.56996",
"0.56746596",
"0.5672537",
"0.563901",
"0.5611255",
"0.5554513",
"0.554773",
"0.55267185",
"0.55062586",
"0.54888093",
"0.54832774",
"0.5472991",
"0.54684776",
"0.5447625",
"0.5411495",
"0.5409127"... | 0.73026836 | 0 |
Helper function to expect a class to have a set of options defined. These options are not firstclass citizens of puppet, but instead a keyvalue map. So regular rspec matchers don't help. To stay DRY, introduce this helper. | def expect_option(klass, key, val)
# test each option
it do
should contain_class(klass).with_options(
lambda do |map|
if map[key] == val
true
else
fail "#{klass} option #{key.inspect} doesn't match (-- expected, ++ actual):\n"\
"-- #{val.inspect}\n"\
"++ #{map[key].inspect}\n"
end
end
)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expect_option(klass, key, val)\n # test each option\n it do\n should contain_class(klass).with_options(\n lambda do |map|\n # check\n if map[key] == wrap_expected(val)\n true\n else\n fail \"#{klass} option #{key.inspect} doesn't match (-- expected, ++ actual):\... | [
"0.7172928",
"0.678551",
"0.6163496",
"0.6143392",
"0.58016455",
"0.57745785",
"0.5760239",
"0.5745142",
"0.57433367",
"0.5733813",
"0.5724448",
"0.5716634",
"0.57087576",
"0.5706889",
"0.5699857",
"0.5690678",
"0.5689048",
"0.5671607",
"0.5663806",
"0.5651863",
"0.5648074",
... | 0.71979326 | 0 |
add new books to library | def add_book(book)
@books << book
@book_status[book.title] = book.get_status
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_book(book)\n @books << book\n puts \"Added \" + book.title + \" to the library.\"\n end",
"def add_new_library_book\n\t\tputs \"To add new book to library, You need to enter book name and book's author name\"\n\t\tprint \"\\tEnter New Book name:\"\n\t\tnew_book_name=gets.chomp\n\t\tprint \"\\tEnte... | [
"0.82015294",
"0.808889",
"0.79042834",
"0.7871736",
"0.7861397",
"0.7769984",
"0.7750974",
"0.77293766",
"0.76724565",
"0.76467663",
"0.7630567",
"0.7591981",
"0.7506425",
"0.74597526",
"0.72975314",
"0.7232313",
"0.7223413",
"0.7190821",
"0.7181932",
"0.7122811",
"0.7107612... | 0.7364022 | 14 |
get list of current books | def book_list
puts "Here are the books in our library:"
@books.each { |book| puts "#{book.name}" }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list\n @books = Book.all\n end",
"def list_books\n @books.each do |books|\n puts books.title + \" is currently \" + books.status + \".\"\n end\n end",
"def list_books\n @books.each { |book| puts \"#{book.title} - #{book.author} : #{book.status}\"}\n end",
"def list_books\n @books.e... | [
"0.80968136",
"0.8096255",
"0.805572",
"0.8028576",
"0.79529315",
"0.79529315",
"0.79170257",
"0.7869154",
"0.7852637",
"0.78347653",
"0.7792328",
"0.76236504",
"0.75693256",
"0.7561943",
"0.75227135",
"0.7455525",
"0.7428323",
"0.7422485",
"0.7408384",
"0.7408384",
"0.740838... | 0.80696136 | 2 |
get list of current available books | def available_books
puts "Available Books:"
@book_status.each { |k, v| puts "#{k}" if v == "available" }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def available_books\n @books.each do |book|\n if book.status == \"available\"\n puts \"#{book.title} by #{book.author} is available.\"\n end\n end\n end",
"def available_books\n @books.select { |book| book.status == 'available' }\n end",
"def available\n @books = Book.all\n end"... | [
"0.821038",
"0.8146145",
"0.8103563",
"0.8034198",
"0.78797823",
"0.77441853",
"0.77196896",
"0.7670728",
"0.7670728",
"0.7607577",
"0.75827783",
"0.75540465",
"0.75470656",
"0.75229883",
"0.75056064",
"0.7451121",
"0.7438426",
"0.7419048",
"0.7416641",
"0.7391632",
"0.726700... | 0.8305527 | 0 |
get list of current borrowed books | def borrowed_books
puts "Borrowed Books:"
@book_status.each { |k, v| puts "#{k}" if v == "checked_out" }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def borrowed_books_list\n @borrowed_books.each do |book|\n puts \"#{book.title} by #{book.author}\"\n end\n end",
"def borrowed_books_list\n @borrowed_books.each {|book| puts \"'#{book.title}' by #{book.author}\" }\n end",
"def borrowed_books\n @borrowed_books\n end",
"def borrowed_books\... | [
"0.8493122",
"0.8485885",
"0.8048137",
"0.8048137",
"0.8036679",
"0.80096036",
"0.770446",
"0.76775086",
"0.7544679",
"0.7441755",
"0.7373068",
"0.7373068",
"0.7373068",
"0.7308638",
"0.7308638",
"0.72465485",
"0.71922845",
"0.71463466",
"0.7137135",
"0.7105979",
"0.70724905"... | 0.76176375 | 8 |
get a list of books and associated borrowers who have them checked out | def who_has_what
@who_has_book.each do |k, v|
puts "#{k}: #{v}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def borrowed_books\n @books.each do |book|\n if book.status == \"checked out\"\n puts \"#{book.title} by #{book.author}: Checked out by #{book.borrower.name}.\"\n end\n end\n end",
"def borrowed_books\n @books.select { |book| book.status == 'checked_out' }\n end",
"def borrowed_book... | [
"0.77372646",
"0.7669424",
"0.7510868",
"0.7384308",
"0.73736984",
"0.71874225",
"0.71434414",
"0.7088372",
"0.70500267",
"0.70134974",
"0.6971864",
"0.694846",
"0.6884953",
"0.6782223",
"0.6782223",
"0.66567093",
"0.66146207",
"0.6606853",
"0.6599217",
"0.6553294",
"0.647276... | 0.0 | -1 |
get borrower's checkedout books | def add_my_books(book)
@my_books << book.title
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def borrowed_books\n @books.each do |book|\n if book.status == \"checked out\"\n puts \"#{book.title} by #{book.author}: Checked out by #{book.borrower.name}.\"\n end\n end\n end",
"def currently_checked_out_books\n # Select all checkouts that are active (checked out) and returns a... | [
"0.80825424",
"0.8031436",
"0.8022487",
"0.7895307",
"0.787718",
"0.78391045",
"0.78195703",
"0.78195703",
"0.77343357",
"0.7701199",
"0.7679688",
"0.74925995",
"0.7437474",
"0.741272",
"0.7409224",
"0.7364294",
"0.7230866",
"0.7230866",
"0.71825236",
"0.7146887",
"0.7138314"... | 0.0 | -1 |
get book's current status | def get_status
status
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def status(book)\n\t\tif book.status == \"available\"\n\t\t\tputs \"#{book.title} is not checked out.\"\n\t\telse\n\t\t\tputs \"#{book.title} is checked out. Please try again later.\"\t\t\n\t\tend \n\tend",
"def get_book_info(book)\n if book.status = available\n\t\t puts \"#{book.title} is currently availabl... | [
"0.7583656",
"0.75706863",
"0.7349699",
"0.7275047",
"0.7275047",
"0.7203799",
"0.71825325",
"0.71825325",
"0.7171333",
"0.7171333",
"0.7136064",
"0.7127748",
"0.7112571",
"0.7110476",
"0.7088622",
"0.7071286",
"0.706601",
"0.7026579",
"0.6983958",
"0.6983745",
"0.6983745",
... | 0.7299398 | 3 |
prints book's current status | def print_status
puts "#{status}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def status(book)\n\t\tif book.status == \"available\"\n\t\t\tputs \"#{book.title} is not checked out.\"\n\t\telse\n\t\t\tputs \"#{book.title} is checked out. Please try again later.\"\t\t\n\t\tend \n\tend",
"def get_book_info(book)\n if book.status = available\n\t\t puts \"#{book.title} is currently availabl... | [
"0.8002259",
"0.7544418",
"0.73484236",
"0.7245971",
"0.70691013",
"0.70116425",
"0.70007265",
"0.6962276",
"0.69563866",
"0.6937367",
"0.6900952",
"0.6826163",
"0.68155986",
"0.67655575",
"0.6747564",
"0.66894835",
"0.66432345",
"0.66406226",
"0.6589331",
"0.6513183",
"0.650... | 0.71367043 | 4 |
change book's current status | def change_status
if status.include?("available")
status = "checked_out"
elsif status.include?("checked_out")
status = "available"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_book_status\n @book_status = BookStatus.find(params[:id])\n end",
"def set_bookstatus\n @bookstatus = Bookstatus.find(params[:id])\n end",
"def is_lost\r\n\t\tbook.status = 'Lost'\r\n\tend",
"def status(book)\n\t\tif book.status == \"available\"\n\t\t\tputs \"#{book.title} is not chec... | [
"0.73006505",
"0.7125522",
"0.70472693",
"0.7015082",
"0.6951112",
"0.6818929",
"0.6708869",
"0.66592616",
"0.66592544",
"0.665515",
"0.6630387",
"0.66065747",
"0.65960467",
"0.6586793",
"0.6546079",
"0.6508952",
"0.64928216",
"0.64711815",
"0.6462325",
"0.6435405",
"0.642727... | 0.69158626 | 5 |
Initialises a new instance; it's probably easier to use one of the subclass constructors. | def initialize(name, aes_size, sha_size, alg)
@name = name
@aes_size = aes_size
@sha_size = sha_size
@cipher_name = "aes-#{aes_size}-cbc"
@alg = alg
@digest = OpenSSL::Digest.new("sha#{@sha_size}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def constructor; end",
"def initialize() end",
"def initialize(*) end",
"def initialize(*) end",
"def initialize(*) end",
"def initialize(*) end",
"def initialize(*) end",
"def initialize()\n raise \"#{self.class.to_s} should not be instantiated directly.\"\n end",
"def new()\n #... | [
"0.78590393",
"0.782267",
"0.7782394",
"0.7782394",
"0.7782394",
"0.7782394",
"0.7782394",
"0.77448875",
"0.76544297",
"0.7587664",
"0.7587664",
"0.7587664",
"0.7587664",
"0.7587664",
"0.7587664",
"0.7587664",
"0.7587664",
"0.7587664",
"0.7587664",
"0.7587664",
"0.75645834",
... | 0.0 | -1 |
Encrypts a token payload. | def encrypt(header, payload)
key = get_encryption_key
mac_key, enc_key = derive_keys(key)
encrypted_key = @alg.encrypt_key(key)
cipher = OpenSSL::Cipher.new(@cipher_name).encrypt
cipher.key = enc_key
cipher.iv = iv = SecureRandom.random_bytes(16)
ciphertext = cipher.update(payload) + cipher.final
auth_data = Sandal::Util.jwt_base64_encode(header)
auth_data_length = [auth_data.length * 8].pack("Q>")
mac_input = [auth_data, iv, ciphertext, auth_data_length].join
mac = OpenSSL::HMAC.digest(@digest, mac_key, mac_input)
auth_tag = mac[0...(mac.length / 2)]
remainder = [encrypted_key, iv, ciphertext, auth_tag].map { |part| Sandal::Util.jwt_base64_encode(part) }
[auth_data, *remainder].join(".")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encrypt_token(password, token)\n key = obtain_key(password)\n cipher = OpenSSL::Cipher::AES256.new(:CBC)\n cipher.encrypt\n cipher.key = key\n @iv = cipher.random_iv\n @encrypted_token = cipher.update(token) + cipher.final\n end",
"def encrypt_token *args\n raw = [\"Ra... | [
"0.72000957",
"0.7030947",
"0.69518614",
"0.6934157",
"0.6817055",
"0.68026245",
"0.67568296",
"0.6744234",
"0.67320013",
"0.6683996",
"0.667373",
"0.6665103",
"0.6645568",
"0.66204506",
"0.66085553",
"0.6566169",
"0.65581423",
"0.6543872",
"0.6524992",
"0.650559",
"0.6493372... | 0.6574249 | 15 |
Decrypts an encrypted JSON Web Token. | def decrypt(token)
parts, decoded_parts = Sandal::Enc.token_parts(token)
header, encrypted_key, iv, ciphertext, auth_tag = *decoded_parts
key = @alg.decrypt_key(encrypted_key)
mac_key, enc_key = derive_keys(key)
auth_data = parts[0]
auth_data_length = [auth_data.length * 8].pack("Q>")
mac_input = [auth_data, iv, ciphertext, auth_data_length].join
mac = OpenSSL::HMAC.digest(@digest, mac_key, mac_input)
unless auth_tag == mac[0...(mac.length / 2)]
raise Sandal::InvalidTokenError, "Invalid authentication tag."
end
cipher = OpenSSL::Cipher.new(@cipher_name).decrypt
begin
cipher.key = enc_key
cipher.iv = decoded_parts[2]
cipher.update(decoded_parts[3]) + cipher.final
rescue OpenSSL::Cipher::CipherError => e
raise Sandal::InvalidTokenError, "Cannot decrypt token: #{e.message}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decrypt_token(data)\n cipher = OpenSSL::Cipher::AES.new(128, :CBC)\n cipher.decrypt\n cipher.key = @client_secret.byteslice(0..15)\n cipher.iv = @client_id.byteslice(0..15)\n json = cipher.update(data) + cipher.final\n JSON.parse(json)\n end",
"def decrypt_jwt\n begin\n ... | [
"0.7827826",
"0.7544373",
"0.74195147",
"0.6899909",
"0.6870497",
"0.6849893",
"0.67728925",
"0.67592233",
"0.6749598",
"0.67491424",
"0.6735458",
"0.67055154",
"0.6631554",
"0.6628709",
"0.65307546",
"0.65154064",
"0.6497516",
"0.64950633",
"0.6478973",
"0.6478899",
"0.64678... | 0.66622645 | 12 |
Gets the key to use for mac and encryption | def get_encryption_key
key_bytes = @sha_size / 8
if @alg.respond_to?(:preshared_key)
key = @alg.preshared_key
unless key.size == key_bytes
raise Sandal::KeyError, "The pre-shared content key must be #{@sha_size} bits."
end
key
else
SecureRandom.random_bytes(key_bytes)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_key\n @key = Base64.decode64('MzRlZTc5ODMtNWVlNi00MTQ3LWFhODYtNDQzZWEwNjJhYmY3NzQ0OTNkNmEtMmExNS00M2ZlLWFhY2UtZTc4NTY2OTI3NTg1Cg==')\n end",
"def crypto_key\n # Returns singleton object\n EmailEncryptionKey.instance.key\n end",
"def get_crypto_key_hex\n return @crypto_key if ! @crypto... | [
"0.7500222",
"0.7319265",
"0.72643584",
"0.703711",
"0.6933901",
"0.6887599",
"0.67987984",
"0.67661184",
"0.6755895",
"0.669948",
"0.6574078",
"0.65711313",
"0.6531993",
"0.6476435",
"0.64588434",
"0.64533705",
"0.64533705",
"0.6425864",
"0.6423998",
"0.6421576",
"0.64196146... | 0.6490919 | 13 |
Derives the mac key and encryption key | def derive_keys(key)
derived_key_size = key.size / 2
mac_key = key[0...derived_key_size]
enc_key = key[derived_key_size..-1]
return mac_key, enc_key
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_crypto_key_hex\n return @crypto_key if ! @crypto_key\n @crypto_key.unpack(\"H*\")\n end",
"def crypto_key\n # Returns singleton object\n EmailEncryptionKey.instance.key\n end",
"def key(hash160)\n key = Bitcoin::Key.new\n key.priv = hash160\n key\n end",
"def key(hash160)\n ... | [
"0.67573506",
"0.6469433",
"0.6421602",
"0.6187748",
"0.6174795",
"0.6153859",
"0.61152786",
"0.6113035",
"0.6106023",
"0.6080731",
"0.6058705",
"0.6050827",
"0.60343266",
"0.6021635",
"0.6020837",
"0.60139185",
"0.60079",
"0.59283787",
"0.5915352",
"0.5915091",
"0.5907426",
... | 0.7485602 | 0 |
Initialises a new instance. | def initialize(alg)
super(NAME, KEY_SIZE / 2, KEY_SIZE, alg)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n init\n end",
"def initialize\n initialize!\n end",
"def initialize\n initialize!\n end",
"def initialize()\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n ... | [
"0.773726",
"0.76945853",
"0.76945853",
"0.7577139",
"0.75688547",
"0.7566295",
"0.7566295",
"0.7566295",
"0.7566295",
"0.7566295",
"0.7566295",
"0.75623906",
"0.75091994",
"0.73299444",
"0.72947663",
"0.72947663",
"0.72947663",
"0.72947663",
"0.72947663",
"0.72947663",
"0.72... | 0.0 | -1 |
Initialises a new instance. | def initialize(alg)
super(NAME, KEY_SIZE / 2, KEY_SIZE, alg)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize\n init\n end",
"def initialize\n initialize!\n end",
"def initialize\n initialize!\n end",
"def initialize()\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n ... | [
"0.773726",
"0.76945853",
"0.76945853",
"0.7577139",
"0.75688547",
"0.7566295",
"0.7566295",
"0.7566295",
"0.7566295",
"0.7566295",
"0.7566295",
"0.75623906",
"0.75091994",
"0.73299444",
"0.72947663",
"0.72947663",
"0.72947663",
"0.72947663",
"0.72947663",
"0.72947663",
"0.72... | 0.0 | -1 |
If an error occurs, set the response status to 500 and call the error handler. | def _roda_handle_main_route
begin
res = super
ensure
_roda_after(res)
end
rescue *opts[:error_handler_classes] => e
_handle_error(e)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error_500\n if !request.xhr?\n render :template => \"errors/500\", :status => \"500 Internal Server Error\"\n else\n respond_to do |format|\n format.json {render :json => {\n :error => \"500\",\n }, :status => \"... | [
"0.8084791",
"0.80613744",
"0.8007675",
"0.79165703",
"0.78441066",
"0.78001463",
"0.7739065",
"0.75448465",
"0.7540432",
"0.74953777",
"0.7429068",
"0.7420174",
"0.73963326",
"0.73265415",
"0.7319743",
"0.7236823",
"0.7196397",
"0.715707",
"0.7148659",
"0.705529",
"0.7054215... | 0.0 | -1 |
Default empty implementation of _roda_after, usually overridden by Roda.def_roda_before. | def _roda_after(res)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def def_roda_after\n meths = private_instance_methods.grep(/\\A_roda_after_\\d\\d/).sort\n unless meths.empty?\n plugin :error_handler unless private_method_defined?(:_roda_after)\n if meths.length == 1\n class_eval(\"alias _roda_after #{meths.first}\", __FILE__... | [
"0.81931144",
"0.6234094",
"0.6234094",
"0.5841248",
"0.58328044",
"0.57832104",
"0.5742591",
"0.569086",
"0.56727916",
"0.5619244",
"0.55398107",
"0.55398107",
"0.5523276",
"0.54220074",
"0.5413007",
"0.53838795",
"0.5372664",
"0.5365784",
"0.5365784",
"0.5365784",
"0.536578... | 0.7350155 | 1 |
Handle the given exception using handle_error, using a default status of 500. Run after hooks on the rack response, but if any error occurs when doing so, log the error using rack.errors and return the response. | def _handle_error(e)
res = @_response
res.send(:initialize)
res.status = 500
res = _roda_handle_route{handle_error(e)}
begin
_roda_after(res)
rescue => e2
if errors = env['rack.errors']
errors.puts "Error in after hook processing of error handler: #{e2.class}: #{e2.message}"
e2.backtrace.each{|line| errors.puts(line)}
end
end
res
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_exception(exception, request, response)\n response.flush\n response.status = 500\n\n if config.development?\n response.content_type = \"text/html\"\n response.puts(Rack::ShowExceptions.new(nil).pretty(request.env, exception))\n else\n response.layout = \"layouts/... | [
"0.731188",
"0.7174244",
"0.7033307",
"0.6968687",
"0.6931454",
"0.6908432",
"0.68350697",
"0.67627835",
"0.6713306",
"0.65973717",
"0.65823203",
"0.65475065",
"0.65432066",
"0.65420574",
"0.65269786",
"0.65223503",
"0.650062",
"0.65005255",
"0.6499815",
"0.64948493",
"0.6478... | 0.73504764 | 0 |
By default, have the error handler reraise the error, so using the plugin without installing an error handler doesn't change behavior. | def handle_error(e)
raise e
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_error error\n raise error\n end",
"def error_handler()\n @error_handler\n end",
"def load_plugin_failed(name, exception); end",
"def handle_perform_error(_e); end",
"def error_handler\n @error_handler || DEFAULT_ERROR_HANDLER\n end",
"def safe_run\n run\n re... | [
"0.63501745",
"0.63232166",
"0.6296712",
"0.6173001",
"0.6118793",
"0.61060685",
"0.60580313",
"0.60235834",
"0.60235834",
"0.5972303",
"0.59628636",
"0.5955065",
"0.5936267",
"0.59330046",
"0.58835405",
"0.5874568",
"0.58693206",
"0.5846903",
"0.5846903",
"0.5846903",
"0.584... | 0.57939947 | 25 |
Sets all of the required and the optional attributes. | def initialize(options = {})
@id = options[:id]
@x_origin = options[:x_origin]
@y_origin = options[:y_origin]
set_options(options)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attr_required(*attr_names)\n @required_attrs ||= []\n @required_attrs += attr_names\n attr_accessor(*attr_names)\n end",
"def set_attributes\n self.paid = is_paid?\n self.amount = amount_to_set if amount_to_set\n self.status = capture_status if... | [
"0.66818255",
"0.66603273",
"0.6531071",
"0.63768125",
"0.63477355",
"0.63477355",
"0.6323797",
"0.63057363",
"0.62776846",
"0.6205068",
"0.6172358",
"0.6123336",
"0.61230844",
"0.609781",
"0.609781",
"0.6092469",
"0.60563517",
"0.60498506",
"0.6005111",
"0.6002007",
"0.59788... | 0.0 | -1 |
Formats the output ready for a print job. This does not include escape characters. Example: PF001;ABCDE1234 | def formatted(separator = ';')
"#{prefix}#{id}#{separator}#{control_codes}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display\n puts \" 0 1 2 3 4 5 6 7 \"\n puts \"#{format}\"\n end",
"def print output_formatter\n output_formatter.print({ \"Commits:\" => @commits, \"Standard churn:\" => @result, \"Deletions:\" => @deletions, \"Insertions:\" => @insertions })\n end",
"def format(text); end",
"d... | [
"0.6214708",
"0.62108475",
"0.6137955",
"0.60222536",
"0.60222536",
"0.60222536",
"0.60222536",
"0.60222536",
"0.60222536",
"0.60222536",
"0.60222536",
"0.6014265",
"0.5984492",
"0.5954122",
"0.5916429",
"0.5916429",
"0.5916429",
"0.5889493",
"0.5864472",
"0.58469",
"0.582326... | 0.55058146 | 36 |
Set the id and value | def initialize(id, value)
@id = id
@value = value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_ID(value)\n set_input(\"ID\", value)\n end",
"def set_ID(value)\n set_input(\"ID\", value)\n end",
"def set_ID(value)\n set_input(\"ID\", value)\n end",
"def set_ID(value)\n set_input(\"ID\", value)\n end",
"def set_ID(value)\n ... | [
"0.8087808",
"0.8042741",
"0.8042741",
"0.8042741",
"0.8042741",
"0.80413914",
"0.80413914",
"0.80413914",
"0.80413914",
"0.80413914",
"0.80413914",
"0.80413914",
"0.80413914",
"0.80404854",
"0.80404854",
"0.80404854",
"0.7918111",
"0.7839612",
"0.7839612",
"0.7839612",
"0.78... | 0.70565283 | 52 |
The standard commands which never change. | def standard_commands
{
'C' => Commands::ClearImageBuffer,
'T' => Commands::Feed,
'XS' => Commands::Issue
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def commands\n {}\n end",
"def commands; end",
"def commands\n @commands ||= []\n end",
"def get_commands\n return nil\n end",
"def commands\n @@commands.dup\n end",
"def commands\n COMMANDS\n end",
"def commands\n load_commands unless @commands\n @commands... | [
"0.7855798",
"0.77812415",
"0.76808256",
"0.76807827",
"0.7663106",
"0.7656751",
"0.75898874",
"0.7530471",
"0.75160503",
"0.7499065",
"0.7473173",
"0.74081194",
"0.74054396",
"0.7366237",
"0.7355058",
"0.731455",
"0.7310965",
"0.73096603",
"0.72974914",
"0.7296988",
"0.72390... | 0.7909898 | 0 |
Take a list of commands and execute them. Returns an array of objects. In the case of standard commands will just create a new command. With a derived command it will execute the method. A derived command may itself contain a list of commands so the whole thing is flattened to produce a single array. | def commands
@commands ||= [].tap do |c|
commands_list.each do |command|
if command.instance_of? String
c << standard_commands[command].new
else
ret_command = send(command)
c << (ret_command.instance_of?(Hash) ? ret_command.values : ret_command)
end
end
end.flatten
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invoke_all #:nodoc:\n self.class.all_commands.map { |_, command| invoke_command(command) }\n end",
"def commands\n return [] unless options[\"commands\"]\n options[\"commands\"].map do |options|\n options['parents'] = parents + [name]\n Command.new options\n end... | [
"0.71134484",
"0.7039111",
"0.70300555",
"0.70222014",
"0.6867172",
"0.68665916",
"0.67523247",
"0.67329425",
"0.6723371",
"0.67002696",
"0.66542965",
"0.6629754",
"0.6566343",
"0.65500635",
"0.64870524",
"0.6472526",
"0.6455409",
"0.6412508",
"0.641077",
"0.6380616",
"0.6377... | 0.7644019 | 0 |
Telling devise to allow custom fields on new user registration and user registration edit | def configure_permitted_marameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:name])
devise_parameter_sanitizer.permit(:account_update, keys: [:name])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configure_permitted_parameters\n devise_parameter_sanitizer.permit(:sign_up, keys: [:name, :cpf, :user_type, phone_number_attributes: [:user_id, :phone_number]])\n devise_parameter_sanitizer.permit(:edit, keys: [:name, :cpf, :user_type, phone_number_attributes: [:user_id, :phone_number]])\n end",
"def... | [
"0.65128386",
"0.6455171",
"0.64283127",
"0.63349026",
"0.63101685",
"0.6307707",
"0.6298371",
"0.6279234",
"0.626926",
"0.6265694",
"0.62482095",
"0.62464464",
"0.62420064",
"0.6212567",
"0.62057674",
"0.61985266",
"0.6183548",
"0.6170937",
"0.615491",
"0.6146501",
"0.613007... | 0.0 | -1 |
Registers a new property in `config.rb`. If you use this method, you should also define two additional methods: comment_for_$name emits a comment against the properly into the configuration file when serialized default_$name provides a default value for the property when one isn't specified in the configuration file | def add_property(name)
Compass::Configuration::ATTRIBUTES.push(name)
inherited_accessor(name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_property(name, default = nil)\n add_property_default(name, default)\n attr_accessor(name)\n end",
"def add_property(name, default = nil)\n self.add_property_default(name, default)\n attr_accessor(name)\n end",
"def define_setting(name, default = nil)\n class_variable_se... | [
"0.6922837",
"0.6874012",
"0.61953694",
"0.6061913",
"0.6009421",
"0.5909298",
"0.5906379",
"0.59018177",
"0.58869696",
"0.58383566",
"0.5783642",
"0.5728513",
"0.57229763",
"0.57152",
"0.5654162",
"0.56460726",
"0.56389827",
"0.5637876",
"0.561328",
"0.5606757",
"0.55813926"... | 0.5761557 | 11 |
Converts a Cygwin Unix path to a Windows path, e.g.: /cygdrive/d/path/to/file ==> D:/path/to/file | def cygwin_path(path)
if RUBY_PLATFORM.include?('cygwin') && path.index('/') == 0
IO.popen("cygpath -m #{path.include?(':') ? '-p' : ''} #{path.shellescape}").readline.chomp.gsub(/;/, '\\;')
else
path
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def makeWindowsPathIntoMinGWPath(path)\n modifiedPath = path.gsub(/\\\\/, '/')\n modifiedPath.gsub(/^(\\w+):[\\\\\\/]/) { \"/#{$1.downcase}/\" }\nend",
"def windows_path(path)\n path.gsub(/\\//, '\\\\')\n end",
"def to_windows_path(path)\n path.gsub('/', \"\\\\\")\n end",
"def makeWindo... | [
"0.7466854",
"0.74545604",
"0.7454556",
"0.7245687",
"0.70774406",
"0.68850356",
"0.68850356",
"0.6841165",
"0.6809859",
"0.67986107",
"0.67639595",
"0.6714192",
"0.66852015",
"0.6679233",
"0.667161",
"0.6664879",
"0.6618574",
"0.656552",
"0.6312081",
"0.62101406",
"0.6208756... | 0.8176252 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.