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 |
|---|---|---|---|---|---|---|
Agreement Version Manager Begin Here. | def new_version
@title = "Create New Agreement Version"
@agreement = Agreement.find(params[:id])
@version = AgreementVersion.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_install_actions\n Dir.chdir(@project_name) do\n SemVer.new.save(SemVer::FILE_NAME)\n end\n end",
"def run\n super\n \n require_enrichment\n \n # check our fingerprints for a version\n our_version = nil\n fp = _get_entity_detail(\"fingerprint... | [
"0.59224886",
"0.5770551",
"0.57098585",
"0.565654",
"0.5633346",
"0.5621525",
"0.55339205",
"0.55126035",
"0.54582083",
"0.5425049",
"0.5416216",
"0.5318356",
"0.53102195",
"0.5300008",
"0.5294505",
"0.5266402",
"0.5260387",
"0.5252903",
"0.5249895",
"0.524243",
"0.524243",
... | 0.6275166 | 0 |
TODO: Not sure if this should be used or not. | def require_dotopts
begin
require 'dotopts'
rescue LoadError
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def probers; end",
"def schubert; end",
"def implementation; end",
"def implementation; end",
"def refutal()\n end",
"def custom; end",
"def custom; end",
"def spec; end",
"def spec; end",
... | [
"0.7579518",
"0.6376904",
"0.6376904",
"0.6376904",
"0.6376904",
"0.6365564",
"0.6036862",
"0.60147744",
"0.60147744",
"0.5949318",
"0.5843742",
"0.5843742",
"0.5755933",
"0.5755933",
"0.57490647",
"0.57490647",
"0.57490647",
"0.57490647",
"0.5747757",
"0.57421464",
"0.574214... | 0.0 | -1 |
Load configuration file. An example file might look like: Test.configure do |run| run.files << 'test/case_.rb' end | def load_config
file = config_file
unless file
if chdir
file = Dir.glob(File.join(chdir, GLOB_CONFIG)).first
else
file = Dir.glob(GLOB_CONFIG).first
end
end
load file if file
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_config(file)\n file = file + '.rb' if File.extname(file) == ''\n\n if chdir\n file = File.join(chdir, file)\n else\n file = File.join('.', file)\n end\n\n if File.exist?(file)\n return require(file)\n else\n raise \"config file not found -- `#{file... | [
"0.7212579",
"0.7185939",
"0.70389056",
"0.7030028",
"0.69978994",
"0.6907112",
"0.6905392",
"0.6900013",
"0.6899021",
"0.6887405",
"0.6846186",
"0.6793687",
"0.67575383",
"0.6745856",
"0.6729428",
"0.6719761",
"0.6713715",
"0.6710168",
"0.6678098",
"0.6651861",
"0.66507536",... | 0.7123384 | 2 |
Find traditional configuration file. | def config_file
@config_file
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_config(file); end",
"def find_config_file\n\n root_directory = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))\n app_config = File.join(root_directory, CONFIG_FILE_NAME)\n global_config = File.join('/etc', CONFIG_FILE_NAME)\n\n [app_config, global_config].each do |con... | [
"0.8077646",
"0.7193284",
"0.6929956",
"0.67933905",
"0.6733379",
"0.6677208",
"0.6573953",
"0.65677774",
"0.6521669",
"0.65048134",
"0.6308932",
"0.6068672",
"0.6029475",
"0.6029475",
"0.5975342",
"0.58394104",
"0.5836528",
"0.5789052",
"0.5781245",
"0.57639825",
"0.5749795"... | 0.52517897 | 87 |
If given a String then split up at `:` and `;` markers. Otherwise ensure the list is an Array and the entries are all strings and not empty. | def makelist(list)
case list
when String
list = list.split(/[:;]/)
else
list = Array(list).map{ |path| path.to_s }
end
list.reject{ |path| path.strip.empty? }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse( line )\r\n line.split(';')\r\nend",
"def f_semicolon(str)\n # workaround to bug or upgrade ruby to 2.4\n # str.split(';').map(&:flatten).flatten\n str.split(';').map { |s| s.flatten }.flatten\n end",
"def line_split str\n content = str.split(': ')[1] || ''\n if conte... | [
"0.63900405",
"0.6032758",
"0.5968314",
"0.59507877",
"0.57967305",
"0.5735755",
"0.5732039",
"0.57158923",
"0.56986845",
"0.56607103",
"0.56394374",
"0.56347305",
"0.5600484",
"0.5574464",
"0.54853106",
"0.5427672",
"0.5397547",
"0.53775287",
"0.53650856",
"0.5352428",
"0.53... | 0.57560134 | 7 |
GET /courses GET /courses.json | def index
@courses = Course.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n\t\t@courses = Course.all\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.json { render json: @courses }\n\t\tend\n\tend",
"def index\n @courses = Course.all\n render json: @courses, status: :ok\n end",
"def courses\n @courses = Course.where(faculty_id: params[:faculty_id]).or... | [
"0.7943173",
"0.78570646",
"0.7742099",
"0.7729055",
"0.7729055",
"0.76939315",
"0.76708746",
"0.76526207",
"0.752899",
"0.74440956",
"0.74415404",
"0.73988724",
"0.7373047",
"0.7365082",
"0.73555565",
"0.7347125",
"0.7311683",
"0.7271882",
"0.7270879",
"0.72251445",
"0.72230... | 0.7169304 | 49 |
GET /courses/1 GET /courses/1.json | def show
@sections = @course.sections
@reviews = Review.where(course_id: @course.id).order("created_at DESC")
if @reviews.blank?
@avg_rating = 0
else
@avg_rating = @reviews.average(:rating).round(2)
end
#@sections = Section.where("course_id = ?", params[:id])
#if user_signed_in?... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def course\n\t\t@course = Course.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tformat.json\n\t\tend\n\tend",
"def index\n @courses = Course.all\n render json: @courses, status: :ok\n end",
"def courses\n @courses = Course.where(faculty_id: params[:faculty_id]).order(:name)\n respond_to do... | [
"0.7639248",
"0.7600732",
"0.7561499",
"0.7498261",
"0.7492566",
"0.7492566",
"0.7460362",
"0.7459336",
"0.7438278",
"0.7280991",
"0.7248682",
"0.7241407",
"0.723878",
"0.72222453",
"0.72222453",
"0.72222453",
"0.72222453",
"0.72222453",
"0.72222453",
"0.721023",
"0.71961445"... | 0.0 | -1 |
POST /courses POST /courses.json | def create
@course = Course.new(course_params)
respond_to do |format|
if @course.save
#format.html { redirect_to course_build_path(:id =>"courseinfo", :course_id => @course.id), notice: "Course Created" }
format.html { redirect_to @course, notice: 'Course was successfully created.' }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n # render plain: params[:courses].inspect\n @courses = Courses.new(courses_params)\n\n respond_to do |format|\n if @courses.save\n format.html { redirect_to @courses, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @cour... | [
"0.76898974",
"0.73798543",
"0.7334656",
"0.72327256",
"0.72273064",
"0.7157716",
"0.7128817",
"0.71268123",
"0.7109645",
"0.71044004",
"0.71044004",
"0.71044004",
"0.71044004",
"0.71044004",
"0.71044004",
"0.71044004",
"0.7092889",
"0.70824045",
"0.70697033",
"0.7053714",
"0... | 0.6693364 | 59 |
PATCH/PUT /courses/1 PATCH/PUT /courses/1.json | def update
respond_to do |format|
if @course.update(course_params)
format.html { redirect_to @course, notice: 'Course was successfully updated.' }
format.json { render :show, status: :ok, location: @course }
else
format.html { render :edit }
format.json { render json: @co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @course.update(course_params)\n render_jsonapi_response(@course)\n end",
"def update\n @course = Course.find(params[:id])\n respond_to do |format|\n if @course.update(courses_params)\n format.html { redirect_to @course, notice: 'Course was successfully updated.' }\n f... | [
"0.7237806",
"0.71378005",
"0.71210366",
"0.7102518",
"0.70813376",
"0.70813376",
"0.70813376",
"0.70813376",
"0.70813376",
"0.70813376",
"0.70813376",
"0.70813376",
"0.705258",
"0.70461214",
"0.69679666",
"0.6966587",
"0.6964444",
"0.6953862",
"0.6948685",
"0.69339997",
"0.6... | 0.6830538 | 49 |
DELETE /courses/1 DELETE /courses/1.json | def destroy
@course.destroy
respond_to do |format|
format.html { redirect_to courses_url, notice: 'Course was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @course = Course.find(params[:id])\n @course.destroy\n\n respond_to do |format|\n format.html { redirect_to courses_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @course.destroy\n respond_to do |format|\n format.html { redirect_to courses_url }\n ... | [
"0.77230847",
"0.77079666",
"0.77079666",
"0.77079666",
"0.77079666",
"0.76962376",
"0.7696043",
"0.7696043",
"0.7696043",
"0.7696043",
"0.7696043",
"0.7696043",
"0.7696043",
"0.7696043",
"0.7696043",
"0.7696043",
"0.7696043",
"0.76494783",
"0.76408905",
"0.7619815",
"0.76093... | 0.73929405 | 70 |
Use callbacks to share common setup or constraints between actions. | def set_course
@course = Course.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 course_params
params.require(:course).permit(:name, :description, :level, :duration, :format, :image, :category_id, :instructor_id, :status, :sections_attributes => [:course_id, :section, :_destroy])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.6980384",
"0.6782743",
"0.6746196",
"0.6742575",
"0.6736",
"0.6594004",
"0.65037984",
"0.6496699",
"0.64819324",
"0.64791185",
"0.6456292",
"0.64403296",
"0.63795286",
"0.6375975",
"0.6365291",
"0.63210756",
"0.6300542",
"0.6299717",
"0.62943304",
"0.6292561",
"0.6290683",... | 0.0 | -1 |
NEXT > tanggani approved saat lebih dari satu dan boleh dipesansan dan kasih notice kalau product sudah habis akan di batalkan semua. nanti proses update tengkulak saat tengkulak sudah bayar. untuk pengurangan stok saat payment berhasil ketika stok berkurang akan di batalkan atau kirim seadanya. whole seller di tambahk... | def update_attribute_post
puts "kirim email approved ke tengkulak."
puts "update status order menjadi approved by seller."
order = self.order
post = self.order.post
order.update_attributes(:order_status => "Bergain-approved")
post.update_attributes(:purchase_price => self.bergain_price)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def paid\r\n #if @notification.acknowledge # check if it’s genuine Robokassa request\r\n #@user.approve! # project-specific code\r\n render :text => @notification.success_response\r\n @payment.approve!\r\n #else\r\n #head :bad_request\r\n #end\r\n end",
"def paid\n #if @notificati... | [
"0.6722385",
"0.65763384",
"0.6498916",
"0.6350844",
"0.6341704",
"0.6299782",
"0.62637573",
"0.6188441",
"0.6135831",
"0.61174184",
"0.61043435",
"0.60996664",
"0.60857975",
"0.60426074",
"0.60368454",
"0.6032444",
"0.6027736",
"0.60076916",
"0.5997806",
"0.59777695",
"0.597... | 0.6637056 | 1 |
Here is a selection of the best practices solutions as well as the solution I was thinking of with if, | def bonus_time(salary, bonus)
salary = (salary*10).to_i if bonus == true
"$#{salary}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def conditionally(*) end",
"def conditionally(*) end",
"def if_condition; end",
"def complex_condition?(condition); end",
"def check ; true ; end",
"def main\n\n #\n # In Ruby, everything is an expression, even the control structures.\n #\n\n #\n # if, else, elsif\n #\n # The value that results fr... | [
"0.6600314",
"0.6600314",
"0.59171987",
"0.59105885",
"0.588953",
"0.5710536",
"0.5701134",
"0.5680905",
"0.5680905",
"0.5680905",
"0.56782675",
"0.561158",
"0.5601151",
"0.5584712",
"0.55605507",
"0.55515844",
"0.55212426",
"0.54984134",
"0.5492697",
"0.54850316",
"0.5478611... | 0.0 | -1 |
As with the other solutions, this one also includes string interpolation and is probably my favorite of the three for its readability. | def bonus_time(salary, bonus)
bonus ? "$#{(salary*10).to_s}" : "$#{salary.to_s}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def interpolate_strings(string1, string2)\n p \"#{string1} is cooler than #{string2}\"\nend",
"def cheese_and_crackers(cheese_count, boxes_of_crackers)\n # print a string that interpolates the cheese_count parameter\n puts \"You have #{cheese_count} cheeses!\"\n # print a string that interpolates the boxes_o... | [
"0.678773",
"0.6748852",
"0.6693233",
"0.66557693",
"0.6611686",
"0.6597752",
"0.65898186",
"0.6562001",
"0.6529052",
"0.650195",
"0.65018517",
"0.64096457",
"0.6399306",
"0.63751996",
"0.6365924",
"0.63535833",
"0.63489944",
"0.6329092",
"0.6316525",
"0.63128036",
"0.6296407... | 0.0 | -1 |
This is an interesting way to output a variable in a string using with the formatter %d. I had to try this in irb out to really understand what is going on here. The use of d after % is for decimals. I found that this can be useful if you want to have a leading zero in the output, even if the number is under 10 (e.g. 0... | def bonus_time(salary, bonus)
format("$%d", bonus ? salary * 10 : salary)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bonus_time(salary, bonus)\n salary = (salary*10).to_i if bonus == true\n \"$#{salary}\"\nend",
"def bonus_time(salary, bonus)\n bonus ? \"$#{(salary*10).to_s}\" : \"$#{salary.to_s}\"\nend",
"def bonus_time(salary, bonus)\n bonus == true ? \"$#{salary *= 10}\" : \"$#{salary}\"\nend",
"def doll... | [
"0.68410987",
"0.6751744",
"0.6558663",
"0.61482847",
"0.6142767",
"0.5940736",
"0.5883629",
"0.57984763",
"0.5732737",
"0.5717926",
"0.5713277",
"0.5709753",
"0.5661725",
"0.5627226",
"0.5621583",
"0.553114",
"0.5527128",
"0.5525825",
"0.55208635",
"0.55153376",
"0.54979634"... | 0.6778413 | 1 |
update the name of the group | def edit; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def student_edit_grp_name(course, group, new_name)\n student_visit_grp(course, group)\n logger.debug \"Changing group title to '#{group.title = new_name}'\"\n wait_for_update_and_click edit_group_link_element\n wait_for_element_and_type(edit_group_name_input_element, group.title)\n wait_fo... | [
"0.7859491",
"0.7516513",
"0.7486115",
"0.7486115",
"0.7486115",
"0.7486115",
"0.7260406",
"0.7118146",
"0.7108456",
"0.70658916",
"0.6970861",
"0.6895618",
"0.6888457",
"0.6888457",
"0.6882831",
"0.6848988",
"0.6800526",
"0.6718956",
"0.6717069",
"0.67164564",
"0.67164564",
... | 0.0 | -1 |
is the registrant eligible to be in this group type? | def registrant_eligible_for?(registrant, registrant_group_type)
registrant.has_event?(registrant_group_type.source_element)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def accepts_registrations?\n in_reg_period? and !invite_only?\n end",
"def restricted?\n self.groups.any?\n end",
"def registrable?\n # Almost all Names in MO are potentially registrable, so use a blacklist\n # instead of a whitelist\n !unregistrable?\n end",
"def group?\n self.invoi... | [
"0.7103294",
"0.70966",
"0.69178104",
"0.6671382",
"0.6667852",
"0.6591839",
"0.65806806",
"0.6553749",
"0.65406984",
"0.6535249",
"0.6527824",
"0.65210533",
"0.6472246",
"0.64681643",
"0.6436336",
"0.64258385",
"0.64103025",
"0.6362807",
"0.6346493",
"0.63450325",
"0.6338519... | 0.7647413 | 0 |
list the registrant group for which this registrant is a member IN THIS GROUP TYPE | def registrant_group_for(registrant, registrant_group_type)
registrant.registrant_groups.merge(registrant_group_type.registrant_groups).first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def groups\n institution_groups + ['registered']\n end",
"def group_members\n members(\"Group\")\n end",
"def groups\n Vedeu::Groups.registered\n end",
"def groups\n return [] if self.group_list.nil?\n self.group_list\n end",
"def groups\n\t\t\t@groups ||= Group.find(:all, :d... | [
"0.74534655",
"0.72381765",
"0.6938491",
"0.69222504",
"0.6845478",
"0.6753901",
"0.6743805",
"0.66954577",
"0.6676147",
"0.6596923",
"0.6585888",
"0.65560883",
"0.655217",
"0.6528228",
"0.64807874",
"0.6415566",
"0.6415566",
"0.6402701",
"0.64020294",
"0.6401007",
"0.6395073... | 0.68150455 | 5 |
necessary during early stages of development | def cors_header_check
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'POST, GET'
headers['Access-Control-Request-Method'] = '*'
headers['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept, Authorization'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def used?; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; ... | [
"0.727531",
"0.676443",
"0.6747725",
"0.6739919",
"0.6739919",
"0.6739919",
"0.6739919",
"0.6739919",
"0.6739919",
"0.6739919",
"0.6739919",
"0.6739919",
"0.6739919",
"0.6739919",
"0.6739919",
"0.6739919",
"0.6739919",
"0.6739919",
"0.6739919",
"0.6739919",
"0.6739919",
"0.... | 0.0 | -1 |
GET /arrivals/1 GET /arrivals/1.json | def show
@arrival = Arrival.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @arrival }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @arrivals = Arrival.all\n\n respond_to do |format|\n format.html # fill.html.erb format.json { render json: @arrivals }\n end\n end",
"def airport_arrivals(id, params={})\n perform_get(\"/airports/#{id}/arrivals.xml\", params)\n end",
"def arrivals\n #Project.hit 35\n... | [
"0.7115645",
"0.7077157",
"0.6717325",
"0.6703367",
"0.6671721",
"0.6671721",
"0.65515316",
"0.6488147",
"0.6439535",
"0.62288547",
"0.62100846",
"0.61870587",
"0.6110343",
"0.6110343",
"0.609364",
"0.60695106",
"0.6059268",
"0.6059268",
"0.6042537",
"0.6032776",
"0.5990097",... | 0.7093639 | 2 |
GET /arrivals/new GET /arrivals/new.json | def new
@arrival = Arrival.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @arrival }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @trip = Trip.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trip }\n end\n end",
"def new\n @trip = Trip.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trip }\n end\n end",
"d... | [
"0.70843905",
"0.70843905",
"0.7022519",
"0.69995266",
"0.69335663",
"0.69335663",
"0.69335663",
"0.6931884",
"0.6917015",
"0.6890206",
"0.6869495",
"0.6867715",
"0.6852929",
"0.68528306",
"0.6768532",
"0.6739359",
"0.6717665",
"0.67142737",
"0.6709775",
"0.66990256",
"0.6699... | 0.7962941 | 1 |
POST /arrivals POST /arrivals.json | def create
@arrival = current_user.arrivals.build(params[:arrival])
respond_to do |format|
if @arrival.save
Pusher['presence-arrivals'].trigger('new_arrival', {
:arrival_time => @arrival.created_at.to_s(:long),
:user_email => @arrival.user.email
})
for... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @arrival = Arrival.new(params[:arrival])\n\n respond_to do |format|\n if @arrival.save\n format.html { redirect_to @arrival, notice: 'Arrival was successfully created.' }\n format.json { render json: @arrival, status: :created, location: @arrival }\n else\n format.... | [
"0.6761283",
"0.61860013",
"0.6126515",
"0.6105326",
"0.5993828",
"0.5993828",
"0.59782386",
"0.59549093",
"0.5865398",
"0.5817396",
"0.5789994",
"0.57825863",
"0.57809466",
"0.5773923",
"0.57686347",
"0.57629305",
"0.57517576",
"0.57504517",
"0.57251084",
"0.5698114",
"0.568... | 0.6969931 | 0 |
PUT /arrivals/1 PUT /arrivals/1.json | def update
@arrival = Arrival.find(params[:id])
respond_to do |format|
if @arrival.update_attributes(params[:arrival])
format.html { redirect_to @arrival, notice: 'Arrival was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n travel = Travel.find(params[:id])\n if travel.update(travel_params)\n render json: travel, status: 200\n else\n render json: travel.errors, status: 422\n end\n end",
"def update\n @trip = Trip.find(params[:id])\n\n if @trip.end_point = Station... | [
"0.60552293",
"0.60204107",
"0.6019775",
"0.5958024",
"0.59351474",
"0.5834267",
"0.5811108",
"0.5799083",
"0.5799018",
"0.57833135",
"0.56771964",
"0.5675235",
"0.5655865",
"0.56378907",
"0.563252",
"0.5632405",
"0.5632405",
"0.56269854",
"0.5622864",
"0.559195",
"0.5583971"... | 0.6641301 | 1 |
DELETE /arrivals/1 DELETE /arrivals/1.json | def destroy
@arrival = Arrival.find(params[:id])
@arrival.destroy
respond_to do |format|
format.html { redirect_to arrivals_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n client.delete(\"/#{id}\")\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def destroy\n @flight.destroy\n respond_to do |format|\n format.html { redirect_to flights_url }\n ... | [
"0.6750658",
"0.6557023",
"0.6552008",
"0.6547484",
"0.6547484",
"0.6547484",
"0.65338945",
"0.65030587",
"0.65030587",
"0.6502469",
"0.6502469",
"0.6502469",
"0.6493088",
"0.6492818",
"0.64850503",
"0.64850503",
"0.64850503",
"0.647369",
"0.6463625",
"0.64549553",
"0.644022"... | 0.7438638 | 1 |
a command came from a client, execute its effect on the world. | def handle_command(command)
cmd = command.command
return Response.new unless cmd
if cmd.start_with?("'")
cmd = "say " + cmd[1, cmd.length-1]
end
if cmd.start_with?('say ')
command.say = cmd[4, cmd.length-4].strip
end
command.command = cmd.downcase
handlers = find_handlers(co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_action\n if self.affects == \"world\" then\n player_tile = self.character.tile\n\n # an aoe effect is represented as a list of objects,\n # each one representing the effect on one tile\n ITEM_PROPERTIES[self.item_type][\"aoe\"].each do |aoe|\n dx = aoe[\"xCoordPlus\"]\n ... | [
"0.60586",
"0.58513767",
"0.57897276",
"0.5765125",
"0.57513386",
"0.5748976",
"0.5699783",
"0.5622968",
"0.55862224",
"0.55159926",
"0.55079955",
"0.5498288",
"0.5457609",
"0.53801364",
"0.53693694",
"0.53678244",
"0.53562075",
"0.53513926",
"0.53484535",
"0.5312533",
"0.531... | 0.50521654 | 66 |
a message arrived, execute it | def handle_event(event)
if event.is_a? CommandMessage
handle_command(event)
elsif event.is_a? LoginMessage
player_data = @database.check_password(event.username, event.password)
if player_data
puts "#{player_data[:username]} logs in"
body = @world.find_player(event.username) ||... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def receive_object message\n message.exec self \n end",
"def execute(message)\n data_payload = unpack(message)\n payload = new_payload(\n config[:name],\n :cfn_event => data_payload\n )\n if(config[:reprocess])\n debug \"Reprocessing payload through ... | [
"0.7005879",
"0.6956976",
"0.6938491",
"0.68255776",
"0.66809577",
"0.6656992",
"0.66569304",
"0.66385996",
"0.6594332",
"0.65762395",
"0.6471502",
"0.643358",
"0.64027405",
"0.63653463",
"0.6364423",
"0.63560396",
"0.63545686",
"0.6320944",
"0.63101244",
"0.62892354",
"0.628... | 0.0 | -1 |
GB uses Markdown's strong emphasis of double asterisks. Text like text does not render as bold in Slack until it is converted to single asterisks. Render demo: | def format_double_bold(text)
redcarpet_markdown.render(text)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def markdown(text)\n BlueCloth.new(text).to_html\n end",
"def markdown(text)\n BlueCloth::new(text).to_html\n end",
"def markdown(text)\n BlueCloth::new(text).to_html\nend",
"def markdown(text)\n BlueCloth::new(text).to_html.html_safe\n end",
"def asterisks(text)\n asterisks = text.split.ma... | [
"0.6910552",
"0.67563766",
"0.6734914",
"0.6672844",
"0.66438663",
"0.6607459",
"0.6575097",
"0.6568459",
"0.6568459",
"0.6480562",
"0.6404398",
"0.6318089",
"0.6309525",
"0.6289904",
"0.6228751",
"0.61809796",
"0.612322",
"0.61115307",
"0.61115307",
"0.6096524",
"0.6082532",... | 0.6943351 | 0 |
Needs arguments to be compatible with rails as_json calls | def as_json(include_config: false, **kwargs)
json = {
name: @name,
replication_factor: @replication_factor,
partitions: @partitions.sort_by(&:partition_id).map(&:as_json)
}
if include_config
json[:config] = {
max_message_bytes: max_message_bytes,
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_json(*args); end",
"def to_json(*_arg0); end",
"def to_json(*_arg0); end",
"def to_json(*args)\n to_arg.to_json(*args)\n end",
"def to_json *args\n as_json.to_json *args\n end",
"def to_json(*args)\n as_json(args).to_json\n end",
"def to_json(*args)\n as_json.to_json(*args... | [
"0.7974914",
"0.7907674",
"0.7907674",
"0.778151",
"0.7751051",
"0.77300876",
"0.7713688",
"0.7713688",
"0.7713688",
"0.7713688",
"0.7705723",
"0.75767976",
"0.7489579",
"0.7428683",
"0.7390233",
"0.7369573",
"0.7318836",
"0.7276543",
"0.7229763",
"0.7209761",
"0.7177428",
... | 0.0 | -1 |
Initialize with the base theme | def initialize(base_theme_directory)
@prefix = 'jquery.ui'
@theme_filename = "#{@prefix}.theme.css"
@base_theme_directory = base_theme_directory
@base_theme = File.read(File.join(@base_theme_directory, @theme_filename))
# Fix opacity issue
print "Fixing overlays\n"
@base_theme.sub!(/\/\*\{b... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(theme = nil)\n @current_theme = theme\n end",
"def initialize\n load_default_styles\n end",
"def initialize(theme_name)\n\t\t@theme_name = theme_name\n\tend",
"def default_theme\n nil\n end",
"def theme; end",
"def theme; end",
"def theme; end",
"def the... | [
"0.7371643",
"0.7208798",
"0.7037796",
"0.7034424",
"0.70009243",
"0.70009243",
"0.70009243",
"0.6903947",
"0.62978727",
"0.6192615",
"0.6186564",
"0.61707383",
"0.61349463",
"0.60952115",
"0.6063776",
"0.6051407",
"0.59607595",
"0.5918559",
"0.5885098",
"0.5881571",
"0.58541... | 0.74888664 | 0 |
This sets up the Regexp that will extract the variables from a theme | def regexp
return @regexp if @regexp
placeholder = '___PLACEHOLDER___'
@regexp = @base_theme.dup
# Install placeholders for the variable data
@regexp.gsub!(VARIABLE_MATCHER) { placeholder }
# Strip the header comments
@regexp.gsub! /.*^\*\/\s*/m, ''
# Collapse all whitespace
@regexp.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def regexp_variables\n return @regexp_variables if @regexp_variables\n @regexp_variables = Array.new\n @base_theme.scan(VARIABLE_MATCHER) { @regexp_variables << $2 }\n @regexp_variables\n end",
"def variable_regex\n /\n \\$ # start tag\n ([a-zA-Z_][\\w_]*) # our variables... | [
"0.7615139",
"0.61254996",
"0.60911113",
"0.5645285",
"0.55826956",
"0.5561406",
"0.5446633",
"0.54244494",
"0.54052573",
"0.5385783",
"0.53745556",
"0.5357795",
"0.534928",
"0.532198",
"0.53193986",
"0.5314709",
"0.5311704",
"0.5240989",
"0.52167237",
"0.52079797",
"0.519977... | 0.72821087 | 1 |
You can zip this with the regexp captures to create a variable hash | def regexp_variables
return @regexp_variables if @regexp_variables
@regexp_variables = Array.new
@base_theme.scan(VARIABLE_MATCHER) { @regexp_variables << $2 }
@regexp_variables
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_hash(str, pat, *matchvars)\n rc = {}\n\n # get the possibilities from the pattern\n namemap = pat.named_captures\n\n pat.match(str) do |m|\n matchvars.each { |var| rc[var] = m.values_at(namemap[var]) if namemap.key? var }\n end\n\n rc\n end",
"def scan_regex_pa... | [
"0.7431161",
"0.65720737",
"0.6410972",
"0.6403152",
"0.63515353",
"0.62570435",
"0.62254936",
"0.62251085",
"0.60857445",
"0.6084638",
"0.6084638",
"0.6081642",
"0.60780644",
"0.6020241",
"0.6002436",
"0.59647655",
"0.5906726",
"0.59057117",
"0.59057117",
"0.59045464",
"0.58... | 0.639564 | 4 |
Convert all the ui..css files into sass goodness | def convert_css(stylesheets)
FileUtils.mkdir_p(File.join(stylesheets))
Dir.foreach @base_theme_directory do |file|
next unless /^#{@prefix}\..*\.css$/ =~ file
next if ["{#{@prefix}.all.css", "#{@prefix}.base.css"].include? file
css = File.read(File.join(@base_theme_directory, file))
if ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_flat_ui_stylesheet_assets!\n log_status 'Processing stylesheets...'\n files = read_files('less', flat_ui_less_files)\n\n log_status ' Converting LESS files to Scss:'\n files.each do |name, file|\n log_processing name\n\n # apply common conversions\n # icon-font... | [
"0.7457896",
"0.7114562",
"0.6858612",
"0.67364323",
"0.6718645",
"0.66263646",
"0.6556766",
"0.6490921",
"0.64855653",
"0.636389",
"0.62936145",
"0.62486863",
"0.6243033",
"0.6207922",
"0.6196938",
"0.61493677",
"0.6148923",
"0.6113094",
"0.6074294",
"0.6052726",
"0.60305816... | 0.7043053 | 2 |
Create a sass file of variables names and copy the images | def convert_theme(name, dir, stylesheets)
if name == 'base'
theme = @base_theme
else
theme = File.read(File.join(dir, @theme_filename))
# Fix Overlay stuff
theme.gsub!(/\;filter:Alpha/, "; filter: Alpha")
theme += WIDGET_BORDER
theme += AUTOCOMPLETE_FIX
end
FileUtils... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy_template_files\n output \"This installs sass variable files you can modify to customize the appearance of your Bootstrap installation.\", :magenta\n template \"stylesheets/colors.css.scss\", \"app/assets/stylesheets/customizable_bootstrap/colors.css.scss\"\n template \"stylesheets/font.css.... | [
"0.65438044",
"0.6503764",
"0.62073773",
"0.62048966",
"0.6025728",
"0.5975111",
"0.5875837",
"0.58534986",
"0.582579",
"0.5701611",
"0.5695355",
"0.5693095",
"0.56529456",
"0.56529456",
"0.56489015",
"0.55846107",
"0.55837893",
"0.55239373",
"0.55239373",
"0.55161685",
"0.55... | 0.5491468 | 24 |
Time complexity: o(n) one each loop Space complexity: O(n) made a reverse and a word holder | def reverse_sentence(my_sentence)
if my_sentence == ""
return ""
elsif my_sentence == nil
return nil
end
split = my_sentence.split("")
reverse = ""
word_holder = ""
split.each do |char|
if char == " "
reverse = "#{word_holder}#{reverse}"
reverse = "#{char}#{reverse}"
word_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def word_reverse(my_words, word_start, word_end)\n return nil if my_words == nil || my_words.length == 0\n\n i = word_start # first index of character word word\n j = word_end # last index of character in word\n\n while i < j\n temp = my_words[i] # swap with temporary variable\n my_words[i] = my_words[j]... | [
"0.73096377",
"0.7173248",
"0.7157435",
"0.71564585",
"0.7105556",
"0.7082549",
"0.70777446",
"0.7074851",
"0.70530105",
"0.70456445",
"0.70445174",
"0.7037284",
"0.70142245",
"0.6995211",
"0.69830436",
"0.6980095",
"0.6963145",
"0.69628966",
"0.69618875",
"0.69480455",
"0.69... | 0.0 | -1 |
this action is only called via Ajax and renders the results to the 'app/views/tasks/_task_list.html.erb' partial | def create
task = Task.new(params[:task])
unless task.save
flash[:error] = "Unable to add task"
end
@tasks = Task.open_tasks
render :partial => "task_list", :layout => false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @tasks = @list.tasks.order(status: :asc)\n return render_success_task_index\n end",
"def index\n @tasks = context.active.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tasks }\n format.json { render :json => @tasks }\n ... | [
"0.7249312",
"0.7059107",
"0.69574124",
"0.6923075",
"0.69186497",
"0.69080186",
"0.6773693",
"0.67551666",
"0.6702523",
"0.6679603",
"0.6663663",
"0.66232955",
"0.6608424",
"0.6598598",
"0.65877974",
"0.65685534",
"0.65479654",
"0.6535919",
"0.6533673",
"0.6526622",
"0.65196... | 0.6374877 | 40 |
This action is only called via Ajax and renders the results to the 'app/views/tasks/_task_list.html.erb' partial | def complete
task = Task.find(params[:id])
task.completed = false
unless task.save
flash[:error] = "Unable to mark task as completed"
end
@tasks = Task.open_tasks
render :partial => "task_list", :layout => false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @tasks = @list.tasks.order(status: :asc)\n return render_success_task_index\n end",
"def index\n @tasks = context.active.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tasks }\n format.json { render :json => @tasks }\n ... | [
"0.73019683",
"0.715066",
"0.7003902",
"0.69786096",
"0.6977844",
"0.6955553",
"0.6840483",
"0.67678106",
"0.6745804",
"0.6730141",
"0.67250156",
"0.6698674",
"0.6687071",
"0.66667694",
"0.6653216",
"0.66346836",
"0.6631281",
"0.66101325",
"0.66086394",
"0.65984684",
"0.65690... | 0.63675207 | 43 |
for DEMO call an agent by name and "run" task > create log record | def agent_call
begin
agent = AgentClient.find_by(name: params[:name])
task = agent.task
log = TaskLog.new(
task_id: task.id,
start_datetime: DateTime.now(),
exc_status: TaskLog::EXC_STATUS[rand(0..1)] # randomize result status
)
# ensure save
if !log.save
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createAgent _args\n \"createAgent _args;\" \n end",
"def hello\n log do |msg|\n msg.add_record(agent_type, \"action\", \"hello\")\n msg.add_record(agent_type, \"uuid\", uuid)\n end\n super\n end",
"def agent _args\n \"agent _args;\" \n end",
"de... | [
"0.6361938",
"0.61715996",
"0.5984144",
"0.5926756",
"0.5900073",
"0.5880284",
"0.57207656",
"0.5688443",
"0.56865335",
"0.5646398",
"0.56320226",
"0.5628586",
"0.5546011",
"0.5538207",
"0.5429098",
"0.5417497",
"0.5417156",
"0.54152596",
"0.54150605",
"0.54102886",
"0.540523... | 0.71584785 | 0 |
Layouts have no default layout. | def default_layout
nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def no_layout?; end",
"def layout\n nil\n end",
"def layout\n nil\n end",
"def _implied_layout_name; end",
"def default_layout\n 'default' if html?\n end",
"def layouts=(_arg0); end",
"def layouts=(_arg0); end",
"def static_layout\n nil\n end",
"def set_layout_to_none\n... | [
"0.814852",
"0.78608483",
"0.77642167",
"0.7673979",
"0.7543518",
"0.73634493",
"0.73634493",
"0.73471946",
"0.7329695",
"0.72892",
"0.72767884",
"0.72578746",
"0.72578746",
"0.7198397",
"0.716212",
"0.7136925",
"0.71168435",
"0.71168435",
"0.7043506",
"0.6984322",
"0.6932122... | 0.8424146 | 0 |
def local_request? false end | def routing_mismatch
raise ::ActionController::RoutingError,"URL not supported"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def local_request?\n false\n end",
"def local_request?\n false\n end",
"def local_request?\n false\n end",
"def local_request?\n true\n end",
"def local_request?\n true\n end",
"def rdaw_local_mode?\n respond_to?(:local_request?) ? local_request? : request.local?\n end",... | [
"0.97187877",
"0.97187877",
"0.97187877",
"0.951732",
"0.94205076",
"0.84819925",
"0.844627",
"0.83703446",
"0.83239925",
"0.83239925",
"0.8188344",
"0.8120051",
"0.7960264",
"0.7960264",
"0.7880922",
"0.7880922",
"0.7856309",
"0.78556037",
"0.78556037",
"0.78231436",
"0.7778... | 0.0 | -1 |
palindrome, false otherwise. (A palindrome reads the same forwards and backwards.) Case matters, and all characters should be considered. recursive | def palindrome1?(str)
if str.size <= 1
true
else
str[0] == str[-1] ? palindrome1?(str[1..-2]) : false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recursive_palindrome?(s)\n s.downcase!\n s.gsub!(/[^a-z0-9]/i, '')\n if s.length <= 1\n return true\n end\n if s[0] == s[-1]\n return recursive_palindrome?(s[1...-1])\n end\n return false\nend",
"def is_palindrome(s)\n return true if s.empty?\n if s[0] == s[-1]\n s.sub... | [
"0.8475074",
"0.83739686",
"0.8353675",
"0.8224958",
"0.8213844",
"0.8161212",
"0.8153377",
"0.815059",
"0.8150101",
"0.81271166",
"0.8123125",
"0.81178415",
"0.81178415",
"0.8114754",
"0.8102596",
"0.80982774",
"0.8094617",
"0.80845016",
"0.80774",
"0.80515",
"0.8034894",
... | 0.0 | -1 |
Use partial "tags/link" , :tags => ARRAY restituisce un array... ' | def sminuzza_tags(str)
return [] unless str
str.split(/[ ,]/).map{|tag| '' + tag.downcase }.select{|tag| tag.length > 1 }.sort.uniq rescue ["Execption::SminuzzaTag", "#{$!}" ]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tags_partial(tags)\n \"tags = [#{tags.map { |name, value| \"\\\"#{name}-#{value}\\\"\" }.join(', ')}]\"\n end",
"def tags_partial(tags)\n \"tags = [#{tags.map { |tag| \"\\\"#{tag}\\\"\" }.join(', ')}]\"\n end",
"def fragment(tags); end",
"def tags; end",
"def tags; end",
"def tags; end",
"d... | [
"0.6226443",
"0.6224019",
"0.6095857",
"0.60513675",
"0.60513675",
"0.60513675",
"0.60513675",
"0.60513675",
"0.6007032",
"0.59896886",
"0.5987791",
"0.5973607",
"0.59630144",
"0.59199554",
"0.5914239",
"0.591213",
"0.59118235",
"0.5904215",
"0.5900666",
"0.581527",
"0.5815",... | 0.0 | -1 |
Stores another 'ClassName' => [id] pair in the session for the person to claim when they signin | def remember_unclaimed_record(record)
if logged_in?
record.claim_by(current_user)
else
session[:unclaimed_records] ||= {}
(session[:unclaimed_records][record.class.to_s] ||= []) << record.id
end
record
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_class_session\n @class_session = ClassSession.find(params[:id])\n end",
"def set_class_session\n @class_session = ClassSession.find(params[:id])\n end",
"def set_class_session\n\t\t@class_session = ClassSession.find(params[:id])\n\tend",
"def login!(session)\n session[:user_id] = s... | [
"0.69740164",
"0.69740164",
"0.6960803",
"0.6756183",
"0.66531646",
"0.66039675",
"0.65591735",
"0.64438194",
"0.6393976",
"0.63540095",
"0.63515216",
"0.6341474",
"0.6341474",
"0.6341474",
"0.6341474",
"0.6341474",
"0.6324125",
"0.6324125",
"0.6324125",
"0.6324125",
"0.63043... | 0.0 | -1 |
Claims the unclaimed records stored in the session | def claim_records
session[:unclaimed_records].each_pair do |klass, record_ids|
record_ids.each do |record_id|
if record = (klass.constantize.find(record_id) rescue nil)
record.claim_by(current_user)
@claimed_records = true
end
end
end.clear if sess... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remember_unclaimed_record(record)\n if logged_in?\n record.claim_by(current_user)\n else\n session[:unclaimed_records] ||= {}\n (session[:unclaimed_records][record.class.to_s] ||= []) << record.id\n end\n record\n end",
"def ageoff\n messages.reject! { |... | [
"0.68307805",
"0.6729823",
"0.64956415",
"0.64956415",
"0.62330407",
"0.5873391",
"0.5873391",
"0.58540535",
"0.5778967",
"0.5777264",
"0.5777264",
"0.5771338",
"0.57573783",
"0.574404",
"0.57420146",
"0.5731468",
"0.56809974",
"0.5640415",
"0.5640264",
"0.56184435",
"0.55458... | 0.75931984 | 0 |
An ivar to record if we've claimed any records in this request | def claimed_records?
@claimed_records || false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def claimed?\n ! @claim.nil?\n end",
"def claimed?\n !claimant.nil?\n end",
"def recorded?\n return ignoring_recorded? if ignoring_request?\n\n @recorded\n end",
"def claim!\n interested.unrequested.each do |membership|\n self << membership\n end\n ... | [
"0.65317273",
"0.6383929",
"0.6199032",
"0.605351",
"0.6044177",
"0.6044177",
"0.59785205",
"0.57473916",
"0.5737981",
"0.5709242",
"0.56452066",
"0.56452066",
"0.56222457",
"0.55894244",
"0.55557346",
"0.55530304",
"0.5542879",
"0.55351686",
"0.54972106",
"0.5495457",
"0.549... | 0.7240788 | 0 |
Returns true if the nonloggedin user has the given class in their session's unclaimed_records. If +func+ is passed in, this only returns true if the func is true for at least one of the records of this class in the session[:unclaimed_records] | def has_unclaimed_record?(klass, func=nil)
if session[:unclaimed_records] && session[:unclaimed_records][klass.to_s] && records = klass.find(session[:unclaimed_records][klass.to_s].compact)
return false if records.empty?
return false if func && !records.any?(&func)
return true
else
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def claim_records\n session[:unclaimed_records].each_pair do |klass, record_ids|\n record_ids.each do |record_id|\n if record = (klass.constantize.find(record_id) rescue nil)\n record.claim_by(current_user)\n @claimed_records = true\n end\n end\n end.... | [
"0.57745177",
"0.54527193",
"0.53767115",
"0.50588834",
"0.48363295",
"0.48290882",
"0.48183557",
"0.48151854",
"0.4811046",
"0.4712848",
"0.4694201",
"0.4677493",
"0.46302435",
"0.4607934",
"0.45815355",
"0.45684168",
"0.45535812",
"0.45484096",
"0.45470947",
"0.453703",
"0.... | 0.8206539 | 0 |
Omit AJAX from CSFR protection; we can remove this overwritten method when we upgrade to Rails 3. | def verified_request?
!protect_against_forgery? ||
request.method == :get ||
request.xhr? ||
!verifiable_request_format? ||
form_authenticity_token == params[request_forgery_protection_token]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def access_only_for_ajax\r\n unless request.xhr?\r\n render :text => \"Here is an Ajax Service, regular request without security token are denied.\"\r\n return false\r\n end\r\n end",
"def no_ajax # :nologin: :norobots:\n end",
"def check_use_ajax\n case self.use_ajax\n when Obj... | [
"0.71648514",
"0.706473",
"0.6966191",
"0.6893345",
"0.6679608",
"0.65558916",
"0.63888943",
"0.63364136",
"0.6317158",
"0.6294185",
"0.6255316",
"0.6203483",
"0.6191548",
"0.61675733",
"0.61539096",
"0.61493456",
"0.61085176",
"0.60548586",
"0.60192496",
"0.598675",
"0.59867... | 0.0 | -1 |
=begin input = pre_doc.join("\n") + "\n" + input unless pre_doc.empty? input = input + "\n" + post_doc.join("\n") unless post_doc.empty? return input =end | def output_post_model
#post_doc
out_post=""
#puts "output_post_model:post doc";p @post_doc
unless @post_doc.empty?
post_doc="\n"+@post_doc.join("\n")
txt= post_doc
parse(txt)
end
unless @post_model.empty?
post_model="\n"+@post_model.join("\n")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collect_document(input, output)\r\n inputs=input.map{|xx| xx.esc.to_osPath }.join(\" \") # qoute cond combine the inputs\r\n\r\n #now combine the input files\r\n @log.info(\"combining the input files\")\r\n cmd=\"pandoc -s -S -o #{output} --ascii #{inputs}\" # note that inputs is a... | [
"0.6407976",
"0.6294126",
"0.5683688",
"0.566322",
"0.56109875",
"0.552638",
"0.55038154",
"0.54679185",
"0.54154027",
"0.54024816",
"0.5373148",
"0.53612936",
"0.5357979",
"0.5285006",
"0.5265163",
"0.52648664",
"0.5260708",
"0.5251229",
"0.52300996",
"0.5229219",
"0.5208005... | 0.61101913 | 2 |
output the result after parsing txt | def output(input,fromfile=nil)
@filename=@tmpl_cfg[:filename_tmpl]
input=CqlsDoc.input_from_file(@filename=input) if fromfile
## fetch the contents of all saved variables! This fasten the compilation!
Utils.saved_content_fetch_variables_from_file(@filename,self)
#p @filename
init_path(inp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse(text); end",
"def parse_answer(answer, file)\n return \"Result #{file}:\\n#{answer}\"\n end",
"def raw_output\n @raw_output ||= begin\n lines = path.read.split(\"\\n\")\n lines.shift\n [titre, lines.join(' ').strip_tags(' ')]\n end\n end",
"def output text\n puts text\n... | [
"0.6250036",
"0.6219438",
"0.62093717",
"0.6142294",
"0.5985216",
"0.59772867",
"0.59543616",
"0.5952289",
"0.59401685",
"0.59401685",
"0.5888307",
"0.5849031",
"0.58380306",
"0.58353925",
"0.58282846",
"0.58073735",
"0.58018655",
"0.57928514",
"0.5745153",
"0.57395774",
"0.5... | 0.0 | -1 |
=begin DONE: put in Document class writing in final file def write(file) | def query_library(libname)
init_doc({:format_doc=>:tex})
parse(CqlsDoc.input_from_file(libname))
p @calls.keys.sort
p @meths.sort
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_to(doc);end",
"def write_to_file(filename, method)\n\t\t\tFile.open(filename, method) do |file|\n\t\t\t\tfile.write(@doc)\n\t\t\tend\n\t\tend",
"def modify_file(path,document) \n File.open(path,'w') do|file|\n file.write(document) if document\n end\nend",
"def save!\n Powirb.log.debug(\"[... | [
"0.75950444",
"0.74687445",
"0.7273328",
"0.7145226",
"0.702389",
"0.7023609",
"0.69743204",
"0.69465804",
"0.6920927",
"0.6905362",
"0.6853137",
"0.6853137",
"0.68005615",
"0.67018455",
"0.667238",
"0.66621417",
"0.6661189",
"0.66573095",
"0.66044724",
"0.65745384",
"0.65691... | 0.0 | -1 |
`initialize` will receive all params, loaded from ARGV | def initialize(*, verbose: '1', log_file: STDERR, **)
v = (verbose =~ /\d+/) ? verbose.to_i : verbose.to_sym
self.logger = Logger.new(log_file, v)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(args = {})\n parse_args(args)\n end",
"def initialize(args=ARGV)\n @args = args\n end",
"def initialize(given_args=ARGV)\n @options, @arguments, @extras = self.class.parse_options!(given_args)\n end",
"def initialize(argv = nil)\n\t\t\targv ||= ARGV.drop(1)\n\n\t\t\traise \"Not... | [
"0.7734921",
"0.7701596",
"0.75890106",
"0.7334812",
"0.73026526",
"0.71489984",
"0.71341103",
"0.71050763",
"0.7055103",
"0.7048398",
"0.7038699",
"0.6925915",
"0.69227093",
"0.6915212",
"0.68961304",
"0.689531",
"0.6885062",
"0.68718046",
"0.68645847",
"0.68444324",
"0.6833... | 0.0 | -1 |
Stores the graph in the database. | def create
@name_changed = false
@wait_for_sync_changed = false
body = {}.merge(@attributes)
body.merge!(@changed_attributes)
@properties.each do |k, v|
body[:options][k.to_s.camelize(:lower)] = v unless v.nil?
end
params = {}
if @wait_for_syn... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def store_graph\n FileUtils.mkdir_p(File.dirname(self.filename))\n store = PStore.new(self.filename)\n store.transaction do\n store[:version] = STORE_VERSION\n store[:vertices] = @graph.vertices.map { |i| i && i.identifier }\n store[:edges] = @graph.edges\n end\n end... | [
"0.7632864",
"0.7584782",
"0.7116761",
"0.69814783",
"0.6385597",
"0.63572454",
"0.63221514",
"0.63187957",
"0.6232046",
"0.6232046",
"0.6232046",
"0.6222854",
"0.62070495",
"0.61688983",
"0.61485374",
"0.6121949",
"0.6086479",
"0.60348296",
"0.59859526",
"0.5978978",
"0.5955... | 0.0 | -1 |
Helper function used to insert a value to a nodes left or right (less or more) | def insert node, value= nil
if value < node.value
node.left.nil? ? node.left = Node.new(value, node) : insert(node.left, value)
elsif value >= node.value
node.right.nil? ? node.right = Node.new(value, node) : insert(node.right, value)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_right(value)\n right.insert(value) or self.right = Node.new(value, self)\n end",
"def insert(value, node = root)\n return nil if value == node.data\n \n if value < node.data\n node.left.nil? ? node.left = Node.new(value) : insert(value, node.left)\n else\n node.ri... | [
"0.77724874",
"0.7589239",
"0.75648034",
"0.75409967",
"0.7536452",
"0.7435418",
"0.73986894",
"0.7398428",
"0.7351477",
"0.7317015",
"0.728522",
"0.72436285",
"0.7202105",
"0.7187135",
"0.7144521",
"0.7120059",
"0.7112189",
"0.7095632",
"0.7094324",
"0.6988529",
"0.69539535"... | 0.74767053 | 5 |
Creates a binary tree from an input array of variables using the helper function 'insert'. | def build_tree array
@root = Node.new array[0]
@nodes += 1
array[1..-1].each do |var|
insert(@root,var)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_tree(array)\n tree = TreeNode.new(array[0], 0)\n (1..array.length-1).each {|i|\n insert_into_tree(tree, array[i], i)\n }\n tree\nend",
"def build_tree(ary)\n # If the array is sorted, the tree will not be balanced\n ary.shuffle!\n ary.each { |item| insert(item) }\n end",
"def build_t... | [
"0.73282427",
"0.7293244",
"0.72882175",
"0.7253828",
"0.7180085",
"0.71399933",
"0.69514185",
"0.6717783",
"0.6635269",
"0.66324043",
"0.66176105",
"0.6597935",
"0.6556088",
"0.6502982",
"0.6491265",
"0.6490909",
"0.64087355",
"0.63506305",
"0.63440204",
"0.6317904",
"0.6312... | 0.7431215 | 0 |
Runs a breadth first search for value using an array acting as a queue. | def breadth_first_search node= self.root, value
queue = [node]
while queue.length > 0
current = queue.pop
return "Value #{value} found in #{current.to_s}" if current.value == value
queue.unshift(current.left) if current.left
queue.unshift(current.right) if current.right
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def breadth_first_search(tree, value)\n tgt_node = nil\n \n queue = Array(tree)\n \n while !queue.empty?\n cur_node = queue.shift \n \n\tif cur_node.value == value\n\t tgt_node = cur_node\n\t break\n\tend\n\t\n\tcur_node.children.each { |child| queue << child unless child.nil? }\n end\n \n tgt_nod... | [
"0.76666874",
"0.73679",
"0.730551",
"0.7275885",
"0.7225089",
"0.71600777",
"0.71015966",
"0.70995975",
"0.70870453",
"0.7011919",
"0.6951017",
"0.6917698",
"0.68982434",
"0.68845546",
"0.6884544",
"0.68579715",
"0.67995167",
"0.67693204",
"0.6765907",
"0.67166215",
"0.67023... | 0.7632636 | 1 |
Runs a depth first search for value an array acting as a stack. | def depth_first_search node= self.root, value
stack =[node]
while stack.length > 0
current = stack.pop
return "Value #{value} found in #{current.to_s}" if current.value == value
stack.push(current.left) if current.left
stack.push(current.right) if current.right
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def depth_first_search(array)\n array.append(self.name)\n self.children.each do |child|\n child.depth_first_search(array)\n end\n return array\n\n end",
"def depth_first_search(tree, value)\n tgt_node = nil\n \n stack = Array(tree)\n \n while !stack.empty?\n cur_node = stack.pop\n \n\t... | [
"0.6980464",
"0.6877953",
"0.6613963",
"0.65824693",
"0.6575633",
"0.6571671",
"0.65531284",
"0.65468967",
"0.6533253",
"0.6475401",
"0.6471366",
"0.6462783",
"0.64551365",
"0.64415497",
"0.64407045",
"0.6392054",
"0.6379745",
"0.632337",
"0.6321352",
"0.63100743",
"0.6304715... | 0.6894411 | 1 |
Runs a depth first search for value using recursion. | def dfs_rec node= self.root, value
if node.value == value
return "Value #{value} found in #{node.to_s}"
else
dfs_rec(node.left, value) if node.left
dfs_rec(node.right, value) if node.right
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def depth_first_search node= self.root, value\n\t\tstack =[node]\n\n\t\twhile stack.length > 0\n\t\t\tcurrent = stack.pop\n\t\t\treturn \"Value #{value} found in #{current.to_s}\" if current.value == value\n\t\t\tstack.push(current.left) if current.left\n\t\t\tstack.push(current.right) if current.right\n\t\tend\n\... | [
"0.8036232",
"0.7929115",
"0.7784866",
"0.7717743",
"0.7578265",
"0.7555512",
"0.7444659",
"0.74339294",
"0.739267",
"0.7365349",
"0.7267244",
"0.7240084",
"0.72175163",
"0.71723056",
"0.71441466",
"0.7143881",
"0.7141611",
"0.71362954",
"0.7133122",
"0.71283793",
"0.7044505"... | 0.70228016 | 23 |
GET /showtimes GET /showtimes.json | def index
params[:day] ||= "today"
if params[:day] == "today"
@show_times = ShowTime.all.where(:show_time => ((Date.current.beginning_of_day)..(Date.current.end_of_day)))
elsif params[:day] == "tomorrow"
@show_times = ShowTime.all.where(:show_time => ((Date.current.beginning_of_day + 216000)..(D... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n render :json => @timecard.to_json(:include => :time_entry), status: :ok\n end",
"def show\n render json: @timer\n end",
"def index\n @service_times = ServiceTime.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @service_times }\n e... | [
"0.7116196",
"0.70107234",
"0.70066756",
"0.69948155",
"0.68383545",
"0.6796034",
"0.67670864",
"0.67585844",
"0.66972965",
"0.6631273",
"0.66299087",
"0.66299087",
"0.65714365",
"0.6564712",
"0.6558048",
"0.65553963",
"0.6550556",
"0.6548504",
"0.65483695",
"0.6545399",
"0.6... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_grid_box
@grid_box = GridBox.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def grid_box_params
params.require(:grid_box).permit(:boxId, :type, :key, :value)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7120904",
"0.70538116",
"0.69469863",
"0.6901261",
"0.67348766",
"0.6717708",
"0.66874576",
"0.6676195",
"0.66601187",
"0.65563625",
"0.6525127",
"0.64565873",
"0.64494514",
"0.644928",
"0.64452374",
"0.6433947",
"0.6412815",
"0.6412815",
"0.6391939",
"0.63792473",
"0.6379... | 0.0 | -1 |
CSV functional test sample data 1 2 3 4 5 6 7 8 +++++++++ | foo | "foo" | foo,bar | "" |(empty) |(null)| \r | \r\n | +++++++++ | NaHi | "Na" | Na,Hi | \r.\n | \r\n\n | " | \n | \r\n | +++++++++ | def test_s_parseAndCreate
colSize = 8
csvStr = "foo,!!!foo!!!,!foo,bar!,!!!!!!,!!,,!\r!,!\r\n!\nNaHi,!!!Na!!!,!Na,Hi!,!\r.\n!,!\r\n\n!,!!!!,!\n!,!\r\n!".gsub!('!', '"')
csvStrTerminated = csvStr + "\n"
myStr = csvStr.dup
res1 = []; res2 = []
idx = 0
col, idx = CSV::parse_row(myStr, 0, res1)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def csv_row\n #empty by default\n []\n end",
"def csv_row\n #empty by default\n []\n end",
"def prepare_csv\n unparsed_file = File.open(csv.path)\n self.parsed_csv_string = \"\"\n string = unparsed_file.readlines()\n string.each_with_index do |line,i|\n parsed_line = line.encode(... | [
"0.65002334",
"0.65002334",
"0.63735694",
"0.63704556",
"0.6353413",
"0.63448125",
"0.6294348",
"0.6220221",
"0.61978936",
"0.61808413",
"0.61486274",
"0.6144548",
"0.6087816",
"0.6026904",
"0.5996811",
"0.59717935",
"0.5946989",
"0.5946989",
"0.5909173",
"0.59081465",
"0.585... | 0.68253714 | 0 |
Parse postegrespr Result into array of key value records. Force utf8 encoding | def parse_results(results)
results.rows.collect do |row|
record = {}
row.each_with_index{|val, i|
val = val.force_encoding('utf-8') if val
record[results.fields[i].name] = val
}
record
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_hash_to_array(rest_client_response)\n array = JSON.parse(rest_client_response)['data']\n # this part is cleaning up mistakes made in the API backend\n # most of the data comes back encoded correctly, but in a couple cases there\n # are characters that are HTML encoded, e.g. \"Haleakalā N... | [
"0.6337812",
"0.5808518",
"0.5665232",
"0.553735",
"0.5392031",
"0.53714573",
"0.5370701",
"0.53537506",
"0.5341749",
"0.53414613",
"0.5293699",
"0.52849627",
"0.52838403",
"0.5280743",
"0.5278633",
"0.52724797",
"0.5220114",
"0.51934797",
"0.5153553",
"0.5145408",
"0.5121922... | 0.78060055 | 0 |
Escape string for SQL and force USASCII encoding as workaround For postgrespr unicode limitations TODO: Handle propper encoding | def escape(str)
str.to_s.gsub(/\\/, '\&\&').gsub(/'/, "''").force_encoding('US-ASCII')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def escape_string(str)\n if not defined? Encoding and @charset.unsafe\n raise ClientError, 'Mysql#escape_string is called for unsafe multibyte charset'\n end\n self.class.escape_string str\n end",
"def escape(s)\n dummy_conn.escape(s)\n end",
"def escape(str)\n return ActiveRe... | [
"0.73590285",
"0.71966517",
"0.7158294",
"0.7047062",
"0.6987968",
"0.69319814",
"0.6904033",
"0.687371",
"0.6837401",
"0.68191904",
"0.6792378",
"0.6787569",
"0.67871684",
"0.67762744",
"0.6740227",
"0.67158073",
"0.6698037",
"0.6678102",
"0.66630775",
"0.66588265",
"0.66542... | 0.725644 | 1 |
Login is where the login form actually posts to. | def login
# Checks if there's a user associated
# with the given email.
u = User.find_by_email(params[:email])
# If we find an email and the user
# supplied the correct password we
# login the user by starting a session.
# We also redirect the user to the
# control panel.
if u && u.authenticate(para... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def login\n\t#Login Form\n end",
"def login\n # show LOGIN form\n\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def login\n end",
"def loginp... | [
"0.85393703",
"0.8211741",
"0.7979325",
"0.7962633",
"0.7962633",
"0.7962633",
"0.7962633",
"0.7962633",
"0.7962633",
"0.7962633",
"0.7962633",
"0.7962633",
"0.7891583",
"0.78869903",
"0.78649575",
"0.7820526",
"0.7820526",
"0.7806804",
"0.77056146",
"0.76870775",
"0.7680023"... | 0.0 | -1 |
in_place_edit_for :page, :title GET /pages GET /pages.xml | def index
@pages = Page.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @pages }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit\n @page = Page.find(params[:id])\n # render :edit - app/views/pages/\n end",
"def edit\n # Clear the page cache for this page... ?\n @page = Comatose::Page.find_is_snippet params[:id]\n if request.post?\n @page.update_attributes(params[:page])\n @page.updated_on = Tim... | [
"0.6955938",
"0.6890909",
"0.6886115",
"0.67862225",
"0.6767124",
"0.6716111",
"0.66822475",
"0.65994394",
"0.65887666",
"0.65887666",
"0.65830815",
"0.6491433",
"0.6402502",
"0.6205837",
"0.61996734",
"0.61890817",
"0.61648",
"0.61293393",
"0.6027093",
"0.5985993",
"0.593871... | 0.0 | -1 |
GET /pages/1 GET /pages/1.xml | def show
@page = Page.find(params[:id])
@select_list=@page.select_list
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @page }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @pages = Page.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n... | [
"0.7240595",
"0.7175242",
"0.71416986",
"0.71416986",
"0.7135126",
"0.7135126",
"0.7057775",
"0.70284396",
"0.6986637",
"0.6978276",
"0.697713",
"0.6938267",
"0.69377303",
"0.68386036",
"0.6821595",
"0.6812652",
"0.6787446",
"0.67184156",
"0.6716908",
"0.6694082",
"0.66778725... | 0.0 | -1 |
GET /pages/new GET /pages/new.xml | def new
@page = Page.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @page }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @page = current_cms.pages.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def new\n @page = Page.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n ... | [
"0.7837418",
"0.7740716",
"0.7740716",
"0.7740716",
"0.7740716",
"0.7740716",
"0.7740716",
"0.7714634",
"0.76722115",
"0.7594718",
"0.75105387",
"0.7480689",
"0.7444072",
"0.73575026",
"0.73414886",
"0.73297346",
"0.72564614",
"0.72548366",
"0.7247537",
"0.7242822",
"0.724016... | 0.7693529 | 8 |
preinit values so we can sumup in case of aggregated test sessions (always use calc_ok_tests when you use this) | def init_tests
unless @init_tests
@test_duration = 0
@num_tests_run = 0
@num_tests_failed = 0
@num_tests_ok = 0
@num_tests_skipped = 0
@init_tests = true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uninit_ok_tests\n if (!@num_tests_run.nil? && !@num_tests_failed.nil?)\n @num_tests_ok += @num_tests_run - @num_tests_failed\n end\n end",
"def pre_testdata\n RVTEST_DATA_BEGIN()\n TEST_DATA()\n RVTEST_DATA_END()\n end",
"def test_intialize\r\n\tassert_equal 0, @test_prospector.curren... | [
"0.6946969",
"0.5869985",
"0.58566684",
"0.57437897",
"0.5707678",
"0.5694035",
"0.5682612",
"0.5616593",
"0.5600137",
"0.5585921",
"0.54965365",
"0.5469027",
"0.5437389",
"0.537975",
"0.5360416",
"0.5341834",
"0.5341559",
"0.5300788",
"0.5295162",
"0.5295162",
"0.52886456",
... | 0.66736096 | 1 |
For nonaggregated reporting, at the end (always use this when you use init_tests) | def uninit_ok_tests
if (!@num_tests_run.nil? && !@num_tests_failed.nil?)
@num_tests_ok += @num_tests_run - @num_tests_failed
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reporters; end",
"def reporters; end",
"def reporters; end",
"def reporters; end",
"def reporters; end",
"def report; end",
"def report; end",
"def report; end",
"def report; end",
"def report; end",
"def summary_at_exit\n reporter = Speciny::Reporter.new(@description)\n @tests.ea... | [
"0.7030722",
"0.7030722",
"0.7030722",
"0.7030722",
"0.7030722",
"0.6964856",
"0.6964856",
"0.6964856",
"0.6964856",
"0.6964856",
"0.65895975",
"0.64980304",
"0.64710766",
"0.6459588",
"0.6459588",
"0.63869375",
"0.6345569",
"0.6296575",
"0.6296243",
"0.6296243",
"0.6294646",... | 0.56653476 | 95 |
steps 1 define method to take in array of hashes 2 loop through array 3 find values beginning with "t" 4 return just those keys | def return_t(hash)
hash.each do |key, value|
if value.to_s.start_with?("t")
puts value
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def part1(clues, aunts)\n result = Array.new aunts\n clues.each do |clue|\n #filter aunts that do not match the key:value in clue\n key = clue.keys.first\n result.reject! {|a| a.has_key? key and clue[key] != a[key] }\n\n #puts \"Using #{key} as the filter, there are now #{aunts.length} remaining poss... | [
"0.5772939",
"0.5658231",
"0.56570834",
"0.56174266",
"0.55018413",
"0.54826903",
"0.5447811",
"0.54375273",
"0.54097927",
"0.5358257",
"0.5357088",
"0.5299037",
"0.52504426",
"0.52070963",
"0.5190202",
"0.5163366",
"0.51589525",
"0.5154215",
"0.5131267",
"0.5131267",
"0.5126... | 0.61332434 | 0 |
Assigns driver to interface according to given class name. | def assign_driver(cls, args, block)
_cls = cls
if not _cls.kind_of? Class
_cls = cls.class
end
driver = nil
name = nil
self.class::DRIVERS.each_pair do |_name, _driver|
begin
_module... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assign_driver(cls, args, block)\n _cls = cls\n if not _cls.kind_of? Class\n _cls = cls.class\n end\n \n driver = nil\n name = nil\n \n self.class::DRIVERS.each_pair do |_name, _driver|\n begin\... | [
"0.6898396",
"0.6414887",
"0.6245282",
"0.6136212",
"0.6022116",
"0.59782004",
"0.590935",
"0.590935",
"0.590935",
"0.590935",
"0.5890892",
"0.58529884",
"0.5818016",
"0.5802407",
"0.5802407",
"0.5788462",
"0.5763683",
"0.5703497",
"0.5703443",
"0.5666455",
"0.5665176",
"0.... | 0.6891401 | 1 |
Pushes value to the currently used queue. | def push(value, key = value, &block)
@driver.push(value, key, &block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(value)\n @queue.push(value)\n end",
"def enqueue(value)\n\t\t\tself.push value\n\t\tend",
"def push(queue, value, args)\n if !defined?(value.queue)\n value.class_eval do \n @queue = queue\n end\n end\n Resque.enqueue value, args\n end",
"def push_queue_pus... | [
"0.8100472",
"0.80925524",
"0.78276044",
"0.78179634",
"0.7678237",
"0.76237106",
"0.7457083",
"0.7403275",
"0.72859806",
"0.725245",
"0.72374123",
"0.7154599",
"0.710109",
"0.70835805",
"0.70767254",
"0.70664155",
"0.70587337",
"0.70398974",
"0.7036825",
"0.7032749",
"0.6993... | 0.0 | -1 |
Pops value from the queue. In contrast to default Queue library, blocks or returns +nil+ if empty. | def pop(blocking = false, &block)
@driver.pop(blocking, &block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pop\n @lock.synchronize do\n @queue.pop\n end\n end",
"def pop()\n res = @pop_queue.shift()\n return res\n end",
"def pop()\n @queue.shift\n end",
"def pop\n if @q.empty?\n raise QueueEmptyError, \"tried to pop empty queue in #{@component.inspect}\"\n ... | [
"0.78295755",
"0.7811208",
"0.7751085",
"0.7718835",
"0.76714605",
"0.7586303",
"0.7570981",
"0.7564747",
"0.75258833",
"0.7518314",
"0.7414804",
"0.7378366",
"0.72887325",
"0.72631633",
"0.72582084",
"0.72483456",
"0.71857494",
"0.71857494",
"0.71430933",
"0.7105133",
"0.703... | 0.634737 | 72 |
Unsubscribes from the queue. | def unsubscribe(name, &block)
@driver.unsubscribe(name, &block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unsubscribe\n raise UnsubscribedError\n end",
"def unsubscribe(name)\n if subscriptions.has_key? name\n subscriptions[name].queue.unsubscribe(:nowait => false)\n subscriptions.delete(name)\n end\n end",
"def unsubscribe!\n @consumer.try(:cancel)\n @consumer = ni... | [
"0.71457344",
"0.71352464",
"0.7115152",
"0.70846844",
"0.7068522",
"0.7033684",
"0.7022528",
"0.6992369",
"0.6953565",
"0.6941829",
"0.6921847",
"0.6903614",
"0.6903614",
"0.68665546",
"0.68665546",
"0.68600345",
"0.6848758",
"0.68473554",
"0.6835722",
"0.6816247",
"0.677507... | 0.0 | -1 |
Lists names of all available queues. | def list(&block)
@driver.list(&block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def names_list\n backend.queue_names\n end",
"def list_queues(options ={})\r\n content = execute(:get, nil, { :comp => 'list' }.merge!(options), { :x_ms_version => \"2009-09-19\" })\r\n doc = REXML::Document.new(content)\r\n queues = []\r\n \r\n REXML::XPath.each(doc, '//Qu... | [
"0.7818388",
"0.74340034",
"0.7228563",
"0.7228563",
"0.71422684",
"0.7141632",
"0.7029463",
"0.70138925",
"0.6960896",
"0.6955575",
"0.68747705",
"0.6842184",
"0.68217856",
"0.67909765",
"0.6786015",
"0.67858887",
"0.673122",
"0.6725873",
"0.67118317",
"0.66961986",
"0.66952... | 0.0 | -1 |
Lists all used queues. | def list_used(&block)
@driver.list_used(&block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_queues(options ={})\r\n content = execute(:get, nil, { :comp => 'list' }.merge!(options), { :x_ms_version => \"2009-09-19\" })\r\n doc = REXML::Document.new(content)\r\n queues = []\r\n \r\n REXML::XPath.each(doc, '//Queue/') do |item|\r\n metadata = {}\r\n ... | [
"0.72419775",
"0.72296345",
"0.7212593",
"0.7212593",
"0.72080034",
"0.71411973",
"0.7079286",
"0.7038783",
"0.6949748",
"0.6937943",
"0.68989444",
"0.6898308",
"0.68709",
"0.6845103",
"0.6818828",
"0.68159103",
"0.680594",
"0.6762415",
"0.67204016",
"0.6709416",
"0.66458523"... | 0.55044365 | 70 |
Lists all subscribed queues. | def list_subscribed(&block)
@driver.list_subscribed(&block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def queues\n @channel.queues\n end",
"def queues\n subject.queues\n end",
"def all_subscriptions(&block)\n subscriptions.list(&block)\n end",
"def list_queues(prefix=nil)\n doc = Adapter.list_queues(prefix)\\\n ['ListQueuesResponse']['ListQueuesResult']\n if d... | [
"0.7321432",
"0.7053913",
"0.6997477",
"0.69509554",
"0.6784317",
"0.67827076",
"0.6779218",
"0.6776401",
"0.67107666",
"0.66905695",
"0.6680743",
"0.6576786",
"0.6515363",
"0.6511169",
"0.63975734",
"0.63680476",
"0.6348695",
"0.6316944",
"0.625861",
"0.625861",
"0.6256063",... | 0.6272559 | 18 |
This method is called from the appserver controller handler. | def render_result
layout = @render_args[:layout]
view = @render_args[:view]
if layout.kind_of? Symbol # this handles the layout(:none)
view.result(binding)
else
@view[:timestamp] = "<!-- server: #{@port} / rendered: #{Time.now()} / env: #{rack_env} -->"
@vie... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def handler; end",
"def handler; end",
"def controller\n ... | [
"0.67471004",
"0.67471004",
"0.67471004",
"0.67471004",
"0.67471004",
"0.67471004",
"0.67471004",
"0.67471004",
"0.67471004",
"0.67471004",
"0.65464276",
"0.65464276",
"0.6517308",
"0.6517308",
"0.64892226",
"0.6342926",
"0.62721676",
"0.62721676",
"0.62721676",
"0.6270918",
... | 0.0 | -1 |
A method to render a partial from a controller. Expects a file name and optional local variables. See Partial for more details. | def partial(file=nil, locals={})
# self.instance_variables.each { | k |
# locals[k.gsub(/@/,'').to_s] = eval(k)
# }
# p locals.inspect
locals[:request] = @request
Doozer::Partial.partial(file, locals, route=@route)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def partial_in(controller, partial_name, *args)\n partial_name = PARTIAL_PREFIX + partial_name.to_s\n begin\n controller.render_partial(partial_name, *args)\n rescue\n Ramaze::Log.error(\"Error loading partial #{controller.to_s}.#{partial_name}\")\n raise $!\n ... | [
"0.8177621",
"0.793868",
"0.76897156",
"0.75072014",
"0.7421098",
"0.72904855",
"0.7240152",
"0.7216561",
"0.7091854",
"0.69767416",
"0.69530475",
"0.69305533",
"0.6918047",
"0.69144297",
"0.6906409",
"0.6906409",
"0.68998224",
"0.6869278",
"0.684563",
"0.68193406",
"0.681897... | 0.7209802 | 8 |
Redirect the response object to the tokenized route url with optional query string values The route is passed through the ViewHelpers.url method. See url() for examples. | def redirect_to(route={}, opts={})
path = url(route)
# p "Redirect to: #{path}"
raise Doozer::Redirect.new(path, opts)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def route_link\n\t\tnew_url = Rlink.url_lookup_by_token(params[:link_token])\n\t\tnew_url == nil ? (render :token_not_found) : (redirect_to new_url)\n\tend",
"def redirect_to url, options = {}\n\t\t\t\treturn super() if defined? super\n\t\t\t\turl = full_url_for(url, params) unless url.is_a?(String) || url.nil?\... | [
"0.6724981",
"0.6628224",
"0.6272731",
"0.6266265",
"0.6227857",
"0.61656255",
"0.60809463",
"0.5990799",
"0.5948626",
"0.5937713",
"0.58845115",
"0.5865235",
"0.58374393",
"0.58280396",
"0.57808423",
"0.57792366",
"0.5723146",
"0.5695282",
"0.56847745",
"0.5682902",
"0.56785... | 0.5881066 | 11 |
Sequel ORM db connection | def db
Doozer::Configs.db_conn
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sequel\n Sequel.connect( sequel_url )\n end",
"def connect\n Alf::Tools::friendly_require('sequel')\n @db ||= ::Sequel.connect(@uri, @options)\n end",
"def connect\n @db = Sequel.mysql(@database,\n :user => @db_user,\n :password => @db_password,\n :host => @host... | [
"0.8033123",
"0.7750979",
"0.77483827",
"0.77101386",
"0.7597503",
"0.75889647",
"0.75202364",
"0.74727464",
"0.7436436",
"0.7336345",
"0.7211858",
"0.72013766",
"0.71992636",
"0.7184156",
"0.716115",
"0.7076065",
"0.7029372",
"0.69512606",
"0.6896233",
"0.6896233",
"0.688341... | 0.67145854 | 29 |
Compile flash keys as name=value array which are stored in the flash cookie. The flash variables are only persisted for one response. | def flash_to_cookie
#loop over all flash messages and return as name/value array
out=[]; @flash.each { |key, value| out.push("#{key}=#{CGI::escape(value.to_s)}") if not value.nil? }
return out
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def session_to_cookie\n #loop over all flash messages and return as name/value array\n out=[]; @session.each { |key, value| out.push(\"#{key}=#{CGI::escape(value.to_s)}\") if not value.nil? }\n return out\n end",
"def values\n @store[:__FLASH__] ||= {}\n end",
"def values\n ... | [
"0.7015615",
"0.6899873",
"0.6749244",
"0.667643",
"0.65745276",
"0.6542557",
"0.6529801",
"0.6436348",
"0.64224887",
"0.623039",
"0.62035704",
"0.6200416",
"0.6195517",
"0.6178565",
"0.6156659",
"0.61289614",
"0.60082734",
"0.59230244",
"0.589749",
"0.57812446",
"0.5729126",... | 0.7908933 | 0 |
Compile session keys as name=value array which are eventually stored as cookies. | def session_to_cookie
#loop over all flash messages and return as name/value array
out=[]; @session.each { |key, value| out.push("#{key}=#{CGI::escape(value.to_s)}") if not value.nil? }
return out
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_cookie_header cookies\r\n cookies.to_a.map { |a| a.join '=' }.join '; '\r\n end",
"def sessions\n @sessions.each_key.to_a\n end",
"def serialize_into_session(record)\n [record.serializable_hash.stringify_keys, nil]\n end",
"def flash_to_cookie\n #loop over all flash mes... | [
"0.62803054",
"0.6092727",
"0.60203874",
"0.60152787",
"0.59753406",
"0.59377396",
"0.5803427",
"0.57975036",
"0.57758725",
"0.5769984",
"0.5761602",
"0.5752951",
"0.5716377",
"0.57008743",
"0.5685381",
"0.5680204",
"0.55919254",
"0.5579945",
"0.5575497",
"0.55423856",
"0.552... | 0.6880772 | 0 |
DEPRECATED: use render() instead | def layout(sym)
raise "Deprecated: Controller#layout; Use render({:layout=>:symbol}) instead"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render(*args, &block); end",
"def render!(*args); end",
"def render_to_string(*args, &block); end",
"def render(*args); end",
"def render(*args); end",
"def render!; raise NotImplementedError end",
"def render; end",
"def render; end",
"def render; end",
"def render; end",
"def render; end"... | [
"0.7743092",
"0.7585749",
"0.75722134",
"0.75690466",
"0.75690466",
"0.7557137",
"0.75431085",
"0.75431085",
"0.75431085",
"0.75431085",
"0.75431085",
"0.7456572",
"0.7421678",
"0.7417614",
"0.7417614",
"0.738961",
"0.738961",
"0.738961",
"0.73836726",
"0.73579925",
"0.735512... | 0.0 | -1 |
Controller hook called after controllerinitialize call. By default, this method automatically checks if the authtoken is present for post requests. It throws an error if it's missing or has been tampered with. | def after_initialize
# test if request == post and if so if authtoken is present and valid
if @request.post?
token=@params[:_authtoken]
if token
raise "Doozer Authtoken Tampered With!" if not authtoken_matches?(token)
else
raise "Doozer Authtoken Missing! By defau... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authentication_required!\n @access_token.nil?\n end",
"def ensure_auth_token!\n reset_auth_token! if auth_token.blank?\n end",
"def ensure_auth_token\n unless self.auth_token\n self.auth_token = User.generate_token\n end\n end",
"def after_token_authentication\n end",
"def ... | [
"0.68076384",
"0.647567",
"0.64021003",
"0.6361387",
"0.6361387",
"0.63179487",
"0.62266755",
"0.6224843",
"0.6217747",
"0.6216708",
"0.6179478",
"0.61742246",
"0.6172804",
"0.6156966",
"0.61529",
"0.61516905",
"0.61206204",
"0.61121327",
"0.6106528",
"0.60593927",
"0.6053758... | 0.76463956 | 0 |
Controller hook called before controllermethod call | def before_filter; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def before_dispatch(env); end",
"def before_action \n end",
"def before_dispatch(_env)\n end",
"def controller(controller); end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controlle... | [
"0.68023556",
"0.676527",
"0.6547108",
"0.65015376",
"0.6500159",
"0.6500159",
"0.6500159",
"0.6500159",
"0.6500159",
"0.6500159",
"0.6500159",
"0.6500159",
"0.6500159",
"0.6500159",
"0.6497791",
"0.64570165",
"0.6419394",
"0.63856876",
"0.62825525",
"0.6267816",
"0.6245131",... | 0.6476192 | 15 |
Controller hook called after controllermethod call | def after_filter; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller; end",
"def controller(controller); end",
"def after( controller )\n\n ... | [
"0.68684375",
"0.68684375",
"0.68684375",
"0.68684375",
"0.68684375",
"0.68684375",
"0.68684375",
"0.68684375",
"0.68684375",
"0.68684375",
"0.6865349",
"0.650578",
"0.6496369",
"0.6427111",
"0.6398898",
"0.6375839",
"0.6375839",
"0.6299275",
"0.62803894",
"0.62400216",
"0.62... | 0.5629277 | 66 |
Global teardown called at the end of every request. Hooks ORM.teardown | def finished!
Doozer::ORM.after_request if Doozer::Configs.orm_loaded
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def teardown\n teardown_db\n end",
"def after_teardown; end",
"def teardown\n cleanup_tables\n cleanup_caches\n end",
"def teardown\n self.db_disconnect\n self.logout()\n super\n end",
"def teardown\n if @models.any?\n teardown_models\n teardown_namespace... | [
"0.8341777",
"0.7820824",
"0.77564657",
"0.7682146",
"0.7647216",
"0.75638133",
"0.751229",
"0.751229",
"0.74825597",
"0.74612576",
"0.7438921",
"0.7400803",
"0.7400803",
"0.7400803",
"0.7400803",
"0.7400803",
"0.7400803",
"0.7400803",
"0.7400803",
"0.738279",
"0.738279",
"... | 0.0 | -1 |
Save all of the bars given by the Google Places API. | def save_bars
if ENV['GOOGLE_PLACES_API_KEY'].nil?
raise "Please set ENV['GOOGLE_PLACES_API_KEY'] to run this code"
else
bars_with_info.lazy.map { |bar| save_bar(bar) }.force
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_bar(bar)\n Bar.create!(\n name: bar.name,\n address: bar.formatted_address,\n place_id: bar.place_id,\n lat: bar.geometry.location.lat,\n lon: bar.geometry.location.lng,\n website: bar.website\n )\n logger.info(\"Created bar with name: #{bar.name}\")\n rescue => ex\... | [
"0.6953104",
"0.64619493",
"0.6149403",
"0.59194076",
"0.5860258",
"0.5651822",
"0.55931485",
"0.5569968",
"0.5554731",
"0.5542815",
"0.5483613",
"0.54738295",
"0.54235303",
"0.5370145",
"0.53605264",
"0.5308077",
"0.5293231",
"0.52865714",
"0.5275978",
"0.52487195",
"0.52312... | 0.7791756 | 0 |
Save a single bar. | def save_bar(bar)
Bar.create!(
name: bar.name,
address: bar.formatted_address,
place_id: bar.place_id,
lat: bar.geometry.location.lat,
lon: bar.geometry.location.lng,
website: bar.website
)
logger.info("Created bar with name: #{bar.name}")
rescue => ex
logger.warn("... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save\n File.open(SaveLocation, 'w') do |file|\n file.puts @value.join(\"\")\n file.puts @progress.join(\"\")\n file.puts @bad_guesses.join(\"\")\n end\n end",
"def save_bars\n if ENV['GOOGLE_PLACES_API_KEY'].nil?\n raise \"Please set ENV['GOOGLE_PLACES_API_KEY'] to r... | [
"0.66568923",
"0.6155544",
"0.61411977",
"0.6081979",
"0.5992909",
"0.59081894",
"0.588623",
"0.58774585",
"0.5852489",
"0.5849648",
"0.5846443",
"0.58331555",
"0.58210284",
"0.58210284",
"0.5819895",
"0.5819895",
"0.5819895",
"0.5819895",
"0.5819895",
"0.5819895",
"0.5819895... | 0.77897793 | 0 |
Get all of the bars with their info. | def bars_with_info
bars.lazy.map { |bar| client.details(placeid: bar.place_id) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @bar_graphs = BarGraph.all\n end",
"def all\n @charts\n end",
"def bars(&block)\n return enum_for(:bars) if block.nil?\n\n range = [\n BigDecimal.new('0.025'),\n BigDecimal.new('0'),\n BigDecimal.new('-0.025')\n ]\n range.each do |delta_north|\n range.each do... | [
"0.6688754",
"0.64424914",
"0.64395535",
"0.6371176",
"0.6247589",
"0.6211527",
"0.61797255",
"0.6112378",
"0.5987633",
"0.5967199",
"0.5857382",
"0.5856227",
"0.5776259",
"0.57551384",
"0.57515216",
"0.57432926",
"0.5725892",
"0.5724255",
"0.5723849",
"0.57138777",
"0.571248... | 0.7633245 | 0 |
Retrieve 200 bars from boston. | def bars(&block)
return enum_for(:bars) if block.nil?
range = [
BigDecimal.new('0.025'),
BigDecimal.new('0'),
BigDecimal.new('-0.025')
]
range.each do |delta_north|
range.each do |delta_west|
coord = [NORTH + delta_north, WEST + delta_west].join(',')
client.searc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_bars_from_category_and_city_limit(category_id, city_id)\n @all_bars_from_category = HomeBar.all_by_category_and_city(category_id, city_id).all(:order => 'RAND()', :limit => 7)\n end",
"def get_bars_from_category_limit(category_id)\n @all_bars_from_category = HomeBar.all_by_category(category_id).al... | [
"0.5841392",
"0.57371926",
"0.5593387",
"0.553072",
"0.5425293",
"0.5387628",
"0.5272304",
"0.5259744",
"0.52545077",
"0.5151871",
"0.51365316",
"0.5124347",
"0.51081514",
"0.51074594",
"0.50905395",
"0.50853604",
"0.50775534",
"0.5072142",
"0.50382173",
"0.5031945",
"0.50280... | 0.5178696 | 9 |
This is the client that interacts with the Google Places API | def client
@client ||= PlacesAPI.new(ENV['GOOGLE_PLACES_API_KEY'])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def api_client\n @api_client ||= GooglePlaces::Client.new(GOOGLE_API_KEY)\n end",
"def google_places\n @client = GooglePlaces::Client.new(ENV['GOOGLE_API_KEY'])\n @results = @client.spots(params[:latitude], params[:longitude], :name => 'bar', :types => ['bar', 'night_club'], :radius => 10000)\n ... | [
"0.74836034",
"0.70089495",
"0.6964682",
"0.64512646",
"0.63839215",
"0.6335181",
"0.62824225",
"0.62742823",
"0.62501717",
"0.6226984",
"0.6205911",
"0.6077963",
"0.60447145",
"0.59618014",
"0.59454095",
"0.59342074",
"0.58193505",
"0.58120877",
"0.5800879",
"0.5795064",
"0.... | 0.7863653 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_desarrollo
@desarrollo = Desarrollo.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def desarrollo_params
params.require(:desarrollo).permit(:politicas, :entornos, :funcionalidad, :aceptacion, :empresa_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
return formatted statistics percentage e.g. 20% | def to_s
"#{( "%.f" % @value )}#{'%'} "
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_pct()\n\t sprintf('%0.3f', self.pct())\n\tend",
"def percentage; end",
"def percent\n \"%0.1f%%\" % (to_f * 100)\n end",
"def percent()\n ''\n end",
"def percentage\n 0.0\n end",
"def percent\n self.scan(/./).join('%')\n end",
"def format_pct_value(ror)\n (ror * 100)... | [
"0.79141563",
"0.78374267",
"0.7825688",
"0.7695415",
"0.7614218",
"0.75958216",
"0.7580361",
"0.73593843",
"0.73369455",
"0.7291149",
"0.72605604",
"0.7244996",
"0.7244996",
"0.7244505",
"0.7244505",
"0.7219596",
"0.71949035",
"0.71933293",
"0.71933293",
"0.7177744",
"0.7174... | 0.0 | -1 |
no need to implement incr_age | def conscript
puts "Too old to be conscripted"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def a_birthday \n @age += 1\n end",
"def make_one_year_older\n @age += 1\n end",
"def make_one_year_older\n @age +=1\n end",
"def age!\r\n @age += 1;\r\n lay_egg(@age);\r\n end",
"def celebrate_birthday\n @age += 1\nend",
"def celebrate_birthday \r\n\t@age += 1\r\n\tend",
... | [
"0.7734575",
"0.7673294",
"0.76723135",
"0.7612911",
"0.7517233",
"0.7426106",
"0.739977",
"0.73587644",
"0.7352715",
"0.73499703",
"0.73436224",
"0.73065144",
"0.73065144",
"0.7298755",
"0.72827995",
"0.72827995",
"0.72827995",
"0.72827995",
"0.72827995",
"0.72827995",
"0.72... | 0.0 | -1 |
GET match results for given day Params: day: DD month: MM year: YYYY Ex: results(day: '02', month: '05', year: '2017') | def results(day:, month:, year:)
date = "#{year}-#{month}-#{day}"
uri = URI("/schedules/#{date}/results.#{response_format}?api_key=#{API_KEYS[:tennis]}")
response = Net::HTTP.get_response(uri)
puts response.status unless response.is_a?(Net::HTTPSuccess)
puts response.body
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def results(test_id, day, month, year, options={})\n args = {testId: test_id, day: day, month: month, year: year}\n .merge(options)\n get('testresult', args)\n end",
"def by_date(year, month, day)\n request = @client.call(:recupera_tc_dia, message: {\n Ano: year,\n Mes: month,\n ... | [
"0.6832852",
"0.6783955",
"0.67799634",
"0.63679296",
"0.6251904",
"0.6240876",
"0.61382484",
"0.6098697",
"0.60621053",
"0.60586315",
"0.6031007",
"0.6003844",
"0.5998038",
"0.59631234",
"0.59438646",
"0.59104675",
"0.5864055",
"0.5861185",
"0.58574706",
"0.58529913",
"0.584... | 0.7584814 | 0 |
POST /contacts POST /contacts.xml | def create
@contact = Contact.new(params[:contact])
@guide = params[:guide] || false
respond_to do |format|
if @contact.save
if @guide
email = ContactMailer.deliver_guide_notice(@contact)
confirm = ContactMailer.deliver_guide_email(@contact)
else
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @contacts = Contact.new(params[:contact])\n\n respond_to do |format|\n if @contacts.save\n flash[:notice] = 'Mensagem enviada com sucesso.'\n format.html { redirect_to(root_path) }\n format.xml { render :xml => @contacts, :status => :created, :location => @contacts }\n... | [
"0.69865465",
"0.6721982",
"0.6519159",
"0.6457588",
"0.64505166",
"0.64457744",
"0.64451087",
"0.6412084",
"0.638949",
"0.638949",
"0.638949",
"0.6342526",
"0.6340055",
"0.63252723",
"0.6321219",
"0.6319932",
"0.63106585",
"0.62943727",
"0.62921387",
"0.62825155",
"0.6235885... | 0.0 | -1 |
Specifies the mapping from an ActiveRecordcolumn_definition to an SQLRecord instance attribute. | def column attribute_name, opts = {}
klass = opts[:class] || @default_opts[:class] || nil
raise ArgumentError, 'You must specify a :class option, either explicitly, or using with_opts' if klass.nil?
source_attribute = (opts[:from] || attribute_name).to_s
define_method attribute_name do... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attributes_from_column_definition\n connection.columns(self.class.table_name, \"#{self.class.name} Columns\").inject({}) do |attributes, column| \n attributes[column.name] = column.default unless column.name == self.class.primary_key\n attributes\n end\n end",
"def attrib... | [
"0.67587554",
"0.6686181",
"0.6555762",
"0.6460165",
"0.6440749",
"0.62439686",
"0.61688524",
"0.61426014",
"0.6088796",
"0.60738784",
"0.60738784",
"0.5946289",
"0.59062374",
"0.58944166",
"0.5848167",
"0.57462984",
"0.5705384",
"0.5703644",
"0.5679782",
"0.5675138",
"0.5674... | 0.5610461 | 25 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.