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
Never trust parameters from the scary internet, only allow the white list through.
def spent_params params.require(:spent).permit(:category, :value, :description) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.6980629", "0.67819995", "0.67467666", "0.67419875", "0.67347664", "0.65928614", "0.6504013", "0.6498014", "0.64819515", "0.64797956", "0.64562726", "0.64400834", "0.6380117", "0.6377456", "0.63656694", "0.6320543", "0.63002014", "0.62997127", "0.629425", "0.6293866", "0.62...
0.0
-1
=== Description Your application should override this method. Define application command line options. === Parameters opt:: (OptionParser) use this to define options
def define_options(opt) # override this; no additional options by default end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def options(opt); end", "def options(opt); end", "def options(opt)\n end", "def common_opts(opt)\n opt.on_tail(\"-h\", \"-?\", \"--help\", \"Show this help message.\") do\n puts opt\n exit\n end\n opt.on_tail(\"-v\", \"--version\", \"Show the version.\") do\n puts \"Tav...
[ "0.7118333", "0.7117604", "0.70960796", "0.6870463", "0.6639433", "0.6578563", "0.6551517", "0.64392525", "0.6408635", "0.63547367", "0.6349535", "0.63261074", "0.63260627", "0.63227546", "0.6310772", "0.6281424", "0.6280924", "0.62721825", "0.62721825", "0.62721825", "0.6272...
0.70181286
3
=== Description Your application should override this method. Implement the main entry point. === Parameters argv:: (Array) of positional arguments Basically left over after processing command line options starting with dash(s) as defined in get_options. === Returns (Integer) exit code
def main(argv) # override this; no default action in main end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(argv = ARGV)\n #p [:argv, argv]\n begin\n # cheating\n if argv.include?('-h') or argv.include?('--help')\n puts help_text\n else\n app = from_argv(argv)\n app.run\n end\n rescue Exception => e\n if exit_statu...
[ "0.7565795", "0.69048387", "0.68647856", "0.68382984", "0.67724186", "0.6733345", "0.6711474", "0.66102684", "0.65572083", "0.6534257", "0.65159637", "0.6473957", "0.6469824", "0.6443771", "0.6437997", "0.64216685", "0.64182794", "0.64128083", "0.64062244", "0.6402456", "0.63...
0.7791449
0
=== Description Parse options, and run the main method === Returns (Integer) exit code
def run code = 0 opt = OptionParser.new define_options(opt) default_options(opt) define_exit_codes(opt) argv = opt.parse! if @help puts_msg(opt.help) else begin main(argv) rescue Exception => e arr = @@exit_code_map[e.class] code = arr ? arr[0] : 1 puts_err e.to_s puts_err "[ERROR]" end end exit(code) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run\n if !options_parsed?() || !options_valid?()\n @stderr.puts(\"\")\n output_usage(@stderr)\n return 1\n end\n return run_real()\nend", "def parse!\n begin\n @opts = OptionParser.new(&method(:set_opts))\n @opts.parse!(@args)\n @options\n rescue Exception => e\n ...
[ "0.767985", "0.74173754", "0.71463656", "0.7116004", "0.705908", "0.70411134", "0.7036456", "0.6995846", "0.6971928", "0.69436526", "0.6931246", "0.6906994", "0.6893284", "0.6886774", "0.6882564", "0.68564314", "0.6835208", "0.68287444", "0.6809437", "0.6796433", "0.6790949",...
0.8654356
0
=== Description Print out msg to STDOUT
def puts_msg(msg) STDOUT.puts(msg) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_message(msg)\n print \">> #{msg.to_s} \\n\"\n end", "def message(msg)\n STDOUT.puts msg\n end", "def out(msg)\n io.print(msg) if io\n end", "def msg(message)\n stdout.puts message\n end", "def print_stdout(msg)\n puts \" #{msg}\"\n end", "...
[ "0.8586264", "0.85794103", "0.8359861", "0.83237344", "0.82765245", "0.8213711", "0.8157286", "0.8143191", "0.81098366", "0.7982241", "0.79725975", "0.79621303", "0.7821825", "0.7745828", "0.77333415", "0.76939815", "0.76923054", "0.7665979", "0.76278186", "0.76264846", "0.76...
0.8524942
2
=== Description Print out msg to STDERR in red color
def puts_err(msg) STDERR.puts(msg.to_s.red) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_stderr(msg)\n puts \" #{color(msg, 31)}\"\n end", "def error_message( msg, details='' )\n\t\t\t$stderr.puts colorize( 'bold', 'white', 'on_red' ) { msg } + details\n\t\tend", "def error_message( msg, details='' )\n\t\t$stderr.puts colorize( 'bold', 'white', 'on_red' ) { msg } + ' ' + de...
[ "0.87337965", "0.82728803", "0.8242551", "0.82000345", "0.8098276", "0.8080287", "0.78530663", "0.780545", "0.7705156", "0.76129603", "0.7535064", "0.741853", "0.73221236", "0.7239498", "0.7171502", "0.71554863", "0.71274287", "0.7108954", "0.70611954", "0.7034199", "0.701279...
0.8678974
1
Write a method that returns true if its integer is palindromic, false otherwise. A palindromic number reads the same forwards and backwards.
def palindromic_number?(num) num.to_s == num.to_s.reverse end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def palindromic_number?(int)\r\n int.to_s == int.to_s.reverse\r\nend", "def palindromic_number?(int)\n int.to_s == int.to_s.reverse\nend", "def palindromic_number?(integer)\n integer.to_s == integer.to_s.reverse!\nend", "def palindromic_number?(integer)\n integer.to_s == integer.to_s.reverse\nend", "de...
[ "0.8810984", "0.87939155", "0.8771195", "0.87482905", "0.87386256", "0.87324905", "0.8675722", "0.86734205", "0.86734205", "0.8651917", "0.86509025", "0.8641991", "0.86208445", "0.8605032", "0.8589484", "0.8588952", "0.8585475", "0.85803384", "0.8563643", "0.8548378", "0.8541...
0.8605417
14
Used to log the activity of the scraper methods.
def scraper_logger @@scraper_logger ||= Logger.new("#{Rails.root}/log/scraper.log") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log\n end", "def logs\n end", "def log; end", "def log; end", "def log; end", "def log; end", "def log; end", "def log; end", "def log; end", "def log; end", "def logs\n\n end", "def logme\n\t\tlogger.debug \"============Main ApplicationController get calls at #{Time.now}\"\n\tend", ...
[ "0.66825444", "0.66351515", "0.65919787", "0.65919787", "0.65919787", "0.65919787", "0.65919787", "0.65919787", "0.65919787", "0.65919787", "0.65490013", "0.64487576", "0.6360396", "0.6342089", "0.61816376", "0.611208", "0.60609543", "0.60609543", "0.60609543", "0.60609543", ...
0.64462554
12
Updates all stations from BOM website.
def update_stations State.all.each do |s| fetch_stations(s) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def updateStation()\n uri=URI.parse(ViaggiatrenoURLs.STATION_INFO)\n response = Net::HTTP.post_form(uri,{\"stazione\" => @stationFrom, \"lang\" => \"IT\"})\n doc = Nokogiri::HTML(response.body)\n\n doc.xpath(XPathMatchInfo.XPATH_STATION).each do |x|\n \n StringUtils.remove_newlines_tabs_and_s...
[ "0.698828", "0.6278264", "0.5869688", "0.58676517", "0.5729337", "0.56947315", "0.5577968", "0.5575948", "0.55673766", "0.55408454", "0.55315363", "0.55167544", "0.54987544", "0.54011744", "0.5377886", "0.5368271", "0.53562886", "0.53431135", "0.5324092", "0.5319878", "0.5318...
0.72969127
0
Updates all weather observations from BOM data feeds.
def update_observations State.all.each do |s| fork do Station.where(state_id: s.id).each do |s| fetch_observations(s) end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_from_darksky(historical_dates=[Date.today-1], forecast=true)\n darksky_secret = ApiKey.where(:service => 'Darksky').first.key\n hydra = Typhoeus::Hydra.new\n requests = Hash.new\n forecast_request = nil\n\n logger.debug(\"Updating Station #{name} for dates: #{historical_dates}\")\n \n ...
[ "0.65698314", "0.64219064", "0.61091524", "0.5979429", "0.5871049", "0.5771896", "0.5708098", "0.570155", "0.5655932", "0.5645692", "0.5630039", "0.5600645", "0.55835366", "0.5520503", "0.5468013", "0.5421823", "0.54199296", "0.5389205", "0.536105", "0.5356867", "0.53242546",...
0.5537161
13
Retrieves a list of the URLS for each weather station given a State. Each url is then passed to the extract_station method.
def fetch_stations(state) scraper_logger.info("Fetching stations for #{state.name}") doc = Nokogiri::HTML(open(state.url)) doc.css('a').each do |s| Global::OBSERVATION_PRODUCT_CODE.each do |c| if s.attr('href').include?(c) and s.attr('href').include?(state.product_group) extract_station(s.attr('href'), state) end end end scraper_logger.info("Completed fetching stations for #{state.name}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_station(url, state)\n\n id, json_url = nil\n\n doc = Nokogiri::HTML(open(\"#{Global::BOM_BASE_URL}#{url}\"))\n doc.css('a').each do |l|\n\n if l.attr('href').include?('json')\n json_url = l.attr('href')\n id = l.attr('href').split('.')\n id = id[1]\n end\n\n e...
[ "0.6223554", "0.5820403", "0.57375234", "0.56964236", "0.56822276", "0.56321967", "0.5613308", "0.5611582", "0.56078744", "0.5523439", "0.5521253", "0.55070436", "0.5458414", "0.5438868", "0.5430657", "0.53995764", "0.5375218", "0.5367982", "0.5304522", "0.5283608", "0.526027...
0.73837906
0
Creates a new, or updates an existing, Station given it's URL and the State to which it belongs.
def extract_station(url, state) id, json_url = nil doc = Nokogiri::HTML(open("#{Global::BOM_BASE_URL}#{url}")) doc.css('a').each do |l| if l.attr('href').include?('json') json_url = l.attr('href') id = l.attr('href').split('.') id = id[1] end end begin station = Station.find(id) scraper_logger.info("Updating existing station #{id}") rescue station = Station.new station.id = id scraper_logger.info("Creating new station #{id}") end begin station.state = state name = doc.css('h1').first station.name = name.text.gsub('Latest Weather Observations for ','') station.station_url = "#{Global::BOM_BASE_URL}#{url}" station.json_url = "#{Global::BOM_BASE_URL}#{json_url}" json = extract_observations(station.json_url) station.latitude = json['observations']['data'].first['lat'] station.longitude = json['observations']['data'].first['lon'] tz = Timezone.where(abbreviation: json['observations']['header'].first['time_zone']) if tz.size > 0 station.timezone = tz.first station.save scraper_logger.info("#{station.id} - #{station.name} has been saved") else scraper_logger.warn("#{station.id} - #{station.name} could not be saved due to unknown TZ (#{json['observations']['header'].first['time_zone']})") end rescue scraper_logger.warn("#{station.id} - #{station.name} could not be saved due missing data in JSON file)") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @station = Station.new(station_params)\n\n if @station.save\n render json: @station, status: :created, location: @station\n else\n render json: @station.errors, status: :unprocessable_entity\n end\n end", "def create_station!(name)\n station = Station.new(name...
[ "0.6124878", "0.5908352", "0.5855723", "0.5855723", "0.5790763", "0.5772726", "0.5731229", "0.5681185", "0.5606074", "0.5506624", "0.54587865", "0.5431429", "0.5410876", "0.53667563", "0.5360192", "0.5360192", "0.5360192", "0.5357474", "0.5355892", "0.5342366", "0.5306843", ...
0.6925179
0
Will retrieve all new observations given a Station.
def fetch_observations(station) scraper_logger.info("Fetching latest weather observations for #{station.id} - #{station.name}") new = 0 json = extract_observations(station.json_url) json['observations']['data'].each do |o| Time.zone = 'UTC' recording_time = Time.zone.parse("#{o['aifstime_utc']}Z") unless Observation.already_exists?(station, recording_time) observation = Observation.new observation.station = station observation.recording_time = recording_time observation.save parse_readings(o, observation) new += 1 end end scraper_logger.info("Added #{new} new observations") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_stations\n\n State.all.each do |s|\n fetch_stations(s)\n end\n\n end", "def index\n @stations = Station.all\n end", "def index\n @stations = Station.all\n end", "def index\n @station_infos = StationInfo.all\n end", "def gather!\n @observations = get_datas!\n ...
[ "0.60627115", "0.60454845", "0.60211325", "0.60140836", "0.60013545", "0.599155", "0.5933164", "0.58868164", "0.58325136", "0.57831836", "0.5751916", "0.57026345", "0.56444305", "0.55942184", "0.5555724", "0.55298007", "0.54736036", "0.54655385", "0.5448267", "0.5442694", "0....
0.7462373
0
Returns the JSON object from a stations observation.
def extract_observations(url) JSON.load(open(url)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stations\n ActiveModel::ArraySerializer.new(object.station, each_serializer: Api::V1::StationSerializer)\n end", "def get_stations\n CF::Station.get(\"/lines/#{ACCOUNT_NAME}/#{self.title.downcase}/stations.json\")\n end", "def load_station_data\n data = Net::HTTP.get(URI.parse(stations_url))...
[ "0.6266639", "0.59415406", "0.59089315", "0.5828578", "0.57521707", "0.5751328", "0.5745187", "0.57077765", "0.57033914", "0.5675881", "0.5658068", "0.5614545", "0.5517063", "0.54889625", "0.54767823", "0.54497343", "0.54438025", "0.5437412", "0.5387793", "0.53203434", "0.531...
0.5382424
19
Given a JSON feed containing a group of BOM observations, along with an Observation, this method will create all necessary Reading records based on ReadingType records.
def parse_readings(json, observation) ReadingType.all.each do |r| reading = Reading.new reading.observation = observation reading.reading_type = r unless json[r.bom_field_name].nil? if r.numeric reading.numeric_value = json[r.bom_field_name].to_d unless json[r.bom_field_name] == '-' else reading.string_value = json[r.bom_field_name] unless json[r.bom_field_name] == '-' end end reading.save end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @readings = []\n lines = Base64.decode64 params[:file].sub('data:text/csv;base64,','')\n solar_readings = lines.split(\"\\n\").reverse\n solar_readings.each do |reading|\n reading = reading.split(\";\")\n begin\n date = DateTime.strptime(reading[0], '%d/%m/%Y')\n @r...
[ "0.5236031", "0.50617695", "0.50402725", "0.4994088", "0.48664123", "0.48345155", "0.47930834", "0.47810516", "0.47340125", "0.47205272", "0.46971118", "0.46683747", "0.4653783", "0.4649695", "0.46401024", "0.4635319", "0.4583495", "0.4558224", "0.45501173", "0.45426437", "0....
0.73365414
0
Welcome_email is a eMail sent to the Channel Admin, after setting up the channel and contains the Sec_Hash
def welcome_email(channel) @channel = channel @url = 'http://example.com/login' mail(to: @channel.email, subject: 'Welcome to your Constructeev Channel') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def welcome_email\n # User welcome email sent.\n end", "def welcome_email(user, currenthost)\n\t @user = user\n\t @currenthost = currenthost\n\n\t mail(to: @user.email, subject: 'Welcome to Changefindr').deliver()\n\tend", "def welcome_email\n UserMailer.welcome_email\n end", "def welcome_em...
[ "0.7122097", "0.7005587", "0.69214004", "0.69214004", "0.68974185", "0.6884443", "0.68843615", "0.68599933", "0.6839519", "0.6827258", "0.6815871", "0.68025696", "0.6710657", "0.66929525", "0.66835964", "0.6652146", "0.66480637", "0.66356033", "0.66262025", "0.6588923", "0.65...
0.78109956
0
receive post and email that feedback
def send_feedback @message = params[:message] @subject = params[:subject] if Staff.feedback_email(current_user, @subject, @message).deliver redirect_to root_path, notice: t("flash.feedback_sent") else render action: "feedback", alert: t("flash.feedback_failed") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_post_notification(post)\n @post = post\n @post = post\n @poster = post.poster\n if @post.post_needs.size == 0\n @post_needs = []\n else\n @post_needs = @post.post_needs.alphabetical\n end\n recipients = @post.notify_emails\n\n if recipients != \"\"\n mail(:to => recipi...
[ "0.73912334", "0.71305496", "0.706481", "0.69875", "0.691727", "0.68479", "0.6812092", "0.6791208", "0.6728435", "0.67026794", "0.666112", "0.66548264", "0.6641871", "0.66367143", "0.6604505", "0.65924966", "0.65881306", "0.65679574", "0.6559134", "0.654583", "0.65415394", ...
0.6082675
75
page to allow user changing password
def change_password @user = current_user end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def change_password\r\n \r\n end", "def edit_password; end", "def change_password\n return if generate_filled_in\n if do_change_password_for(@user)\n # since sometimes we're changing the password from within another action/template...\n #redirect_to :action => params[:back_to] if params[:ba...
[ "0.84290123", "0.8193663", "0.79619133", "0.78120226", "0.7776304", "0.7762628", "0.77188057", "0.7714539", "0.7679163", "0.7676821", "0.76365185", "0.7623872", "0.7599448", "0.7590641", "0.7584725", "0.7584069", "0.7581752", "0.75761884", "0.755969", "0.7553241", "0.75531113...
0.0
-1
Execute some code Execute some code condition = true another_condition = false if !condition && !another_condition puts 'This evaluated to true' else puts 'This evaluated to false' end puts 'La la la' name = 'Fikar' if name == 'Fikar' puts 'Welcome to the program, Fikar' elsif name == 'Jack' puts 'Welcome to the world, Jack' elsif name == 'Evgeny' puts 'Welcome to the world, Evgeny' else puts 'Welcome to the program, User' end List of Methods
def add(first_num, second_num) first_num.to_f + second_num.to_f end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main\n\n #\n # In Ruby, everything is an expression, even the control structures.\n #\n\n #\n # if, else, elsif\n #\n # The value that results from evaluating an if expression is the\n # value of the last expression in the code that was executed, or\n # nil if no block of code is executed.\n #\n \n ...
[ "0.65457773", "0.63962626", "0.61645144", "0.6052445", "0.59823644", "0.59612036", "0.5883614", "0.5883614", "0.57998335", "0.5707243", "0.56869644", "0.56635284", "0.5638576", "0.5607927", "0.55924493", "0.55822223", "0.55742896", "0.55622834", "0.55575985", "0.55393755", "0...
0.0
-1
an empty array accessible to all methods
def save_students file = File.open("students.csv","w") @students.each do |student| student_data = [student[:name], student[:cohort]] csv_line = student_data.join(",") file.puts csv_line end file.close end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def array\n raise \"Not implemented\"\n end", "def another; return []; end", "def all\n []\n end", "def __array__; self; end", "def to_ary\n\t []\n\tend", "def variables\n EMPTY_ARRAY\n end", "def array\n @@array\n end", "def initialize; @ary = []; end", "def to_a; []...
[ "0.73341405", "0.7154377", "0.70395124", "0.6939797", "0.68577194", "0.6831367", "0.67742383", "0.67736715", "0.6770608", "0.675761", "0.6746169", "0.67191696", "0.6681353", "0.661779", "0.661779", "0.661779", "0.661779", "0.6611431", "0.65442127", "0.6529813", "0.652277", ...
0.0
-1
Creates the window contents
def create_contents @shell.layout = GridLayout.new(6, true) Label.new(@shell, SWT::NONE).text = "Your name:" @name_box = Text.new(@shell, SWT::BORDER) layout_data = GridData.new(GridData::FILL_HORIZONTAL) layout_data.horizontalSpan = 4 @name_box.layout_data = layout_data @status_label = Label.new(@shell, SWT::BORDER) layout_data = GridData.new(GridData::FILL_HORIZONTAL) layout_data.horizontalSpan = 3 @status_label.layout_data = layout_data @button = Button.new(@shell, SWT::PUSH) @button.text = "Click me!" layout_data = GridData.new(GridData::END, GridData::CENTER, false, false) layout_data.horizontalSpan = 6 @button.layout_data = layout_data @button.addSelectionListener do handle_click end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def createWindow\r\n \r\n end", "def create\r\n super # Create the windows\r\n show(PLACEMENT_SCREEN) # Make the main window appear\r\n end", "def remake_window\n self.width = window_width\n self.height = window_height\n create_contents\n end", "def main_window\r\n su...
[ "0.8128017", "0.73508704", "0.7312985", "0.70642495", "0.70542985", "0.70298475", "0.698378", "0.69769484", "0.6923041", "0.6913859", "0.68736434", "0.6871386", "0.68163425", "0.6775724", "0.6772868", "0.67457336", "0.6744301", "0.6741835", "0.6728215", "0.67052084", "0.66843...
0.6732302
18
Return the current binding.
def get_binding binding end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_binding\n return binding()\n end", "def get_binding\n return binding()\n end", "def get_binding\n return binding\n end", "def get_binding\n return binding()\n end", "def get_binding\n binding()\n end", "def get_binding\n binding()\n end"...
[ "0.88186055", "0.88186055", "0.8805381", "0.87528974", "0.86933494", "0.86933494", "0.86273885", "0.86273885", "0.86273885", "0.86273885", "0.86273885", "0.86273885", "0.86273885", "0.86273885", "0.86273885", "0.8626539", "0.8626539", "0.8626539", "0.8626539", "0.8601867", "0...
0.8375841
36
GET /forum_cat_l1s/1 GET /forum_cat_l1s/1.xml
def show @forum_cat_l1 = ForumCatL1.find(params[:id]) @forum_cat_l2s = ForumCatL2.find(:all, :conditions => ["forum_cat_l1_id = ?", params[:id]]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @forum_cat_l1 } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @forum_cat_l1 = ForumCatL1.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @forum_cat_l1 }\n end\n end", "def get_categories\n body = build_request(2935, 1501, \"ACTIVEHEADINGS\")\n response = send_to_localeze(body)\n xml_d...
[ "0.6666921", "0.657437", "0.6237197", "0.6066407", "0.6056434", "0.60168463", "0.5993059", "0.59686416", "0.5965243", "0.58546954", "0.5843813", "0.5819074", "0.58076763", "0.5786881", "0.57772726", "0.5771613", "0.57529575", "0.5740423", "0.57294387", "0.57013685", "0.570136...
0.67749006
0
GET /forum_cat_l1s/new GET /forum_cat_l1s/new.xml
def new @forum_cat_l1 = ForumCatL1.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @forum_cat_l1 } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @forum_cat_l1 = ForumCatL1.new(params[:forum_cat_l1])\n\n respond_to do |format|\n if @forum_cat_l1.save\n flash[:notice] = t(:category1_created)\n format.html { redirect_to(@forum_cat_l1) }\n format.xml { render :xml => @forum_cat_l1, :status => :created, :location =>...
[ "0.7542703", "0.7050673", "0.7031274", "0.7031274", "0.68963134", "0.6877075", "0.68483984", "0.6834801", "0.68277633", "0.68277633", "0.68277633", "0.68277633", "0.680393", "0.6793724", "0.6777852", "0.67618775", "0.67491084", "0.67463917", "0.6737806", "0.6737038", "0.67322...
0.7759111
0
POST /forum_cat_l1s POST /forum_cat_l1s.xml
def create @forum_cat_l1 = ForumCatL1.new(params[:forum_cat_l1]) respond_to do |format| if @forum_cat_l1.save flash[:notice] = t(:category1_created) format.html { redirect_to(@forum_cat_l1) } format.xml { render :xml => @forum_cat_l1, :status => :created, :location => @forum_cat_l1 } else format.html { render :action => "new" } format.xml { render :xml => @forum_cat_l1.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @forum_cat_l1 = ForumCatL1.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @forum_cat_l1 }\n end\n end", "def update\n @forum_cat_l1 = ForumCatL1.find(params[:id])\n\n respond_to do |format|\n if @forum_cat_l1.update_attr...
[ "0.61182815", "0.5838544", "0.57440066", "0.56360775", "0.5618319", "0.561795", "0.55866885", "0.5584254", "0.5566893", "0.5534312", "0.55145437", "0.5512915", "0.54744476", "0.54412353", "0.5435567", "0.5377139", "0.537596", "0.53596586", "0.53553075", "0.53281456", "0.52806...
0.72710294
0
PUT /forum_cat_l1s/1 PUT /forum_cat_l1s/1.xml
def update @forum_cat_l1 = ForumCatL1.find(params[:id]) respond_to do |format| if @forum_cat_l1.update_attributes(params[:forum_cat_l1]) flash[:notice] = t(:category_updated) format.html { redirect_to(@forum_cat_l1) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @forum_cat_l1.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @cat = Cat.find(params[:id])\n\n respond_to do |format|\n if @cat.update_attributes(params[:cat])\n _update_topics \n format.html { redirect_to action: \"edit\", notice: 'Cat was successfully updated.' }\n format.json { head :no_content }\n else\n format.htm...
[ "0.61464083", "0.61202496", "0.6073736", "0.6055222", "0.60029536", "0.5998899", "0.59769785", "0.5892616", "0.58444476", "0.58378303", "0.58305293", "0.5809139", "0.5806455", "0.5758757", "0.57459974", "0.57392335", "0.57291216", "0.571252", "0.5706334", "0.569899", "0.56981...
0.7152804
0
DELETE /forum_cat_l1s/1 DELETE /forum_cat_l1s/1.xml
def destroy @forum_cat_l1 = ForumCatL1.find(params[:id]) @forum_cat_l1.destroy respond_to do |format| format.html { redirect_to(forum_cat_l1s_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @forum_post = ForumPost.find(params[:id])\n forum_cat_l2 = @forum_post.forum_cat_l2\n @forum_post.destroy\n\n respond_to do |format|\n format.html { redirect_to forum_cat_l2_path(forum_cat_l2) }\n format.xml { head :ok }\n end\n end", "def delete_forum id\n\t\t\t\t\tFresh...
[ "0.71156746", "0.67091733", "0.66993564", "0.665105", "0.66479176", "0.65998554", "0.65891576", "0.6509587", "0.6448298", "0.64113075", "0.640622", "0.6388922", "0.6378038", "0.63606995", "0.6355409", "0.63508177", "0.62868", "0.6277622", "0.6273756", "0.62716573", "0.6259538...
0.77989984
0
Things to do: Clean up code Add error exceptions Make UI understandable Create sudoku generator Add more simple way to input nums to sudoku (let user write in each square, and tab through them with enter) Write code to solve harder sudokus!!! Functions:
def mainSheet # Add sudoku defaults after hashes to run them hashes puts sudokuGUI(0.3) terminal end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solve!\n simple_sudoku_logic\n puts \"HERE'S YOUR BOARD, SOLVED. ?\"\n display_board\n end", "def solve!\n \t# keep looping if previous board doesn't match current board (new grids are being solved)\n\t \twhile true do\n\t\t \t@sudoku.each_with_index do |row, rowindex|\n\t\t \t\trow.each_with...
[ "0.765487", "0.7586966", "0.73946303", "0.7381409", "0.7256992", "0.71871614", "0.7110504", "0.7104196", "0.7091132", "0.7065601", "0.70635486", "0.7026126", "0.6937003", "0.691396", "0.691396", "0.691396", "0.691396", "0.691396", "0.691396", "0.691396", "0.691396", "0.6913...
0.7352753
4
GET /portal/learners GET /portal/learners.xml
def index @portal_learners = Portal::Learner.search(params[:search], params[:page], nil) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @portal_learners } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @learners = Learner.all\n end", "def new\n @portal_learner = Portal::Learner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @portal_learner }\n end\n end", "def index\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE\n ...
[ "0.6887659", "0.6740972", "0.6546517", "0.6353626", "0.6158483", "0.60948175", "0.5989694", "0.5976165", "0.5920067", "0.585862", "0.58358645", "0.58119965", "0.57782644", "0.5743717", "0.57227707", "0.57206905", "0.5714451", "0.5702505", "0.56483495", "0.56342185", "0.558779...
0.703121
0
GET /portal/learners/1/open_response_report GET /portal/learners/1/open_response_report.xml
def open_response_report @portal_learner = Portal::Learner.find(params[:id]) respond_to do |format| format.html # report.html.haml end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def open_response_report\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHOOSE_AUTHORIZE\n # no authorization needed ...\n # authorize Portal::Learner\n # authorize @learner\n # authorize Portal::Learner, :new_or_create?\n # authorize @learner, :update_edit_or_destroy?\n @portal_learner = Portal::L...
[ "0.69289225", "0.6280504", "0.6258765", "0.6258765", "0.5913563", "0.58976084", "0.58624345", "0.58320194", "0.5812011", "0.5787797", "0.5779233", "0.5773819", "0.5771644", "0.5771005", "0.57687", "0.57683724", "0.57568294", "0.5755484", "0.57528955", "0.5735385", "0.56987286...
0.7529565
0
GET /portal/learners/1/multiple_choice_report GET /portal/learners/1/multiple_choice_report.xml
def multiple_choice_report @portal_learner = Portal::Learner.find(params[:id]) respond_to do |format| format.html # report.html.haml end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def multiple_choice_report\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHOOSE_AUTHORIZE\n # no authorization needed ...\n # authorize Portal::Learner\n # authorize @learner\n # authorize Portal::Learner, :new_or_create?\n # authorize @learner, :update_edit_or_destroy?\n @portal_learner = Portal:...
[ "0.73271894", "0.62780035", "0.62171257", "0.6011317", "0.5902038", "0.58832306", "0.5837398", "0.5745126", "0.56874603", "0.56874603", "0.56849986", "0.5626224", "0.55406445", "0.5522408", "0.55100685", "0.5503292", "0.5492647", "0.5462987", "0.5432649", "0.54154414", "0.540...
0.80092335
0
GET /portal/learners/1/bundle_report GET /portal/learners/1/bundle_report.xml
def bundle_report @portal_learner = Portal::Learner.find(params[:id]) respond_to do |format| format.html # report.html.haml end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def bundle_report\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHOOSE_AUTHORIZE\n # no authorization needed ...\n # authorize Portal::Learner\n # authorize @learner\n # authorize Portal::Learner, :new_or_create?\n # authorize @learner, :update_edit_or_destroy?\n @portal_learner = Portal::Learner....
[ "0.67965174", "0.60938025", "0.60678214", "0.602353", "0.5999329", "0.59496105", "0.58446866", "0.5828353", "0.57782066", "0.57782066", "0.57239056", "0.5691119", "0.56887", "0.5677733", "0.56447494", "0.5640766", "0.5632636", "0.5608801", "0.55764884", "0.5571586", "0.556530...
0.7743663
0
GET /portal/learners/1 GET /portal/learners/1.xml
def show @portal_learner = Portal::Learner.find(params[:id]) @portal_learner.console_logger = Dataservice::ConsoleLogger.create! unless @portal_learner.console_logger @portal_learner.bundle_logger = Dataservice::BundleLogger.create! unless @portal_learner.bundle_logger respond_to do |format| format.html # show.html.erb format.jnlp { render :partial => 'shared/learn', :locals => { :runnable => @portal_learner.offering.runnable, :learner => @portal_learner } } format.config { # if this isn't the learner then it is launched read only properties = {} if @portal_learner.student.user == current_user if @portal_learner.bundle_logger.in_progress_bundle launch_event = Dataservice::LaunchProcessEvent.create( :event_type => Dataservice::LaunchProcessEvent::TYPES[:config_requested], :event_details => "Activity configuration loaded. Loading prior learner session data...", :bundle_content => @portal_learner.bundle_logger.in_progress_bundle ) end bundle_post_url = dataservice_bundle_logger_bundle_contents_url(@portal_learner.bundle_logger, :format => :bundle) else bundle_post_url = nil properties['otrunk.view.user_data_warning'] = 'true' end render :partial => 'shared/sail', :locals => { :otml_url => polymorphic_url(@portal_learner.offering.runnable, :format => :dynamic_otml, :learner_id => @portal_learner.id), :session_id => (params[:session] || request.env["rack.session.options"][:id]), :console_post_url => dataservice_console_logger_console_contents_url(@portal_learner.console_logger, :format => :bundle), :bundle_url => dataservice_bundle_logger_url(@portal_learner.bundle_logger, :format => :bundle), :bundle_post_url => bundle_post_url, :properties => properties } } format.xml { render :xml => @portal_learner } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @portal_learner = Portal::Learner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @portal_learner }\n end\n end", "def index\n @portal_learners = Portal::Learner.search(params[:search], params[:page], nil)\n\n respond_to do |format|\n...
[ "0.6907847", "0.6860391", "0.6570956", "0.63729715", "0.625766", "0.618486", "0.61430395", "0.6115878", "0.60385853", "0.59582907", "0.5929482", "0.5908546", "0.5834841", "0.58073485", "0.5769593", "0.5768594", "0.5747755", "0.57408077", "0.57163537", "0.5711283", "0.5695722"...
0.57050246
20
GET /portal/learners/new GET /portal/learners/new.xml
def new @portal_learner = Portal::Learner.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @portal_learner } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @portal_learner = Portal::Learner.new(params[:learner])\n\n respond_to do |format|\n if @portal_learner.save\n flash[:notice] = 'Portal::Learner was successfully created.'\n format.html { redirect_to(@portal_learner) }\n format.xml { render :xml => @portal_learner, :st...
[ "0.73440623", "0.7120477", "0.704073", "0.6972769", "0.6964356", "0.68110347", "0.67845285", "0.675575", "0.6717819", "0.66996443", "0.66921794", "0.6691826", "0.66797376", "0.6663254", "0.6658634", "0.66570395", "0.6641818", "0.6639715", "0.66185206", "0.6604964", "0.6600085...
0.78264666
0
POST /portal/learners POST /portal/learners.xml
def create @portal_learner = Portal::Learner.new(params[:learner]) respond_to do |format| if @portal_learner.save flash[:notice] = 'Portal::Learner was successfully created.' format.html { redirect_to(@portal_learner) } format.xml { render :xml => @portal_learner, :status => :created, :location => @portal_learner } else format.html { render :action => "new" } format.xml { render :xml => @portal_learner.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE\n # authorize Portal::Learner\n @portal_learner = Portal::Learner.new(params[:learner])\n\n respond_to do |format|\n if @portal_learner.save\n flash[:notice] = 'Portal::Learner was successfully created.'\n format.ht...
[ "0.6938103", "0.6385076", "0.6179851", "0.59332085", "0.5912572", "0.59061766", "0.5651073", "0.56488985", "0.5646559", "0.55446005", "0.5529626", "0.5484558", "0.5480279", "0.5458917", "0.54394794", "0.5380092", "0.53788173", "0.5377595", "0.5368053", "0.5321442", "0.5303776...
0.7061077
0
PUT /portal/learners/1 PUT /portal/learners/1.xml
def update @portal_learner = Portal::Learner.find(params[:id]) respond_to do |format| if @portal_learner.update_attributes(params[:learner]) flash[:notice] = 'Portal::Learner was successfully updated.' format.html { redirect_to(@portal_learner) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @portal_learner.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE (did not find instance)\n # authorize @learner\n @portal_learner = Portal::Learner.find(params[:id])\n\n respond_to do |format|\n if @portal_learner.update_attributes(params[:learner])\n flash[:notice] = 'Portal::Learner w...
[ "0.66387635", "0.63641405", "0.61911106", "0.6068104", "0.58350945", "0.5793474", "0.5713103", "0.56420976", "0.5604703", "0.5587539", "0.5583807", "0.55471885", "0.55346245", "0.5482316", "0.5470577", "0.5464942", "0.5450375", "0.5440535", "0.5422126", "0.53941256", "0.53704...
0.6968493
0
DELETE /portal/learners/1 DELETE /portal/learners/1.xml
def destroy @portal_learner = Portal::Learner.find(params[:id]) @portal_learner.destroy respond_to do |format| format.html { redirect_to(portal_learners_url) } format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n # PUNDIT_REVIEW_AUTHORIZE\n # PUNDIT_CHECK_AUTHORIZE (did not find instance)\n # authorize @learner\n @portal_learner = Portal::Learner.find(params[:id])\n @portal_learner.destroy\n\n respond_to do |format|\n format.html { redirect_to(portal_learners_url) }\n format.xml {...
[ "0.70256513", "0.6791501", "0.65993", "0.65353346", "0.65283394", "0.64936334", "0.6363794", "0.6329985", "0.6323121", "0.62932867", "0.62773335", "0.6267726", "0.6203709", "0.61961305", "0.6189406", "0.61839694", "0.6148021", "0.6148021", "0.6147826", "0.61392593", "0.613715...
0.7416241
0
Refresh token and get a new one
def call api_key = ApiKey.find_by(access_token: @expired_token) if api_key.present? api_key.refresh api_key.save { token: api_key.access_token } else raise ExceptionService.new('Invalid Token.') end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fresh_token\n refresh! if token_expired?\n access_token\n end", "def fresh_token\n refresh! if expired?\n access_token\n end", "def refresh_token\n return if token\n refresh_token!\n end", "def refresh_auth_token\n generate_token(:auth_token)\n save!\n end", "def refre...
[ "0.8607038", "0.84962076", "0.8459562", "0.8394218", "0.8325173", "0.8255056", "0.8212024", "0.820078", "0.8198548", "0.8151004", "0.8076849", "0.80393016", "0.80309474", "0.8026996", "0.79955965", "0.7963001", "0.7918421", "0.7887903", "0.78613967", "0.78613967", "0.785747",...
0.7183969
70
Adjusts the hash storage and redistributes the entries among the new bins. Any Iterator instance will be invalid after a call to redistribute. Does not recalculate the cached key_hash values. See +rehash+.
def redistribute(entries) capacity = @capacity # Rather than using __setup__, initialize the specific values we need to # change so we don't eg overwrite @state. if @size > @max_entries @capacity = capacity * 2 @max_entries = @max_entries * 2 @min_entries = @min_entries * 2 else @capacity = capacity / 2 @max_entries = @max_entries / 2 @min_entries = @min_entries / 2 end @entries = Entries.new @capacity @mask = @capacity - 1 i = -1 while (i += 1) < capacity if item = entries[i] next if item.deleted index = key_index item.key_hash index = (1 + index) % @capacity while @entries[index] @entries[index] = item end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def redistribute(entries)\n capacity = @capacity\n\n # TODO: grow smaller too\n __setup__ @capacity * 2, @max_entries * 2, @size\n\n i = -1\n while (i += 1) < capacity\n next unless old = entries[i]\n while old\n old.next = nil if nxt = old.next\n\n index = key_index old.key_...
[ "0.6982203", "0.675086", "0.6451028", "0.605086", "0.57184774", "0.5632947", "0.56229144", "0.55872303", "0.5548985", "0.54727006", "0.54340965", "0.5432246", "0.5380388", "0.5318216", "0.528489", "0.51877475", "0.517789", "0.5117986", "0.5104547", "0.50954103", "0.5089018", ...
0.68818825
1
ensure user account is active
def active_for_authentication? super && !deleted_at end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def require_active_user\n unless current_user && current_user.status == UserStatus::ACTIVE\n flash[:alert]= I18n.t 'auth.msg.lock_account'\n redirect_to new_user_sessions_url\n return false\n end\n end", "def activate\n @user.activate! if @user.pending?\n redirect_to root_url\n end",...
[ "0.7820145", "0.73031145", "0.7296796", "0.72714067", "0.72605324", "0.7186465", "0.7184313", "0.7182273", "0.7140091", "0.70876205", "0.7038106", "0.7035326", "0.7020518", "0.699827", "0.69793344", "0.6973365", "0.6956432", "0.69559634", "0.69512725", "0.6950539", "0.6938509...
0.0
-1
provide a custom message for a deleted account
def inactive_message !deleted_at ? super : :deleted_account end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inactive_message\n \t!delete_flag ? super : :deleted_account\n end", "def inactive_message\n\t\t\t!delete_flag ? super : :deleted_account\n\t\tend", "def inactive_message\n !deleted_at ? super : :deleted_account\n end", "def inactive_message\n !deleted_at ? super : :deleted_account\n end", "d...
[ "0.77490103", "0.761186", "0.73685765", "0.73685765", "0.73685765", "0.73685765", "0.73685765", "0.73685765", "0.73685765", "0.73685765", "0.73685765", "0.73685765", "0.73685765", "0.73685765", "0.73685765", "0.73685765", "0.73685765", "0.73685765", "0.7335921", "0.7304492", ...
0.7341333
19
Accessors to make the subscription toggle available via forms
def subscription_active active_subscription.present? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def toggle_subscription!\n self.unsubscribed = !unsubscribed\n save\n end", "def toggle_subscription\n authorize model\n authorize Subscription\n subscription_toggle\n @model = model\n render 'toggle_subscription'\n end", "def toggle_comment_subscription user\n subscription = find_or_...
[ "0.7289069", "0.7285285", "0.62209094", "0.6070989", "0.6051465", "0.5994141", "0.59850216", "0.5976862", "0.5966283", "0.5954533", "0.5888644", "0.5837743", "0.5837743", "0.58372706", "0.58372706", "0.58346313", "0.5832813", "0.58259267", "0.5819059", "0.5819059", "0.5819059...
0.5921847
10
Extract any payment errors from pending offer orders
def payment_error_notifications payment_logs = order_logs .joins(:order => :offer_order) .where("orders.status IN ('pending') AND lower(order_logs.action) IN ('bill', 'payment')") .order('order_logs.created_at') payment_logs.group_by(&:order_id).reduce([]) do |a, (order_id, logs)| logs.sort_by(&:created_at).reverse.first.tap do |log| a.push log unless log.succeeded? end a end.flatten end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def errors\n p = build_payment\n p.valid?\n p.errors\n end", "def paypal_errors_msg\n \"We are sorry, but the purchase was not completed due the following errors: #{errors.full_messages.join(', ')}\"\n end", "def return_shipment_errors\n [\"#{@shipment}.buy(no rates found for this shipment...
[ "0.6203334", "0.61273426", "0.6099045", "0.59701705", "0.56007934", "0.55140173", "0.5483827", "0.53790593", "0.5370483", "0.52740854", "0.5249226", "0.52462", "0.5234787", "0.5234353", "0.52242297", "0.51837796", "0.5175309", "0.5161314", "0.5143378", "0.5122039", "0.510268"...
0.689593
0
This overwrites the default implementation provided by Devise::Models::Validatable. It ignores blanks strings.
def password_required? !persisted? || !password.blank? || !password_confirmation.blank? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_and_sanitize\n super\n end", "def validate_and_sanitize\n r = super\n return r unless r.success?\n\n @email = @email.to_s.downcase.strip\n @name = @name.to_s.downcase.strip\n\n return error_with_data(\n 'am_au_i_vas_1',\n ...
[ "0.65571713", "0.65002215", "0.63973045", "0.62082416", "0.61323094", "0.61208147", "0.610173", "0.610173", "0.610173", "0.610173", "0.610173", "0.610173", "0.60779613", "0.60002655", "0.59819067", "0.59806836", "0.5974878", "0.58948916", "0.5894875", "0.58794737", "0.5878454...
0.0
-1
Compute the actual value of a field for a given serializer instance.
def value(serializer) if block serializer.instance_eval(&block) else serializer.read_attribute_for_serialization(name) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_field_value(obj, name)\n begin\n @struct_field_getter.call(obj, name)\n rescue\n 0\n end\n end", "def get_value(field)\n field = item_type.find_field(field) unless field.is_a? Field\n field.value_for_item(self)\n end", "def field_value(field)\n ...
[ "0.6748203", "0.6200198", "0.6184239", "0.61141616", "0.6105577", "0.60647213", "0.60548264", "0.58782715", "0.5868786", "0.5817276", "0.5768793", "0.57410145", "0.5691646", "0.56735164", "0.5661844", "0.5659576", "0.56276053", "0.5621258", "0.5609502", "0.56037843", "0.56009...
0.6846504
0
Decide whether the field should be serialized by the given serializer instance.
def excluded?(serializer) case condition_type when :if !evaluate_condition(serializer) when :unless evaluate_condition(serializer) else false end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def serialized?\n false\n end", "def serializable?(value)\n true\n end", "def use_serializer(serializer)\n @serializer = serializer\n end", "def deserialized?\n !!@deserialized\n end", "def deserialized?\n true\n end", "def serializer(name)\n ...
[ "0.63052595", "0.6021169", "0.59802556", "0.58818585", "0.5848223", "0.5766111", "0.5580565", "0.5555198", "0.5526788", "0.55017895", "0.5501461", "0.5501461", "0.54995996", "0.54956186", "0.5441833", "0.5422963", "0.5386071", "0.53638804", "0.5346086", "0.532033", "0.5290175...
0.54653513
14
See the wiki for details:
def initialize(user) ############################## Household ############################## can :administrate, Household do |household| user.administrates?(household) end can :add_admin, Household do |household| user == household.head_admin end ############################## Completable ############################## can :accept, Completable do |todo| household = todo.household can?(:edit, todo) && todo.completed? && !todo.accepted? && can?(:administrate, household) end can :complete, Completable do |todo| household = todo.household user.household == household && !todo.completed? && !todo.accepted? end can :destroy, Completable do |todo| household = todo.household user.household == household && ( can?(:administrate, household) || todo.creator_id == user.id && !todo.accepted? ) end can :edit, Completable do |todo| household = todo.household todo.creator_id == user.id || can?(:administrate, household) end can :reorder, Completable do |todo| can?(:complete, todo) || can?(:uncomplete, todo) end can :uncomplete, Completable do |todo| household = todo.household user.household == household && !todo.accepted? && todo.completed? && (todo.completor_id == user.id || can?(:edit, todo)) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def probers; end", "def schubert; end", "def refutal()\n end", "def implementation; end", "def implementation; end", "def verdi; end", "def who_we_are\r\n end", "def operations; end", "def ...
[ "0.82539827", "0.7248938", "0.7248938", "0.7248938", "0.7248938", "0.71688086", "0.6990566", "0.6774227", "0.6738524", "0.6738524", "0.6698437", "0.6693817", "0.6595375", "0.6595375", "0.6557783", "0.6554582", "0.64854026", "0.64631957", "0.6449498", "0.6434066", "0.6420554",...
0.0
-1
Just parse the json
def parse_json content json = ActiveSupport::JSON.decode(content) # validation validate json.kind_of?(Array), "JSON was not an array" json.each do |item| validate item.kind_of?(Hash), "JSON was not an array of objects" validate (item.keys.to_set == json.first.keys.to_set), "JSON objects did not have consistent keys" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse json; return JSON.parse File.read json end", "def parse json; return JSON.parse File.read json end", "def parse\n return if @id\n\n data = @json.is_a?(String) ? JSON.parse(@json) : @json\n @id = data[\"id\"]\n @time = data[\"created_at\"]\n @text = parse_text(data[\"text\"])\...
[ "0.82131994", "0.82131994", "0.7791423", "0.7739692", "0.76633525", "0.7576196", "0.75624394", "0.74237925", "0.74210227", "0.7412259", "0.7392964", "0.73841506", "0.733591", "0.72919303", "0.72065187", "0.7084971", "0.7078051", "0.7049218", "0.703197", "0.69876367", "0.69451...
0.7187587
15
Convert the CSV to the equivalent JSON
def parse_csv content, sep CSV.parse(content, :col_sep => sep, :converters => [:numeric], :headers => true, :skip_blanks => true). map{ |row| row.to_hash } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def csv_to_json(rows)\n\n objs = []\n \n headers = rows[0]\n \n for i in 1..rows.size - 1\n row = rows[i]\n obj = {}\n for j in 0..headers.size - 1\n header = headers[j].to_s\n val = row[j]\n obj[header] = val\n end\n objs << obj \n end\n\n return objs\n\nend", "def csvtojson...
[ "0.7817338", "0.7480153", "0.68120503", "0.6781689", "0.6759254", "0.6533264", "0.6384062", "0.6341786", "0.63136166", "0.62600416", "0.62183356", "0.60903275", "0.60695463", "0.6049749", "0.5975226", "0.59274507", "0.5923353", "0.5853881", "0.5850669", "0.5830756", "0.580079...
0.0
-1
:callseq: add(MyReleaseClass) Add a Release implementation to the list of available Release classes.
def add(release) @list ||= [] @list |= [release] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def define_on_distro_release(distro, release, name, version=nil)\n distro_releases[[distro, release]] << [name, version]\n end", "def add_class(new_class)\n @classes << new_class\n end", "def add(klass)\n @known_classes << klass\n end", "def add(klass, position = registered_items.size...
[ "0.5785558", "0.5385419", "0.5381441", "0.53082067", "0.51846546", "0.51846546", "0.51443654", "0.5133686", "0.50745404", "0.5027424", "0.50091416", "0.50054693", "0.49902195", "0.49484912", "0.49325216", "0.49302375", "0.49039114", "0.4899441", "0.48849308", "0.48402685", "0...
0.69061494
1
The list of supported Release implementations
def list @list ||= [] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def supported_versions\n raise NotImplementedError\n end", "def supported\n @supported ||= []\n end", "def released_specs\n specs.select { |s| not s.prerelease? }\n end", "def prerelease_specs\n specs.select { |s| s.prerelease? }\n end", "def current_releases(release_type, i...
[ "0.6722644", "0.6671164", "0.6608091", "0.63739526", "0.6267588", "0.6239261", "0.6217117", "0.6217117", "0.61964744", "0.6194433", "0.60981023", "0.6090361", "0.60682416", "0.6067655", "0.60629797", "0.6034048", "0.6011994", "0.597705", "0.5936987", "0.59355795", "0.59255844...
0.0
-1
Finds and returns the Release instance for this project.
def find unless @release klass = list.detect { |impl| impl.applies_to? } @release = klass.new if klass end @release end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_release(release_id)\n query_and_build \"releases/#{release_id}\"\n end", "def get_release(project)\n info = get_github_api(project, \"releases\")\n release = 'master'\n if info.length > 0\n unpublishedDraftLimit = 5\n x = 0\n release = info[x]['tag_name']\n ...
[ "0.7268631", "0.68467784", "0.6148033", "0.6148033", "0.6148033", "0.6148033", "0.61349833", "0.6049865", "0.60407513", "0.60337824", "0.6030666", "0.59262", "0.5924428", "0.5877056", "0.5791091", "0.5622114", "0.5621887", "0.5546335", "0.5546335", "0.5526048", "0.5518329", ...
0.7010312
2
:callseq: make() Make a release.
def make(options) @this_version = extract_version check with_release_candidate_version do |release_candidate_buildfile| args = '-S', 'rake', '--rakefile', release_candidate_buildfile if options args += options.split(' ') else args << 'clean' << 'build' << 'DEBUG=no' end ruby *args end tag_release resolve_tag update_version_to_next if this_version != resolve_next_version(this_version) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def release\n end", "def release\n end", "def create_release(attrs = {})\n release = build_release(attrs)\n release.save\n release\n end", "def release\n action('release')\n end", "def release\n end", "def release\n fail AlreadyRelease unless prerelease?\n ...
[ "0.64916646", "0.64916646", "0.64575815", "0.63807654", "0.6346428", "0.62295675", "0.58892614", "0.58656013", "0.5859781", "0.5768092", "0.57487524", "0.57013816", "0.5693733", "0.56701195", "0.5611331", "0.5546409", "0.5535584", "0.55115175", "0.55000645", "0.5468179", "0.5...
0.57080096
11
:callseq: extract_version() => this_version Extract the current version number from the buildfile. Raise an error if not found.
def extract_version buildfile = File.read(Rake.application.rakefile).force_encoding("ISO-8859-1").encode("utf-8", replace: nil) buildfile.scan(THIS_VERSION_PATTERN)[0][2] rescue fail 'Looking for THIS_VERSION = "1.0.0-rc1" in your Buildfile, none found' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_version\n buildfile = File.read(version_file)\n buildfile.scan(THIS_VERSION_PATTERN)[0][2]\n rescue\n fail 'Looking for THIS_VERSION = \"...\" in your Buildfile, none found'\n end", "def build_version\n string = plist_buddy.plist_read(\"CFBundleVersion\", info_plist_path)\n ...
[ "0.84408754", "0.6472261", "0.64500403", "0.6438712", "0.63816166", "0.63013315", "0.62654823", "0.6176433", "0.61686075", "0.61397475", "0.6132354", "0.6118228", "0.6117402", "0.6113286", "0.60789984", "0.607277", "0.60645723", "0.60093766", "0.59999335", "0.59854895", "0.59...
0.7951729
1
Return the name of the tag to tag the release with.
def resolve_tag version = extract_version tag = Release.tag_name || version tag = tag.call(version) if Proc === tag tag end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tag_name\n return @tag_name\n end", "def _tag_name\n @tag_name\n end", "def tag_name\n @tag_name ||= name && name.to_s.split(\"::\")[-1].downcase\n end", "def name\n tag.name\n end", "def tagname\n @tagname.id2name\n end", "def getReleaseTag(release)\n return sh(\"git...
[ "0.7451726", "0.736835", "0.73360884", "0.7268493", "0.71349627", "0.705389", "0.6893099", "0.6864708", "0.678296", "0.678296", "0.678296", "0.67488974", "0.67329144", "0.67293864", "0.6674817", "0.6633394", "0.66200745", "0.6561663", "0.65083766", "0.6489976", "0.64248496", ...
0.69965696
7
Return the new value of THIS_VERSION based on the version passed. This method receives the existing value of THIS_VERSION
def resolve_next_version(current_version) next_version = Release.next_version next_version ||= lambda { |v| snapshot = v.match(/-SNAPSHOT$/) version = v.gsub(/-SNAPSHOT$/, "").split(/\./) if snapshot version[-1] = sprintf("%0#{version[-1].size}d", version[-1].to_i + 1) + '-SNAPSHOT' end version.join('.') } next_version = ENV['NEXT_VERSION'] if ENV['NEXT_VERSION'] next_version = ENV['next_version'] if ENV['next_version'] next_version = next_version.call(current_version) if Proc === next_version next_version end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new_version\n @version = Time.now.to_i\n end", "def set_version\n self.version ||= latest_version + 1\n end", "def version value = nil\n return @version if value.nil?\n @version = value\n end", "def version(version = nil)\n @version = version if version\n @version\n end", ...
[ "0.7604738", "0.7596295", "0.7528393", "0.7474805", "0.7422443", "0.7383106", "0.7378605", "0.7223136", "0.7203363", "0.7203363", "0.7195645", "0.7177888", "0.717154", "0.71639985", "0.71573514", "0.71052223", "0.7053746", "0.7041835", "0.7016261", "0.7011862", "0.70042044", ...
0.0
-1
Move the version to next and save the updated buildfile
def update_buildfile buildfile = change_version { |version| # THIS_VERSION minus SNAPSHOT resolve_next_version(this_version) # THIS_VERSION } File.open(Rake.application.rakefile.to_s, 'w') { |file| file.write buildfile } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_buildfile\n buildfile = change_version { |version| # THIS_VERSION minus SNAPSHOT\n resolve_next_version(this_version) # THIS_VERSION\n }\n File.open(version_file, 'w') { |file| file.write buildfile }\n end", "def update_version_to_next\n super\n info \"Current versio...
[ "0.77271146", "0.7209762", "0.63637227", "0.6313188", "0.6283097", "0.62792295", "0.62788224", "0.6259882", "0.61795384", "0.61575544", "0.61250705", "0.61115867", "0.60973257", "0.6060992", "0.6026321", "0.59850246", "0.5981068", "0.59690034", "0.5958315", "0.5954643", "0.59...
0.752837
1
Return the message to use to commit the buildfile with the next version
def message version = extract_version msg = Release.commit_message || "Changed version number to #{version}" msg = msg.call(version) if Proc === msg msg end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_version_to_next\n super\n info \"Current version is now #{extract_version}\"\n Hg.commit File.basename(version_file), message\n Hg.push if Hg.remote\n end", "def commit_message\n @commit.sub '%.%.%', @after_version\n end", "def update_buildfile\n buildfile = chang...
[ "0.7133768", "0.70819384", "0.6720151", "0.6618071", "0.65373284", "0.6351196", "0.62521625", "0.6127682", "0.60882264", "0.60267824", "0.59917647", "0.5972133", "0.5931828", "0.5928321", "0.592758", "0.58913636", "0.5838882", "0.5831469", "0.58167374", "0.5810524", "0.578811...
0.7228319
1
:callseq: git(args) Executes a Git command and returns the output. Throws exception if the exit status is not zero. For example: git 'commit' git 'remote', 'show', 'origin'
def git(*args) cmd = "git #{args.shift} #{args.map { |arg| arg.inspect }.join(' ')}" output = `#{cmd}` fail "GIT command \"#{cmd}\" failed with status #{$?.exitstatus}\n#{output}" unless $?.exitstatus == 0 return output end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def git(*args)\n cmd(*['git'] + args)\n end", "def git(*args)\n cmd(*['git'] + args)\n end", "def git(*args, &block)\n options = args.extract_options!\n system_args = ['--git-dir', root_url, '-c', 'core.quotepath=false']\n\n args = system_args + Array.wrap(args)\n args = arg...
[ "0.80866045", "0.80866045", "0.7993441", "0.798694", "0.79055065", "0.7795743", "0.7695566", "0.7680668", "0.76475877", "0.7645145", "0.76142055", "0.75880176", "0.75628316", "0.73071253", "0.7188069", "0.7121762", "0.7066952", "0.68923753", "0.67880005", "0.67830676", "0.670...
0.8750967
1
Returns list of uncommited/untracked files as reported by git status.
def uncommitted_files `git status`.scan(/^#(\t|\s{7})(\S.*)$/).map { |match| match.last.split.last } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_uncommitted_files\n\t\t\tlist = read_command_output( 'hg', 'status', '-n', '--color', 'never' )\n\t\t\tlist = list.split( /\\n/ )\n\n\t\t\ttrace \"Changed files: %p\" % [ list ]\n\t\t\treturn list\n\t\tend", "def uncommitted_files\n svn('status', '--ignore-externals').split(\"\\n\").reject { |line| ...
[ "0.7949743", "0.7858256", "0.7604518", "0.7592769", "0.6977188", "0.69291365", "0.686998", "0.684934", "0.6786466", "0.65984774", "0.64842325", "0.6372661", "0.6371909", "0.63645184", "0.62491596", "0.62377334", "0.62377334", "0.60348916", "0.59823763", "0.5968926", "0.596131...
0.836846
1
Commit the given file with a message. The file has to be known to Git meaning that it has either to have been already committed in the past or freshly added to the index. Otherwise it will fail.
def commit(file, message) git 'commit', '-m', message, file end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def commit(file, message)\n hg 'commit', '-m', message, file\n end", "def commit(message = nil)\n # Write current index back to the repository\n index = @repo.index\n commit_tree = index.write_tree @repo\n\n # Commit message\n message = \"Affected files: #{@affected_files.uniq.jo...
[ "0.7875317", "0.75850695", "0.7332475", "0.72253996", "0.70301443", "0.7004379", "0.69789493", "0.6968867", "0.6931715", "0.6870631", "0.6769182", "0.6611701", "0.6474825", "0.64290655", "0.6427936", "0.6417664", "0.6413019", "0.63693213", "0.636375", "0.63595146", "0.6358841...
0.8352529
1
Update the remote refs using local refs By default, the "remote" destination of the push is the the remote repo linked to the current branch. The default remote branch is the current local branch.
def push(remote_repo = remote, remote_branch = current_branch) git 'push', remote, current_branch end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def updateRepo()\n $repo.checkout(BRANCH)\n\n # fetch\n remote = $repo.remotes['' << REMOTE]\n remote.fetch()\n\n # merge\n distant_commit = $repo.branches['' << REMOTE << '/' << BRANCH].target\n $repo.references.update($repo.head, distant_commit.oid)\nend", "def apply\n repo.push('origin', ['refs/...
[ "0.67076653", "0.6661574", "0.6569846", "0.65409166", "0.64433914", "0.6433975", "0.63664246", "0.6357785", "0.6330111", "0.62794983", "0.62723064", "0.62672", "0.6245432", "0.6143999", "0.61360043", "0.60852474", "0.6076615", "0.60738564", "0.6001373", "0.59698576", "0.58807...
0.65835553
3
Return the name of the remote repository whose branch the current local branch tracks, or nil if none.
def remote(branch = current_branch) remote = git('config', '--get', "branch.#{branch}.remote").to_s.strip remote if !remote.empty? && git('remote').include?(remote) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def branch_remote_name(branch_name)\n `git config branch.#{branch_name}.remote`.strip\n end", "def branch_name\n $repo.current_branch\n end", "def branch\n %x[cd #{repo_path};git symbolic-ref HEAD 2>/dev/null | awk -F/ {'print $NF'}].chomp\n end", "def branch\n `git rev-parse -...
[ "0.7634662", "0.7627754", "0.7370738", "0.7323804", "0.7300565", "0.7287466", "0.72450316", "0.7174111", "0.71588176", "0.70677924", "0.70431435", "0.7028649", "0.6997016", "0.69865197", "0.6963658", "0.69410735", "0.6904603", "0.68913186", "0.68551034", "0.6850846", "0.68384...
0.7011398
13
Return the name of the current branch
def current_branch git('branch')[/^\* (.*)$/, 1] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def branch_name\n $repo.current_branch\n end", "def branch_name\n `git name-rev --name-only HEAD`.strip\n end", "def current_branch\n git.branch.name\n end", "def branchname\n @branchname ||= self.branch.name\n end", "def current_branch\n hg('branch').to_s.strip...
[ "0.90367657", "0.8721565", "0.86619645", "0.86010396", "0.8582537", "0.8473796", "0.8352805", "0.83074737", "0.8234233", "0.8144074", "0.81439143", "0.804588", "0.8009763", "0.79761547", "0.79706085", "0.7922965", "0.7849014", "0.7828018", "0.78195804", "0.775794", "0.7756447...
0.80956787
12
:callseq: git(args) Executes a Git command and returns the output. Throws exception if the exit status is not zero. For example: git 'commit' git 'remote', 'show', 'origin'
def p4(*args) port = ENV['P4PORT'] user = ENV['P4USER'] password = ENV['P4PASSWD'] client = ENV['P4CLIENT'] fail 'perforce release missing required P4PORT environment' unless port fail 'perforce release missing required P4USER environment' unless user fail 'perforce release missing required P4PASSWORD environment' unless password fail 'perforce release missing required P4CLIENT environment' unless client cmd = "p4 -p #{port} -u #{user} -P #{password} -c #{client} #{args.map { |arg| arg.inspect }.join(' ')}" output = `#{cmd}` fail "P4 command \"#{cmd}\" failed with status #{$?.exitstatus}\n#{output}" unless $?.exitstatus == 0 return output end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def git(*args)\n cmd = \"git #{args.shift} #{args.map { |arg| arg.inspect }.join(' ')}\"\n output = `#{cmd}`\n fail \"GIT command \\\"#{cmd}\\\" failed with status #{$?.exitstatus}\\n#{output}\" unless $?.exitstatus == 0\n return output\n end", "def git(*args)\n cmd = \"git #{args.shi...
[ "0.8751879", "0.8751879", "0.8087265", "0.8087265", "0.7994413", "0.7986992", "0.79054403", "0.7796345", "0.7695725", "0.7681175", "0.76486105", "0.7645474", "0.76147425", "0.7589856", "0.7565014", "0.73084056", "0.718944", "0.71232164", "0.7067989", "0.68932986", "0.67885095...
0.0
-1
Returns list of uncommited/untracked files as reported by git status.
def uncommitted_files files = nil p4 (['change','-o']).each do |line| files << line.strip if files files = [] if line.start_with?('Files:') end files ||= [] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def uncommitted_files\n `git status`.scan(/^#(\\t|\\s{7})(\\S.*)$/).map { |match| match.last.split.last }\n end", "def uncommitted_files\n `git status`.scan(/^#(\\t|\\s{7})(\\S.*)$/).map { |match| match.last.split.last }\n end", "def get_uncommitted_files\n\t\t\tlist = read_command_output( 'hg'...
[ "0.8367702", "0.8367702", "0.7949428", "0.7858047", "0.759202", "0.697779", "0.6929143", "0.6869004", "0.6848623", "0.67857504", "0.6598226", "0.64837974", "0.63715374", "0.63712436", "0.63645965", "0.6248532", "0.6237173", "0.6237173", "0.60338616", "0.59826505", "0.5969127"...
0.76043624
4
Commit the given file with a message. The file has to be known to Git meaning that it has either to have been already committed in the past or freshly added to the index. Otherwise it will fail.
def commit(message) p4 'submit', '-d', message end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def commit(file, message)\n git 'commit', '-m', message, file\n end", "def commit(file, message)\n git 'commit', '-m', message, file\n end", "def commit(file, message)\n hg 'commit', '-m', message, file\n end", "def commit(message = nil)\n # Write current index back to the reposi...
[ "0.8353085", "0.8353085", "0.78761", "0.758509", "0.7333082", "0.72248983", "0.7030328", "0.7003578", "0.6978619", "0.6968783", "0.6930752", "0.687088", "0.676969", "0.6609509", "0.64741194", "0.6428782", "0.6428287", "0.6417623", "0.64120424", "0.636832", "0.63641596", "0....
0.6356128
23
Fails if one of these 2 conditions are not met: 1. the repository is clean: no content staged or unstaged 2. some remote repositories are defined but the current branch does not track any
def check super uncommitted = Perforce.uncommitted_files fail "Uncommitted files violate the First Principle Of Release!\n#{uncommitted.join("\n")}" unless uncommitted.empty? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_repo_clean\n @gitrepo = Grit::Repo.new(@repo_root)\n status = @gitrepo.status\n if !status.changed.nil? || status.changed.size != 0 # This has to be a convoluted way to determine a non-empty...\n # Test each for the magic sha_index. Ref: https://github.com/mojombo/grit/issues/142...
[ "0.7559468", "0.727234", "0.7259476", "0.72218883", "0.7090443", "0.70489347", "0.69626975", "0.6953265", "0.6695067", "0.66317797", "0.6629588", "0.66195047", "0.65545267", "0.6515617", "0.6476684", "0.6381038", "0.63756263", "0.63606435", "0.6317604", "0.62510467", "0.62278...
0.64117765
15
Add a tag reference in .git/refs/tags and push it to the remote if any. If a tag with the same name already exists it will get deleted (in both local and remote repositories).
def tag_release(tag) unless this_version == extract_version puts "Committing buildfile with version number #{extract_version}" Perforce.p4 'edit', Rake.application.rakefile.to_s Perforce.commit message end puts "Tagging release #{tag}" Perforce.p4 'tag', '-l', tag, "//#{ENV['P4CLIENT']}/..." end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def push\n if @tags.empty?\n gash.send(:git, 'push', @push_to, @refspec)\n else\n gash.send(:git, 'push', '--tags', @push_to, @refspec)\n end\n end", "def create_remote_tag tag_name\n in_secondary_repository do\n create_local_tag tag_name\n run 'git push --tags'\n end\nend", "def pu...
[ "0.7778907", "0.7551029", "0.748117", "0.7453234", "0.7365221", "0.6966967", "0.68797684", "0.6761167", "0.66993517", "0.66701823", "0.66433847", "0.65453184", "0.650499", "0.650499", "0.64788896", "0.64710593", "0.64458066", "0.6379185", "0.63728774", "0.63488644", "0.632482...
0.0
-1
Fails if one of these 2 conditions are not met: 1. the repository is clean: no content staged or unstaged 2. some remote repositories are defined but the current branch does not track any
def check super uncommitted = Git.uncommitted_files fail "Uncommitted files violate the First Principle Of Release!\n#{uncommitted.join("\n")}" unless uncommitted.empty? # fail "You are releasing from a local branch that does not track a remote!" unless Git.remote end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_repo_clean\n @gitrepo = Grit::Repo.new(@repo_root)\n status = @gitrepo.status\n if !status.changed.nil? || status.changed.size != 0 # This has to be a convoluted way to determine a non-empty...\n # Test each for the magic sha_index. Ref: https://github.com/mojombo/grit/issues/142...
[ "0.75594795", "0.7272357", "0.7259582", "0.7091303", "0.704813", "0.6962056", "0.6953005", "0.66941285", "0.663144", "0.66307986", "0.6620442", "0.655548", "0.65153396", "0.64772177", "0.64114606", "0.6380712", "0.6375067", "0.6360829", "0.6318231", "0.625163", "0.622914", ...
0.72219425
3
Add a tag reference in .git/refs/tags and push it to the remote if any. If a tag with the same name already exists it will get deleted (in both local and remote repositories).
def tag_release(tag) unless this_version == extract_version puts "Committing buildfile with version number #{extract_version}" Git.commit File.basename(Rake.application.rakefile.to_s), message Git.push if Git.remote end puts "Tagging release #{tag}" # Git.git 'tag', '-d', tag rescue nil Git.git 'push', Git.remote, ":refs/tags/#{tag}" rescue nil if Git.remote Git.git 'tag', '-f', '-a', tag, '-m', "[rake_release] Cutting release #{tag}" Git.git 'push', Git.remote, 'tag', tag if Git.remote end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def push\n if @tags.empty?\n gash.send(:git, 'push', @push_to, @refspec)\n else\n gash.send(:git, 'push', '--tags', @push_to, @refspec)\n end\n end", "def create_remote_tag tag_name\n in_secondary_repository do\n create_local_tag tag_name\n run 'git push --tags'\n end\nend", "def pu...
[ "0.7777915", "0.7551755", "0.7480573", "0.7452982", "0.7365588", "0.6967257", "0.68803537", "0.6762316", "0.6700378", "0.66698194", "0.6644311", "0.654587", "0.65042657", "0.65042657", "0.64787716", "0.64714426", "0.6445232", "0.6379065", "0.63734734", "0.63487726", "0.632376...
0.54731333
86
AYUDAME: Refactoriza buscando elegancia
def squared_primes(array) primos = array.find_all{|x| (2...x).select(){|i| x % i == 0 }.count == 0 } primos.map{|p| p*p} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def suivre; end", "def private; end", "def schubert; end", "def zuruecksetzen()\n end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def mi_carrera\n\n\tend", "def romeo_and_juliet; end", "def probers; end", "def formation; end", "def operations; end", "de...
[ "0.65795237", "0.64750725", "0.60494614", "0.6011357", "0.59995115", "0.59995115", "0.59995115", "0.59995115", "0.5991556", "0.5959397", "0.5831461", "0.5824543", "0.5770559", "0.5770559", "0.5756773", "0.5740751", "0.57021457", "0.56953394", "0.56877494", "0.566284", "0.5636...
0.0
-1
Override with value object
def number HookNumber.new(number_record) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new_value(old_value)\n raise 'to be implemented in subclass'\n end", "def set_additional_values(object, override)\n override.class.attributes.each do |o|\n object.instance_variable_set(\"@#{o}\", override[o])\n object.define_singleton_method(o.to_sym) { instance_variable_get(\"@#...
[ "0.7061474", "0.67341113", "0.670489", "0.6695306", "0.6600072", "0.65814215", "0.65393674", "0.65245336", "0.64697385", "0.64697385", "0.6439522", "0.643331", "0.6427863", "0.64169306", "0.6416056", "0.6413187", "0.6413028", "0.6375861", "0.63615185", "0.63596934", "0.635658...
0.0
-1
def start(inode) logger.info("machine.start") begin vm.PowerOnVM_Task.wait_for_completion
def nics=(_nics) @nics = _nics.map {|nic| MachineNic.new(nic)} if @nics.nil?.eql?(false) @nics.each do |nic| nic.stats = stats end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def start(inode)\n logger.info(\"machine.start\")\n raise Exceptions::NotImplemented\n end", "def start\n\t\t# puts \"Starting #{@ip} ...\"\n\t\tsystem ipmi_command + \" chassis power on\"\n\tend", "def start()\n\t\t_start\n\t\tpossibly_self_provision()\n\tend", "def start_vm\n unless File.exists?(...
[ "0.7645129", "0.7043179", "0.6978433", "0.69695646", "0.67998564", "0.66819066", "0.663508", "0.6635071", "0.6571847", "0.6555738", "0.6545403", "0.6529706", "0.64496946", "0.6444058", "0.6372515", "0.63362724", "0.628545", "0.628453", "0.6270069", "0.62529606", "0.62460876",...
0.0
-1
lockable locks the obj with user
def lock(obj, time = RedisMutexer.config.time) logger locked = RedisMutexer.config.redis.setnx(key(obj), self.id) if locked return RedisMutexer.config.redis.expire(key(obj), time) end locked end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lock _obj, _args\n \"_obj lock _args;\" \n end", "def lockDriver _obj, _args\n \"_obj lockDriver _args;\" \n end", "def set_wo_lock(obj)\n @obj = obj\n end", "def toggle_locking(current_user)\n if can_toggle_locking?(current_user)\n is_locked? ? unlock : lock(current_user....
[ "0.7552429", "0.71941376", "0.7080969", "0.7075627", "0.7049906", "0.70121384", "0.7002947", "0.6996355", "0.69748634", "0.6931699", "0.6913005", "0.6884086", "0.68341905", "0.68155366", "0.67948484", "0.6751871", "0.6747776", "0.67460716", "0.67281514", "0.6693664", "0.66827...
0.6937128
9
this will check if the obj is locked with any user.
def locked?(obj) RedisMutexer.config.redis.exists(key(obj)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def locked?\n !!@owner\n end", "def locked?\n fetch_lock_info\n\n obj_exists_and_is_not_type? obj: @lock_info, type: []\n end", "def can_lock?(current_user)\n return false if current_user.anonymous?\n\n not is_locked?\n end", "def can_lock?\n SpaceRequestPolicy.can_lock?(curren...
[ "0.7684398", "0.7403483", "0.7345187", "0.72594255", "0.71440417", "0.7131871", "0.7095968", "0.708216", "0.7010908", "0.6980229", "0.6971062", "0.69588786", "0.6956333", "0.69508123", "0.694917", "0.69092435", "0.69092435", "0.69092435", "0.69092435", "0.6883724", "0.6838925...
0.74661
1
to check if the user is the owner of the lock.
def owner?(obj) (self.id == RedisMutexer.config.redis.get(key(obj)).to_i) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_owner?(this_user)\n user == this_user\n end", "def is_owner?(user)\n !user.nil? && (self.user_id == user.id)\n end", "def is_owner?(user)\n user.id == self.user_id\n end", "def owner? (user)\n user == owner\n end", "def owner? usr\n user_id == usr.id\n end", "def is_owner?\...
[ "0.82136476", "0.8160013", "0.81559306", "0.80702865", "0.8044053", "0.8028054", "0.79976916", "0.79792124", "0.7958204", "0.7933038", "0.792701", "0.79254127", "0.7866226", "0.7864399", "0.7846951", "0.7809227", "0.77896965", "0.7754226", "0.7717571", "0.7684922", "0.7681078...
0.7455256
34
find time remaining to expire a lock in seconds.
def unlocking_in(obj) RedisMutexer.config.redis.ttl(key(obj)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def time_until_unlock\n return 0 unless access_locked?\n return ((User.unlock_in - (Time.current - locked_at)) / 60).round\n end", "def expires_in\n @lock_expire.to_f - Time.now.to_f if @lock_expire && owner_ident == @locked_owner_id\n end", "def calculate_remaining_time\n expiry_time...
[ "0.7399344", "0.73928326", "0.7186327", "0.70761275", "0.70751756", "0.6949728", "0.6881007", "0.67768145", "0.67613465", "0.6754436", "0.67071015", "0.6692524", "0.665605", "0.6642701", "0.6632026", "0.6586644", "0.6583359", "0.6578869", "0.65775007", "0.65617335", "0.650627...
0.0
-1
unlock obj if required
def unlock(obj) logger if locked?(obj) RedisMutexer.config.redis.del(key(obj)) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lockedCargo _obj, _args\n \"_obj lockedCargo _args;\" \n end", "def unlock_access!; end", "def unlock; end", "def unlock\n @locking = false\n end", "def unlock\n end", "def unlock\n self.is_locked = false\n self\n end", "def lock _obj, _args\n \"_obj lock _args;\" \n ...
[ "0.72209734", "0.7140033", "0.7085236", "0.70580643", "0.6900973", "0.68980694", "0.687733", "0.68606055", "0.67848706", "0.6768044", "0.6700292", "0.65396726", "0.6535347", "0.65267664", "0.65067124", "0.6462361", "0.6410759", "0.6383346", "0.63611275", "0.6324751", "0.62218...
0.7081866
3
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength
def rate_limit!(namespace, limit: 5, minutes: 5) request_time = DateTime.now log_path = Rails.root.join("tmp/rate_limits/#{namespace}.log") unless File.exist?(log_path) FileUtils.mkdir_p(File.dirname(log_path)) FileUtils.touch(log_path) timestamp = request_time.strftime('%Y-%m-%dT%H:%M:%S%Z') count = 0 File.write(log_path, "#{timestamp} #{count}") end # Check if log is in limit state log = File.open(log_path, 'r') timestamp, count = log.read.chomp.split time = DateTime.parse(timestamp, '%Y-%m-%dT%H:%M:%S%Z') count = count.to_i if time < (request_time - minutes.minutes) # Time window expired - reset timestamp = request_time.strftime('%Y-%m-%dT%H:%M:%S%Z') count = 1 else # Current time window count += 1 if count > limit flash[:alert] = 'Too many recent requests. Please try again later.' render(status: :too_many_requests) timestamp = DateTime.now.strftime('%Y-%m-%dT%H:%M:%S%Z') # Refresh timestamp File.write(log_path, "#{timestamp} #{count}") return false end end # Update log and allow request to proceed File.write(log_path, "#{timestamp} #{count}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def probers; end", "def implementation; end", "def implementation; end", "def refutal()\n end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def schubert; end", "def strategy; end", "def used?; end", "def offences_by; end", "def custo...
[ "0.7687934", "0.6349491", "0.6315199", "0.6315199", "0.6275309", "0.6207741", "0.6207741", "0.6207741", "0.6207741", "0.6172574", "0.6029909", "0.5963366", "0.5911472", "0.5881053", "0.5881053", "0.5860235", "0.58521295", "0.58521295", "0.5839214", "0.57903016", "0.5770094", ...
0.0
-1
Array output original array algo each takes an array and a block given the array iterate over array invoke the block passing in element as arg return passed in array
def each(arr) counter = 0 while counter < arr.length yield(arr[counter]) counter += 1 end arr end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def each(array)\n for elem in array do\n yield(elem)\n end\n\n array\nend", "def each(&block)\n array.each(&block)\n end", "def each(&block)\n @array.each(&block)\n end", "def custom_each(array)\n i = 0\n while i < array.length\n #yield will pass this element to the block\n yield ar...
[ "0.75485575", "0.74348205", "0.74239683", "0.736643", "0.728209", "0.728209", "0.7272646", "0.7272646", "0.7236823", "0.72240263", "0.7173359", "0.7173057", "0.7145331", "0.71402687", "0.7139408", "0.71120423", "0.71055305", "0.7104836", "0.70990276", "0.709017", "0.7079499",...
0.68069834
50
Calculate the sub_total as the SUM(line_item.line_amount).
def sub_total total_cache(:sub_total) || sum_line_items(line_items, :line_amount) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subtotal\n line_items.reduce(BigDecimal(\"0\")) { |result, item| result += item.amount }\n end", "def sub_total\n sum = 0\n line_items.each do |line_item|\n sum += line_item.total_price\n end\n sum\n end", "def sub_total\n return ApplicationHelper.round_currency(self.line_items.inj...
[ "0.8941642", "0.87423617", "0.8526777", "0.8475841", "0.81044716", "0.7917328", "0.7806597", "0.77830803", "0.77776575", "0.7768823", "0.77299535", "0.77105564", "0.77105564", "0.7653539", "0.76464564", "0.76460207", "0.76066554", "0.7598901", "0.7590735", "0.75285095", "0.74...
0.87697595
1
Calculate the total_tax as the SUM(line_item.tax_amount).
def total_tax total_cache(:total_tax) || sum_line_items(line_items, :tax_amount) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def total_tax\n line_items.reduce(Money.zero) { |a, e| a + e.total_tax }\n end", "def tax_total\n self.tax_amount = line_items.inject(0.to_money) {|sum,l| sum + l.tax_amount }\n self.tax_amount\n end", "def tax_total\n self.tax_amount = line_items.inject(::Money.new(0, self.curren...
[ "0.91519034", "0.90613794", "0.903708", "0.89413226", "0.89005405", "0.8607375", "0.81528765", "0.8117022", "0.80188704", "0.7996691", "0.79483753", "0.7921185", "0.7885601", "0.78657436", "0.7857986", "0.7809498", "0.78011584", "0.7796635", "0.7780616", "0.77156", "0.7695280...
0.90230715
3
Calculate the toal as sub_total + total_tax.
def total total_cache(:total) || (sub_total + total_tax) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def total\n subtotal\n # + tax\n end", "def calc_total\n (@total_after_tax * @gratuity) + @total_after_tax\n end", "def total_before_tax\n self.delivery_price + self.items_sub_total\n end", "def sub_total\n (self.subtotal + self.taxes + self.shipping_cost)\n end", "def total_without_...
[ "0.8092417", "0.79347134", "0.78405243", "0.78202415", "0.77440614", "0.7682706", "0.762453", "0.74780154", "0.74429786", "0.7405017", "0.73900545", "0.7373795", "0.7368895", "0.73362714", "0.73166233", "0.7277744", "0.7270196", "0.7263673", "0.7220909", "0.71075124", "0.7106...
0.7670291
6
If a templating language other than ERB is specified, add the relevant gem to the Gemfile.
def add_view_language_gem return if view_language == "erb" add_gems %(gem "#{view_language}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def template_linter_gems(engine)\n return '' if engine.blank?\n\n case engine.to_s\n when 'haml'\n \"gem 'haml_lint'#{gemfile_requirement('haml_lint')}, require: false\"\n when 'slim'\n \"gem 'slim_lint'#{gemfile_requirement('slim_lint')}, require: false\"\n else\n \"g...
[ "0.6434705", "0.62683153", "0.6247927", "0.62002105", "0.61389774", "0.57077384", "0.56590736", "0.5601729", "0.557176", "0.5535659", "0.5502187", "0.5473761", "0.54413515", "0.5350218", "0.52036774", "0.52022403", "0.5175113", "0.51533234", "0.51533234", "0.51533234", "0.515...
0.7270648
0
Run the Views generator to produce views
def generate_views Views.new(cli: cli, app_path: app_path).generate end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_view \n \n return if skip_method(__method__)\n \n # build edit _form index new show\n \n ['_form','edit','new','index','show'].each do |file|\n \n \n template = File.read(template(\"rails/views/#{file}.html.erb\"))\n \n # need to use ERB for these templates\n t...
[ "0.72299117", "0.7178173", "0.69774723", "0.6902254", "0.67007166", "0.66692483", "0.6498586", "0.6430707", "0.6332138", "0.62775815", "0.6263002", "0.62627524", "0.6200726", "0.6200673", "0.6165071", "0.6149146", "0.61454237", "0.6119936", "0.60735446", "0.6062002", "0.60467...
0.79429555
0
generates a fetch statistic image
def stats! info "STATS" task "generate chart" do c = Chart::StatsPerCollection.new @dbi.execute( File.read( sql_query(:chart) ) ).each{ |date,collection| c.add_one(collection, Date.parse(date).day) } Chart.new(c).write File.join( @config['settings']['output'], '/chart.jpg' ) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @samples = ImageReaderService.new(@image).analyze.generate_samples 4\n end", "def show\n unless (request.path.scan(/^\\/(.{1,})\\/.{1,}$/)[0].nil? || request.path.scan(/^\\/(.{1,})\\/.{1,}$/)[0][0] == \"imgnewsletters\")\n @newsletter = Newsletter.find(params[:id])\n respond_wit...
[ "0.5667243", "0.5641356", "0.55593824", "0.5435218", "0.53880805", "0.53696626", "0.53649914", "0.536338", "0.5345917", "0.53441507", "0.5323299", "0.532244", "0.53213435", "0.5309056", "0.53035444", "0.5246989", "0.5244687", "0.523554", "0.523322", "0.52300507", "0.52249205"...
0.5662734
1
Excerpted from "Everyday Scripting in Ruby" We make no guarantees that this code is fit for any purpose. Visit for more book information.
def convert_to_integer(string) unless /^-?\d+$/ =~ string raise "'#{string}' is not an integer." #(1) end string.to_i end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def herald; end", "def program; end", "def main; end", "def probers; end", "def jack_handey; end", "def schubert; end", "def hiss; end", "def code_like_crazy\r\n puts \"I'm crushing some code!\"\r\n end", "def p15\n\t\nend", "def p003rubystrings\n\tputs \"Hello World\"\n\t\n\t# CAn use ...
[ "0.62879074", "0.61298084", "0.5957766", "0.59353083", "0.59229153", "0.5814389", "0.57971877", "0.5789178", "0.5785706", "0.5734955", "0.57174236", "0.5608481", "0.5593764", "0.559197", "0.55728775", "0.5568986", "0.5566202", "0.55647683", "0.55463326", "0.55463326", "0.5546...
0.0
-1
> compress [1, 1, 2, 3, 3, 3] => [1, 2, 3]
def compress(array) array.uniq end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compress(list)\n list.zip(list[1..-1] + [nil]). # Zip with shifted list\n select {|a,b| a != b}. # Filter dups\n map {|a,b| a} # Unzip\nend", "def compress(array)\n prev = nil\n array.select {|v| v == prev ? false : prev = v}\nend", "def compress(data); end", "def compres...
[ "0.7903527", "0.73421437", "0.6634792", "0.6615078", "0.6261407", "0.61034465", "0.60872287", "0.60740423", "0.6065707", "0.6043544", "0.59632117", "0.5960188", "0.5942582", "0.5940796", "0.5913524", "0.5880538", "0.5861572", "0.5854636", "0.5848758", "0.5837404", "0.5806937"...
0.80014986
0
if user has courses and logged in via root, send to courses listing
def redirect_path_for(user) requested_path = session.delete(:requested_path) requested_path_from_cookie = cookies.delete(:requested_path) if requested_path_from_cookie requested_path_from_cookie elsif requested_path requested_path elsif user.courses.any? root_path else root_path end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n if current_user.nil?\n redirect_to user_session_path\n return\n end\n @courses = current_user.courses\n @permission = current_user\n end", "def check_courses\n\t\t# Check permissions\n\t\tif (not @current_user.is_administrator?) && (not @current_user.courses.include?(@course))\...
[ "0.7592931", "0.75892025", "0.75892025", "0.7547961", "0.75016683", "0.74610686", "0.74197644", "0.7391246", "0.7385164", "0.73444295", "0.7246492", "0.72037655", "0.7148991", "0.7054611", "0.7012976", "0.6893904", "0.6887844", "0.68810856", "0.686988", "0.68076384", "0.67822...
0.0
-1
GET /admin/enrollments/new GET /admin/enrollments/new.xml
def new @enrollment = Enrollment.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @enrollment } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @entitlement = Entitlement.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entitlement }\n end\n end", "def new\n @assessment = Assessment.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { rend...
[ "0.7059007", "0.7040094", "0.7016466", "0.7011768", "0.7005482", "0.7005482", "0.6924383", "0.6910551", "0.6910551", "0.68755823", "0.68755823", "0.68755823", "0.68608713", "0.6819725", "0.6760885", "0.6758027", "0.67453074", "0.6742924", "0.67345005", "0.67328286", "0.673001...
0.76625216
1
POST /enrollments POST /enrollments.xml
def create @enrollment = Enrollment.new(params[:enrollment]) respond_to do |format| if @enrollment.save @log_entry = LogEntry.last format.html { redirect_to admin_scheduled_course_url(@enrollment.scheduled_course), :notice => 'A student was successfully enrolled.' } #format.xml { render :xml => @enrollment, :status => :created, :location => @enrollment } else #format.html { render :action => "new" } #format.xml { render :xml => @enrollment.errors, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def enrollment(params = {})\n scope 'default'\n post('enrollment/', params)\n end", "def create\n @enrollment = Enrollment.new(params[:enrollment])\n\n respond_to do |format|\n if @enrollment.save\n flash[:notice] = 'Enrollment was successfully created.'\n format.html { redi...
[ "0.68580055", "0.6438068", "0.63683385", "0.6174988", "0.6160666", "0.5962718", "0.5962718", "0.58450824", "0.58260685", "0.5815332", "0.5739992", "0.57312495", "0.5713923", "0.5619601", "0.56070054", "0.56008565", "0.5591116", "0.55532026", "0.55532026", "0.55532026", "0.555...
0.58234847
9
PUT /admin/enrollments/1 PUT /admin/enrollments/1.xml
def update @enrollment = Enrollment.find(params[:id]) respond_to do |format| if @enrollment.update_attributes(params[:enrollment]) @log_entry = LogEntry.last format.html { redirect_to @enrollment, :notice => 'The details of this enrollment have changed.' } format.xml { head :ok } format.js else format.html { render :action => "edit" } format.xml { render :xml => @enrollment.errors, :status => :unprocessable_entity } format.js end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @enrollment = Enrollment.find(params[:id])\n\n respond_to do |format|\n if @enrollment.update_attributes(params[:enrollment])\n flash[:notice] = 'Enrollment was successfully updated.'\n format.html { redirect_to(@enrollment) }\n format.xml { head :ok }\n else\n ...
[ "0.6596078", "0.630038", "0.630038", "0.6183862", "0.6183862", "0.6183862", "0.6183862", "0.61791563", "0.6172935", "0.61470383", "0.61290914", "0.61149824", "0.6074484", "0.60686827", "0.6024957", "0.595611", "0.5912802", "0.5909143", "0.59031934", "0.5885574", "0.5864468", ...
0.5694984
40
DELETE /admin/enrollments/1 DELETE /admin/enrollments/1.xml
def destroy @enrollment = Enrollment.find(params[:id]) @scheduled_course = @enrollment.scheduled_course @enrollment.destroy respond_to do |format| if(current_person.current_crew) format.html { redirect_to admin_scheduled_course_url(@scheduled_course) } else format.html { redirect_to enrollments_url } end format.xml { head :ok } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @enrollment = Enrollment.find(params[:id])\n @enrollment.destroy\n\n respond_to do |format|\n format.html { redirect_to(enrollment_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @enrollment = Enrollment.find(params[:id])\n @enrollment.delete\n end", "...
[ "0.6982586", "0.66441727", "0.66232467", "0.66232055", "0.6545451", "0.653755", "0.6508032", "0.64824784", "0.6458054", "0.64530575", "0.6424514", "0.64085263", "0.6378808", "0.6378808", "0.6365029", "0.63641405", "0.63586396", "0.6342038", "0.63415694", "0.6340282", "0.63310...
0.60688674
93
Generate a searchable schema list in the output
def generate_schema_list puts "GENERATE SCHEMA LIST" # load all the features from the Registry @items = Registry.all(:schema).sort { |a,b| a.name.downcase <=> b.name.downcase } @list_title = "Schema List" @list_type = "schema" # optional: the specified stylesheet class # when not specified it will default to the value of @list_type @list_class = "schema" # Generate the full list html file with named feature_list.html # @note this file must be match the name of the type asset('schema_list.html', erb(:full_list)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @schemas = Schema.all\n end", "def schema\n []\n end", "def available_schemas\n load_schemas.transform_values(&:description).to_a\n end", "def user_defined_schemas(stream)\n return if (list = (@connection.user_defined_schemas - ['public'])).empty?\n\n ...
[ "0.64337724", "0.6202368", "0.6157455", "0.6154027", "0.614332", "0.61003363", "0.60073525", "0.60014963", "0.59498584", "0.5901143", "0.58913946", "0.58911574", "0.5885941", "0.5870931", "0.58381474", "0.5816694", "0.58004546", "0.5765432", "0.5716042", "0.56836516", "0.5682...
0.6860441
0
Create a new Website
def initialize(title = "Link List") @links = [] @title = title end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n\t\t@website = Website.new(params[:website])\n\n\t\trespond_to do |format|\n\t\t\tif @website.save\n\t\t\t\tflash[:notice] = 'Website was successfully created.'\n\t\t\t\tformat.html { redirect_to websites_url }\n\t\t\t\tformat.xml\t{ render :xml => @website, :status => :created, :location => @website }...
[ "0.7090664", "0.7039746", "0.69364256", "0.69164723", "0.68795747", "0.6878071", "0.6863321", "0.67511964", "0.66125214", "0.65740234", "0.6570023", "0.6564045", "0.65628874", "0.64869785", "0.64228046", "0.64178336", "0.6379928", "0.6345181", "0.62986666", "0.62978494", "0.6...
0.0
-1
Add a link to the website
def add_link(link) links << link end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def link() url; end", "def link() url; end", "def link(link, title, content)\n\t \"<u><link href='#{link}'>#{content}</link></u>\"\n\t end", "def link(link, title, content)\n \"#{content} (#{link})\"\n end", "def link uri\n self.apply_hyperlink java.net.URI.new(ur...
[ "0.7272793", "0.7272793", "0.71232647", "0.7049978", "0.70148504", "0.7010466", "0.6913935", "0.68870544", "0.68052584", "0.679065", "0.67857206", "0.67855346", "0.6762925", "0.67523545", "0.6732364", "0.6720014", "0.67156154", "0.6708738", "0.6689934", "0.66776645", "0.66776...
0.6902849
7
Remove a link from the website
def remove_link(link) links.delete(link) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strip_links\n gsub(%r{</?a.*?>}, \"\")\n end", "def clear_link\n @link = nil\n @autolink = false\n end", "def strip_links(html); end", "def strip_links(html); end", "def strip_links(html); end", "def remove_hyperlink(hyperlink_to_delete)\n hyperlinks = self.hyperlinks\n hyperli...
[ "0.72726053", "0.72398233", "0.713943", "0.713943", "0.713943", "0.70390487", "0.6958023", "0.6928066", "0.68861246", "0.677371", "0.677371", "0.67188716", "0.6716101", "0.67093617", "0.67045206", "0.6691306", "0.6643811", "0.65920997", "0.65794975", "0.6573608", "0.65212876"...
0.7798636
0
List links that match the attributes
def list_links(args = {}) if args.empty? links else links.select { |link| link.match? args } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display_all_links_attributes\n # Interface method\n end", "def link(attribute)\n links.find_all { |l| l.rel == attribute.to_s }\n end", "def links\n each_link.to_set\n end", "def links\n self[\"link\"].map { |l| l.href }\n end", "def links\n self[\"link\"].map {...
[ "0.73371696", "0.71691275", "0.7080161", "0.70359284", "0.70359284", "0.6885857", "0.6885857", "0.6767168", "0.67192537", "0.6717245", "0.6700448", "0.66823786", "0.6674021", "0.6674021", "0.66558456", "0.6645124", "0.66331834", "0.6629481", "0.6601029", "0.6598765", "0.65905...
0.6734793
8
Finds all links that contain the search string
def find_links(search) links.select { |link| link.contains? search } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def search_links(page,content)\n page.links_with( :text => Regexp.new(content, true))\n end", "def research_sites(search_str)\n search_sites = link_to \"Google\", 'http://www.google.com/search?q=' + search_str, :target => '_blank'\n search_sites += ' | '\n search_sites += link_to \"Yahoo\", 'http://...
[ "0.7509331", "0.6644939", "0.6555102", "0.6539062", "0.6487399", "0.6372842", "0.6367508", "0.6366524", "0.62081313", "0.61661977", "0.61636686", "0.5996572", "0.597002", "0.5932552", "0.5927549", "0.5926851", "0.5862333", "0.5827129", "0.582345", "0.5766893", "0.5757087", ...
0.84877676
0