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 |
|---|---|---|---|---|---|---|
GET /surgeries/1 GET /surgeries/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @surgeries = Surgery.all\n end",
"def index\n @surgeries = Surgery.all\n end",
"def surgery_name_list\n\t\tsurgeries = current_user.surgeries\n\t\tif surgeries.present?\n\t\t# response to the JSON\n \t render json: { success: true, response: {surgeries: surgeries.collect(&:name).as_js... | [
"0.68215907",
"0.68215907",
"0.64664173",
"0.60792726",
"0.5848986",
"0.58368206",
"0.575722",
"0.57187206",
"0.56963193",
"0.56569594",
"0.5653277",
"0.5641617",
"0.5638659",
"0.56322944",
"0.56272936",
"0.56244427",
"0.5617362",
"0.5598971",
"0.5576895",
"0.5540252",
"0.553... | 0.0 | -1 |
POST /surgeries POST /surgeries.json | def create
# Initializing the surgery the params
@surgery = devise_current_user.surgeries.new(surgery_params)
# saving the surgery save after that redirect to the surgeries index page
if @surgery.save
redirect_to surgeries_path
else
# else redirect to the same page of the surgery
redirect_to :back
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @surgeries = Surgery.all\n end",
"def index\n @surgeries = Surgery.all\n end",
"def create\n @surgery = Surgery.new(params[:surgery])\n\n respond_to do |format|\n if @surgery.save\n format.html { redirect_to @surgery, notice: 'Surgery was successfully created.' }\n ... | [
"0.61305094",
"0.61305094",
"0.6031113",
"0.5936804",
"0.58223677",
"0.5785059",
"0.5736796",
"0.5622155",
"0.54896826",
"0.54663295",
"0.54391634",
"0.5414384",
"0.5395321",
"0.53423953",
"0.53045684",
"0.52957374",
"0.52830577",
"0.5280918",
"0.5242118",
"0.5230695",
"0.522... | 0.60885787 | 2 |
PATCH/PUT /surgeries/1 PATCH/PUT /surgeries/1.json | def update
# Updating the particular surgery and after update redirecto toe surgries page
if @surgery.update(surgery_params)
redirect_to surgeries_path
else
# else redirect to the same page surgery
redirect_to :back
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n if @person.seat\n render json: {errors: 'Cannot update a seated person'}, status: 422\n else\n @person.update person_params\n render json: @person\n end\n end",
"def update\n @surgery = Surgery.find(params[:id])\n\n respond_to do |format|\n if @surgery.update_attr... | [
"0.642432",
"0.64216095",
"0.6362022",
"0.6230579",
"0.6190886",
"0.61774284",
"0.6166517",
"0.60608333",
"0.60224664",
"0.6012223",
"0.5957312",
"0.5900556",
"0.58719105",
"0.58699477",
"0.5867168",
"0.5848815",
"0.5847209",
"0.58368814",
"0.5827533",
"0.581599",
"0.5770683"... | 0.57580376 | 22 |
DELETE /surgeries/1 DELETE /surgeries/1.json | def destroy
@surgery.destroy
respond_to do |format|
format.html { redirect_to surgeries_url, notice: 'Surgery was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @surgery = Surgery.find(params[:id])\n @surgery.destroy\n\n respond_to do |format|\n format.html { redirect_to surgeries_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fridge = Fridge.find(params[:id])\n @fridge.destroy\n\n respond_to do |form... | [
"0.7182643",
"0.67730254",
"0.67230374",
"0.6630993",
"0.6616279",
"0.66024643",
"0.65978736",
"0.6595678",
"0.6594261",
"0.6591922",
"0.6575546",
"0.6570498",
"0.6569284",
"0.654879",
"0.65446955",
"0.65432924",
"0.65346247",
"0.6517912",
"0.6517912",
"0.6482941",
"0.6481099... | 0.64824486 | 21 |
Method for search the surgery names | def surgery_search
# Search for the speciality names
@surgeries = find_surgery_term(params[:surgeryterm])
# respond to rendering the pages
respond_to do |format|
format.js
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_surgery\n\t\t# Searching for surgery as per user entered term\n\t\tif Surgery.where(user_type: \"admin\").any_of({ :name => /^#{params[:term]}/i }).present?\n\t\t\t# if search show from the admin then the search term from surgery of admin\n\t\t\tsurgeries = Surgery.where(user_type: \"admin\").any_of({ :... | [
"0.70865774",
"0.6948414",
"0.6447701",
"0.6417929",
"0.63556087",
"0.6207575",
"0.6091319",
"0.60365766",
"0.60101146",
"0.60049766",
"0.5953369",
"0.5876188",
"0.58475107",
"0.58171266",
"0.5816419",
"0.5768957",
"0.5758103",
"0.5746169",
"0.57448435",
"0.5700687",
"0.56794... | 0.669805 | 2 |
Use callbacks to share common setup or constraints between actions. | def set_surgery
@surgery = Surgery.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 surgery_params
params.require(:surgery).permit(:name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
Method for search the surgery term | def find_surgery_term surgeryterm
# Search the surgery terms
Surgery.where(user_type: "admin").any_of({ :name => /^#{surgeryterm}/i })
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_surgery\n\t\t# Searching for surgery as per user entered term\n\t\tif Surgery.where(user_type: \"admin\").any_of({ :name => /^#{params[:term]}/i }).present?\n\t\t\t# if search show from the admin then the search term from surgery of admin\n\t\t\tsurgeries = Surgery.where(user_type: \"admin\").any_of({ :... | [
"0.7489109",
"0.71838355",
"0.7124443",
"0.7071348",
"0.7062752",
"0.68411064",
"0.6829328",
"0.6821051",
"0.6799708",
"0.6770622",
"0.67631733",
"0.6725981",
"0.671604",
"0.66948384",
"0.66834325",
"0.66834325",
"0.66834325",
"0.66834325",
"0.66834325",
"0.66834325",
"0.6683... | 0.7859314 | 0 |
Method for cheking the user type | def check_user_type
# find the user
user = User.find(@surgery.user_id)
# condition for checking the admin is present or not
if user.admin == true
# if admin then update the user type as admin
@surgery.update(user_type: "admin")
else
# else user then update the user type as user
@surgery.update(user_type: "user")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_type; end",
"def check_user_type\n if self.user_type.present?\n self.contractor = self.user_type.to_s.downcase.include? \"contractor\"\n else\n self.contractor = false\n end\n end",
"def user_type\n\t\tif (current_user.type == 'Trainer')\n\t\t\ttrainer\n\t\telsif (current_user.type... | [
"0.7675585",
"0.75585",
"0.7380855",
"0.72564244",
"0.725392",
"0.71342456",
"0.71238893",
"0.70644027",
"0.7029367",
"0.69523215",
"0.68518215",
"0.6832593",
"0.6791029",
"0.67834175",
"0.6770133",
"0.67578083",
"0.6734221",
"0.67315376",
"0.67299163",
"0.67034715",
"0.67011... | 0.71222055 | 7 |
Renames the Service type from "type" to "service_type" to avoid conflicts | def rename_service_type(hash)
hash["service_type"] = hash["type"]
hash.delete("type")
hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def service_name\n raise TypeError, 'no type on this reply' unless\n instance_variable_defined? :@type\n\n @type.split('.').first.sub '_', ''\n end",
"def service_type_name\n \"\" \n end",
"def set_service_type\n @service_type = ServiceType.find(params[:id])\n end",
"def _ser... | [
"0.6752241",
"0.6633492",
"0.6623655",
"0.65550786",
"0.6356624",
"0.6350679",
"0.6260855",
"0.61445904",
"0.6143448",
"0.61054903",
"0.6100868",
"0.6057287",
"0.5906334",
"0.58981097",
"0.58810383",
"0.58692807",
"0.5853573",
"0.5847273",
"0.5810481",
"0.5793755",
"0.5725508... | 0.8576102 | 0 |
Create a new successful response | def success(output)
respond_with(Response::Success, output)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_success_response\n response = {\n body: {\n status: \"ok\"\n },\n status: 200\n }\n return response\n end",
"def new_response\n {:success => true}\n end",
"def create_success_response(message='')\n message = message.present? ? message : 'ok'\n response = {\n... | [
"0.8080813",
"0.8046698",
"0.75259787",
"0.7169528",
"0.6976638",
"0.69230324",
"0.6897721",
"0.68887573",
"0.68688375",
"0.6812383",
"0.6774347",
"0.6754712",
"0.6728282",
"0.6692494",
"0.6669174",
"0.6579711",
"0.6570765",
"0.6559044",
"0.65308756",
"0.65150386",
"0.6510562... | 0.6431265 | 32 |
Create a new failure response | def error(output)
respond_with(Response::Failure, output)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def failure\n {:response=>:failure}\n end",
"def fail_response(data={})\n status = data.delete(:status) || 400\n {\n status: status,\n json: {\n status: \"fail\",\n data: data\n }\n }\n end",
"def create_response(api_response, errors)\n Rails.logger.error \"#{Time.... | [
"0.7212774",
"0.7067432",
"0.70068365",
"0.6946382",
"0.6822346",
"0.6742092",
"0.660483",
"0.6565303",
"0.6549323",
"0.6520697",
"0.64870495",
"0.64820105",
"0.64443636",
"0.64108276",
"0.6385243",
"0.63821274",
"0.62842053",
"0.62665963",
"0.6264063",
"0.6239963",
"0.623038... | 0.67707795 | 5 |
Instantiate an instance of +klass+ and pass +output+ | def respond_with(klass, output)
klass.new(self, output)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(output)\n @output = output\n end",
"def initialize(output)\n @output = output\n end",
"def initialize(output)\n @output = output\n end",
"def initialize(output)\n @output = output\n end",
"def initialize(output)\n @output = output\n end... | [
"0.7180216",
"0.699429",
"0.699429",
"0.699429",
"0.6947501",
"0.6887096",
"0.6884629",
"0.67193204",
"0.66616166",
"0.6391762",
"0.6358704",
"0.6208677",
"0.6205884",
"0.6191878",
"0.61585855",
"0.6156144",
"0.61158764",
"0.60943145",
"0.6093336",
"0.6046234",
"0.59016114",
... | 0.7288034 | 0 |
This method is responsible for receiving the exchange_rate of a specific currency to the GBP from an API. | def find_rate()
uri_string = "https://free.currconv.com/api/v7/convert?q=GBP_"\
"#{@currency}&compact=ultra&apiKey=2d46a9b5b650dca0dbb1"
uri = URI(uri_string)
res = Net::HTTP.get_response(uri)
return(JSON.parse(res.body)["GBP_#{@currency}"]/100.0)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exchange_rate(to_currency)\n self.bank.exchange(self.base_currency, to_currency)\n end",
"def conv_exchange_rate\n currency_exchange.exchange_rate\n end",
"def get_exchange_rate(currencyCode)\n begin\n exhash = JSON.parse(exchange_rate)\n BigDecimal(exhash[currencyCode])\n rescue\n ... | [
"0.7444457",
"0.7184691",
"0.70807207",
"0.6828173",
"0.673572",
"0.67350835",
"0.66884565",
"0.66806954",
"0.66609746",
"0.6636957",
"0.6605665",
"0.6591344",
"0.6559951",
"0.65384525",
"0.65216565",
"0.64503866",
"0.64170665",
"0.6379565",
"0.63773113",
"0.635374",
"0.63455... | 0.72135526 | 1 |
puts "This is my first method!" end my_first_method def maths_two number = 2 + 2 puts number end maths_two | def my_math_method(num1, num2)
number = num1 + num2
puts number
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_math_method(num1, num2)\n sum = num1 + num2\n\tputs \"The sum of 2 + 2 is #{sum}\"\nend",
"def first_method(num_1, num_2)\n puts num_1 + num_2\nend",
"def my_math_method(num1, num2)\n\tanswer = num1 + num2\n\tputs \"The sum of #{num1} and #{num2} is #{answer}.\"\nend",
"def second_method\n puts... | [
"0.80283225",
"0.7977191",
"0.79619974",
"0.7734897",
"0.7718372",
"0.7708104",
"0.77013636",
"0.75006264",
"0.74790674",
"0.73886573",
"0.73772085",
"0.7348514",
"0.73257035",
"0.7293632",
"0.7219465",
"0.7195867",
"0.71928096",
"0.7190184",
"0.71810865",
"0.71699834",
"0.71... | 0.7958045 | 4 |
Forces the request format to be :mobile | def force_mobile_format
unless request.xhr?
request.format = :mobile
session[:mobile_view] = true if session[:mobile_view].nil?
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_mobile\n return if session[:mobylette_override] == :ignore_mobile\n if respond_as_mobile?\n request.format = set_mobile_format\n end\n end",
"def set_mobile_format\n if !mobile_exempt? && is_mobile_device? && !request.xhr?\n request.format = session[:mobile_vie... | [
"0.7999035",
"0.77233654",
"0.76544625",
"0.76544625",
"0.76067305",
"0.7598015",
"0.7591584",
"0.7575264",
"0.74661297",
"0.73907405",
"0.7111284",
"0.7108537",
"0.7048257",
"0.7028259",
"0.7027514",
"0.6986914",
"0.6967916",
"0.69441617",
"0.69310933",
"0.69310933",
"0.6923... | 0.7713949 | 3 |
Determines the request format based on whether the device is mobile or if the user has opted to use either the 'Standard' view or 'Mobile' view. | def set_mobile_format
if is_mobile_device? && !request.xhr?
request.format = session[:mobile_view] == false ? :html : :mobile
session[:mobile_view] = true if session[:mobile_view].nil?
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def determine_format\n mobile_request? ? mobile_format.to_sym : request.format.to_sym\n end",
"def in_mobile_view?\n return false unless request.format\n request.format.to_sym == :mobile\n end",
"def is_mobile_view?\n request.format.to_sym == :mobile\n end",
"def handle_mobile\... | [
"0.8514575",
"0.76423806",
"0.760539",
"0.7587628",
"0.7587628",
"0.7584652",
"0.755119",
"0.7549973",
"0.7497575",
"0.74893177",
"0.74883425",
"0.7488262",
"0.74511087",
"0.7411899",
"0.7411899",
"0.73184055",
"0.7303132",
"0.7218012",
"0.71842897",
"0.7073713",
"0.7073713",... | 0.75309813 | 8 |
Returns either true or false depending on whether or not the format of the request is either :mobile or not. | def in_mobile_view?
request.format.to_sym == :mobile
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mobile?\n return params[:format] == 'm'\n end",
"def mobile?\n return params[:format] == 'm'\n end",
"def in_mobile_view?\n request.format.to_sym == :mobile\n end",
"def respond_as_mobile?\n processing_xhr_requests? and skip_mobile_param_not_present? and (force_mobile_by_session? o... | [
"0.816326",
"0.816326",
"0.80765265",
"0.8076151",
"0.8042823",
"0.79404104",
"0.78978485",
"0.78556645",
"0.7846801",
"0.7846801",
"0.78075576",
"0.77295065",
"0.7670152",
"0.763183",
"0.75345737",
"0.7499576",
"0.74253076",
"0.7413261",
"0.74080706",
"0.7351661",
"0.7351661... | 0.80171365 | 5 |
Returns either true or false depending on whether or not the user agent of the device making the request is matched to a device in our regex. | def is_mobile_device?
!!mobile_device
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def request_device?(device)\n (request.user_agent.to_s.downcase =~ (Mobylette.devices.device(device) || %r{not_to_be_matched_please}) ? true : false)\n end",
"def user_agent_match(req, pattern)\n req.user_agent && req.user_agent[pattern]\n end",
"def match?\n ua.match?(/SogouMobileBrowser/i) |... | [
"0.78794944",
"0.7647633",
"0.75884247",
"0.75001377",
"0.7395123",
"0.73902845",
"0.722873",
"0.7225667",
"0.7104287",
"0.70859146",
"0.70817584",
"0.70780754",
"0.70533675",
"0.70259815",
"0.70259815",
"0.70259815",
"0.69556886",
"0.6915082",
"0.6915082",
"0.68802434",
"0.6... | 0.0 | -1 |
Can check for a specific user agent e.g., is_device?('iphone') or is_device?('mobileexplorer') | def is_device?(type)
request.user_agent.to_s.downcase.include? type.to_s.downcase
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_device\n # if HTTP_USER_AGENT is blank/nil defaults to blank, i.e. desktop \n agent = request.env[\"HTTP_USER_AGENT\"].blank? ? \"\" : request.env[\"HTTP_USER_AGENT\"].downcase \n if agent =~ tablet_agents\n \"tablet\"\n elsif (agent =~ mobile_agents_one) || (agent[0..3] =~ mobil... | [
"0.75859034",
"0.75070226",
"0.74954325",
"0.7490642",
"0.7376007",
"0.73159945",
"0.7292912",
"0.7280186",
"0.7280186",
"0.7280186",
"0.7184447",
"0.7179834",
"0.7133441",
"0.71235406",
"0.7061011",
"0.70328015",
"0.69874",
"0.6967959",
"0.69402933",
"0.6939325",
"0.69107175... | 0.6968986 | 18 |
Zip def my_zip(arr) result_arr = [] self.my_each do |el| end Rotate | def my_rotate(num = 1)
offset = num % self.length
self.drop(offset) + self.take(offset)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_zip(*arrs)\n zipped = []\n self.each_with_index do |ele, i|\n sub = [ele]\n arrs.each do |arr|\n sub << arr[i]\n end\n zipped << sub\n end\n zipped\n end",
"def zip(*arr)\n (0...arr[0].length).map do |i|\n ... | [
"0.8540384",
"0.80693436",
"0.8067127",
"0.8039325",
"0.7993101",
"0.784742",
"0.7763381",
"0.7663384",
"0.75189614",
"0.74319786",
"0.7428339",
"0.7375697",
"0.7319816",
"0.7308451",
"0.72927517",
"0.72720647",
"0.72638446",
"0.72536325",
"0.7252348",
"0.7243587",
"0.7223962... | 0.0 | -1 |
Get a diff that can be stored as a JSON string, persisted and retrieved to apply (by default, Diff::LCS::Changeas_json isn't very useful) | def persistable_diff(a, b)
diff = Diff::LCS.diff a, b
reify_diff_element(diff).as_json
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def diff\n @diff ||= begin\n commit.diffs.collect{|diff| diff.diff}.join(\"\\n\")\n end\n end",
"def changes\n @changes ||= JSON.parse(File.read(ARGV[1]))\nend",
"def json\n delta_pack.to_json\n end",
"def diff_init(diff, path)\n Smash.new.tap do |di|\n if dif... | [
"0.66141504",
"0.6368866",
"0.60854304",
"0.58906037",
"0.58535475",
"0.584853",
"0.57909197",
"0.54888964",
"0.5454939",
"0.5436178",
"0.5413507",
"0.5353406",
"0.53247666",
"0.53161436",
"0.52924263",
"0.5253892",
"0.52419835",
"0.52074444",
"0.5183777",
"0.51828593",
"0.51... | 0.69219756 | 0 |
Create a Revision using revised content compared to base content | def revise_from_content(base_content, revised_content)
revisions.build(diffs: generate_diff_hash(base_content, revised_content))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_revision!\n logger.info(\"Creating a new revision for article_submission id: #{self.id}\")\n rev = self.copy(false)\n unless rev.article_submission\n rev.article_submission = self \n self.update_attribute(:last_revision,false)\n else\n rev.article_submission.article_submis... | [
"0.70113164",
"0.6950661",
"0.66123986",
"0.6515512",
"0.6488422",
"0.64601314",
"0.62441635",
"0.6213863",
"0.6176663",
"0.61356765",
"0.6105925",
"0.6102364",
"0.6084698",
"0.6066202",
"0.6046146",
"0.604109",
"0.60341835",
"0.6008621",
"0.6001054",
"0.6000184",
"0.59718364... | 0.7457926 | 0 |
Generate the hash of diffs to populate a Revision | def generate_diff_hash(base_content, revised_content)
revised_content.compact.collect {|content_key, revised_value|
current_value = base_content.send(content_key) || ''
# Ignore unchanged contents or nil (not blank!) content attributes
unless current_value == revised_value
[content_key, persistable_diff(current_value, revised_value || '').to_json]
end
}.compact.to_h
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash\n h = {}\n h['_rm'] = removed_keys unless removed_keys.empty?\n h['_ch'] = Hash[changes.collect {|k,v| [k, v.is_a?(Diff) ? v.hash : v]}] unless\n changes.empty?\n h\n end",
"def hash\n name.hash ^ version.hash\n end",
"def create\n revisions do |orig_file, ... | [
"0.6152752",
"0.6136501",
"0.61138356",
"0.6078793",
"0.60560924",
"0.6039968",
"0.6039968",
"0.6039968",
"0.6039968",
"0.6039968",
"0.6039968",
"0.6039968",
"0.6019143",
"0.59232783",
"0.5911321",
"0.59080535",
"0.5866775",
"0.5850416",
"0.5840386",
"0.5827198",
"0.5820805",... | 0.6122528 | 2 |
This is a bit gross, but I didn't want to monkeypatch Diff::LCS::Change | def reify_diff_element(element)
case element
when Array
element.collect do |el|
reify_diff_element el
end
when Diff::LCS::Change
element.to_a
else
element
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def changed\n _find_changed_twins!(@_changes)\n\n @_changes\n end",
"def added_change what, from_start, from_end, to_start, to_end = nil\n make_fdiff_change format(added_msg_fmt, what), from_start, from_end, to_start, to_end || loctext(to_start, what)\n end",
"def source_change(change, filename)\n ... | [
"0.66661704",
"0.66523665",
"0.65853006",
"0.649974",
"0.63615906",
"0.63281566",
"0.61472815",
"0.612383",
"0.6118165",
"0.61106163",
"0.60854095",
"0.6081466",
"0.6068333",
"0.6037956",
"0.5997624",
"0.599586",
"0.5982023",
"0.5954718",
"0.59471846",
"0.5915047",
"0.5860089... | 0.0 | -1 |
For cooperation with ESOD | def set_esod_user_id
Esodes::EsodTokenData.new(current_user.id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eplore\n end",
"def etfs\n\n end",
"def private; end",
"def service; end",
"def schubert; end",
"def run\n super\n\n # Attach to the corpwatch service & search\n x = Client::Corpwatch::CorpwatchService.new\n corps = x.search @entity.name\n\n corps.each do |corp|\n # Create a new organizatio... | [
"0.6194225",
"0.61586684",
"0.615679",
"0.6002673",
"0.59442455",
"0.5940392",
"0.5846928",
"0.5846928",
"0.5846928",
"0.5846928",
"0.5834069",
"0.5809064",
"0.5748612",
"0.57210004",
"0.57082444",
"0.5693672",
"0.5679735",
"0.56640464",
"0.56640464",
"0.56640464",
"0.5626277... | 0.0 | -1 |
Callback that github_jenkins uses | def build_success(commit, build, callback)
repo = commit.repo_name
branch = commit.branch
return unless (app = @apps[repo])
return unless branch == app.auto_deploy
callback.call("#{"DEPLOY".irc_cyan.irc_bold} - Attempting automatic deploy of #{app.name}")
callback.call(app.deploy!(commit.pusher, callback).tap do |status|
if status =~ /started for/
callback.call(SQUIRRELS.sample)
plugin_send(:Notifier, :notify, "pre_deploy")
plugin_send(:NewRelicDeployPerformance, :pre_deploy, app.name)
end
end)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def any_status_hook\n repo = params[:name]\n link = \"https://github.com/#{repo}\"\n sha = params[:sha]\n state = params[:state]\n context = params[:context]\n description = params[:description]\n target = params[:target_url]\n\n return if state == 'pending' || (state == 'success' && contex... | [
"0.63358945",
"0.6151897",
"0.6139544",
"0.61141145",
"0.6104233",
"0.60940367",
"0.5968304",
"0.5953476",
"0.5934538",
"0.5878198",
"0.58777976",
"0.5871155",
"0.584904",
"0.5827009",
"0.5738334",
"0.57212186",
"0.5713353",
"0.56985116",
"0.56445605",
"0.5630612",
"0.5619784... | 0.5575557 | 26 |
=begin my_basket is configured to the current user =end | def my_basket
@user = current_user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_basket\n if !current_user.nil?\n @basket = current_user.basket\n @categories = Category.all\n @total_price = @basket.total_price\n else\n redirect_to '/users/sign_up'\n end\n end",
"def basket\n \t#if the user doesn't have a basket\n \t#give them an empty one\n \tif sessi... | [
"0.71763974",
"0.70489395",
"0.69249535",
"0.6874542",
"0.6844382",
"0.67905056",
"0.65807974",
"0.6403643",
"0.63191754",
"0.63191754",
"0.63191754",
"0.63191754",
"0.63191754",
"0.63191754",
"0.6296771",
"0.61556643",
"0.61149406",
"0.6059588",
"0.60516125",
"0.59962314",
"... | 0.78195983 | 0 |
=begin add_to_basket includes an if statement. If the users basket already exists it adds the book details Else it will create the basket =end | def add_to_basket
if Basket.exists?(user_id: params[:user_id], book_id: params[:book_id])
@basket = Basket.find_by(user_id: params[:user_id], book_id: params[:book_id])
@basket.increment!(:amount)
else
Basket.create(user_id: params[:user_id], book_id: params[:book_id], amount: 1)
end
redirect_to my_basket_path(params[:user_id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addBook(book)\n\t\tinventories.create(book_id: book.id)\n\tend",
"def add_item_to_basket(item_id)\n @session[:item_basket] << item_id unless @session[:item_basket].include? item_id\n end",
"def add_book author, title\n books = @books[author]\n if books\n if books.include? title\n ... | [
"0.6615606",
"0.649829",
"0.64770126",
"0.6437923",
"0.637861",
"0.6339421",
"0.62966764",
"0.6277239",
"0.62671065",
"0.62582695",
"0.6208262",
"0.6206987",
"0.6176562",
"0.6167054",
"0.615192",
"0.61467165",
"0.61344904",
"0.61278075",
"0.6074642",
"0.6066711",
"0.6062431",... | 0.8253183 | 0 |
=begin Remove basket allows the user to clear down their basket by destroying it for the given user. it then redirects them to an empty basket =end | def remove_from_basket
@basket = Basket.find_by(user_id: params[:user_id], book_id: params[:book_id])
@basket.destroy
redirect_to my_basket_path(params[:user_id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n\t\t@user_basket = UserBasket.find(params[:id])\n\t\t@shop = ShopProfile.find(@user_basket.shop_profile_id);\n\t\t@price = ShopProduct.find(@user_basket.shop_product_id).selling_price\n\t\t@price *= @user_basket.quantity\n\t\t@user_basket.destroy\n\t\tif current_user.user_baskets.empty?\n\t\t\trespond... | [
"0.7578817",
"0.72867954",
"0.7027629",
"0.6891593",
"0.68793637",
"0.685834",
"0.67777246",
"0.66327655",
"0.66145456",
"0.6535209",
"0.65331733",
"0.6470347",
"0.6469474",
"0.6438997",
"0.6421963",
"0.6398868",
"0.6397889",
"0.6327976",
"0.6323923",
"0.63047916",
"0.6281804... | 0.78387153 | 0 |
GET /socials/1 GET /socials/1.json | def show
@social = Story.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def indexUserSocial\n render json: User.where( id: params[:user_id] ).last.socials.page(params[:page] || 1).per(params[:per] || 10) , status: 200\n end",
"def show\n render json: @social_networking\n end",
"def show\n @social_network = SocialNetwork.find(params[:id])\n\n respond_to do |format|\n ... | [
"0.7387056",
"0.73777515",
"0.709712",
"0.6965081",
"0.68503934",
"0.6846297",
"0.6760098",
"0.66520447",
"0.65816677",
"0.64837164",
"0.64611864",
"0.6303543",
"0.63007665",
"0.6280707",
"0.6156164",
"0.6156164",
"0.6101346",
"0.6059054",
"0.60487026",
"0.6044441",
"0.601829... | 0.5827854 | 32 |
POST /socials POST /socials.json | def create
@social = Story.create(social_params)
redirect_to social_path(@social)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n \n @social = Social.new(params[:social])\n\n respond_to do |format|\n if @social.save\n format.html { redirect_to @social, notice: 'Social was successfully created.' }\n format.json { render json: @social, status: :created, location: @social }\n else\n format.ht... | [
"0.74315274",
"0.6608617",
"0.62561065",
"0.6123282",
"0.61076224",
"0.59671944",
"0.59575886",
"0.5941007",
"0.5903792",
"0.58661276",
"0.5860758",
"0.5848099",
"0.58363485",
"0.58124346",
"0.58062637",
"0.5776592",
"0.5771321",
"0.57707304",
"0.5752828",
"0.5727452",
"0.567... | 0.6124487 | 3 |
PATCH/PUT /socials/1 PATCH/PUT /socials/1.json | def update
respond_to do |format|
if @social.update(social_params)
format.html { redirect_to @social, notice: 'Social was successfully updated.' }
format.json { render :show, status: :ok, location: @social }
else
format.html { render :edit }
format.json { render json: @social.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n\n @social = Social.find(params[:id])\n\n respond_to do |format|\n if @social.update_attributes(params[:social])\n format.html { redirect_to '/', notice: 'Social was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"... | [
"0.72042495",
"0.70514506",
"0.6772194",
"0.64453024",
"0.6419766",
"0.6323626",
"0.6231504",
"0.6214845",
"0.61820847",
"0.61677885",
"0.6157639",
"0.61163336",
"0.6104987",
"0.6037311",
"0.6006371",
"0.5984298",
"0.5972196",
"0.5962332",
"0.59486806",
"0.5934311",
"0.590058... | 0.69970423 | 2 |
DELETE /socials/1 DELETE /socials/1.json | def destroy
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @social = Social.find(params[:id])\n @social.destroy\n\n respond_to do |format|\n format.html { redirect_to '/' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @social.destroy\n respond_to do |format|\n format.html { redirect_to socials_url }\n ... | [
"0.7830353",
"0.7816142",
"0.7570174",
"0.74011",
"0.72452354",
"0.7224009",
"0.7214274",
"0.72115654",
"0.7132446",
"0.71213543",
"0.704383",
"0.7007332",
"0.69715756",
"0.69631135",
"0.6919055",
"0.68624973",
"0.6840862",
"0.68261343",
"0.681191",
"0.68037",
"0.67761683",
... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_social
@social = Social.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 social_params
params.require(:story).permit(:title, :author, :category, :body, :img, :description)
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 |
Should be used when logged in user don't have rights to perform given action | def redirect_if_not_an_admin
return if current_user.admin?
flash[:danger] = 'Access denied.'
redirect_to root_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ensure_user\n current_user? || deny_access('You must be logged in to perform this action.')\n end",
"def access action\n\t\tif current_user\n \treturn true\n else\n \treturn false\n end\n\n\tend",
"def user_actions(user)\n can_act_as_logged_in_user(user) unle... | [
"0.76345205",
"0.7491912",
"0.7108821",
"0.7091189",
"0.7089053",
"0.7088044",
"0.7067415",
"0.69824374",
"0.69402945",
"0.69317067",
"0.6927439",
"0.6927417",
"0.6918458",
"0.6907153",
"0.6905519",
"0.6905519",
"0.6904749",
"0.68697476",
"0.68641204",
"0.6860207",
"0.6856224... | 0.0 | -1 |
Remove a listening channel, the LiveQuery will automatically remove itsself from the pool when there are no channels. | def remove_listener(collection, query)
live_query = @volt_app.live_query_pool.lookup(collection, query)
live_query.remove_channel(@channel)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_channel(channel_name)\r\n @channels.delete(channel_name.downcase)\r\n end",
"def unsubscribe_from_channel; end",
"def remove_channel( channel )\n @channel_map.delete channel.local_id\n end",
"def unsubscribe_from_channel # :nodoc:\n run_callbacks :unsubscribe do\n ... | [
"0.70596963",
"0.68710816",
"0.6856037",
"0.67398417",
"0.67341447",
"0.6712721",
"0.6665118",
"0.65435237",
"0.64570767",
"0.6428591",
"0.63431275",
"0.6270383",
"0.62609154",
"0.62468237",
"0.6215457",
"0.62048614",
"0.62048614",
"0.6191188",
"0.61433023",
"0.6038613",
"0.6... | 0.70706624 | 0 |
Removes a channel from all associated live queries | def close!
live_queries = @volt_app.channel_live_queries[@channel]
if live_queries
live_queries.each do |live_query|
live_query.remove_channel(@channel)
end
end
@volt_app.channel_live_queries.delete(@channel)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_channel( channel )\n @channel_map.delete channel.local_id\n end",
"def delete_facebook_channel(project_id, query_id)\n delete \"/projects/#{project_id}/facebookchannels/#{query_id}\"\n end",
"def remove_channel(channel_name)\r\n @channels.delete(channel_name.downca... | [
"0.69945365",
"0.68250734",
"0.6788795",
"0.67515117",
"0.6709242",
"0.6559873",
"0.6499193",
"0.6446304",
"0.6427382",
"0.6427382",
"0.6407356",
"0.6380801",
"0.6374218",
"0.6371486",
"0.6262556",
"0.62399656",
"0.62184054",
"0.61931026",
"0.6152476",
"0.6128578",
"0.6127365... | 0.7334368 | 0 |
Tracks that this channel will be notified from the live query. | def track_channel_in_live_query(live_query)
channel_live_queries = @volt_app.channel_live_queries
channel_live_queries[@channel] ||= []
channel_live_queries[@channel] << live_query
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def notify_observers(*args)\n return unless changed?\n\n unwrap(connection).exec \"NOTIFY #{channel}, #{args}\"\n\n changed false\n end",
"def notify\n changed(true)\n notify_observers(self)\n end",
"def notify_game_change\n connection.execute \"NOTIFY #{channel}, #{co... | [
"0.6165639",
"0.60553515",
"0.6018944",
"0.5887589",
"0.584748",
"0.583743",
"0.5718442",
"0.5641111",
"0.56367415",
"0.5604656",
"0.5567094",
"0.5544769",
"0.554235",
"0.554235",
"0.55167496",
"0.54863924",
"0.5463499",
"0.54607975",
"0.54401386",
"0.5414997",
"0.538091",
... | 0.7171607 | 0 |
Send the request to the URL and retrun raw data of the response | def raw_exchange_rates
# BanqueMisr provide 18 currencies (17 Used and CYPRUS POUND)
# But they have 2 <tr> for headers
table_rows = Oga.parse_html(response.body).css('.exchangeRates tbody tr')
fail ResponseError, 'Unknown HTML' unless table_rows&.size == 20
# remove the first 2 headers of the array and the last element
# which is CYPRUS POUND which is not used anymore
table_rows.lazy.drop(2).take(17).map(&:children).map do |cell|
cell.map(&:text)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_request()\n uri = URI.parse(API_BASE_URL + build_request_path())\n response = Net::HTTP.get_response(uri)\n response.body\n end",
"def raw_response\n Net::HTTP.get(endpoint)\n end",
"def send_and_receive\n url = to_s\n raw_response = HTTPClient.new.get(url).... | [
"0.727657",
"0.7268351",
"0.72491515",
"0.7040075",
"0.6970304",
"0.6948901",
"0.69078064",
"0.68542325",
"0.68305176",
"0.68120384",
"0.67594266",
"0.6684522",
"0.664027",
"0.6539485",
"0.6530578",
"0.651048",
"0.6477634",
"0.64664763",
"0.64615965",
"0.645067",
"0.643878",
... | 0.0 | -1 |
Convert currency string to ISO symbol | def currency_symbol(currency)
case currency
when /UAE DIRHAM/ then :AED
when /AUSTRALIA/ then :AUD
when /BAHRAIN/ then :BHD
when /CANADA/ then :CAD
when /SWISS/ then :CHF
when /DENMARK/ then :DKK
when /EURO/ then :EUR
when /GB POUND/ then :GBP
when /JORDANIAN/ then :JOD
when /JAPAN/ then :JPY
when /KUWAIT/ then :KWD
when /NORWAY/ then :NOK
when /OMAN/ then :OMR
when /QATARI/ then :QAR
when /SAUDI/ then :SAR
when /SWEDISH/ then :SEK
when /US DOLLAR/ then :USD
else fail ResponseError, "Unknown currency #{currency}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_currency_symbol\n \"€\"\n end",
"def currency_as_string; end",
"def currency_symbol\n Currency.new(currency).symbol\n end",
"def currency_as_string=(val); end",
"def currency()\n return \" ש\\\"ח\"\n end",
"def currency_as_string\n currency.to_s\n end",
"def currency_as_st... | [
"0.74886477",
"0.7350946",
"0.70146245",
"0.6815757",
"0.6814545",
"0.67513037",
"0.67513037",
"0.6680303",
"0.65636426",
"0.65365803",
"0.65365803",
"0.64891684",
"0.63780355",
"0.6372301",
"0.6372301",
"0.6372301",
"0.6372301",
"0.63666016",
"0.6266222",
"0.6266222",
"0.625... | 0.68355113 | 3 |
Validate if the session is active, the user is correct, and that they have permission to stream the derivative based on the session_id and the path to the stream. The values should be put into a POST. The method will reject a GET request for security reasons | def authorize
resp = { authorized: StreamToken.validate_token(params[:token]) }
if params[:name] and not resp[:authorized].any? { |valid| params[:name].index(valid).present? }
return head :forbidden
end
respond_to do |format|
format.urlencoded do
resp[:authorized] = resp[:authorized].join(';')
render plain: resp.to_query, content_type: :urlencoded, status: :accepted
end
format.text do
render plain: resp[:authorized].join("\n"), status: :accepted
end
format.xml do
render xml: resp, root: :response, status: :accepted
end
format.json do
render json: resp, status: :accepted
end
end
rescue StreamToken::Unauthorized
return head :forbidden
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rc_facebook_check_params_session\n return if rc_facebook.authorized? || !params[:session]\n\n rc_facebook.parse_json!(params[:session])\n logger.debug(\"DEBUG: Facebook: detected session, parsed:\" \\\n \" #{rc_facebook.data.inspect}\")\n\n if rc_facebook.authorized?\n rc_faceb... | [
"0.5843818",
"0.5541384",
"0.5517537",
"0.5426414",
"0.54233617",
"0.538619",
"0.53434867",
"0.52863324",
"0.52765924",
"0.52765924",
"0.52765924",
"0.52765924",
"0.52765924",
"0.52765924",
"0.52765924",
"0.52765924",
"0.52765924",
"0.52765924",
"0.52765924",
"0.52765924",
"0... | 0.0 | -1 |
POST /company_businesses POST /company_businesses.json | def create
respond_to do |format|
if @company_business.save
format.html { redirect_to @company_business, notice: 'Company business was successfully created.' }
format.json { render json: @company_business, status: :created, location: @company_business }
else
format.html { render action: "new" }
format.json { render json: @company_business.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_businesses()\n @good_business_records.each do |rec|\n existing_business = @businesses[rec.fields[\"name\"]]\n ## If the business doesn't exist then create it.\n if (existing_business.nil?)\n\tnew_business = Business.new\n\tnew_business.create(rec)\n\t@businesses[new_business.name] = ne... | [
"0.68930036",
"0.65929097",
"0.6588629",
"0.62476134",
"0.6207495",
"0.6207495",
"0.6207495",
"0.61460567",
"0.61074334",
"0.60978484",
"0.6089459",
"0.6083822",
"0.6080458",
"0.6065163",
"0.60603803",
"0.6004575",
"0.5987673",
"0.59868383",
"0.59698814",
"0.59531635",
"0.588... | 0.62538105 | 3 |
PUT /company_businesses/1 PUT /company_businesses/1.json | def update
respond_to do |format|
if @company_business.update_attributes(params[:company_business])
format.html { redirect_to @company_business, notice: 'Company business was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @company_business.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: Company.update(params[\"id\"], params[\"company\"])\n end",
"def putBusiness( name, building_number, branch_name, address1, address2, address3, district, town, county, province, postcode, country, latitude, longitude, timezone, telephone_number, additional_telephone_number, email, w... | [
"0.6704675",
"0.6606723",
"0.6140297",
"0.61236435",
"0.6117336",
"0.6115292",
"0.6087208",
"0.6046817",
"0.60376763",
"0.6005924",
"0.6003887",
"0.5985254",
"0.59735674",
"0.5939711",
"0.5933765",
"0.5911271",
"0.58980525",
"0.5846838",
"0.5843454",
"0.583731",
"0.5835817",
... | 0.6234021 | 2 |
DELETE /company_businesses/1 DELETE /company_businesses/1.json | def destroy
@company_business.destroy
respond_to do |format|
format.html { redirect_to company_businesses_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n render json: Company.delete(params[\"id\"])\n end",
"def destroy\n @company.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @biz_company = BizCompany.find(params[:id])\n @biz_company.destroy\n\n respond_to do |format|\n ... | [
"0.7447605",
"0.7153824",
"0.7148692",
"0.69967127",
"0.6976809",
"0.696085",
"0.695971",
"0.69507307",
"0.69425535",
"0.6911259",
"0.69102603",
"0.6869113",
"0.6869113",
"0.6869113",
"0.6851295",
"0.6851295",
"0.6851295",
"0.6851295",
"0.6851295",
"0.6851295",
"0.6851295",
... | 0.7238638 | 1 |
Grabs all of the yaml files found in /pages, and loads them as Page objects. | def find_all
Dir["#{pages_dir}**/*.yml"].map {|f| new f }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pages\n plantuml_files.map { |static_file| page_from_static_file(static_file) }\n end",
"def retrieve_pages(dir, dot_pages)\n site.pages.concat(PageReader.new(site, dir).read(dot_pages))\n end",
"def retrieve_pages(dir, dot_pages); end",
"def retrieve_pages(dir, entries_pages)\n ... | [
"0.7043972",
"0.6895947",
"0.68627375",
"0.67453283",
"0.6696323",
"0.6664716",
"0.66500103",
"0.66384196",
"0.65258586",
"0.6386816",
"0.6380106",
"0.6305485",
"0.63036996",
"0.6290372",
"0.6273399",
"0.62681454",
"0.626001",
"0.6256252",
"0.62232804",
"0.6206196",
"0.618298... | 0.7678771 | 0 |
A requriement of the Templette::DataAccessors interface. Returns self. | def page; self end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data\n DataProxy.new(self)\n end",
"def d(name)\n DataAccessor.new(name)\n end",
"def data_accessor_for(clazz) #:nodoc:\n (@data_accessors ||= {})[clazz.name.to_sym] ||=\n Adapters::DataAccessor.create(clazz)\n end",
"def data() @data ||= Data.new( self ); e... | [
"0.67281437",
"0.64211106",
"0.6259309",
"0.60524756",
"0.6001653",
"0.597192",
"0.597192",
"0.597192",
"0.58240175",
"0.575634",
"0.56876516",
"0.5637037",
"0.56338525",
"0.56282914",
"0.56139356",
"0.561037",
"0.56041664",
"0.5582524",
"0.55754375",
"0.5575363",
"0.5575363"... | 0.0 | -1 |
declare a function with parameter "r" | def circleArea(r)
# return PI * r^2
PI * r ** 2
# set end of circleArea function
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def r; end",
"def r; end",
"def setR(r)\r\n @r = r\r\n end",
"def setR(method, *args)\n @r_interop = R::Support.exec_function_i(method, @r_interop, *args)\n self\n end",
"def make_function(exp, register = true)\n name = map_name exp.shift\n args = exp.shift\n ruby_args = args.deep... | [
"0.6568186",
"0.6568186",
"0.6134554",
"0.5840588",
"0.58327186",
"0.57965195",
"0.55696076",
"0.554189",
"0.5514058",
"0.54656667",
"0.53988093",
"0.5373943",
"0.5366967",
"0.5266914",
"0.5261096",
"0.52348727",
"0.52191013",
"0.52098393",
"0.5208977",
"0.5196114",
"0.517305... | 0.0 | -1 |
kind: 'preflop', 'flop', 'turn', 'river', 'showdown', 'exchange' | def initialize(attributes)
@kind = attributes[:kind].to_s
@players_count = (attributes[:players_count] || 0)
@previous_pot = (attributes[:previous_pot] || 0)
@cards = Utils::Cards.parse(attributes[:cards])
@board = attributes[:board] || []
@events = []
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_flop\r\n show_hand\r\n end",
"def normal_interactions\n [ Question, Fine, Woah ]\n end",
"def kind; end",
"def kind; end",
"def kind; end",
"def kind; end",
"def kind; end",
"def kind; end",
"def kase_kinds\n [:idea, :question, :problem, :praise]\n end",
"def chord_types; end... | [
"0.5995832",
"0.59265536",
"0.5804005",
"0.5804005",
"0.5804005",
"0.5804005",
"0.5804005",
"0.5804005",
"0.57620907",
"0.5714421",
"0.56148887",
"0.55120504",
"0.5486864",
"0.5480728",
"0.5459612",
"0.5457901",
"0.5457008",
"0.5439573",
"0.5426686",
"0.54238695",
"0.5393056"... | 0.0 | -1 |
sets appriate fields to nil on artist and returns a new rejection object | def switch_thing(thing, act)
if thing == ARTICLE_TITLE || thing == SUMMARY
data = self.article_title
self.summary = nil
self.article_title = nil
self.rejections() << Rejection.new_from_rejecting(Artist::ARTICLE_TITLE, data) if act == Artist::REJECT
elsif thing == SAMPLE_TRACK_URL
data = sample_track_url
self.sample_track_url = nil
self.rejections() << Rejection.new_from_rejecting(thing, data) if act == Artist::REJECT
elsif thing == WEBSITE
data = website
self.website = nil
self.rejections() << Rejection.new_from_rejecting(thing, data) if act == Artist::REJECT
elsif thing == MYSPACE_URL
data = myspace_url
self.myspace_url = nil
self.rejections() << Rejection.new_from_rejecting(thing, data) if act == Artist::REJECT
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reject\n self['reject']||{}\n end",
"def artist\n art = super\n if art.nil?\n art = Artist.new\n art.title = \"Unknown Artist\"\n end\n art\n end",
"def new_artist_or_nah(request_artist)\n artist = Artist.find_by name: request_artist\n if artist == nil\n Artist.create(... | [
"0.58507925",
"0.56096077",
"0.5585204",
"0.5334831",
"0.5233449",
"0.5122796",
"0.5113652",
"0.50821024",
"0.50710475",
"0.50166625",
"0.49891585",
"0.49865782",
"0.49436396",
"0.4939488",
"0.49385795",
"0.4926694",
"0.49212027",
"0.49212027",
"0.49212027",
"0.49086744",
"0.... | 0.47195303 | 38 |
`scope_name` is set as :current_user by default in the controller. If the instance does not have a method named `scope_name`, it defines the method so that it calls the +scope+. | def initialize(object, options = {})
self.object = object
self.instance_options = options
self.root = instance_options[:root]
self.scope = instance_options[:scope]
return if !(scope_name = instance_options[:scope_name]) || respond_to?(scope_name)
define_singleton_method scope_name, -> { scope }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scope_name; end",
"def scope\n @scope ||= Array(@root_scope) + [Inflector.underscore(name)]\n end",
"def current_user_scope\n current_user\n end",
"def current_scope\n params[:scope].try(:to_sym) || railgun_resource.default_scope.try(:key)\n end",
"def scope(scope_name)\n S... | [
"0.71355224",
"0.70047474",
"0.69022596",
"0.6802003",
"0.67924047",
"0.6745818",
"0.6744598",
"0.67323834",
"0.67269176",
"0.6723036",
"0.6610529",
"0.6594619",
"0.6586762",
"0.65806764",
"0.65806764",
"0.65772337",
"0.65422356",
"0.6514057",
"0.6400125",
"0.6322532",
"0.630... | 0.0 | -1 |
Used by adapter as resource root. | def json_key
root || _type || object.class.model_name.to_s.underscore
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def root; resource :path => '/'; end",
"def root \n context.metadata.root\n end",
"def resource; end",
"def resource\n (@nested_resource || @root_resource)\n end",
"def resources; end",
"def resources; end",
"def resource_base_uri\n @resource ||= \"#{Hyperloop::Resource::ClientDrivers.... | [
"0.69672817",
"0.6171338",
"0.6076182",
"0.60425866",
"0.6013549",
"0.6013549",
"0.5998068",
"0.59105426",
"0.58628017",
"0.577526",
"0.57501394",
"0.57086957",
"0.57086957",
"0.57071584",
"0.57018405",
"0.57018405",
"0.5647029",
"0.5645331",
"0.5636747",
"0.56353456",
"0.563... | 0.0 | -1 |
ax^2 + bx + c = 0 | def quadra (a, b, c)
if a == 0
puts "Решение не возможно!"
return
end
d = (b**2)-(4*a*c)
puts "Дискриминант равен #{d}"
if d < 0
puts "d < 0 - Корней нет, а значит нет решения"
elsif d == 0
m1 = -b - Math.sqrt(d)
m2 = 2*a
x = m1 / m2
#x = -b - Math.sqrt(d)/2*a - Этот вариант записи уравнения не работает почему-то.
puts "В уравнении только один корень x = #{x}"
elsif d > 0
v1 = -b + Math.sqrt(d)
puts v1
v2 = -b - Math.sqrt(d)
puts v2
v3 = 2*a
puts v3
x1 = v1/v3
x2 = v2/v3
puts "В уравнении два корня: x1 = #{x1} и x2 = #{x2}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transmogrifier (a,b,c)\n (a*b)^c\n end",
"def x\n @x ||= X.new( c*r, a, (-1*c*(b - c*n)), (r*r*a - (b - c*n)*(b - c*n)) )\n end",
"def x\n @x ||= X.new( c*r, a, (-1*c*(b - c*n)), (r*r*a - (b - c*n)*(b - c*n)) )\n end",
"def cac2\n 0\n end",
"def c\n @c ||= self.p1.x * self.p2.y - s... | [
"0.63203514",
"0.60915214",
"0.60915214",
"0.60713476",
"0.6071139",
"0.59412324",
"0.5905334",
"0.57929564",
"0.5734745",
"0.57135224",
"0.57093173",
"0.5709317",
"0.5665201",
"0.56453323",
"0.56384766",
"0.56364495",
"0.5633788",
"0.5632742",
"0.5585169",
"0.5512094",
"0.55... | 0.53070533 | 54 |
After it is determined that a user is on a Newsfeed or Timeline feed, determine if that feed should get the new post | def validate_post_for_user_location(post, user, action)
# First verify that the person on a Newsfeed is the current user, or
# if the current user is on a user's Timeline, the current user
# is allowed to see posts on that Timeline (depending on the user's
# privacy setting)
unless (( action == 'newsfeed' && access_level?(user, :self) ) ||
( action == 'timeline' && access_level?(user, :public) ))
return false
end
receiver = post.receiver
creator = post.creator
# Now check if the Newsfeed or Timeline of the user should receive
# the new post. Newsfeeds get posts created for or by the owner,
# or friends of the owner, of the Newsfeed; Timelines only get
# posts created for or by the owner of the Timeline.
( action == 'newsfeed' && (access_level?(receiver, :friend) ||
access_level?(creator, :friend)) ) ||
( action == 'timeline' && (receiver == user || creator == user) )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_from_news_feed\n unless self.facebook_omniauth.blank?\n fb_user = self.facebook_client_user\n unless fb_user.blank?\n posts = fb_user.home # fetch posts\n Movie.name_is_not_blank.name_without_dictionary_word.this_year.each do |movie|\n posts.each do |post|\n ... | [
"0.70568943",
"0.6994355",
"0.6989487",
"0.66720164",
"0.6630223",
"0.64489996",
"0.64114517",
"0.632869",
"0.6325523",
"0.632544",
"0.6248006",
"0.6207678",
"0.61979693",
"0.61706525",
"0.6158824",
"0.61478025",
"0.61162364",
"0.6111978",
"0.60858166",
"0.60746443",
"0.60647... | 0.682481 | 3 |
Returns a collection that represents the instances belonging to this Auto Scaling group. You can use this collection to further refine the instances you are interested in: group.ec2_instances.filter('availabilityzone', 'useast1a').each do |i| puts instance.id end | def ec2_instances
instances = EC2::InstanceCollection.new(:config => config)
instances.tagged('aws:autoscaling:groupName').tagged_values(name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_instances(incl_stopped=false)\n \n instances = @ec2.describe_instances\n instances = instances.select { |x| x[:aws_groups].include? @group_name }\n \n if(instances.length == 0)\n raise CaTPAWS::EC2::Error::InstanceRetrieval, \"No instances found in this group\"\n ... | [
"0.7120154",
"0.700922",
"0.69817704",
"0.6866905",
"0.6765711",
"0.6765711",
"0.6621574",
"0.65516955",
"0.65302515",
"0.6495344",
"0.6442376",
"0.6400759",
"0.63791084",
"0.6370542",
"0.6361791",
"0.63461304",
"0.6186976",
"0.61823565",
"0.61771417",
"0.6108272",
"0.6090563... | 0.723362 | 0 |
Adjusts the desired size of the Auto Scaling group by initiating scaling activities. When reducing the size of the group, it is not possible to define which Amazon EC2 instances will be terminated. This applies to any Auto Scaling decisions that might result in terminating instances. | def set_desired_capacity capacity, options = {}
client_opts = {}
client_opts[:auto_scaling_group_name] = name
client_opts[:desired_capacity] = capacity
client_opts[:honor_cooldown] = options[:honor_cooldown] == true
client.set_desired_capacity(client_opts)
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scale(max_size, desired_capacity)\n client.update_auto_scaling_group(auto_scaling_group_name: asg_name, max_size: max_size, desired_capacity: desired_capacity)\n end",
"def update_auto_scaling_group(auto_scaling_group_name, options = {})\n if availability_zones = options.delete('AvailabilityZone... | [
"0.75889874",
"0.64803857",
"0.639634",
"0.5995356",
"0.5989149",
"0.5931947",
"0.58502275",
"0.5831773",
"0.580236",
"0.57989293",
"0.57058764",
"0.5676442",
"0.5649288",
"0.5638111",
"0.5621373",
"0.5608299",
"0.5593765",
"0.5592327",
"0.5578411",
"0.5553519",
"0.5514979",
... | 0.5212971 | 34 |
Suspends processes for this Auto Scaling group. suspend two processes by name auto_scaling_group.suspend_processes 'Launch', 'AZRebalance' | def suspend_processes *processes
client_opts = {}
client_opts[:auto_scaling_group_name] = name
client_opts[:scaling_processes] = processes.flatten
client.suspend_processes(client_opts)
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def suspend_processes(auto_scaling_group_name, options = {})\n if scaling_processes = options.delete('ScalingProcesses')\n options.merge!(AWS.indexed_param('ScalingProcesses.member.%d', [*scaling_processes]))\n end\n request({\n 'Action' => 'SuspendPro... | [
"0.87122166",
"0.75313544",
"0.7240648",
"0.7142046",
"0.6909668",
"0.6502795",
"0.6167026",
"0.61294985",
"0.6110244",
"0.6031816",
"0.6025132",
"0.5929465",
"0.5771859",
"0.5760472",
"0.5751843",
"0.5751843",
"0.57494515",
"0.57237697",
"0.566512",
"0.56474036",
"0.5591733"... | 0.82164705 | 1 |
Suspends all processes for this Auto Scaling group. | def suspend_all_processes
suspend_processes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def suspend_processes(auto_scaling_group_name, options = {})\n if scaling_processes = options.delete('ScalingProcesses')\n options.merge!(AWS.indexed_param('ScalingProcesses.member.%d', [*scaling_processes]))\n end\n request({\n 'Action' => 'SuspendPro... | [
"0.7878253",
"0.73964447",
"0.73952764",
"0.6985465",
"0.67330927",
"0.6577605",
"0.65640837",
"0.65640837",
"0.655745",
"0.6305511",
"0.6054132",
"0.6017615",
"0.5987914",
"0.5923863",
"0.588988",
"0.58294874",
"0.57266843",
"0.56494606",
"0.56315875",
"0.5628368",
"0.559364... | 0.73492324 | 3 |
Resumes processes for this Auto Scaling group. resume two processes by name auto_scaling_group.suspend_processes 'Launch', 'AZRebalance' | def resume_processes *processes
client_opts = {}
client_opts[:auto_scaling_group_name] = name
client_opts[:scaling_processes] = processes.flatten
client.resume_processes(client_opts)
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def suspend_processes(auto_scaling_group_name, options = {})\n if scaling_processes = options.delete('ScalingProcesses')\n options.merge!(AWS.indexed_param('ScalingProcesses.member.%d', [*scaling_processes]))\n end\n request({\n 'Action' => 'SuspendPro... | [
"0.7782267",
"0.72685194",
"0.7184569",
"0.7073122",
"0.6832541",
"0.6691391",
"0.6535876",
"0.6292499",
"0.610317",
"0.60867125",
"0.59854287",
"0.5759839",
"0.57172036",
"0.5659814",
"0.55444354",
"0.5537938",
"0.552023",
"0.54997283",
"0.5472325",
"0.5393976",
"0.5385579",... | 0.8200772 | 0 |
Resumes all processes for this Auto Scaling group. | def resume_all_processes
resume_processes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resume_processes *processes\n client_opts = {}\n client_opts[:auto_scaling_group_name] = name\n client_opts[:scaling_processes] = processes.flatten\n client.resume_processes(client_opts)\n nil\n end",
"def resume_all_processes\n groups.each do |group|\n gro... | [
"0.76529264",
"0.7550506",
"0.69527906",
"0.6786772",
"0.65701437",
"0.6296431",
"0.6282769",
"0.6035294",
"0.6005665",
"0.5958181",
"0.59269327",
"0.59145147",
"0.5896866",
"0.58966523",
"0.5895775",
"0.56975245",
"0.56890625",
"0.5688524",
"0.56334895",
"0.5604643",
"0.5592... | 0.75933415 | 1 |
Enables all metrics collection for the Auto Scaling group. | def enable_all_metrics_collection
enable_metrics_collection
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def autoscaling_instances\n autoscaling_group.auto_scaling_instances\n end",
"def autoscaling_instances\n autoscaling_group.auto_scaling_instances\n end",
"def disable_all_metrics_collection\n disable_metrics_collection\n end",
"def init_groups\n @@client.describe_auto_scaling_grou... | [
"0.63155496",
"0.63155496",
"0.63154894",
"0.6124643",
"0.58603215",
"0.58343536",
"0.58028674",
"0.54997826",
"0.53667444",
"0.5340069",
"0.5304826",
"0.529975",
"0.5293918",
"0.52245384",
"0.5170505",
"0.51577646",
"0.5143741",
"0.5143741",
"0.5143741",
"0.513776",
"0.50459... | 0.8177668 | 0 |
Disables all metrics collection for the Auto Scaling group. | def disable_all_metrics_collection
disable_metrics_collection
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enable_all_metrics_collection\n enable_metrics_collection\n end",
"def destroy\n info(\"Disabling Metricbeat module\")\n metricbeat(['modules','disable',@resource[:name]])\n end",
"def remove_auto_scaling_group_properties\n properties = []\n properties << :AvailabilityZones... | [
"0.695738",
"0.63754964",
"0.61624557",
"0.5633099",
"0.5563048",
"0.55241174",
"0.5523639",
"0.5467503",
"0.5460256",
"0.544506",
"0.544506",
"0.5440977",
"0.54260665",
"0.54249275",
"0.5412217",
"0.53986275",
"0.5384166",
"0.53650624",
"0.5345516",
"0.53441924",
"0.5320656"... | 0.80768263 | 0 |
Update one or more attributes on the Auto Scaling group. | def update options = {}
group_opts = group_options(options)
# tags must be updated using a separate request from the
# other attributes, *sigh*
if tags = group_opts.delete(:tags)
tags.map(&:to_hash).each do |tag|
tag[:resource_type] = 'auto-scaling-group'
tag[:resource_id] = name
end
client.create_or_update_tags(:tags => tags)
end
unless group_opts.empty?
client_opts = group_opts.merge(:auto_scaling_group_name => name)
client.update_auto_scaling_group(client_opts)
end
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_auto_scaling_group(auto_scaling_group_name, options = {})\n if availability_zones = options.delete('AvailabilityZones')\n options.merge!(AWS.indexed_param('AvailabilityZones.member.%d', [*availability_zones]))\n end\n request({\n 'Action' =>... | [
"0.74691784",
"0.7061314",
"0.63325363",
"0.63305366",
"0.62738395",
"0.62424904",
"0.6221506",
"0.62184185",
"0.6218149",
"0.614807",
"0.61462647",
"0.6125194",
"0.61241025",
"0.6101883",
"0.6095457",
"0.6094295",
"0.60861397",
"0.6073944",
"0.60582435",
"0.6037467",
"0.6036... | 0.7522412 | 0 |
Removes all tags from this Auto Scaling group. | def delete_all_tags
delete_tags(self.tags)
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset\n @tags.clear\n end",
"def delete_tags\n @tags.delete_tags(@filename) unless @tags.nil?\n end",
"def delete\n resource.delete_tags([self])\n nil\n end",
"def destroy\n tag_ids.clone.each { |tag_id| destroy_tag(tag_id) }\n super\n end",
"def purge_unused_t... | [
"0.6701327",
"0.6678438",
"0.6633569",
"0.6585839",
"0.6535254",
"0.65154374",
"0.63734984",
"0.6359661",
"0.63518476",
"0.63514024",
"0.62728924",
"0.62476224",
"0.62399614",
"0.6209171",
"0.6176984",
"0.61742646",
"0.60872024",
"0.60832626",
"0.60548097",
"0.59624183",
"0.5... | 0.7555071 | 0 |
Deletes the Auto Scaling group. If you pass +:force+ as true then all the instances associated with this group will also be terminated. | def delete options = {}
client_opts = {}
client_opts[:force_delete] = options[:force] == true
client_opts[:auto_scaling_group_name] = name
client.delete_auto_scaling_group(client_opts)
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy(options = { :force => false })\n requires :id\n\n opts = {}\n opts.merge!({'ForceDelete' => true}) if options[:force]\n\n service.delete_auto_scaling_group(id, opts)\n end",
"def delete_asg name\n auto_scaling = new_auto_scaling\n groups = auto_sca... | [
"0.832787",
"0.6831928",
"0.6784633",
"0.6649838",
"0.6626339",
"0.6558953",
"0.6490728",
"0.63120383",
"0.63002646",
"0.6284608",
"0.62440556",
"0.62024176",
"0.6190439",
"0.6184121",
"0.617778",
"0.617778",
"0.6126916",
"0.6113461",
"0.6077973",
"0.6064484",
"0.60430795",
... | 0.81559837 | 1 |
Deletes the Auto Scaling group along with all instances associated with the group, without waiting for all instances to be terminated. | def delete!
delete(:force => true)
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy(options = { :force => false })\n requires :id\n\n opts = {}\n opts.merge!({'ForceDelete' => true}) if options[:force]\n\n service.delete_auto_scaling_group(id, opts)\n end",
"def terminate\n logger.info \"Terminating any instance with GroupUUID: #{@os... | [
"0.75265706",
"0.7299891",
"0.7165831",
"0.7107583",
"0.69403",
"0.6890642",
"0.6865347",
"0.6856157",
"0.6821598",
"0.6815385",
"0.67711204",
"0.67091054",
"0.6669437",
"0.66642505",
"0.6640211",
"0.6591473",
"0.6535158",
"0.65344995",
"0.65167373",
"0.65167373",
"0.6505168"... | 0.0 | -1 |
GET /course_proposal_questions GET /course_proposal_questions.json | def index
@course_proposal_questions = CourseProposalQuestion.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def questions\n self.class.get(\"/2.2/questions\", @options)\n end",
"def index\n params.require(:course)\n @questions = Course.find(params[:course]).questions.select {|q| q.answered == false}\n\n render json: @questions\n end",
"def index\n @questions = @course.questions.all\n end",
"def i... | [
"0.71004456",
"0.673227",
"0.6493525",
"0.6493525",
"0.63337207",
"0.6300776",
"0.62354195",
"0.62217057",
"0.6143496",
"0.61383724",
"0.6121525",
"0.6104301",
"0.60591197",
"0.60242075",
"0.6000374",
"0.5961999",
"0.59573615",
"0.59563017",
"0.5940224",
"0.59039485",
"0.5895... | 0.76668197 | 0 |
GET /course_proposal_questions/1 GET /course_proposal_questions/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @course_proposal_questions = CourseProposalQuestion.all\n end",
"def questions\n self.class.get(\"/2.2/questions\", @options)\n end",
"def index\n params.require(:course)\n @questions = Course.find(params[:course]).questions.select {|q| q.answered == false}\n\n render json: @questi... | [
"0.7434157",
"0.692222",
"0.65849966",
"0.6531316",
"0.6327199",
"0.6303049",
"0.6303049",
"0.62917584",
"0.62825185",
"0.62825185",
"0.62761074",
"0.6248612",
"0.6221303",
"0.61932045",
"0.6179994",
"0.6175323",
"0.6148899",
"0.6145449",
"0.6125792",
"0.6117495",
"0.6097998"... | 0.0 | -1 |
POST /course_proposal_questions POST /course_proposal_questions.json | def create
@course_proposal_question = CourseProposalQuestion.new(course_proposal_question_params)
respond_to do |format|
if @course_proposal_question.save
format.html { redirect_to @course_proposal_question, notice: 'Course proposal question was successfully created.' }
format.json { render :show, status: :created, location: @course_proposal_question }
else
format.html { render :new }
format.json { render json: @course_proposal_question.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def course_proposal_question_params\n params.require(:course_proposal_question).permit(:question, :help_text)\n end",
"def index\n @course_proposal_questions = CourseProposalQuestion.all\n end",
"def create\n @course = Course.find(params[:course_id])\n @question = @course.questions.build(para... | [
"0.71165013",
"0.6742254",
"0.6596467",
"0.6493522",
"0.63982767",
"0.63767076",
"0.6351012",
"0.6346057",
"0.63372546",
"0.62813663",
"0.62396675",
"0.6190765",
"0.6181965",
"0.6173738",
"0.6158913",
"0.6128002",
"0.611729",
"0.611729",
"0.6087749",
"0.608717",
"0.60533935",... | 0.7436503 | 0 |
PATCH/PUT /course_proposal_questions/1 PATCH/PUT /course_proposal_questions/1.json | def update
respond_to do |format|
if @course_proposal_question.update(course_proposal_question_params)
format.html { redirect_to @course_proposal_question, notice: 'Course proposal question was successfully updated.' }
format.json { render :show, status: :ok, location: @course_proposal_question }
else
format.html { render :edit }
format.json { render json: @course_proposal_question.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question.course, notice: 'Question was successfully updated.' }\n format.json { head :ok }\n else\n format.html { rend... | [
"0.687026",
"0.6672324",
"0.6656856",
"0.6604427",
"0.65882283",
"0.65583193",
"0.65362805",
"0.65351844",
"0.6527841",
"0.6519026",
"0.6497865",
"0.6496542",
"0.6494913",
"0.6458557",
"0.64584494",
"0.6455926",
"0.6454532",
"0.64542645",
"0.64514244",
"0.6447249",
"0.6436651... | 0.7374703 | 0 |
DELETE /course_proposal_questions/1 DELETE /course_proposal_questions/1.json | def destroy
@course_proposal_question.destroy
respond_to do |format|
format.html { redirect_to course_proposal_questions_url, notice: 'Course proposal question was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @examquestion.destroy\n respond_to do |format|\n format.html { redirect_to examquestions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_question = TestQuestion.find(params[:id])\n @test_question.destroy\n\n respond_to do |format|\n form... | [
"0.74135524",
"0.7341972",
"0.7326205",
"0.73218465",
"0.72966427",
"0.72838473",
"0.72794825",
"0.7266921",
"0.7263273",
"0.7254235",
"0.7248843",
"0.7248843",
"0.7248843",
"0.7248843",
"0.7248843",
"0.7248843",
"0.72465396",
"0.72347593",
"0.7213497",
"0.7212765",
"0.721274... | 0.80670506 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_course_proposal_question
@course_proposal_question = CourseProposalQuestion.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.6165152",
"0.60463154",
"0.59467196",
"0.5917112",
"0.5890387",
"0.58345735",
"0.57773316",
"0.56991524",
"0.56991524",
"0.565454",
"0.5622282",
"0.54232633",
"0.54119074",
"0.54119074",
"0.54119074",
"0.53937256",
"0.53801376",
"0.5358599",
"0.53412294",
"0.5340814",
"0.5... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def course_proposal_question_params
params.require(:course_proposal_question).permit(:question, :help_text)
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 |
If real_move is false, the move will be undone regardless of legality. Either way, move_to! will return true if the move is fully legal, and false otherwise. | def move_to!(new_x, new_y, real_move = true)
return false unless game.current_player == color
return false unless valid_move?(new_x, new_y)
if (destination_piece = game.piece_at(new_x, new_y))
return capture_piece!(new_x, new_y, destination_piece, real_move)
end
update_piece_attributes(new_x, new_y, real_move)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def legal_move?(move)\n captured_piece = @board.data[move[0]][move[1]]\n move_current_piece(move)\n king = @king_location || move\n result = safe_king?(king)\n @board.data[move[0]][move[1]] = captured_piece\n result\n end",
"def legal_move?(move)\n captured_piece = @board.data[move[0]][move... | [
"0.76601964",
"0.76601964",
"0.74794567",
"0.7450275",
"0.74079376",
"0.72268975",
"0.71966887",
"0.7151723",
"0.71151793",
"0.7111376",
"0.702171",
"0.70205534",
"0.7016901",
"0.70104545",
"0.70008636",
"0.6998319",
"0.6976874",
"0.6951291",
"0.6893735",
"0.68809867",
"0.687... | 0.66846263 | 38 |
Set a default Chef environment name for our chef_search calls. | def chef_env(env)
chef_scope :chef_environment, env
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_environment=(env); end",
"def test_chef_environment\n # If no environment is specified chef needs to use \"_default\" and attribute from cookbook\n actual = cook_environment(run_list: [\"recipe[environment_cookbook]\"])\n assert_equal \"_default/untouched\", actual\n\n # If one is specifi... | [
"0.64914715",
"0.6276075",
"0.62203985",
"0.6024242",
"0.60106164",
"0.60106164",
"0.58833575",
"0.58743966",
"0.57976645",
"0.5753341",
"0.5717913",
"0.56838584",
"0.5645325",
"0.5645325",
"0.55672544",
"0.55611134",
"0.5559538",
"0.5537936",
"0.5532204",
"0.5529475",
"0.550... | 0.6390724 | 1 |
Set a term that is included for every chef_search call. | def chef_scope(field, term="*")
scopes = fetch(:chef_scopes) || []
scopes.delete_if { |scope| scope =~ /chef_environment/ }
set :chef_scopes, scopes << [field, term].join(":")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def term=(value)\n self.content << (value.is_a?(XTF::Search::Element::Term) ? value : XTF::Search::Element::Term.new(value))\n end",
"def search_terms=(value)\n @search_terms = value\n end",
"def term=(term)\n @term = term\n @twitter_search = nil\n load_words\n end",
"... | [
"0.6918432",
"0.66647184",
"0.6598486",
"0.64226973",
"0.64085174",
"0.64021266",
"0.6303566",
"0.6148493",
"0.6143801",
"0.6132444",
"0.60770994",
"0.60770994",
"0.6069548",
"0.59938836",
"0.5972597",
"0.59691733",
"0.59419745",
"0.5935316",
"0.5909544",
"0.5846233",
"0.5807... | 0.0 | -1 |
Set a Capistrano roles by searching a Chef Server for appropriate node data | def chef_role(names, query=nil, options={}, &block)
user = options[:user] ||= fetch(:user)
attribute = options.delete(:attribute) || :ipaddress
index = options.delete(:index) || :node
results_proc = block_given? ? block : chef_results_by(attribute)
terms = [index, query].compact
addresses = chef_search(*terms).flat_map(&results_proc)
addresses.each do |address|
server address, options.merge(roles: names)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_chef_vars(instances, &block)\n instances.each { |inst|\n query = \"name:#{inst['server_name']}\"\n query_nodes = Chef::Search::Query.new\n query_nodes.search('node', query) do |node_item|\n yield node_item\n end\n }\n end",
"def servers... | [
"0.64230657",
"0.6332273",
"0.63054746",
"0.62497824",
"0.6248228",
"0.6095409",
"0.60914296",
"0.60622865",
"0.6020724",
"0.5995489",
"0.59676796",
"0.5967544",
"0.5930855",
"0.5878182",
"0.5830454",
"0.58098686",
"0.5804533",
"0.5804311",
"0.5793348",
"0.5769174",
"0.575912... | 0.61421573 | 5 |
Query a Chef Server to search for specific nodes | def chef_search(type, query="*:*")
chef_scopes = fetch(:chef_scopes) || []
queries = [chef_scopes, query].flatten.join(" AND ")
puts "Searching Chef types \"#{type}\" with \"#{queries}\"" if debug?
results = chef_query_class.new.search(type, queries).first
puts "Found #{results.count}" if debug?
results
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def node_list\n list = {}\n search = Chef::Search::Query.new\n query = config[:query]\n\n ui.msg \"Search nodes '#{query}'\"\n search.search('node', query) do |node|\n if node['chef'] && node['chef']['client_version']\n version = node['chef']['client_versio... | [
"0.72092086",
"0.6907744",
"0.6647727",
"0.65987945",
"0.6517916",
"0.64821213",
"0.63215536",
"0.6308564",
"0.62858826",
"0.6210898",
"0.6196186",
"0.6189882",
"0.61747134",
"0.6170602",
"0.61280453",
"0.60679644",
"0.6048448",
"0.60415477",
"0.5994073",
"0.59644383",
"0.595... | 0.5939358 | 22 |
Interface dependency using Chef for searching by default | def chef_query_class
@chef_query_class ||= ::Chef::Search::Query
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chef_api_client\n @chef_api_client ||= begin\n require \"chef/api_client\"\n Chef::ApiClient\n end\n end",
"def load_cloudflare_cookbook_gems\n return if defined? @@cloudflare_cookbook_gems_loaded\n chef_gem 'clou... | [
"0.58905697",
"0.58658063",
"0.58568287",
"0.58568287",
"0.58568287",
"0.5838765",
"0.5816879",
"0.58113635",
"0.5804071",
"0.5735008",
"0.5643202",
"0.56092715",
"0.5576077",
"0.554456",
"0.55291486",
"0.5526053",
"0.5515817",
"0.5498583",
"0.5494602",
"0.5485111",
"0.547705... | 0.0 | -1 |
Interface dependency of our Capistrano config context | def chef_context
@chef_context || ::Capistrano.env
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def env_config; end",
"def env_config; end",
"def env_config; end",
"def env_config; end",
"def cap_config\n @cap_config ||= Sauce.instance.new_capistrano_config()\n end",
"def create_config \n @config = ::Capistrano::Configuration.new\n if @cloud.debug || @cloud.verb... | [
"0.6797451",
"0.6797451",
"0.6797451",
"0.6797451",
"0.6464963",
"0.6284742",
"0.60308534",
"0.5903349",
"0.5839589",
"0.58211845",
"0.58043116",
"0.58043116",
"0.58043116",
"0.58043116",
"0.58043116",
"0.58043116",
"0.58043116",
"0.58043116",
"0.58043116",
"0.58043116",
"0.5... | 0.5893721 | 8 |
Query a Chef Server to search for specific nodes | def chef_results_by(attribute)
case attribute
when Symbol, String
lambda { |node| node[attribute] }
when Hash # not tested
iface, family = attribute.keys.first.to_s, attribute.values.first.to_s
lambda do |nodes|
addresses = node["network"]["interfaces"][iface]["addresses"]
addresses.select do |address, data|
data["family"] == family
end.to_a.first.first
end
else
Proc.new {} # noop
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def node_list\n list = {}\n search = Chef::Search::Query.new\n query = config[:query]\n\n ui.msg \"Search nodes '#{query}'\"\n search.search('node', query) do |node|\n if node['chef'] && node['chef']['client_version']\n version = node['chef']['client_versio... | [
"0.72092086",
"0.6907744",
"0.6647727",
"0.65987945",
"0.6517916",
"0.64821213",
"0.63215536",
"0.6308564",
"0.62858826",
"0.6210898",
"0.6196186",
"0.6189882",
"0.61747134",
"0.6170602",
"0.61280453",
"0.60679644",
"0.6048448",
"0.60415477",
"0.5994073",
"0.59644383",
"0.595... | 0.0 | -1 |
Returns the first packet in +dump+ | def packet dump
Capp.offline(dump).loop.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_first\r\n if @head \r\n return @head.data\r\n else \r\n return nil\r\n end\r\n end",
"def get_first\n return nil if !@head\n return @head.data\n end",
"def get_first\n return nil if @head.nil?\n\n return @head.data\n end",
"def get_first\n return nil ... | [
"0.59918964",
"0.5966294",
"0.59548736",
"0.59548736",
"0.5946803",
"0.5924725",
"0.5924533",
"0.59197056",
"0.59157085",
"0.5864313",
"0.58566505",
"0.5840855",
"0.58146584",
"0.5809229",
"0.5809229",
"0.579712",
"0.57777494",
"0.5727662",
"0.5702424",
"0.56881046",
"0.56497... | 0.70979226 | 0 |
Reads /proc/mounts and returns partition name of the device mounted at /. It returns a String. But if the info isn't available or /proc/mounts is not readable, it will return an empty frozen String. | def root
find_root[0].to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_of_mount(m)\n unless Pathname.new(m).mountpoint?\n Chef::Log.warn(\n \"#{m} is not a mount point - I can't determine its device.\",\n )\n return nil\n end\n node['filesystem2']['by_pair'].to_hash.each do |pair, info|\n # we skip fake filesystems 'rootf... | [
"0.6930065",
"0.68186027",
"0.67002195",
"0.6683224",
"0.66773266",
"0.66220176",
"0.6585295",
"0.6462865",
"0.63970613",
"0.6382977",
"0.63176656",
"0.6284937",
"0.62830704",
"0.62827677",
"0.6138401",
"0.6130033",
"0.6054028",
"0.60255635",
"0.59874845",
"0.5978643",
"0.593... | 0.0 | -1 |
Reads /proc/mounts and returns the file system of the device mounted at /. It returns a String. But if the info isn't available or /proc/mounts is not readable, it will return an empty frozen String. | def root_fs
find_root[2].to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_mounted?(device)\n system(\"grep -q '#{device}' /proc/mounts\")\nend",
"def device_of_mount(m)\n unless Pathname.new(m).mountpoint?\n Chef::Log.warn(\n \"#{m} is not a mount point - I can't determine its device.\",\n )\n return nil\n end\n node['filesystem2'][... | [
"0.68751645",
"0.6759435",
"0.6738563",
"0.6627858",
"0.662304",
"0.6616091",
"0.65095633",
"0.6439599",
"0.64104897",
"0.640019",
"0.63009113",
"0.6202191",
"0.6198536",
"0.61742616",
"0.6166239",
"0.6055224",
"0.6003462",
"0.6000581",
"0.59881014",
"0.57667184",
"0.56954557... | 0.5600199 | 29 |
Reads /proc/mounts and returns the options used for mounting /. It returns a String. But if the info isn't available or /proc/mounts is not readable, it will return an empty frozen string. | def root_mount_options
find_root[3].to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mounts_info\n @mounts_info ||= vault_client.request(:get, \"/v1/sys/internal/ui/mounts\")\n rescue Vault::VaultError\n unable_to_determine_version\n raise\n end",
"def get_mounts\n mount_hash = {}\n mounts = File.open(\"/etc/mtab\", \"r\").read.split(\"\\n\").map{|l| l.split(... | [
"0.6927114",
"0.6858722",
"0.631671",
"0.6203542",
"0.6201873",
"0.6196647",
"0.60554075",
"0.60455483",
"0.60393727",
"0.5905791",
"0.59029275",
"0.5758121",
"0.57253873",
"0.57090795",
"0.5683376",
"0.56236786",
"0.5562347",
"0.55541927",
"0.55527204",
"0.55078304",
"0.5467... | 0.59032905 | 10 |
Reads /proc/mounts and finds all tmpfs. It returns a Hash But if the info isn't available or /proc/mounts is not readable, it will return an empty Hash. | def tmpfs
ret = {}
mounts.each { |x|
ret.merge!({x.split[1] => x}) if x.start_with?('tmpfs '.freeze)
}
ret
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_mounts\n mount_hash = {}\n mounts = File.open(\"/etc/mtab\", \"r\").read.split(\"\\n\").map{|l| l.split(/\\s+/)}\n mounts.each{|m| mount_hash[m[1]] = m[0] unless %w[devpts udev sysfs tmpfs none proc].include?(m[0])}\n mount_hash\nend",
"def mountpoints\n mtab = IO.readlines '/proc/mounts'\n ... | [
"0.7868856",
"0.705546",
"0.6727915",
"0.66328394",
"0.64825094",
"0.6407223",
"0.63958997",
"0.635185",
"0.6327745",
"0.615456",
"0.6116929",
"0.6062659",
"0.60454106",
"0.5913282",
"0.58284503",
"0.5810452",
"0.57494676",
"0.5737623",
"0.5724618",
"0.5695389",
"0.5632698",
... | 0.7696831 | 1 |
define the arguments that the user will input | def arguments(model)
args = OpenStudio::Ruleset::OSArgumentVector.new
return args
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def arguments; end",
"def arguments; end",
"def arguments; end",
"def arguments\n \"\"\n end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end... | [
"0.73753476",
"0.73753476",
"0.73753476",
"0.70890766",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",
"0.7008301",... | 0.0 | -1 |
end the arguments method define what happens when the measure is run | def run(model, runner, user_arguments)
super(model, runner, user_arguments)
#use the built-in error checking
if not runner.validateUserArguments(arguments(model), user_arguments)
return false
end
epw_file_path = File.join(File.dirname(__FILE__), "resources/srrl_2013_amy.epw")
epw_file = OpenStudio::EpwFile.load(epw_file_path).get
OpenStudio::Model::WeatherFile.setWeatherFile(model, epw_file)
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def measure=(_arg0); end",
"def measure(*args, &b)\n end",
"def measure; end",
"def communicate_measure_result(_ = nil, _ = nil); end",
"def communicate_measure_result(_ = nil, _ = nil); end",
"def arguments; end",
"def arguments; end",
"def arguments; end",
"def run(model, runner, user_argument... | [
"0.7510201",
"0.6948276",
"0.69206923",
"0.62894714",
"0.62894714",
"0.6225757",
"0.6225757",
"0.6225757",
"0.6146954",
"0.61146826",
"0.6114524",
"0.6041721",
"0.5980296",
"0.5975661",
"0.59709084",
"0.5965006",
"0.5961643",
"0.59559",
"0.59477925",
"0.5908425",
"0.5908425",... | 0.0 | -1 |
:callseq: scale_bilinear(width, height) Scales the image using the bilinear interpolation method. Bilinear interpolation calculates the color values in the resulting image by looking at the four nearest pixels for each pixel in the resulting image. This gives a more accurate representation than nearestneighbor interpolation, at the expense of slightly blurring the resulting image. == Example i = Axon::JPEG('test.jpg') i.scale_bilinear(50, 75) i.width => 50 i.height => 75 | def scale_bilinear(*args)
@source = BilinearScaler.new(@source, *args)
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scale(width: @image.width, height: @image.height,\n algorithm: 'bilineal') # bilinear, nearest_neighbor\n if algorithm == 'nearest_neighbor'\n Image.new(@image.resample_nearest_neighbor(width, height), path)\n else\n Image.new(@image.resample_bilinear(width, height), path)\... | [
"0.74876934",
"0.6929598",
"0.62904245",
"0.62255514",
"0.6087487",
"0.58767915",
"0.58165014",
"0.5636177",
"0.5613749",
"0.56060153",
"0.5601863",
"0.5581311",
"0.5555667",
"0.5544393",
"0.55158347",
"0.5513507",
"0.5510966",
"0.54933",
"0.54405916",
"0.54188484",
"0.535726... | 0.79472375 | 0 |
:callseq: scale_nearest(width, height) Scales the image using the nearestneighbor interpolation method. Nearestneighbor interpolation selects the value of the nearest pixel when calculating colors in the scaled image. == Example i = Axon::JPEG('test.jpg') i.scale_nearest(50, 75) i.width => 50 i.height => 75 | def scale_nearest(*args)
@source = NearestNeighborScaler.new(@source, *args)
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scale(width: @image.width, height: @image.height,\n algorithm: 'bilineal') # bilinear, nearest_neighbor\n if algorithm == 'nearest_neighbor'\n Image.new(@image.resample_nearest_neighbor(width, height), path)\n else\n Image.new(@image.resample_bilinear(width, height), path)\... | [
"0.7143473",
"0.5917895",
"0.5883907",
"0.5648101",
"0.5527938",
"0.549518",
"0.54871935",
"0.5457946",
"0.54511553",
"0.5260264",
"0.5172822",
"0.5139375",
"0.50794816",
"0.5040413",
"0.5021077",
"0.50138474",
"0.4997212",
"0.49891388",
"0.49704787",
"0.49383867",
"0.4881466... | 0.7812567 | 0 |
:callseq: fit(width, height) Scales the image to fit inside given box dimensions while maintaining the aspect ratio. == Example i = Axon::JPEG('test.jpg') i.fit(5, 20) i.width => 5 i.height => 10 | def fit(*args)
@source = Fit.new(@source, *args)
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resize_to_fit width, height\n process :resize_to_fit => [width, height]\n end",
"def scale_to_fit(width, height)\n @image = @image.scale_to_fit(width, height)\n self\n end",
"def resize_to_fit!(image, width, height)\n with_minimagick(image) do |img|\n img.combine_options do |... | [
"0.7722023",
"0.7651965",
"0.7620072",
"0.75771636",
"0.75520515",
"0.734139",
"0.7337059",
"0.73110384",
"0.72737026",
"0.7128217",
"0.7128217",
"0.7058629",
"0.6775835",
"0.6749554",
"0.672748",
"0.66617566",
"0.66500825",
"0.65700096",
"0.65528005",
"0.6536908",
"0.6467356... | 0.0 | -1 |
:callseq: crop(width, height, x_offset = 0, y_offset = 0) Crops the image and extracts regions. If the region extends beyond the boundaries of the image then the cropped image will be truncated at the boundaries. == Example i = Axon::JPEG('test.jpg') i.crop(50, 75, 10, 20) c.width => 50 c.height => 75 == Example of Cropping Past the Boundaries i = Axon::JPEG('test.jpg') i.crop(50, 75, 60, 20) i.width => 40 note that this is not 50 | def crop(*args)
@source = Cropper.new(@source, *args)
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cropper(crop_width, crop_height)\n manipulate! do |img|\n width = img.columns\n height= img.rows\n if width == crop_width and height==crop_height then\n img\n else\n img.crop(width / 2,height / 2,crop_width,crop_height)\n end\n end\n end",
"def crop!(image, width... | [
"0.7682654",
"0.76611024",
"0.741268",
"0.7372462",
"0.73018813",
"0.72667557",
"0.70802885",
"0.7049784",
"0.70281863",
"0.6989052",
"0.68854666",
"0.682947",
"0.6705565",
"0.66106725",
"0.65904933",
"0.65126276",
"0.6457028",
"0.6446116",
"0.6355576",
"0.6315622",
"0.631562... | 0.6344204 | 19 |
:callseq: jpeg(io_out [, options]) Writes the image to +io_out+ as compressed JPEG data. Returns the number of bytes written. If the image has an alpha channel it will be stripped. +options+ may contain the following symbols: :bufsize the maximum size in bytes of the writes that will be made to +io_out+ :quality JPEG quality on a 0..100 scale. :exif Raw exif string that will be saved in the header. :icc_profile Raw ICC profile string that will be saved in the header. == Example i = Axon::JPEG('input.jpg') io_out = File.open('output.jpg', 'w') i.jpeg(io_out, :quality => 88) writes the image to output.jpg | def jpeg(*args)
case @source.components
when 2,4 then @source = AlphaStripper.new(@source)
end
JPEG.write(@source, *args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compress_jpg(input, quality = 80, output = nil)\n unless output.nil?\n FileUtils.cp(input, output)\n input = output\n end\n\n options = [\n '-q -p -f',\n \"--max=#{quality}\",\n '--strip-all',\n '--all-progressive',\n input.shellescape\n ]\n\n command = \"jpego... | [
"0.63904643",
"0.5964231",
"0.5818225",
"0.56014895",
"0.55442303",
"0.528265",
"0.51608825",
"0.51367235",
"0.5063151",
"0.49861535",
"0.49382746",
"0.49120033",
"0.48495376",
"0.48303932",
"0.47554582",
"0.47347322",
"0.46941128",
"0.46901345",
"0.4676059",
"0.46240562",
"0... | 0.5372031 | 5 |
:callseq: jpeg_file(path [, options]) Writes the image to a new file at +path+ as compressed JPEG data. Returns the number of bytes written. If the image has an alpha channel it will be stripped. See Axonjpeg for a description of +options+. == Example Axon.png_file("image.png") do |image| image.jpeg_file("image.jpg") saves the image to "image.jpeg" end | def jpeg_file(path, *args)
File.open(path, 'wb') do |f|
jpeg(f, *args)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def jpeg(*args)\n case @source.components\n when 2,4 then @source = AlphaStripper.new(@source)\n end\n JPEG.write(@source, *args)\n end",
"def to_jpeg(path, options = {})\n return raise Exceptions::InvalidFileFormatError unless valid_output_format?(path, 'jpeg')\n screenshot(path... | [
"0.62616533",
"0.6066551",
"0.59234285",
"0.5789741",
"0.57895213",
"0.5787651",
"0.5714007",
"0.5708735",
"0.56916076",
"0.56242615",
"0.560582",
"0.55802304",
"0.5488504",
"0.5437542",
"0.54049474",
"0.53955424",
"0.5385785",
"0.5368424",
"0.5361975",
"0.5354941",
"0.534731... | 0.7635153 | 0 |
:callseq: png(io_out) Writes the image to +io_out+ as compressed PNG data. Returns the number of bytes written. == Example i = Axon::JPEG('input.png') io_out = File.open('output.png', 'w') i.png(io_out) writes the image to output.png | def png(*args)
PNG.write(@source, *args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compress_png(input, quality = 80, output = nil)\n # Override file if no output selected\n output = input if output.nil?\n\n # PNGQuant does not allow update in place, so we save in a temp file\n output_tmp = Tempfile.new('temp_png').path\n\n options = [\n input.shellescape,\n '--force'... | [
"0.69359374",
"0.6256808",
"0.6150044",
"0.59207785",
"0.57372075",
"0.57175267",
"0.5687176",
"0.55965036",
"0.55744183",
"0.5539418",
"0.55202305",
"0.5517066",
"0.5509904",
"0.5502224",
"0.5496602",
"0.5472919",
"0.54127526",
"0.5406111",
"0.5379772",
"0.53405535",
"0.5309... | 0.6128945 | 3 |
:callseq: png_file(path) Writes the image to a new file at +path+ as compressed PNG data. Returns the number of bytes written. == Example Axon.jpeg_file("image.jpg") do |image| image.png_file("image.png") saves the image to "image.jpeg" end | def png_file(path, *args)
File.open(path, 'wb') do |f|
png(f, *args)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def jpeg_file(path, *args)\n File.open(path, 'wb') do |f|\n jpeg(f, *args)\n end\n end",
"def png(file)\n file.write PNG_HEADER\n\n # Make sure IEND is actually at the end (Ruby 1.9).\n iend = @chunks.delete 'IEND'\n @chunks['IEND'] = iend\n\n @chunks.each do |type, d... | [
"0.6506414",
"0.63885915",
"0.60311306",
"0.5949819",
"0.5875201",
"0.5871904",
"0.57511646",
"0.572426",
"0.57190067",
"0.5678481",
"0.5675133",
"0.56727326",
"0.5557379",
"0.5436052",
"0.5430585",
"0.5412409",
"0.5401728",
"0.5397639",
"0.539142",
"0.53458035",
"0.53252643"... | 0.6734233 | 0 |
Gets the components in the image. | def components
@source.components
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def components\n key_image.coords + c_array + r_array\n end",
"def components\n return @components\n end",
"def components\n @world.get_components(self)\n end",
"def components\n\t\t\t\treturn @components.values unless (@components.nil?)\n\t\t\t\treturn nil\n\t\... | [
"0.75917554",
"0.69255954",
"0.686619",
"0.686495",
"0.6783539",
"0.6776296",
"0.6724951",
"0.66866016",
"0.6670473",
"0.6670473",
"0.6605553",
"0.6443981",
"0.63614225",
"0.620369",
"0.6099445",
"0.609107",
"0.6051297",
"0.6039096",
"0.5942996",
"0.58960235",
"0.5885776",
... | 0.65710306 | 14 |
Gets the width of the image. | def width
@source.width
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def width\n @image.width\n end",
"def width\n image_ptr[:sx]\n end",
"def width\n image.empty? ? 0 : image.first.size\n end",
"def width\n @image[0].length\n end",
"def image_width\n\t\t\t@data[\"originalimage\"][\"width\"] if @data[\"originalimage\"]\n\t\tend",
"def image... | [
"0.8697535",
"0.854393",
"0.8308485",
"0.8259735",
"0.8184614",
"0.81736064",
"0.8134202",
"0.8132018",
"0.8096049",
"0.775171",
"0.7582849",
"0.7553192",
"0.7429262",
"0.7405392",
"0.7405392",
"0.7329711",
"0.7294532",
"0.7271352",
"0.7265897",
"0.7252846",
"0.72255766",
"... | 0.6504203 | 54 |
Gets the height of the image. | def height
@source.height
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def height\n image.size\n end",
"def height\n image_ptr[:sy]\n end",
"def height\n @image.height\n end",
"def image_height\n\t\t\t@data[\"image\"][\"height\"]\n\t\tend",
"def height\n rmagick_image.rows\n end",
"def image_height\n\t\t\t@data[\"originalimage\"][\"height... | [
"0.868352",
"0.8597373",
"0.8539739",
"0.83560395",
"0.8275449",
"0.8221125",
"0.81993854",
"0.8046682",
"0.7958535",
"0.7801322",
"0.76953936",
"0.7344727",
"0.72934014",
"0.72673",
"0.7234544",
"0.7232246",
"0.72312737",
"0.71938944",
"0.7190046",
"0.7152863",
"0.7113009",
... | 0.6566409 | 66 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.