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
PUT /galleries/1 PUT /galleries/1.xml
def update @gallery = Gallery.find(params[:id]) respond_to do |format| if @gallery.update_attributes(params[:gallery]) flash[:notice] = 'Gallery was successfully updated.' format.html { redirect_to(@gallery) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @gallery.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @gallery = Gallery.find(params[:id])\n @gallery.update_attributes(params[:gallery])\n respond_with(@gallery, :status => :updated)\n end", "def update\n @gallery = Gallery.find(params[:id])\n\n respond_to do |format|\n if @gallery.update_attributes(gallery_params)\n format...
[ "0.6872382", "0.66678125", "0.6603505", "0.64245254", "0.64127916", "0.64085174", "0.6388757", "0.6353336", "0.62822354", "0.62610596", "0.62610596", "0.62274075", "0.62256664", "0.62146187", "0.6195313", "0.61403185", "0.6119523", "0.6111957", "0.6108831", "0.6086081", "0.60...
0.6772149
2
DELETE /galleries/1 DELETE /galleries/1.xml
def destroy @gallery = Gallery.find(params[:id]) @gallery.destroy respond_to do |format| format.html { redirect_to(galleries_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @gallery = Gallery.find(params[:id])\n @gallery.destroy\n\n respond_to do |format|\n format.html { redirect_to(galleries_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @gallery = Gallery.find(params[:id])\n @gallery.destroy\n\n respond_to do |format|\n...
[ "0.7511977", "0.7320309", "0.7190528", "0.7159564", "0.7114107", "0.70761496", "0.7060369", "0.70356435", "0.6985489", "0.6874693", "0.68526244", "0.6841744", "0.68289477", "0.6825904", "0.68080294", "0.68080294", "0.67949057", "0.67816126", "0.67612934", "0.6755818", "0.6751...
0.74769574
3
On update set is_registered as true
def is_registered_true! self.is_registered = true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update?\n return true if event_planner? || super_admin?\n\n my_record? && !registration_closed?\n end", "def is_registered?\n # keep track of where we are: if no password in db\n # it means we still are at the registration step\n\n # Note that we use the \"_was\" suffix here (AR::Dirty) to ch...
[ "0.68361485", "0.65950364", "0.6592204", "0.65852654", "0.64490485", "0.6371413", "0.63576543", "0.6296275", "0.6235359", "0.6234845", "0.6233909", "0.62240326", "0.62211317", "0.61800563", "0.616624", "0.613512", "0.6091692", "0.6066158", "0.6065775", "0.6021812", "0.6017067...
0.75915956
0
Try to execute block. If block raises ddxception, it puts bactrace and returns specified value.
def handle_errors options = {}, &block begin yield rescue Exception => e name = caller[1][/`.*'/][1..-2] defaults = {puts: "#{name} failed. See backtrace:", and_return: nil, call: nil} opts = defaults.merge options if @logger @logger.message :error, "#{opts[:puts]}" else puts "#{opts[:puts]}".on_red end unless opts[:quite] p e puts e.backtrace end opts[:call].call if opts[:call].kind_of? Proc opts[:and_return] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __execute__\n @result = @block[*@args]\n rescue Exception => e\n @result = e\n ensure\n # Prevent multiple executions\n def self.__execute__; nil; end\n end", "def execute(&block)\n executed = locksmith.execute(&block)\n\n reflect(:execution_failed, item) unless exe...
[ "0.7300511", "0.6875037", "0.65379477", "0.645074", "0.6398", "0.6331848", "0.6331848", "0.6331848", "0.6331557", "0.63262343", "0.63262343", "0.6315398", "0.6315398", "0.63124466", "0.63124466", "0.63124466", "0.63124466", "0.63124466", "0.63124466", "0.63124466", "0.6233215...
0.0
-1
Execute shell command without output
def sh command, sleep_interval = nil, attempts = 3 # success=%x(#{command} 1> /dev/null) success = Open3.popen3("#{command}") do |stdin, stdout, stderr, wait_thr| wait_thr.value.success? end if attempts > 1 unless success sleep sleep_interval if sleep_interval sh command, sleep_interval, attempts-1 end else raise RuntimeError, "Failed to execute [ #{command} ]" unless success end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shell(command, output: false)\n command += ' > /dev/null 2>&1' if !output\n system(command)\nrescue => e\n lex(e, \"Failed to execute shell command: #{command}\")\nend", "def silently_execute(command)\n Open3.popen3(command){|i,e,o| e.read}\n end", "def shell_without_capturing_output(c,display,dry_r...
[ "0.74932027", "0.7353738", "0.71780086", "0.7044101", "0.69639075", "0.6896327", "0.6875044", "0.67656785", "0.6762949", "0.6742126", "0.66989225", "0.66675425", "0.66675425", "0.6642284", "0.6637432", "0.66359603", "0.6627634", "0.6626342", "0.6616126", "0.66135937", "0.6597...
0.0
-1
Look up aptopriate binaries before install and raise SystemExit if some of binaries are missing
def check_binaries all_installed = true BINARIES.each do |bin| if `which #{bin}`.empty? all_installed = false puts "#{bin} "+'[NOT FOUND]'.red else puts "#{bin} "+'[OK]'.green end end unless all_installed puts 'Install appropriate programs before' raise SystemExit end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def programChecker(cmd)\n if which(cmd).nil?\n abort(\"EXITING: Please install #{cmd} before continuing\")\n end\nend", "def check(exec, name, url)\n return unless `which #{exec}`.empty?\n puts \"#{name} not found.\\nInstall it from #{url}\"\n exit\nend", "def check(exec, name, url)\n return unless `w...
[ "0.67374605", "0.66209507", "0.66209507", "0.66209507", "0.66209507", "0.66209507", "0.66061825", "0.6429982", "0.63746226", "0.6364953", "0.6302912", "0.6283195", "0.6271188", "0.62518376", "0.62466913", "0.6227883", "0.6218832", "0.62186766", "0.62031054", "0.6149013", "0.6...
0.7701987
0
Get list of available builtin scripts
def script_list Dir['script/*'].map{|f| File.basename(f, '.*')} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def scripts\n @scripts ||= @options[:scripts].try(:to_sym)\n end", "def methods_available_to_script\n [ 'program', 'version', 'updated, :maintainer',\n 'build_size', 'noarch', 'system_files',\n 'resource.categories', 'resource.dependencies', 'resource.conflicts',\n 'resource.com...
[ "0.6404183", "0.6299505", "0.6290167", "0.6231806", "0.62223", "0.6147302", "0.61452085", "0.6143726", "0.6088464", "0.6073833", "0.6050016", "0.604609", "0.60237956", "0.599934", "0.593507", "0.5901601", "0.58950335", "0.58698577", "0.58514833", "0.5848282", "0.5837587", "...
0.67432237
0
Get list of available plugins
def plugins_links if File.exists? CONFIG_FILENAME File.readlines(CONFIG_FILENAME).reject{|l| l =~ /^[ ]*[#].*$/ }.uniq else [] end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def available_plugins\n PluginList.availables(@client)\n end", "def available_plugins\n @plugins.keys\n end", "def installed_plugins\n PluginList.installed(@client)\n end", "def plugins\n @plugin_list\n end", "def plugins\n return @plugins if @plugins\n\n respo...
[ "0.8877165", "0.8617271", "0.84060717", "0.8390302", "0.8317995", "0.81333125", "0.81024873", "0.806699", "0.8063139", "0.8022701", "0.7793752", "0.76737994", "0.76028", "0.75848943", "0.75396234", "0.7517808", "0.7481891", "0.7433401", "0.742505", "0.740547", "0.73955", "0...
0.0
-1
Install plugins to your home directory
def install_plugins download_plugins generate_goodies_includes end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def install\n pluginpath = Pathname.new(\"#{ENV['HOME']}/.packer.d/plugins\")\n\n unless File.directory?(pluginpath)\n mkdir_p(pluginpath)\n end\n\n cp_r Dir[\"*\"], pluginpath\n bin.install Dir['*']\n end", "def install\n\t install_dir(plugin_dirs) do |file|\n\t\tnext if file =~ /ROBOT/\...
[ "0.81004804", "0.7516732", "0.74550724", "0.6985311", "0.6911489", "0.68256074", "0.65991277", "0.6593025", "0.6592649", "0.65464777", "0.65464777", "0.6492758", "0.64740926", "0.64535683", "0.642059", "0.63710177", "0.63710177", "0.63568234", "0.62768126", "0.6260898", "0.62...
0.71555287
3
Copy scripts to home folder
def copy_scripts script_list.each do |name| source = File.join(__dir__, "script/#{name}.bash") dest = File.expand_path("~/.#{name}-goodies.bash") puts "Copy #{name}-goodies".green `cp #{source} #{dest}` end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def copy_script\n\n end", "def copy_script(problem_home)\n script_dir = \"#{problem_home}/script\"\n std_script_dir = get_std_script_dir\n\n raise \"engine: std-script directory not found\" if !FileTest.exist?(std_script_dir)\n\n scripts = Dir[std_script_dir + '/*']\n\n copied = []\n\...
[ "0.72614497", "0.71863854", "0.6522155", "0.639147", "0.6391171", "0.63881147", "0.63380194", "0.6327128", "0.62879795", "0.6244121", "0.6204479", "0.6135689", "0.61187834", "0.6116872", "0.6054343", "0.59798694", "0.59631616", "0.5961535", "0.59549546", "0.5951683", "0.59373...
0.71702766
2
Add scripts to .bashrc
def patch_bashrc bashrc = File.readlines(BASHRC_PATH) require_line = 'source ~/.goodies-sources' if bashrc.any? { |l| l =~ /#{require_line}/ } puts 'goodies-sources already in your bash config' else puts 'Install goodies-sources in your bash config' open(BASHRC_PATH, 'a') { |f| f.puts require_line } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def autoscript\n res = []\n self.shell_scripts.executable.each do |s|\n res << s.contents\n end\n self.shell_scripts.replaceable.each do |s|\n res << \"cat <<EOF > #{s.filename}\\n#{s.contents.gsub(/\\r/, '')}\\nEOF\"\n res << \"chown #{s.owner} #{s.filename}\" unless s.owner.to_s.empty?...
[ "0.659216", "0.61219966", "0.58705395", "0.58359545", "0.58150226", "0.5757566", "0.57021713", "0.5689412", "0.5564189", "0.5544636", "0.5445129", "0.54008335", "0.5380888", "0.5378302", "0.5377164", "0.53736633", "0.53505707", "0.53449976", "0.5322651", "0.52983403", "0.5296...
0.64654595
1
Update current installation of goodies.rb
def update `cd #{__dir__} && git pull origin master` install end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n install\n end", "def update\n # Install in pacman can be used for update, too\n self.install\n end", "def update\n # Install in pacman can be used for update, too\n self.install\n end", "def update\n self.install\n end", "def update\n self.install\n end", "def updat...
[ "0.70099646", "0.6917465", "0.6917465", "0.67574996", "0.67570126", "0.67570126", "0.6148252", "0.60911393", "0.60898536", "0.60713243", "0.5992119", "0.5962085", "0.58962303", "0.5888617", "0.58815616", "0.58271664", "0.5820299", "0.58075047", "0.5798761", "0.5796642", "0.57...
0.5806941
18
you can write to stdout for debugging purposes, e.g. puts "this is a debug message"
def solution(n) max = 0 tmp = 0 n.to_s(2).each_char do |s| if s == "0" tmp += 1 else max = [tmp, max].max tmp = 0 end end max end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def puts(*strs); $stdout.puts(*strs) if ENV['DEBUG'] end", "def print_debug(msg)\n puts msg if (@debug) \n STDOUT.flush\n end", "def debug(message)\n ostream.puts message if $DEBUG\n end", "def debug(msg)\n $stderr.puts(\"DEBUG: #{msg}\") if $options['verbose']\nend", "def debug(msg)\...
[ "0.78991675", "0.72724086", "0.7200812", "0.7157513", "0.7157513", "0.7157513", "0.7155336", "0.7109201", "0.7105798", "0.70522755", "0.7049905", "0.7049905", "0.7049905", "0.7049905", "0.7049905", "0.7049905", "0.69822496", "0.69769484", "0.69413716", "0.69413716", "0.693043...
0.0
-1
Get all alarm names.
def all @bot.alarms.map(&:name) rescue nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_name_strings\n names.collect { |a| a.name }\n end", "def all_names\n @__names__\n end", "def names\n collect { |a| a.name }\n end", "def names\n all.map { |item| item.name_sym }\n end", "def get_item_names\n items = []\n Static.get_i...
[ "0.6703825", "0.6302184", "0.6240042", "0.6172932", "0.5984665", "0.58435285", "0.5838211", "0.5813224", "0.5813224", "0.5748808", "0.5735319", "0.57324326", "0.5723297", "0.5700463", "0.5657085", "0.564949", "0.56394756", "0.5613107", "0.55880076", "0.5562385", "0.5532026", ...
0.800138
0
GET /educations GET /educations.json
def index @educations = Education.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n render json: @educations\n end", "def index\n @educations = Education.all\n render json: @educations\n end", "def educations\r\n @education_levels = Education.find(:all)\r\n end", "def index\n @educations = Education.all\n\n end", "def show\n raise Exceptions::EducatorNotAu...
[ "0.7638952", "0.74768627", "0.6773494", "0.65822774", "0.6162599", "0.6042093", "0.60399425", "0.60078293", "0.5976248", "0.5976248", "0.5941617", "0.59338856", "0.59328896", "0.590891", "0.58886456", "0.5838481", "0.5828123", "0.58130306", "0.5787954", "0.57670933", "0.57352...
0.66460776
4
GET /educations/1 GET /educations/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n render json: @educations\n end", "def index\n @educations = Education.all\n render json: @educations\n end", "def index\n @educations = Education.all\n end", "def index\n @educations = Education.all\n end", "def index\n @educations = Education.all\n\n end", "def educatio...
[ "0.75118214", "0.7397821", "0.6500407", "0.6500407", "0.6441257", "0.63670146", "0.6354011", "0.63258487", "0.62205464", "0.6142016", "0.6009162", "0.5997276", "0.59969527", "0.59969527", "0.59800047", "0.5931988", "0.59313405", "0.59284437", "0.59173965", "0.58989125", "0.58...
0.0
-1
POST /educations POST /educations.json
def create if !params["edu_history"].blank? params["edu_history"].each do |edu| if edu["name"] != "" @education = Education.create(education_params(edu)) @education.user_id = current_user.id @education.save end end else @education = Education.new(education_params(params["education"])) @education.user_id = current_user.id @education.save end @email = current_user.profile.official_email.split("@").first respond_to do |format| if params[:caller] == 'reg' format.html { redirect_to '/registeration_steps?step=3&name='+ @email} else format.html { redirect_to educations_url, notice: 'Education ....' } end format.json { head :no_content } format.js end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @education = Education.new(education_params)\n\n if @education.save\n render json: @education, status: :created, location: @education\n else\n render json: @education.errors, status: :unprocessable_entity\n end\n end", "def create\n @educate = Educate.new(educate_params)\...
[ "0.6145546", "0.6143502", "0.6025714", "0.5982991", "0.59746146", "0.597448", "0.5963557", "0.59492403", "0.5937217", "0.59037054", "0.58201104", "0.58144826", "0.581003", "0.5800948", "0.5776131", "0.5742172", "0.5726304", "0.57125646", "0.5686861", "0.5640812", "0.56353444"...
0.5519367
37
PATCH/PUT /educations/1 PATCH/PUT /educations/1.json
def update respond_to do |format| if @education.update(education_params(params["education"])) if params[:caller] == 'reg' format.html { redirect_to '/registeration_steps?step=3'} else format.html { redirect_to @education, notice: 'Education was successfully updated.' } format.js end format.json { render :show, status: :ok, location: @education } else format.html { render :edit } format.json { render json: @education.errors, status: :unprocessable_entity } format.js end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n #debugger\n if @enrollment.update(update_params)\n head :no_content\n else\n render json: @enrollment.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @educator.update(educator_params)\n format.html { redirect_to @edu...
[ "0.6456778", "0.6435413", "0.6318803", "0.6276022", "0.62550855", "0.6250821", "0.62449753", "0.62383574", "0.6227268", "0.6218372", "0.62041056", "0.6200411", "0.61925185", "0.6170955", "0.61668897", "0.6155413", "0.6152643", "0.61387146", "0.61188763", "0.61058897", "0.6102...
0.5920659
87
DELETE /educations/1 DELETE /educations/1.json
def destroy @education.destroy respond_to do |format| format.html { redirect_to educations_url, notice: 'Education was successfully destroyed.' } format.json { head :no_content } format.js end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @educate.destroy\n respond_to do |format|\n format.html { redirect_to educates_url, notice: 'Educate was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @educator.destroy\n respond_to do |format|\n format.html { redirect_to e...
[ "0.7243973", "0.71635103", "0.71316737", "0.70568675", "0.7051705", "0.7051705", "0.7045094", "0.7034173", "0.6959038", "0.69461703", "0.6901784", "0.6883814", "0.6874615", "0.684452", "0.68324494", "0.6830518", "0.6830453", "0.68054205", "0.6794632", "0.6791811", "0.67886394...
0.66573197
47
Use callbacks to share common setup or constraints between actions.
def set_education @education = Education.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 education_params(my_params) my_params.permit(:name, :grade, :city, :country, :user_id, :field, :start_year, :end_year, :title, :thesis_gpa) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
Move this category to be a child of the target category.
def reparent(new_parent) unless new_parent.is_a?(Category) new_parent = Category.find(new_parent) end new_parent_id = new_parent.id if new_parent.leaf? errors.add(:base, "Can't reparent to a leaf category.") elsif get_descendents.include?(new_parent_id) errors.add(:base, "Can't reparent a category to one of its own descendents.") else begin Category.transaction do old_parent = Category.find(parent_id) # Move the node (and its subtree) to the new parent. update_attributes!(:parent_id => new_parent_id) # Fix up the product families, products, and attributes # where for old parent category. old_parent.merge_families old_parent.merge_products old_parent.propagate_families_up old_parent.propagate_products_up old_parent.generate_attributes_up # Fix up the product families, products, and attributes # where for new parent category. self.propagate_families_up self.propagate_products_up new_parent.generate_attributes_up end rescue Exception => e errors.add(:base, "Reparent of category failed: #{e}") end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def move_to_child_of(category)\n self.update_attribute(:parent_id, category.id) unless self.parent_id == category.id\n end", "def move_to_child_of(node)\n self.move_to(node, :child)\n end", "def move_to_child_of(node)\n self.move_to node, :child\n end", "def move_to_child_...
[ "0.76613605", "0.70222986", "0.70110446", "0.70003515", "0.6855256", "0.6855256", "0.6855256", "0.63425153", "0.62862337", "0.62710404", "0.62518114", "0.60630983", "0.60388416", "0.5922989", "0.589387", "0.5875966", "0.58715224", "0.5782326", "0.57715416", "0.5744108", "0.57...
0.5209674
59
Remove a product family from this category. A product family may be only removed from a leaf category, because the product families at interior categories are completely determined by those at the leaves. There may be products associated with the leaf category that belong to the product family being removed. Each such product must be removed from the leaf category. It must also be removed from all ancestor categories where the product originated at this leaf.
def remove_family(fids, propagate = true) count = 0 if leaf? [fids].flatten.each do |fid| fam = product_families.where(:id => fid).first if fam count += 1 # Remove the association between the current category and the # given product family. product_families.delete(fam) # Remove the associations from the category_products table for # the current category and the given product_family. remove_products_in_family(fid) end end else errors.add(:base, "Can't remove a product family from a non-leaf category.") end if (count > 0) && propagate propagate_families_up generate_attributes_up propagate_products_up end count end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_product(prod_id, propagate = true)\n if leaf?\n begin\n Category.transaction do\n CategoryProduct.delete_all(\n [\"category_id = ? AND product_id = ?\", self.id, prod_id]) \n propagate_products_up if propagate\n end\n rescue Exception => e\n ...
[ "0.5942705", "0.53325623", "0.52296436", "0.5185283", "0.4891321", "0.48306417", "0.48092642", "0.4783744", "0.47836995", "0.47415984", "0.47261894", "0.46583673", "0.46195686", "0.46092337", "0.4594878", "0.4594013", "0.45249933", "0.45242837", "0.45155945", "0.44851404", "0...
0.68868804
0
Add a product family or array of product families to this category. A product family may be only be added to a leaf category, because the product families at interior categories are completely determined by those at the leaves.
def add_family(fam, propagate = true) count = 0 if leaf? [fam].flatten.each do |f| if product_families.where(["product_family_id = ?", f.id]).empty? product_families << f count += 1 end end else errors.add(:base, "Can't add product family to non-leaf category.") end if (count > 0) && propagate propagate_families_up generate_attributes_up end count end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_product(prod, propagate = true)\n\n # Can't add products to interior category.\n unless self.leaf?\n errors.add(:base, \"Can't add product to interior category.\")\n return\n end\n \n # Make sure that the category has the product's product family.\n # There is a race condition h...
[ "0.6269541", "0.5637166", "0.5620279", "0.5524436", "0.5464571", "0.5464571", "0.531069", "0.5246958", "0.5191717", "0.5056068", "0.5051238", "0.49953747", "0.4974808", "0.4954884", "0.49279755", "0.48840946", "0.4859723", "0.48105192", "0.47929978", "0.47863004", "0.47107193...
0.79554856
0
Remove a product from a leaf category, and possibly from all its ancestors.
def remove_product(prod_id, propagate = true) if leaf? begin Category.transaction do CategoryProduct.delete_all( ["category_id = ? AND product_id = ?", self.id, prod_id]) propagate_products_up if propagate end rescue Exception => e errors.add(:base, "Removal of product failed: #{e}") end else errors.add(:base, "Can't delete product from interior category.") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_child(product)\r\n\t\tproduct = product.is_a?(Product) ? product.id : product.to_i\r\n\t\tcomponents.delete(components.find_by_child_id(product))\r\n\tend", "def destroy_category\n\t\tCategory.all.each do |i|\n\t\t\tunless i.products.any?\n\t\t\t\ti.destroy\n\t\t\tend\n\t\tend\n \tend", "def destro...
[ "0.6256793", "0.61048734", "0.5975345", "0.5974996", "0.5822381", "0.57950985", "0.5772938", "0.5739941", "0.57153964", "0.5633202", "0.5632625", "0.5593261", "0.5590167", "0.5575145", "0.55678016", "0.5549618", "0.5536368", "0.55201787", "0.550804", "0.54848707", "0.5461518"...
0.72480947
0
Add a product to this leaf category.
def add_product(prod, propagate = true) # Can't add products to interior category. unless self.leaf? errors.add(:base, "Can't add product to interior category.") return end # Make sure that the category has the product's product family. # There is a race condition here. Another administrator could # remove the product family just after we confirm that our # category has this family. XXX if CategoryFamily.where(:category_id => self.id, :product_family_id => prod.product_family_id).empty? errors.add(:base, "Category doesn't have product family for this product.") return end # All OK. Add the product. There is a callback on the CategoryProduct # model that will initialize the ref_count in the category_products # join table to 1. begin products << prod rescue ActiveRecord::RecordNotUnique errors.add(:base, "Can't add product to same category twice.") return end propagate_products_up if propagate end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_product product\n\t\t@products.push product\n\t\tproduct\n\tend", "def <<(product)\r\n\t\tif product.is_a?(CompositeProduct) and (product.id == id || product.has_child?(self))\r\n\t\t\tnil\r\n\t\telse\r\n\t\t\tcomponent = components.find(:first, :conditions => [ 'child_id = ?', product.id ])\r\n\t\t\tif ...
[ "0.692085", "0.6775496", "0.64310825", "0.63561773", "0.632342", "0.6269073", "0.6258771", "0.6201599", "0.61780536", "0.6163781", "0.61365974", "0.61057574", "0.6102334", "0.6087216", "0.6082268", "0.6076592", "0.6071469", "0.6062651", "0.6053118", "0.6042685", "0.60415787",...
0.7051367
0
Allow dashes to be input, but remove them from output
def account_number @account_number ? @account_number.to_s.delete('-') : nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def undasherize(str)\n str.sub(/^-{1,2}/, '')\n end", "def fix_dash_dash(text); end", "def dashify\n strip.gsub(/[ \\/_~]/, '-').squeeze('-')\n end", "def dasherize!\n self.replace(self.scan(/[A-Z][a-z]*/).join(\"-\").downcase)\n end", "def unhyphenate(string)\n string.to_s.gsub(/(pre|post...
[ "0.76146305", "0.74724305", "0.73450387", "0.7206574", "0.718123", "0.6958003", "0.6933847", "0.6876488", "0.6876488", "0.6843888", "0.68345463", "0.6803662", "0.67492515", "0.67492515", "0.67167765", "0.6677433", "0.66732925", "0.6649358", "0.66429794", "0.65592074", "0.6477...
0.0
-1
GET /goods GET /goods.json
def index @goods = Good.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @goods = Good.where(user: current_user.building.users)\n respond_to do |format|\n format.html\n format.json do\n render json: {\n goods: @goods.map{|g|g.attributes.merge(image: url_for(g.user.profile.pic), ownerId: g.user.id)}\n }\n end\n end\n end", "d...
[ "0.7292362", "0.7114621", "0.6816806", "0.6584472", "0.6557103", "0.6505164", "0.64421594", "0.6441967", "0.6426243", "0.63935846", "0.63924265", "0.6380132", "0.6372669", "0.6369521", "0.6367218", "0.636472", "0.63500166", "0.6346882", "0.62856853", "0.6255767", "0.6252027",...
0.7015913
3
GET /goods/1 GET /goods/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @goods_category = GoodsCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @goods_category }\n end\n end", "def index\n @goods = Good.where(user: current_user.building.users)\n respond_to do |format|\n format.h...
[ "0.7131236", "0.70161664", "0.69385153", "0.69105446", "0.69105446", "0.6731007", "0.6605964", "0.6599473", "0.6595357", "0.65017825", "0.6496155", "0.64402866", "0.6418983", "0.641069", "0.63891494", "0.6388751", "0.63618964", "0.635818", "0.6355404", "0.6308228", "0.6302650...
0.0
-1
POST /goods POST /goods.json
def create @good = Good.new(good_params) @good.deadline = JalaliDate.to_gregorian(params[:good_deadline_yyyy],params[:good_deadline_mm],params[:good_deadline_dd]) @good.user_id = current_user.id respond_to do |format| if @good.save format.html { redirect_to @good, notice: 'Good was successfully created.' } format.json { render :show, status: :created, location: @good } else format.html { render :new } format.json { render json: @good.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n render json: Beverage.create!(beverage_post_params), status: :created\n end", "def create\n @goods_item = Goods::Item.new(params[:goods_item])\n\n respond_to do |format|\n if @goods_item.save\n format.html { redirect_to(@goods_item, :notice => 'Item was successfully created.') ...
[ "0.648079", "0.6349735", "0.6345145", "0.6339574", "0.6251283", "0.62106866", "0.6173828", "0.61674243", "0.6153889", "0.61328185", "0.60881376", "0.608574", "0.6062837", "0.6049795", "0.5991415", "0.5980866", "0.59437394", "0.59265983", "0.5923909", "0.5922621", "0.5911951",...
0.0
-1
PATCH/PUT /goods/1 PATCH/PUT /goods/1.json
def update @good.user_id = current_user.id respond_to do |format| if @good.update(good_params) format.html { redirect_to @good, notice: 'Good was successfully updated.' } format.json { render :show, status: :ok, location: @good } else format.html { render :edit } format.json { render json: @good.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @good = Good.find(params[:id])\n\n respond_to do |format|\n if @good.update_attributes(params[:good])\n format.html { redirect_to :action => \"index\" }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { re...
[ "0.6718422", "0.66405004", "0.6492181", "0.64585894", "0.64345837", "0.6413807", "0.63837856", "0.63718987", "0.636126", "0.6275493", "0.6271046", "0.6268197", "0.6264388", "0.6259194", "0.6248868", "0.6242077", "0.6231324", "0.6227427", "0.62031364", "0.619148", "0.6170568",...
0.5888641
85
DELETE /goods/1 DELETE /goods/1.json
def destroy @good.destroy respond_to do |format| format.html { redirect_to goods_url, notice: 'Good was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @good.destroy\n respond_to do |format|\n format.html { redirect_to goods_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @good.destroy\n respond_to do |format|\n format.html { redirect_to admin_goods_url, notice: '商品删除成功.' }\n format.json { ...
[ "0.7354549", "0.73300576", "0.732429", "0.7254437", "0.7215831", "0.71528274", "0.7079962", "0.70703256", "0.70483476", "0.70393795", "0.70038885", "0.6918389", "0.69038963", "0.6858696", "0.68516994", "0.68220717", "0.67531466", "0.6747683", "0.6738469", "0.673428", "0.67180...
0.70682085
9
Use callbacks to share common setup or constraints between actions.
def set_good @good = Good.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 good_params params.require(:good).permit(:name, :description,:avatar, :price, :user_id, :category_id, :sub_category_id, :deadline) 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.6981269", "0.6783559", "0.6746007", "0.67423046", "0.6735905", "0.6593568", "0.6504213", "0.649792", "0.6482664", "0.6478558", "0.64566684", "0.64392304", "0.6380194", "0.6376366", "0.636562", "0.63208145", "0.63006365", "0.63001287", "0.6292953", "0.62927175", "0.62911004...
0.0
-1
GET /tasks/1 GET /tasks/1.json
def show @task = Task.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @task } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @task = Task.find(params[:id])\n\n render json: @task\n end", "def task(name)\n get \"#{base_url}/tasks/#{name}\"\n end", "def show\n render :json => Project.find(params[:project_id]).tasks.find(params[:id])\n end", "def show\n \n @task = @project.tasks.find(params[:i...
[ "0.76096785", "0.7555889", "0.7456459", "0.74471563", "0.73451596", "0.7336069", "0.7332103", "0.72564024", "0.7243799", "0.72252154", "0.72077334", "0.71938455", "0.7161541", "0.7150426", "0.7135579", "0.71324193", "0.7114733", "0.7100787", "0.7086199", "0.70585656", "0.7053...
0.72028416
24
GET /tasks/new GET /tasks/new.json
def new @task = Task.new respond_to do |format| format.html # new.html.erb format.json { render json: @task } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n # raise params.inspect\n @task = Task.new \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task }\n end\n end", "def new\n\n\n\n @task = Task.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render j...
[ "0.81260604", "0.8124787", "0.79524976", "0.7841059", "0.77398324", "0.7718117", "0.7656687", "0.76128024", "0.7572869", "0.756708", "0.7557094", "0.7553868", "0.75147295", "0.7474312", "0.7456394", "0.74538034", "0.7383089", "0.73799187", "0.7363408", "0.7353529", "0.7344293...
0.8030934
13
POST /tasks POST /tasks.json
def create @task = Task.new(params[:task]) @task.user = current_user # mogli byśmy zapisać powyższą linijkę tak: # @task.user_id = current_user.id # ale nie robimy tego, ponieważ znaczy ona to sami # a przemek mówi że jest brzydsza. biedna linijka. respond_to do |format| if @task.save format.html { redirect_to @task, notice: 'Task was successfully created.' } format.json { render json: @task, status: :created, location: @task } else format.html { render action: "new" } format.json { render json: @task.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n #@task = Task.new(task_params)\n task = @task_list.tasks.create!(task_params)\n render json: task\n end", "def create\n @task = Task.new(task_params)\n\n if @task.save\n render json: @task, status: :created\n else\n render json: @task.errors, status: :unprocessable_entit...
[ "0.7529737", "0.74976224", "0.7411092", "0.7389878", "0.7261207", "0.72587913", "0.7183996", "0.7147952", "0.71120256", "0.70759165", "0.70639485", "0.70576006", "0.70560944", "0.70294535", "0.7016957", "0.7012058", "0.70110804", "0.7009976", "0.6993863", "0.69896185", "0.698...
0.0
-1
PUT /tasks/1 PUT /tasks/1.json
def update @task = Task.find(params[:id]) respond_to do |format| if @task.update_attributes(params[:task]) format.html { redirect_to @task, notice: 'Task was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @task.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\r\n @tasks = Task.find(params[:id])\r\n if @tasks.update(task_params)\r\n render json: @tasks\r\n else\r\n render json: @tasks.errors, status: :unprocessable_entity\r\n end\r\n end", "def update\n task = Task.find(params[:id])\n if task.update(t...
[ "0.7574151", "0.7316643", "0.7237948", "0.71661645", "0.7154669", "0.71253306", "0.71253306", "0.6917008", "0.6910182", "0.6883252", "0.68771994", "0.6868434", "0.6843849", "0.68328846", "0.68328846", "0.68328846", "0.6831274", "0.68181574", "0.681357", "0.6804178", "0.68038"...
0.67863333
28
DELETE /tasks/1 DELETE /tasks/1.json
def destroy @task = Task.find(params[:id]) @task.destroy respond_to do |format| format.html { redirect_to tasks_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_task id\n request :delete, \"tasks/#{id}\"\n nil\n end", "def delete_task\n @task = Task.find_by(id: params[:id])\n @task.destroy\n render :json => @task.as_json(:only => [:id])\n end", "def destroy\n @task = Task.find(params[:id])\n @task.destroy\n\n respond_to do |f...
[ "0.78326327", "0.75876695", "0.7564121", "0.75633883", "0.7488168", "0.7488168", "0.7488168", "0.7488168", "0.7488168", "0.7488168", "0.7439073", "0.73971665", "0.7383215", "0.7366426", "0.73521817", "0.7344428", "0.7343063", "0.73387766", "0.7337433", "0.7336587", "0.7327202...
0.7529625
15
Called by the Runtime system to install/upgrade schemas into the database.
def install( schema ) schema_name = schema.name.to_s.identifier_case transact do |connection| connection.execute(@schemas_table.render_sql_create(0, 0, true)) end transact do |connection| installed_version = connection.retrieve_value("version", 0, @version_query, schema_name) if installed_version == 0 then wrap(schema).lay_out() name_width = @tables.name_width type_width = @tables.type_width @tables.each do |table| Schemaform.debug.dump(table.render_sql_create(name_width, type_width)) end fail_todo() @adapter.lay_out(schema).tables.each do |table| table.install(connection) end @versions[schema.name] = self.versions_table[schema_name, connection] = 1 elsif installed_version < schema.version then fail "no version upgrade support yet" else fail_todo() @adapter.lay_out(schema) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pre_migrate_database\n old_schema_version = get_schema_version\n new_schema_version = File.read(File.join(source_directory,'db','schema_version')).to_i\n \n return unless old_schema_version > 0\n \n # Are we downgrading?\n if old_schema_version > new_schema_version\n message \"Downgr...
[ "0.7175705", "0.66757417", "0.6651097", "0.66374993", "0.65729463", "0.6564887", "0.63277185", "0.63277185", "0.6227448", "0.61977446", "0.61738664", "0.6168933", "0.61549455", "0.61549455", "0.6144892", "0.61095154", "0.60918385", "0.6068603", "0.6051185", "0.6049751", "0.60...
0.7481344
0
Defines a new table and calls your block to fill it in.
def define_table( name, or_return_existing = false ) name_string = name.to_s @monitor.synchronize do if @tables.member?(name_string) then assert(or_return_existing, "cannot create duplicate table [#{name_string}]") else create_table(name).use do |table| yield(table) @tables.register(table, name_string) end end end @tables[name_string] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup_tables(&block)\n return nil unless block_given?\n self.class_eval(&block)\n self.table_settings \n end", "def initialize_table; end", "def define( &block )\n fail( ArgumentError, \"missing table definition block\" ) unless block\n Context.new( ...
[ "0.7336862", "0.7216414", "0.71267533", "0.70579445", "0.7032467", "0.70237625", "0.6940046", "0.6889754", "0.6876539", "0.68661726", "0.6846922", "0.68360895", "0.6813095", "0.68031716", "0.6795432", "0.6770477", "0.67611647", "0.6758652", "0.6750334", "0.67448485", "0.66796...
0.0
-1
Defines a new table and gives it an identifier, optionally by linking it to a master table's identifier.
def define_linkable_table( name, base_table = nil ) define_table(name) do |table| id_name = create_internal_name("id") marks = [] marks << (base_table.exists? ? table.create_reference_mark(base_table) : table.create_generated_mark()) marks << table.create_primary_key_mark() table.identifier = table.define_field(id_name, identifier_type, *marks) yield(table) if block_given? end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_table_with_inherits(table_name, options = {}, &block)\n options[:primary_key] = \"#{options[:inherits]}_id\" if options[:inherits]\n\n create_table_without_inherits(table_name, options) do |table_defintion|\n yield table_defintion \n end \n end", "def add_table( name, &block )\n ...
[ "0.6735585", "0.64533025", "0.64399385", "0.6320206", "0.625073", "0.6232913", "0.6213112", "0.6195394", "0.61748207", "0.6170952", "0.61594033", "0.61470026", "0.61298525", "0.6102768", "0.6087855", "0.60838836", "0.6070713", "0.60643977", "0.6048356", "0.60414565", "0.60395...
0.7525224
0
======================================================================================= Object Instantiation =======================================================================================
def create_query( relation ) Query.new(relation) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize\n \n end", "def initialize() end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def initialize\n end", "def constructor; end", "def initialize\n end", "def i...
[ "0.80444825", "0.7907648", "0.7829564", "0.7829564", "0.7829564", "0.7829564", "0.7829564", "0.7829564", "0.7816187", "0.7742366", "0.7739882", "0.773351", "0.7690315", "0.7690315", "0.7690315", "0.7690315", "0.7690315", "0.7690315", "0.7690315", "0.7690315", "0.7690315", "...
0.0
-1
GET /ideia/1 GET /ideia/1.json
def show @ideium = Ideium.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @ideium } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @idiom = Idiom.find(params[:id])\n @essays = Essay.where(idiom_id: params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @idiom }\n end\n end", "def show\n @uchronia = Uchronia.find(params[:id])\n\n respond_to do |format|\n ...
[ "0.6660294", "0.6631672", "0.65816164", "0.6578364", "0.65739954", "0.650779", "0.64984995", "0.6479479", "0.6477501", "0.64650476", "0.64498746", "0.6429459", "0.64084816", "0.6402503", "0.6380035", "0.6377802", "0.63712806", "0.6369968", "0.63607997", "0.63607997", "0.63607...
0.71268386
0
GET /ideia/new GET /ideia/new.json
def new @ideium = Ideium.new respond_to do |format| format.html # new.html.erb format.json { render json: @ideium } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @idiom = Idiom.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @idiom }\n end\n end", "def new\n @etnia = Etnia.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @etnia }\n end\n end"...
[ "0.7719671", "0.73952043", "0.73924226", "0.7299735", "0.72914845", "0.7260813", "0.7260813", "0.7260813", "0.7260813", "0.72190475", "0.72063994", "0.7191158", "0.716771", "0.7167572", "0.7160031", "0.71546096", "0.7152658", "0.7145393", "0.7145393", "0.7142721", "0.7127117"...
0.7485873
1
POST /ideia POST /ideia.json
def create @ideium = Ideium.new(params[:ideium]) respond_to do |format| if @ideium.save format.html { redirect_to @ideium, notice: 'Ideium was successfully created.' } format.json { render json: @ideium, status: :created, location: @ideium } else format.html { render action: "new" } format.json { render json: @ideium.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n # @ideia = Ideia.new(params[:ideia])\n @ideia = current_usuario.ideias.new(params[:ideia])\n\n respond_to do |format|\n if @ideia.save\n format.html { redirect_to(@ideia, :notice => 'Ideia criada com sucesso.') }\n format.xml { render :xml => @ideia, :status => :created...
[ "0.6344031", "0.5944378", "0.5939132", "0.59222275", "0.58325297", "0.5826657", "0.58131105", "0.5811317", "0.5806798", "0.5761741", "0.5739238", "0.57339185", "0.5722361", "0.5715285", "0.5695241", "0.56941015", "0.5681617", "0.56400526", "0.5626948", "0.561902", "0.56047064...
0.6308021
1
PUT /ideia/1 PUT /ideia/1.json
def update @ideium = Ideium.find(params[:id]) respond_to do |format| if @ideium.update_attributes(params[:ideium]) format.html { redirect_to @ideium, notice: 'Ideium was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @ideium.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n # @ideia = Ideia.find(params[:id])\n @ideia = current_usuario.ideias.find(params[:id])\n \n # if an ideia has already been accepted, the user is not allowed to change titulo\n if @ideia.status > 2\n params[:ideia].delete(:titulo)\n end\n\n respond_to do |format|\n if ...
[ "0.65258586", "0.6488312", "0.64531547", "0.6356309", "0.63391656", "0.6272524", "0.62572896", "0.62556624", "0.6185545", "0.61264527", "0.608591", "0.608591", "0.6066937", "0.6063546", "0.60600907", "0.60580605", "0.60221463", "0.6018685", "0.60152787", "0.6010104", "0.59998...
0.6330061
5
DELETE /ideia/1 DELETE /ideia/1.json
def destroy @ideium = Ideium.find(params[:id]) @ideium.destroy respond_to do |format| format.html { redirect_to ideia_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\n render json: Alien.delete(params[\"id\"])\n end", "def destroy\n @iglesia.destroy\n respond_to do |format|\n format.html { redirect_to iglesias_url }\n format.json { head :no_content }\n end\n end", "def delete()\n ...
[ "0.73065996", "0.7192884", "0.69979435", "0.6967741", "0.6967741", "0.6967741", "0.6967741", "0.6918046", "0.69091433", "0.6854551", "0.6837105", "0.6810203", "0.6809668", "0.6807681", "0.6801832", "0.68011093", "0.68000233", "0.67654634", "0.67635226", "0.6747802", "0.673005...
0.736753
0
Sends jobseeker a notification that their applicant have been matched
def jobseeker_notified(employer_name, job_name, employer_email, jobseeker_email, jobseeker_name) @jobseeker_name = jobseeker_name @employer_name = employer_name @job_name = job_name mail to: jobseeker_email, subject: "You have been matched by an employer!" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_email_to_matched_candidates\n error_code = 0\n\n # email alert should not work for expired job\n return error_code if self.expired?\n\n candidates = Candidate.where('candidates.archetype_score >= ? and\n candidates.archetype_score <= ?', self.archetype_low,\n ...
[ "0.6263845", "0.6081788", "0.60398674", "0.60126054", "0.591988", "0.5907042", "0.5870438", "0.58408713", "0.5825584", "0.58220345", "0.5812223", "0.5799766", "0.5799281", "0.57479954", "0.5737534", "0.5733043", "0.5726848", "0.5725077", "0.5722641", "0.57010335", "0.5700265"...
0.62835187
0
return interval for one month param: offset relative to current month
def dmonth(delta=0) ty = Time.now.utc m1 = 1 + (ty.month + delta - 1) % 12 y1 = ty.year + (ty.month + delta - 1) / 12 m2 = 1 + (ty.month + delta) % 12 y2 = ty.year + (ty.month + delta) / 12 puts m1, y1, m2, y2 { :from => Time.utc(y1,m1), :to => Time.utc(y2,m2) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_boundaries\n months = calculate_month_and_next_month(@values[:year],\n @values[:time_frame])\n set_values(months)\n return \"Calculated interval for month from input:\" \\\n \" #{months[:actual]} - #{months[:next]}\"\n e...
[ "0.6478478", "0.63712883", "0.628126", "0.6156412", "0.61283267", "0.6063049", "0.6042009", "0.5976801", "0.59344685", "0.59344685", "0.59259564", "0.59064835", "0.58854383", "0.5874995", "0.5870325", "0.5846577", "0.5846177", "0.5837794", "0.57894355", "0.5786871", "0.578199...
0.0
-1
return interval for one day param: offset relative to current day
def dday(delta=0) now = Time.now.utc ty = Time.utc(now.year,now.month,now.day) { :from => ty + delta * 86400, :to => ty + (delta + 1)* 86400 } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def span\n return 60.days if interval.zero?\n\n interval.days\n end", "def interval\n (Date.current - limit.days) .. Date.tomorrow\n end", "def offset_in_days\n return @offset_in_days\n end", "def interval(dat)\n\n datum = today - dat\n interval = Date.par...
[ "0.66706115", "0.61912423", "0.6177684", "0.6062226", "0.5977018", "0.5865628", "0.5769207", "0.5769207", "0.5769207", "0.5769207", "0.5769207", "0.5769207", "0.5769207", "0.5769207", "0.5727741", "0.57244116", "0.56735456", "0.5633647", "0.5633647", "0.5633647", "0.5633647",...
0.0
-1
Main method, allow to load the configuration of the command interpreter from the XML file.
def load if @configFilePath.nil? || ! File.exists?(@configFilePath) throw QuerySOS::QuerySOSException.new("Missing configuration file for the command interpreter") end file = File.new @configFilePath doc = REXML::Document.new file return getCommands(doc.root) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse\n parse_command\n load_config\n finalize_setup\n end", "def initialize()\n begin\n puts \"Eis::Runner::init called\" if $DEBUG\n @loaded_modules = []\n generate_module_list()\n handle = InputHandler.new()\n set_environment()\n rescue Argume...
[ "0.6306908", "0.60935473", "0.59977764", "0.58359075", "0.5781347", "0.5775973", "0.57694274", "0.57087505", "0.5686961", "0.56674933", "0.5609631", "0.56031823", "0.5580397", "0.5567516", "0.5561165", "0.5545668", "0.5544883", "0.55407155", "0.553993", "0.55293244", "0.55212...
0.65655726
0
Setter for configFilePath. Check that the argument is a not nil and it's an instance of String
def configFilePath=(file) if file.nil? || file.class != String throw QuerySOS::QuerySOSException.new("Invalid configuration file for the command interpreter: " + file.to_s) end @configFilePath=file end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def config_file_path(config_file_path=nil)\n @config_file_path ||= config_file_path || File.join(config_path, config_filename)\n end", "def config_file_path=(path)\n self.config_file_paths = [path]\n end", "def config_file=(config_file)\n @config_file = File.expand_path(config_file)\n e...
[ "0.7186278", "0.6871036", "0.6832266", "0.68141866", "0.66765296", "0.6676087", "0.6558963", "0.65072715", "0.6354858", "0.63263565", "0.6222106", "0.62212634", "0.6152358", "0.6134813", "0.61284715", "0.6121116", "0.60666555", "0.6050466", "0.60003644", "0.59900194", "0.5965...
0.7004525
1
def find_the_cheese(arr) look through each string return the first string that is a cheese with detect or find the array below is here to help cheese_types = ["cheddar", "gouda", "camembert"] if cheese_types.all? do |element| arr.include?(element) return element end end end
def find_the_cheese(arr) # look through each string # return the first string that is a cheese with include? # the array below is here to help cheese_types = ["cheddar", "gouda", "camembert"] arr.find do |type| cheese_types.include?(type) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_the_cheese(arr_of_str)\n cheese_types = [\"cheddar\", \"gouda\", \"camembert\"]\n arr_of_str.find do |str|\n cheese_types.include?(str)\n end\n end", "def find_the_cheese(array)\n\t\tcheese_types = [\"cheddar\", \"gouda\", \"camembert\"]\n\t\t item=nil;\n\t\tcheese_types.each do|cheesetype| \n...
[ "0.9007453", "0.8904642", "0.8876263", "0.88174844", "0.8784113", "0.87711614", "0.8679775", "0.8670605", "0.86614484", "0.8636296", "0.8632149", "0.8599796", "0.8442596", "0.8395849", "0.8384305", "0.8375735", "0.8372562", "0.8366445", "0.8338069", "0.83375025", "0.83180755"...
0.92778933
0
This simply looks at the defined parameters and creates a hash of the ones that have values assigned. Need to work out a way of doing this so I don't need to keep defining exactly the same method in each class.
def params self.class.const_get("REQUEST_PARAMETERS").inject({}) do |parameters, parameter| parameters[parameter] = instance_variable_get("@#{parameter}") unless instance_variable_get("@#{parameter}").nil? parameters end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_params bespoke_params={}\n bespoke_params ||= {}\n h = set.dup.merge(bespoke_params)\n generated_params.each do |k,blk|\n # Make sure we don't call the block if the param is going to be overridden anyway\n next if h.has_key?(k)\n h[k] = blk.call\n end\n h = ...
[ "0.65194005", "0.6439502", "0.64048564", "0.6388731", "0.63059145", "0.6251814", "0.6251814", "0.6192514", "0.61874837", "0.6174676", "0.61010164", "0.6099372", "0.6079933", "0.6075874", "0.60201824", "0.60201824", "0.6009033", "0.6008813", "0.6000731", "0.59643245", "0.59632...
0.5621154
59
ItemSearch requires keywords and a search index to be specified.
def initialize(keywords, search_index = "Books", region = :uk) super() self.keywords = keywords self.search_index = search_index self.operation = "ItemSearch" self.region = region end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def search(index, query_or_params = nil)\n params = case query_or_params\n when String\n { 'Keywords' => query_or_params }\n else\n query_or_params\n end\n rebuild params.merge! 'Operation' => 'ItemSearch',\n ...
[ "0.82220364", "0.79546756", "0.76490456", "0.6946667", "0.68627244", "0.67857987", "0.6765686", "0.6756549", "0.67078245", "0.6604102", "0.6556319", "0.6547733", "0.6545934", "0.6543691", "0.6525867", "0.6482903", "0.6478411", "0.64677423", "0.6443815", "0.64258164", "0.63777...
0.7543436
3
ItemLookup only requires an item id (ASIN) to be specified.
def initialize(item_id, region = :uk) super self.item_id = item_id self.operation = "ItemLookup" self.region = region end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lookup(*asins)\n params = asins.last.is_a?(Hash) ? asins.pop : {:ResponseGroup => :Medium}\n response = call(params.merge(:Operation => :ItemLookup, :ItemId => asins.join(',')))\n arrayfy(response['ItemLookupResponse']['Items']['Item']).map {|item| handle_type(item, :item)}\n end", "def ite...
[ "0.7776444", "0.7527237", "0.7527237", "0.7527237", "0.7322755", "0.7322755", "0.73225427", "0.6965277", "0.6509892", "0.6501203", "0.647479", "0.63865227", "0.6383665", "0.6289678", "0.62256575", "0.61454695", "0.6144142", "0.6141257", "0.6128656", "0.61110824", "0.6085612",...
0.69565487
8
SimilarityLookup only requires an item id (ASIN) to be specified.
def initialize(item_id, region = :uk) super() self.item_id = item_id self.operation = "SimilarityLookup" self.region = region end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def similar(*asins)\n params = asins.last.is_a?(Hash) ? asins.pop : {:SimilarityType => :Random, :ResponseGroup => :Medium}\n response = call(params.merge(:Operation => :SimilarityLookup, :ItemId => asins.join(',')))\n arrayfy(response['SimilarityLookupResponse']['Items']['Item']).map {|item| handle...
[ "0.66105336", "0.6321332", "0.6321229", "0.6321229", "0.61847466", "0.6031202", "0.5822846", "0.5822846", "0.5822846", "0.5767383", "0.57361794", "0.56303424", "0.5607723", "0.5555527", "0.5555206", "0.5544861", "0.5534633", "0.55337095", "0.547066", "0.5439877", "0.5416839",...
0.6875352
0
GET /guardarios GET /guardarios.json display last
def index @guardarios_img = GuardarioImage.last(9).reverse end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @usuarios = Usuario.por_colegio(colegio.id).order(\"nombre\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end", "def display\n @reservas = Reserva.order(fecha_inicio_estadia: :desc)\n render json: @reservas, incl...
[ "0.66155463", "0.654478", "0.6501815", "0.64432466", "0.64369637", "0.64324164", "0.6397389", "0.6307138", "0.6303542", "0.62317604", "0.61614794", "0.61614794", "0.6160399", "0.6148316", "0.61374474", "0.61340225", "0.6118955", "0.61011785", "0.60624593", "0.6023497", "0.602...
0.60951614
18
GET /guardarios/1 GET /guardarios/1.json
def show @imgs = @guardario.guardario_images end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n authorize! :read, Registro\n respond_to do |format|\n format.html { redirect_to registros_url}\n format.json { head :no_content }\n end\n end", "def show\n @respuesta = Respuesta.find(params[:id])\n\n render json: @respuesta\n end", "def show\n @seguro = Seguro.find(par...
[ "0.6935794", "0.67606276", "0.67331886", "0.67230517", "0.6671978", "0.66134167", "0.658836", "0.65707105", "0.654873", "0.654873", "0.6536135", "0.6523545", "0.6523545", "0.6486328", "0.6477544", "0.6452612", "0.6450964", "0.6448823", "0.6444056", "0.64249223", "0.64249223",...
0.0
-1
POST /guardarios POST /guardarios.json
def create @guardario = Guardario.new(guardario_params) @guardario.user_id = current_user.id respond_to do |format| if @guardario.save if params[:images] params[:images].each { |image| GuardarioImage.create(image: image, guardario_id: @guardario.id) } end format.html { redirect_to @guardario, notice: 'O seu avistamento foi reportado com sucesso.' } format.json { render :show, status: :created, location: @guardario } else format.html { render :new } format.json { render json: @guardario.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @respuesta = Respuesta.new(params[:respuesta])\n\n if @respuesta.save\n render json: @respuesta, status: :created, location: @respuesta\n else\n render json: @respuesta.errors, status: :unprocessable_entity\n end\n end", "def create\n\n puts request.body.string\n\n if re...
[ "0.6929326", "0.6768056", "0.67319953", "0.6694156", "0.6684221", "0.6679041", "0.6655631", "0.66427916", "0.66279507", "0.6619318", "0.6611835", "0.65512645", "0.65382624", "0.651262", "0.65006846", "0.64968127", "0.64955103", "0.64895546", "0.64819294", "0.6478087", "0.6473...
0.6258924
71
PATCH/PUT /guardarios/1 PATCH/PUT /guardarios/1.json
def update respond_to do |format| if @guardario.update(guardario_params) if params[:images] params[:images].each { |image| GuardarioImage.create(image: image, guardario_id: @guardario.id) } end format.html { redirect_to @guardario, notice: 'Guardario was successfully updated.' } format.json { render :show, status: :ok, location: @guardario } else format.html { render :edit } format.json { render json: @guardario.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @servicio = Servicio.find(params[:id])\n\n respond_to do |format|\n if @servicio.update_attributes(params[:servicio])\n format.html { redirect_to @servicio, :notice => 'Servicio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { ...
[ "0.67017114", "0.6484432", "0.6462736", "0.64463615", "0.64354485", "0.6429562", "0.6418299", "0.6409847", "0.64082086", "0.640467", "0.63935834", "0.63876843", "0.6384442", "0.6375143", "0.63748103", "0.6370693", "0.6370693", "0.6364112", "0.6361549", "0.6359582", "0.6347639...
0.0
-1
DELETE /guardarios/1 DELETE /guardarios/1.json
def destroy @guardario.destroy respond_to do |format| format.html { redirect_to guardarios_url, notice: 'Guardario was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n respond_to do |format|\n format.html ...
[ "0.7131498", "0.7128002", "0.70376754", "0.7034426", "0.7022732", "0.7014294", "0.7000645", "0.6999154", "0.69925666", "0.69839877", "0.6973615", "0.6971712", "0.6962354", "0.6954281", "0.69519687", "0.6945935", "0.6940991", "0.69386727", "0.6936697", "0.6923888", "0.69177836...
0.71886384
0
rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/PerceivedComplexity
def trigger_plugin(trigger, m) case trigger when 'reconnect' then reconnect if @bot.auth(4, m) when 'disconnect' then quit if @bot.auth(4, m) when 'join' then m.origin.join(m.args[0], m.args[1] || []) if @bot.auth(4, m) when 'part' then m.origin.part(m.args[0], m.args[1] || '') if @bot.auth(4, m) when 'nick' then m.origin.nick(m.args[0]) if @bot.auth(4, m) when 'defaultchan-add' if @bot.auth(4, m) server = m.args[0] channel = m.args[1] target = @s[:servers].find { |s| s[:name] == server } if target target[:default_channels].push(channel).uniq save_settings m.reply 'Updated default channels.' else m.reply 'Could not add default channel. Check server group.' end end when 'defaultchan-rm' if @bot.auth(4, m) server = m.args[0] channel = m.args[1] target = @s[:servers].find { |s| s[:name] == server } if target found = target[:default_channels].delete(channel) if found save_settings m.reply 'Updated default channels.' else m.reply 'Could not remove default channel. Check channel name.' end else m.reply 'Could not remove default channel. Check server group.' end end when 'defaultchan-ls' m.reply @s[:servers].to_s if @bot.auth(4, m) end super(trigger, m) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def probers; end", "def implementation; end", "def implementation; end", "def schubert; end", "def strategy; end", "def refutal()\n end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def offences_by; end", "def used?; end", "def isola...
[ "0.75423425", "0.6258423", "0.62077796", "0.62077796", "0.60551864", "0.6048124", "0.60367054", "0.602361", "0.602361", "0.602361", "0.602361", "0.5934759", "0.59278893", "0.58351535", "0.58351535", "0.58217573", "0.57921255", "0.57921255", "0.57762", "0.57762", "0.57762", ...
0.0
-1
rubocop:enable Metrics/CyclomaticComplexity rubocop:enable Metrics/PerceivedComplexity
def format(string) zwnj = "\u{0200c}" ansi_to_irc_table = { "\033[30m" => "\x031#{zwnj}", # black "\033[31m" => "\x034#{zwnj}", # red "\033[32m" => "\x033#{zwnj}", # green "\033[33m" => "\x037#{zwnj}", # brown "\033[34m" => "\x032#{zwnj}", # blue "\033[35m" => "\x0313#{zwnj}", # magenta "\033[36m" => "\x0311#{zwnj}", # cyan "\033[37m" => "\x031#{zwnj}", # gray "\033[0m" => "\x03#{zwnj}", # color end "\033[1m" => "\x02#{zwnj}", # bold start "\033[22m" => "\x02#{zwnj}" # bold end } s = string.to_s ansi_to_irc_table.each { |ansi, irc| s.gsub!(ansi, irc) } s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def probers; end", "def implementation; end", "def implementation; end", "def schubert; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def refutal()\n end", "def strategy; end", "def used?; end", "def offences_by; end", "def suivr...
[ "0.7587139", "0.6359984", "0.6272321", "0.6272321", "0.61473566", "0.60892856", "0.60892856", "0.60892856", "0.60892856", "0.606673", "0.6055285", "0.6008256", "0.59300876", "0.5921941", "0.58997357", "0.58997357", "0.58641434", "0.58641434", "0.5827586", "0.5827586", "0.5827...
0.0
-1
keep only the elements that start with a vowel
def select_elements_starting_with_vowel(array) array.select {|x| x[0] =~ /^[aeiou]/} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def select_elements_starting_with_vowel(array)\n array.select{|element|element.start_with?('a','e','i','o','u')}\nend", "def select_elements_starting_with_vowel(array)\n array.select {|i| i[0] == \"a\" || i[0] ==\"e\" || i[0] == \"i\" || i[0] == \"o\" || i[0] == \"u\"}\nend", "def select_elements_starti...
[ "0.77460223", "0.7590109", "0.756855", "0.7282824", "0.6854013", "0.67162603", "0.6709391", "0.66875196", "0.6686823", "0.6657956", "0.66249233", "0.6567812", "0.6480129", "0.64768124", "0.6476186", "0.6470962", "0.64474493", "0.6436193", "0.6428963", "0.6406445", "0.640423",...
0.7576823
2
remove instances of nil (but NOT false) from an array
def remove_nils_from_array(array) array.compact end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_nils_and_false_from_array(array)\n array.reject{|element|!element}\nend", "def remove_nils_and_false_from_array(arr)\n arr.reject { |n| n.nil? || n == false }\nend", "def remove_nils_and_false_from_array(array)\n array.select {|i| i != nil && i != false }\nend", "def remove_nils_and_false...
[ "0.8522914", "0.8206851", "0.81997174", "0.8189557", "0.8179721", "0.81379825", "0.8035682", "0.80025584", "0.79424846", "0.78688717", "0.7759937", "0.7590236", "0.7583442", "0.75434643", "0.74492896", "0.7421564", "0.7414071", "0.738235", "0.73021233", "0.7210596", "0.717893...
0.77215785
11
remove instances of nil AND false from an array
def remove_nils_and_false_from_array(array) array.select{|x| x} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_nils_and_false_from_array(array)\n array.reject{|element|!element}\nend", "def remove_nils_and_false_from_array(array)\n array.select {|i| i != nil && i != false }\nend", "def remove_nils_and_false_from_array(array)\n array.reject!{ | word | word == nil || word == false }\nend", "def remove...
[ "0.8495387", "0.84280986", "0.8361522", "0.83453083", "0.82076824", "0.7926466", "0.77702975", "0.7630456", "0.75774413", "0.7574786", "0.7533221", "0.7394485", "0.7372413", "0.73559093", "0.72614586", "0.72523516", "0.720343", "0.7067568", "0.69800705", "0.68471164", "0.6830...
0.82792425
4
don't reverse the array, but reverse every word inside it. e.g. ['dog', 'monkey'] becomes ['god', 'yeknom']
def reverse_every_element_in_array(array) array.map(&:reverse) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reverse_each_word(array)\n new_array = array.split(\" \") \n reversed_array = new_array.each {|x| x.reverse!} \n return reversed_array.join(\" \") \n end", "def reverse_every_element_in_array(array)\n array.map{ | word | word.reverse }\nend", "def reverse_each_word(array)\n array.split(\" \").collect...
[ "0.8484162", "0.84611744", "0.84519345", "0.8273189", "0.82378465", "0.8216044", "0.8208408", "0.81596124", "0.8118644", "0.8091184", "0.8068223", "0.80521387", "0.7992211", "0.79714435", "0.7964549", "0.79454875", "0.7944914", "0.7931461", "0.7917336", "0.79173046", "0.79135...
0.0
-1
given an array of student names, like ['Bob', 'Dave', 'Clive'] give every possible pairing in this case: [['Bob', 'Clive'], ['Bob', 'Dave'], ['Clive', 'Dave']] make sure you don't have the same pairing twice,
def every_possible_pairing_of_students(array) array.combination(2) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def every_possible_pairing_of_students(array)\n\tn = ['Bob', 'Dave', 'Clive']\n\tn.combination(2)\nend", "def pair_students\n \tarr = self.students.to_a\n \tarr.shuffle!\n \tpairs = []\n \tremainder = []\n \twhile !arr.empty?\n \t\tif arr.length == 1\n \t\t\tremainder << arr[0]\n \t\telse\n \t\t\tpair = []\n \t\...
[ "0.8386551", "0.76035947", "0.752221", "0.71294355", "0.69381624", "0.6871703", "0.6578671", "0.6566988", "0.6414187", "0.6382772", "0.6171759", "0.6070742", "0.6064713", "0.6063077", "0.60621923", "0.60584855", "0.6021353", "0.59713274", "0.5947103", "0.58940244", "0.5873229...
0.79091567
2
discard the first 3 elements of an array, e.g. [1, 2, 3, 4, 5, 6] becomes [4, 5, 6]
def all_elements_except_first_3(array) array.drop(3) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_elements_except_first_3 array\n\tarray.drop(3)\n\nend", "def all_elements_except_first_3(array)\n\tn = [1, 2, 3, 4, 5, 6, 7]\n\tn.slice(3..6)\nend", "def all_elements_except_first_3(num_array)\n 3.times {\n num_array.shift\n }\n return num_array\nend", "def all_elements_except_first_3(array)\n ...
[ "0.86583966", "0.84933686", "0.8163286", "0.8131874", "0.81218725", "0.81131786", "0.8053479", "0.7863024", "0.7311931", "0.7148979", "0.7148979", "0.7148979", "0.7104852", "0.7059102", "0.70525736", "0.6962306", "0.6962306", "0.693178", "0.69088304", "0.68959755", "0.6890195...
0.8694433
1
add an element to the beginning of an array
def add_element_to_beginning_of_array(array, element) array.insert(0, element) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_element_to_start_of_array(array, element)\n array.unshift(element) \nend", "def add_element_to_start_of_array(array, element)\n array.unshift(element)\nend", "def add_element_to_start_of_array( array, element)\n return array.unshift(element)\nend", "def add_element_to_beginning_of_array(array,elem...
[ "0.8898256", "0.8891635", "0.8864847", "0.88056", "0.8791929", "0.8781812", "0.86591935", "0.8524888", "0.83300686", "0.7671325", "0.7616645", "0.75926244", "0.75272095", "0.7502218", "0.7468035", "0.7432485", "0.7426746", "0.7410491", "0.73831606", "0.73831606", "0.73831606"...
0.8740714
6
sort an array of words by their last letter, e.g. ['sky', 'puma', 'maker'] becomes ['puma', 'maker', 'sky']
def array_sort_by_last_letter_of_word(array) array.map(&:reverse).sort.map(&:reverse) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def array_sort_by_last_letter_of_word(array)\n\tn =['sky', 'puma', 'maker']\n\tn.sort_by { | thing | thing.chars.last}\nend", "def array_sort_by_last_letter_of_word(array)\n array.sort_by{|word|word[-1]}\nend", "def array_sort_by_last_letter_of_word(array)\n new_array = Array.new\n array.each {|element|...
[ "0.90373224", "0.87379116", "0.8401483", "0.8062946", "0.7665494", "0.74023217", "0.7187987", "0.7090665", "0.7082225", "0.70117277", "0.6931697", "0.69047236", "0.6859694", "0.685604", "0.6848113", "0.68461967", "0.6829564", "0.67183596", "0.67151767", "0.6676839", "0.667608...
0.8685992
2
cut strings in half, and return the first half, e.g. 'banana' becomes 'ban'. If the string is an odd number of letters round up so 'apple' becomes 'app'
def get_first_half_of_string(string) string[0..(string.length-1)/2] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_first_half_of_string(string)\n # Find string length\n # half string length\n # if odd, add one\n string_length = string.size\n string_length += 1 if string_length.odd?\n half_string_length = string_length/2\n string[0..(half_string_length-1)]\n #return string up to half\nend", "de...
[ "0.83953387", "0.8223827", "0.8207649", "0.81983304", "0.8123689", "0.7611226", "0.752563", "0.75051737", "0.74642724", "0.74455345", "0.7424857", "0.7390949", "0.7380174", "0.7328442", "0.7325017", "0.7323945", "0.730377", "0.7233285", "0.7221741", "0.71986616", "0.7196363",...
0.82004416
3
turn a positive integer into a negative integer. A negative integer stays negative
def make_numbers_negative(number) number *= -1 if "++-"[number <=> 0] == "+" number # -number.abs end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def negative(integer)\n integer > 0 ? -integer : integer\nend", "def negative(int)\n int <= 0 ? int : -int\nend", "def negative(number)\n number > 0 ? -number : number\nend", "def negative(number)\n number > 0 ? -number : number\nend", "def makeNegative(num)\n num < 0 ? num : -num\nend", "def make_n...
[ "0.8505343", "0.8495705", "0.83772266", "0.83772266", "0.8359307", "0.8350805", "0.834729", "0.834729", "0.8339464", "0.8339464", "0.8339464", "0.8339464", "0.83134556", "0.83071643", "0.8304751", "0.8301642", "0.83004326", "0.8295365", "0.82500446", "0.8247661", "0.8237374",...
0.7628906
52
turn an array of numbers into two arrays of numbers, one an array of even numbers, the other an array of odd numbers even numbers come first so [1, 2, 3, 4, 5, 6] becomes [[2, 4, 6], [1, 3, 5]]
def separate_array_into_even_and_odd_numbers(array) array.partition {|x| x.even?} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def separate_array_into_even_and_odd_numbers(array)\n #Find out if each element even or odd\n # if even, put into one array\n # if odd, put into other array\n # combine arrays\n even_array = Array.new\n odd_array = Array.new\n final_array = Array.new\n array.each{|number|\n if number.odd...
[ "0.8401241", "0.803261", "0.7980493", "0.79009867", "0.7632507", "0.762936", "0.7572891", "0.75687134", "0.75332934", "0.75218284", "0.7471348", "0.74533135", "0.74373096", "0.74211", "0.73903555", "0.73791516", "0.7375185", "0.7340525", "0.7326728", "0.7324483", "0.73218125"...
0.7790502
4
count the numbers of elements in an element which are palindromes a palindrome is a word that's the same backwards as forward e.g. 'bob'. So in the array ['bob', 'radar', 'eat'], there are 2 palindromes (bob and radar), so the method should return 2
def number_of_elements_that_are_palindromes(array) array.count{|x| x==x.reverse} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def number_of_elements_that_are_palindromes(array)\n # reverse the element\n # check if reversed element is same as previous element\n # add one to the count if yes\n count = 0\n array.each {|element|\n count += 1 if element == element.reverse\n }\n count\nend", "def number_of_elements_th...
[ "0.8084525", "0.80615807", "0.7840802", "0.75598025", "0.72627604", "0.71233577", "0.70347697", "0.6970585", "0.6950738", "0.694522", "0.68500865", "0.6838748", "0.6817788", "0.67987937", "0.6796804", "0.67880744", "0.67515635", "0.6732434", "0.67172277", "0.6669026", "0.6646...
0.82851326
0
return the shortest word in an array
def shortest_word_in_array(array) array.min_by(&:length) # array.min_by { |x| x.length } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shortest_word_in_array(array)\n array.min_by{|word|word.length}\nend", "def shortest_first(array_of_words)\n # TODO\nend", "def shortest_word_in_array(array)\n array.min{ | x, y | x.length <=> y.length }\nend", "def shortest_word_in_array(array)\n\tn = %w(here is a bunch of words of different lengt...
[ "0.8936152", "0.88009495", "0.8745987", "0.871438", "0.8295519", "0.81906533", "0.7904702", "0.7811921", "0.77045095", "0.765992", "0.763713", "0.7577859", "0.7529113", "0.7501954", "0.74812907", "0.74812907", "0.74743265", "0.7468721", "0.7460263", "0.7420718", "0.74172354",...
0.85826856
4
return the shortest word in an array
def longest_word_in_array(array) array.sort_by(&:length).reverse[0] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shortest_word_in_array(array)\n array.min_by{|word|word.length}\nend", "def shortest_first(array_of_words)\n # TODO\nend", "def shortest_word_in_array(array)\n array.min{ | x, y | x.length <=> y.length }\nend", "def shortest_word_in_array(array)\n\tn = %w(here is a bunch of words of different lengt...
[ "0.8936152", "0.88009495", "0.8745987", "0.871438", "0.85826856", "0.8295519", "0.81906533", "0.7904702", "0.7811921", "0.77045095", "0.765992", "0.763713", "0.7577859", "0.7529113", "0.7501954", "0.74812907", "0.74812907", "0.74743265", "0.7468721", "0.7460263", "0.7420718",...
0.6636163
78
add up all the numbers in an array, so [1, 3, 5, 6] returns 15
def total_of_array(array) array.inject(&:+) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum(array)\n\ttotal = 0\n\tfor number in array #could do each do instead of for loop\n\t\ttotal += number\n\tend\n\treturn total\nend", "def sum array\n\tsum = 0\n\tarray.each do |number|\n\t\tsum = sum + number\n\tend\n\tsum\nend", "def arr_sum(array)\n sum = 0 # Declares initial value for variable 'sum'...
[ "0.82760185", "0.8243126", "0.81305605", "0.81279045", "0.81230366", "0.80953676", "0.80733234", "0.80714446", "0.80661744", "0.80636543", "0.80257434", "0.8017691", "0.80129266", "0.7995285", "0.7992095", "0.7991119", "0.79891396", "0.7983101", "0.79722583", "0.797147", "0.7...
0.78581876
41
turn an array into itself repeated twice. So [1, 2, 3] becomes [1, 2, 3, 1, 2, 3]
def double_array(array) array.concat(array) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dup(array)\n output = []\n i = 0\n while i < array.length\n output << array[i]\n i += 1\n end\n return output\nend", "def repa(array, x)\n result = []\n (1..x).each do\n result.concat(array)\n end\n return result\nend", "def duplicate(array)\n array.uniq!\nend", "de...
[ "0.68910384", "0.6879061", "0.6802868", "0.6682269", "0.6635336", "0.66201955", "0.6542348", "0.6505805", "0.6495935", "0.6493639", "0.64877665", "0.6478919", "0.64645284", "0.64586705", "0.6453139", "0.64515907", "0.64255774", "0.6422689", "0.6420876", "0.6396248", "0.637268...
0.65401584
7
convert a symbol into a string
def turn_symbol_into_string(symbol) symbol.to_s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def turn_symbol_into_string(symbol)\n symbol.to_s\nend", "def turn_symbol_into_string(symbol)\n\tn = :foobar\n\tn.to_s\nend", "def to_s\n \"#{symbol}\"\n end", "def to_s\n return self.symbol\n end", "def to_s \n self.symbol\n end", "def to_sym() end", "def to_sym() end", ...
[ "0.86754096", "0.85448426", "0.8246408", "0.7663453", "0.76000756", "0.75471264", "0.75471264", "0.75471264", "0.7347125", "0.71549296", "0.7110664", "0.70985067", "0.7086313", "0.7080766", "0.705333", "0.70359915", "0.6957671", "0.6951367", "0.6873577", "0.6871907", "0.68688...
0.8606445
3
get the average from an array, rounded to the nearest integer so [10, 15, 25] should return 33
def average_of_array(array) (1.0*array.inject{|sum, ele| sum + ele}/array.length).round(0) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def average_of_array(array)\n\tn = [10, 15, 25]\n\taverage = n.inject(0.0) { | total, num | total + num } / n.count\n\taverage.round\nend", "def average_of_array(array)\n (array.inject(:+) / array.size.to_f).round\nend", "def average_of_array(array)\n sum = 0\n array.each {|x|\n sum += x\n }\n...
[ "0.84667814", "0.8436909", "0.83018655", "0.8281473", "0.8266294", "0.8248131", "0.822384", "0.8108749", "0.81072354", "0.8083113", "0.80652195", "0.8050328", "0.8044402", "0.8043461", "0.80231154", "0.79969317", "0.79966474", "0.7995644", "0.7993922", "0.79738283", "0.790736...
0.8223812
7
get all the elements in an array, up until the first element which is greater than five. e.g. [1, 3, 5, 4, 1, 2, 6, 2, 1, 3, 7] becomes [1, 3, 5, 4, 1, 2]
def get_elements_until_greater_than_five(array) result = Array.new array.each {|x| x <= 5 ? result.push(x) : break} result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_elements_until_greater_than_five(array)\n\tn = [1, 3, 5, 4, 1, 2, 6, 2, 1, 3, 7]\n\tn.take_while { | n | n <= 5 }\nend", "def get_elements_until_greater_than_five(array)\n array.take_while{|number|number <=5}\nend", "def get_elements_until_greater_than_five(array)\n # go through array putting into ...
[ "0.8695388", "0.8555648", "0.85123336", "0.84562075", "0.83874947", "0.7848831", "0.750826", "0.69839954", "0.6924527", "0.6775972", "0.6626089", "0.6606612", "0.65408814", "0.644984", "0.63657045", "0.6304176", "0.6263976", "0.61847687", "0.6163819", "0.61602163", "0.6156549...
0.8656793
1
get all the letters used in an array of words and return it as a array of letters, in alphabetical order . e.g. the array ['cat', 'dog', 'fish'] becomes ['a', 'c', 'd', 'f', 'g', 'h', 'i', 'o', 's', 't']
def get_all_letters_in_array_of_words(array) result = [] array.each do |x| for a in 0..(x.length-1) do result.push(x[a]) if !result.include?(x[a]) end end result.sort end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_all_letters_in_array_of_words(array)\n #go through each word\n new_array = []\n array.each {|word|\n new_array << word.split(//)\n }\n new_array.flatten.sort\n #separate each letter and add to new array of letters - .split(//)\n #take all letters and sort for alphabet\nend", "...
[ "0.8664709", "0.8537282", "0.8481538", "0.847985", "0.77370685", "0.73647237", "0.71498805", "0.70370966", "0.70257545", "0.69553417", "0.6953104", "0.6939812", "0.6914184", "0.68854725", "0.6859743", "0.67963594", "0.6781194", "0.67265916", "0.6683525", "0.6682432", "0.66738...
0.80211985
4
take out all the capital letters from a string so 'Hello JohnDoe' becomes 'ello ohnoe'
def remove_capital_letters_from_string(string) string.gsub(/[A-Z]/, "") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_capital_letters_from_string(string)\n #iterate through letter by letter and see if caps = what it was before\n new_string = \"\"\n string.split(\"\").each {|letter|\n new_string << \" \" if letter == \" \"\n if letter != letter.capitalize\n new_string << letter\n ...
[ "0.8109931", "0.79401535", "0.7897637", "0.78135204", "0.7786935", "0.77749187", "0.77587134", "0.7741499", "0.7735781", "0.7684917", "0.7682449", "0.7673983", "0.7653565", "0.76360106", "0.7635154", "0.7631383", "0.7625177", "0.7620143", "0.76115006", "0.75997084", "0.758856...
0.7489368
36
round up a float up and convert it to an Integer, so 3.214 becomes 4
def round_up_number(float) float.to_i + 1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def round_up_number(float)\n\tn = 3.142\n\tn.ceil\nend", "def round_up_number(float)\n float.ceil\nend", "def round_up_number(float)\n float.ceil\nend", "def round_down_number(float)\n float.to_i\nend", "def round_up_number(float)\nend", "def round_down_number(float)\n\tn = 4.9\n\tn.floor\nend", "de...
[ "0.8077806", "0.79055744", "0.79055744", "0.7688301", "0.7212299", "0.7164519", "0.7070261", "0.7070261", "0.7032056", "0.7032056", "0.7032056", "0.66365486", "0.649566", "0.64608526", "0.6449929", "0.6394104", "0.63301754", "0.62512743", "0.6246978", "0.6238756", "0.6176386"...
0.7752888
3
round down a float up and convert it to an Integer, so 9.52 becomes 9
def round_down_number(float) float.to_i end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def round_up_number(float)\n\tn = 3.142\n\tn.ceil\nend", "def round_up_number(float)\n float.ceil\nend", "def round_up_number(float)\n float.ceil\nend", "def round_up_number(float)\n float.to_i + 1\nend", "def round_down_number(float)\n\tn = 4.9\n\tn.floor\nend", "def to_i\n @value.round\n ...
[ "0.78054667", "0.77171993", "0.77171993", "0.7573364", "0.74248505", "0.73107946", "0.73107946", "0.73107946", "0.72673637", "0.72673637", "0.7117598", "0.6824944", "0.6711264", "0.6637828", "0.6616437", "0.6599774", "0.64360017", "0.6424612", "0.64117175", "0.6388196", "0.63...
0.78192353
0
take a date and format it like dd/mm/yyyy, so Halloween 2013 becomes 31/10/2013
def format_date_nicely(date) date.strftime("%d/%m/%Y") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format_date(date)\n date = DateTime.parse(date)\n date.strftime('%m/%d/%y')\n end", "def format_date_nicely(date)\n\tn = Time.new(2013, 10, 31)\n\tn.strftime(\"%d/%m/%Y\")\nend", "def format_date (date)\n\t\treturn date.strftime(\"%d/%m/%Y\")\n\tend", "def format_date date\n date.strftime...
[ "0.8088374", "0.8079799", "0.8002453", "0.7974536", "0.7878386", "0.78126395", "0.77845955", "0.7701854", "0.7595023", "0.7546946", "0.7511764", "0.7506552", "0.74935347", "0.7485204", "0.7426888", "0.7419317", "0.7410767", "0.74100083", "0.7397519", "0.7396019", "0.7374652",...
0.7808841
7
get the domain name without the .com part, from an email address
def get_domain_name_from_email_address(email) med = email[/[@].*[.]/] domain = med[1..-2] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_domain_name_from_email_address(email)\n\temail = 'alex@makersacademy.com'\n\tn = email.gsub(/.+@([^.]+).+/, '\\1')\nend", "def get_domain_name_from_email_address(email)\nemail.scan(/@(\\w+)/)[0].pop\nend", "def get_domain_name_from_email_address(email)\n index_no = email.index('@') + 1\n email[index_...
[ "0.8740158", "0.87025267", "0.8554765", "0.8360987", "0.82963353", "0.8246554", "0.8246554", "0.82442385", "0.82101166", "0.80548596", "0.8025785", "0.7772103", "0.73806155", "0.73332494", "0.7325283", "0.72883445", "0.7277579", "0.7254325", "0.723445", "0.72305053", "0.72237...
0.88697344
0
capitalize the first letter in each word of a string, except 'a', 'and' and 'the' unless they come at the start of the start of the string, e.g. 'the lion the witch and the wardrobe' becomes 'The Lion the Witch and the Wardrobe'
def titleize_a_string(string) result = string.split.each do |x| if (x != 'a' && x != 'and' && x != 'the') x.capitalize! end end result[0].capitalize! result.join(' ') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def titleize_a_string(string)\nsentence = string.capitalize!.split(' ')\n words_not_to_capitalize = ['a', 'and', 'the']\n\n sentence.each do |word|\n word.capitalize! unless words_not_to_capitalize.include?(word)\n end.join(' ')\n\nend", "def titleize(str)\n str.capitalize!\n dont_capitalize = [\"and\", ...
[ "0.83197874", "0.8302083", "0.8109014", "0.80608577", "0.80343324", "0.79757625", "0.7975439", "0.7906768", "0.79047257", "0.7897698", "0.78521043", "0.7787615", "0.7762814", "0.774457", "0.77204734", "0.7715953", "0.77148587", "0.7709569", "0.76992553", "0.7695142", "0.76738...
0.83263725
0
return true if a string contains any special characters where 'special character' means anything apart from the letters az (uppercase and lower) or numbers
def check_a_string_for_special_characters(string) string.include?('@') || string.include?('!') || string.include?('£') || string.include?('$') || string.include?('%') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_a_string_for_special_characters(string)\n\t# match() is used to check if there is any match as in the regexp. /\\W/ means non word characters.\n\tstring.chars.select {|char| char.match(/\\W/) }.any?\nend", "def check_a_string_for_special_characters(string)\n string =~ /\\W/\nend", "def check_a_strin...
[ "0.8618456", "0.8473732", "0.8393732", "0.83814704", "0.83039325", "0.7732395", "0.7579389", "0.7562248", "0.74992883", "0.7438323", "0.7373901", "0.7328733", "0.72313267", "0.71360457", "0.7102218", "0.6976775", "0.69174904", "0.6908581", "0.68811846", "0.6855229", "0.684180...
0.86770624
0
get the upper limit of a range. e.g. for the range 1..20, you should return 20
def get_upper_limit_of(range) range.last end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_upper_limit_of(range)\n range.max\nend", "def get_upper_limit_of(range)\n range.max\nend", "def get_upper_limit_of(range)\n range.end\nend", "def get_upper_limit_of(range)\n\tn = 1..20\n\tn.last\nend", "def get_max_range\n return @maxRange\n end", "def range\n @range ||= 0.upto(@l...
[ "0.9206413", "0.9196181", "0.89698696", "0.8677135", "0.7903234", "0.76456445", "0.7429282", "0.74016565", "0.72938395", "0.71423763", "0.71423763", "0.7117961", "0.70779115", "0.6924296", "0.6907828", "0.68915385", "0.67958736", "0.6782472", "0.67617697", "0.6714404", "0.670...
0.8916967
3
should return true for a 3 dot range like 1...20, false for a normal 2 dot range
def is_a_3_dot_range?(range) a = range.first b = range.last range != (a..b) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_a_3_dot_range?(range)\n range.exclude_end?\nend", "def is_a_3_dot_range?(range)\n\trange.exclude_end?\nend", "def is_a_3_dot_range?(range)\n range.to_s.include?(\"...\")\nend", "def is_a_3_dot_range?(range)\n range.to_s.include?(\"...\")\nend", "def is_range?\n self =~ /\\A(([\\d]+)|(['\"][\...
[ "0.7907765", "0.79009247", "0.76173264", "0.75949055", "0.7079766", "0.6941898", "0.68956643", "0.68879354", "0.688203", "0.68540084", "0.6799367", "0.67930627", "0.6783418", "0.6761574", "0.67348987", "0.6732423", "0.6732423", "0.6711893", "0.6711893", "0.67032915", "0.67032...
0.8060389
0
get the square root of a number
def square_root_of(number) Math.sqrt(number) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def square_root_of(number)\n\tMath.sqrt(number)\nend", "def square_root_of(number)\n Math.sqrt(number)\nend", "def square_root_of(number)\n Math.sqrt number\nend", "def introot (square)\n return Math . sqrt(square) . floor()\nend", "def squareRoot num1\n total = Math.sqrt(num1.to_i)\n puts \"--> T...
[ "0.84159726", "0.82289064", "0.8153827", "0.7786878", "0.7632076", "0.74453664", "0.7409191", "0.7387518", "0.7331509", "0.7327622", "0.7327541", "0.7319395", "0.7308182", "0.72293997", "0.72226655", "0.7195871", "0.70361274", "0.6913521", "0.6871573", "0.68484163", "0.683574...
0.82007086
3
count the number of words in a file
def word_count_a_file(file_path) total = 0 file = File.new(file_path, "r") file.readlines.each do |x| total += x.split.size end total end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def word_count_a_file(file_path)\n\tfile = File.new(file_path,'r')\n\tfile.read.count(\" \")+1 \nend", "def word_count_a_file(file_path)\n word_count = 0\n f = File.open(file_path, \"r\")\n f.each_line {|line|\n word_count += line.to_s.split.size\n }\n word_count\nend", "def w...
[ "0.8860619", "0.87222856", "0.8680747", "0.8632879", "0.84059644", "0.8267078", "0.80155283", "0.7996709", "0.73909473", "0.73909473", "0.7330637", "0.7229115", "0.7212433", "0.70496804", "0.70226234", "0.7003191", "0.6993289", "0.69572693", "0.69495255", "0.69347155", "0.691...
0.86001074
4
tougher ones call an arbitrary method from a string. so if I called call_method_from_string('foobar') the method foobar should be invoked
def call_method_from_string(str_method) str_method.method('str_method').call end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def call_method_from_string(str_method)\n\tcall(str_method)\nend", "def call_method_from_string(str_method)\nend", "def call_method_from_string(str_method)\n send(str_method)\nend", "def call_method_from_string(str_method)\n send(str_method)\nend", "def call_method_from_string(str_method)\n eval(str_m...
[ "0.90649915", "0.904207", "0.88599545", "0.8841693", "0.8726361", "0.648192", "0.648192", "0.6258266", "0.62072736", "0.6115519", "0.60413414", "0.60205746", "0.59941465", "0.5991345", "0.5962411", "0.5934351", "0.5895839", "0.58693457", "0.5869017", "0.58439535", "0.5810539"...
0.8843918
3
return true if the date is a uk bank holiday for 2014 the list of bank holidays is here:
def is_a_2014_bank_holiday?(date) require 'open-uri' content = open("https://www.gov.uk/bank-holidays.json").read formated_date = date.strftime("%Y-%m-%d") content.include?(formated_date) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_a_2014_bank_holiday?(date)\n # e.g. year, month, day\n # date format: Time.local(1976, 8, 3)\n y = 2014\n # store array of bank holiday dates\n array = [Time.local(y,12,25),Time.local(y,12,26),Time.local(y,8,25),Time.local(y,5,26),Time.local(y,5,5),Time.local(y,4,21),Time.local(y,4,18),Time.l...
[ "0.8540713", "0.8394587", "0.82271403", "0.82271403", "0.8214855", "0.81069857", "0.7558174", "0.74024177", "0.73547196", "0.7348312", "0.7204825", "0.7149876", "0.7147339", "0.70008993", "0.6861482", "0.6804807", "0.6719605", "0.67163646", "0.67118806", "0.6696558", "0.66756...
0.7691171
6
given your birthday this year, this method tells you the next year when your birthday will fall on a friday e.g. january 1st, will next be a friday in 2016 return the day as a capitalized string like 'Friday'
def your_birthday_is_on_a_friday_in_the_year(birthday) month = birthday.strftime("%m").to_i day = birthday.strftime("%d").to_i year = birthday.strftime("%Y").to_i loop do year = year += 1 time = Time.new(year, month, day) break if time.strftime("%u") == "5" end year end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def your_birthday_is_on_a_friday_in_the_year(birthday)\n # Key: tells you the YEAR where birthday will be on a Fri\n # each year = moves up 2 days\n loop {\n if birthday.friday? == true\n return birthday.year\n end\n # key -> don't need to account for day of week change in addition, only 1...
[ "0.8109527", "0.7696091", "0.76277554", "0.74576986", "0.74576986", "0.71101797", "0.67849904", "0.6736544", "0.668261", "0.66522056", "0.6636081", "0.6627014", "0.6609094", "0.66056055", "0.65557027", "0.6548161", "0.6537978", "0.65248144", "0.6515274", "0.65023255", "0.6499...
0.71727663
5
implement fizzbuzz without modulo, i.e. the % method go from 1 to 100 (there's no RSpec test for this one)
def fizzbuzz_without_modulo ints = [] for i in 1..50 ints.push(i) end (1..100).each do |x| if ints.include?(x/5.0) puts(ints.include?(x/3.0) ? 'fizzbuzz' : 'fizz') else puts(ints.include?(x/3.0) ? 'buzz' : x) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fizzbuzz_without_modulo\n \nend", "def fizzbuzz_without_modulo\nend", "def fizzbuzz_without_modulo\nend", "def fizzbuzz_without_modulo\n 1.upto(100) do |n|\n str = ''\n if (n / 3.0).round == (n / 3.0)\n str << 'Fizz'\n end\n\n if (n / 5.0).round == (n / 5.0)\n str << 'Buzz'\n e...
[ "0.8469252", "0.84483373", "0.84483373", "0.79814315", "0.79353684", "0.78906816", "0.78395313", "0.7838817", "0.7821575", "0.78027654", "0.7782009", "0.7760392", "0.7757345", "0.77562577", "0.77294147", "0.77283907", "0.7716228", "0.77073157", "0.7700137", "0.7683917", "0.76...
0.8082504
3