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
includes the code, as found if code/filename options: filename: name of the file in rails_root/code/ brush: :ruby, :js, :shell etc highlight_lines: line numbers to highlight (number or array of numbers)
def bob_code(options={}, &block) # if the only string is give, it must be filename by default if options.is_a? String f = options options = {} options[:filename] = f end if block_given? code = capture(&block) options[:brush] ||= :plain else unless options[:brush]...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_highlights_from(code, options)\n code.gsub!(%r[\\{% highlight (.+) %\\}]) do\n enumerable = eval($1.strip)\n enumerable = (Enumerable === enumerable)? enumerable : nil\n options.merge!({:highlight_lines => enumerable}) if enumerable\n ''\n end\n [code.strip, o...
[ "0.7059731", "0.7055948", "0.6917887", "0.69156975", "0.6790325", "0.672842", "0.6712815", "0.6674295", "0.66669434", "0.6579968", "0.6492008", "0.64401865", "0.641795", "0.641795", "0.641795", "0.639498", "0.63711345", "0.63711345", "0.63367", "0.6310719", "0.63008213", "0...
0.71305317
0
generates link to chapter chapter_no can be: :first title if not given, it will be a chapter title as in database
def bob_link_to_chapter chapter_no, title=nil chapter = case chapter_no when Symbol case chapter_no when :first Chapter.first_chapter when :next @chapter.next end when Array Chapter.find_by(chapter_no: chapter_no.to_yaml) when String ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def chapter(title, key)\n @anchors ||= []\n @anchors << [title, key]\n \n content_tag(:a, '', :name => key)+\n \"\\n<h2 class='chapter'>\\n \"+\n content_tag(:a, \"top &uarr;\", :href => \"#\", :class => \"top-anchor\")+\n content_tag(:a, title, :href => \"##{key}\")+\n \"\\n</h2>\"\n ...
[ "0.77383095", "0.760208", "0.7182758", "0.71269804", "0.6996888", "0.69392717", "0.6915772", "0.68683463", "0.6833469", "0.6743911", "0.64322644", "0.6320825", "0.62670386", "0.6213296", "0.61991245", "0.61951184", "0.6187007", "0.6181524", "0.61441565", "0.61340934", "0.6106...
0.8349651
0
Generates new_arrivals list the number of last added chapters no_chapters max number of chapters to generate
def bob_new_arrivals(no_chapters) render partial: 'chapters/new_arrivals', locals: { recently_added: Chapter.recently_added(no_chapters), recently_updated: Chapter.recently_updated(no_chapters), no_chapters: no_chapters } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_new_chapters!\n new_chapters.each do |c|\n chap = Chapter.new(lecture_id: @lecture.id, title: c.second)\n chap.insert_at(c.first)\n corresponding = @chapters.find { |d| d['counter'] == c.third }\n corresponding['mampf_chapter'] = chap\n end\n @lecture = @lecture.reload\n en...
[ "0.64292824", "0.6418099", "0.57000875", "0.5684289", "0.54868597", "0.53833884", "0.517406", "0.508461", "0.5017722", "0.5009256", "0.5009256", "0.49515465", "0.4895037", "0.48657504", "0.48595297", "0.48562768", "0.48190275", "0.47969285", "0.47952908", "0.47936928", "0.479...
0.66321
0
Spans. Divides current paragraph into two spans. Usage html in the left span html to put in the right span
def bob_left_span raw '<div class="row">' \ ' <div class="large-8 medium-6 small-12 columns">' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def html_span(*args, &block)\n html_tag(:span, *args, &block)\n end", "def simple_format_span(text, html_options={}, options={})\n text = '' if text.nil?\n text = text.dup\n start_tag = tag('span', html_options, true)\n text = sanitize(text) unless options[:sanitize] == false\n text = text.to_...
[ "0.59699667", "0.59460616", "0.579369", "0.5769885", "0.5605921", "0.5507641", "0.5462809", "0.53826785", "0.53563905", "0.52389413", "0.522237", "0.51349825", "0.5131418", "0.5121364", "0.5121356", "0.511875", "0.5048374", "0.50360674", "0.5002772", "0.49800727", "0.4976132"...
0.5530588
5
before_action :authenticate_login! Redirection to make sure unauthorized don't have access to pages besides log in
def unauthorized flash[:alert] = "You are not authorized to view that page." redirect_to '/' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def login_required\n redirect_to(login_url) unless logged_in? && authorized?\n end", "def login_required\n redirect_to login_path unless logged_in?\n end", "def require_login\n redirect_to root_path unless logged_in?\n end", "def require_login\n redirect_to root_path unless logged_in?\n e...
[ "0.79804826", "0.78794193", "0.785596", "0.785596", "0.78429157", "0.7838088", "0.78148836", "0.7798107", "0.77815145", "0.7778769", "0.7767252", "0.7744334", "0.77132684", "0.77102315", "0.7699523", "0.76878464", "0.7684077", "0.76692426", "0.7668828", "0.76654196", "0.76266...
0.0
-1
Allows sign_up to accept more login fields and login to take new username key
def configure_permitted_parameters devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:first_name, :middle_initial, :last_name, :username, :type, :email, :password, :password_confirmation) } devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:logon, :username, :email, :password, :remember_me) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def signup!(params)\n self.login = params[:user][:login]\n self.email = params[:user][:email]\n save_without_session_maintenance\n end", "def signup!(params)\n self.username = params[:user][:username]\n self.email = params[:user][:email]\n save_without_session_maintenance\n end", "def signu...
[ "0.74420744", "0.73910064", "0.73910064", "0.72692364", "0.7188364", "0.70180535", "0.70180535", "0.7008201", "0.6959768", "0.68991643", "0.6859902", "0.68133074", "0.6770402", "0.669237", "0.669237", "0.6687533", "0.6678038", "0.6656538", "0.66533864", "0.6645009", "0.663307...
0.0
-1
todo/fix: add alternate support for kwargs instead of positional number list why? why not?
def generate( type, *args ) puts "==> generate >#{type}< - with #{args.size} part(s) #{args.inspect}" character = @chars[ type ] img = nil ## (by default) auto-derive width x height dimension from first image character.each_with_index do |(part_key, part),i| num = args[i] ## todo/check - double c...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def in_kwarg=(_arg0); end", "def in_kwarg; end", "def **(arg0)\n end", "def **(arg0)\n end", "def test_keyword_arguments\n assert_equal Array, method_with_keyword_arguments.class\n assert_equal [1, 'two'], method_with_keyword_arguments\n assert_equal ['one','two'], method_with_keyword_arguments(...
[ "0.70029175", "0.6948669", "0.6766901", "0.6766901", "0.6731528", "0.6643144", "0.6641813", "0.6404625", "0.63999397", "0.6369966", "0.6313029", "0.6283088", "0.62815315", "0.625144", "0.62090826", "0.62035936", "0.61748415", "0.6130817", "0.6130817", "0.609814", "0.609814", ...
0.0
-1
GET /service_starts/1 GET /service_starts/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_service_start\n @service_start = ServiceStart.find(params[:id])\n end", "def show\n @scheduled_service = ScheduledService.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @scheduled_service }\n end\n ...
[ "0.6835137", "0.64435846", "0.6310882", "0.6120043", "0.61169076", "0.6111092", "0.60849637", "0.60093516", "0.5948024", "0.5935352", "0.5933702", "0.5912952", "0.5889575", "0.5866395", "0.58330995", "0.5827404", "0.582413", "0.58183825", "0.58183825", "0.58183825", "0.581818...
0.0
-1
POST /service_starts POST /service_starts.json
def create @service_start = ServiceStart.new(service_start_params) respond_to do |format| action_message_for('new') if create_service_start format.html { redirect_to redirect_target(@service_start), flash: @feedback_flash } format.json { render :show, status: :created, location: @se...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_service_start\n @service_start = ServiceStart.find(params[:id])\n end", "def create\n @start = Start.new(start_params)\n\n respond_to do |format|\n if @start.save\n format.html { redirect_to @start, notice: 'Start was successfully created.' }\n format.json { render :show, sta...
[ "0.6638013", "0.66120005", "0.6317793", "0.6317729", "0.62771976", "0.61284506", "0.6124609", "0.6078573", "0.6032003", "0.5996308", "0.5884123", "0.58695334", "0.58578664", "0.5853757", "0.5852414", "0.5850786", "0.58088994", "0.5801108", "0.5786956", "0.5762813", "0.575993"...
0.6951156
0
PATCH/PUT /service_starts/1 PATCH/PUT /service_starts/1.json
def update respond_to do |format| action_message_for(@service_start.content_item.status) if update_service_start format.html { redirect_to redirect_target(@service_start), flash: @feedback_flash } format.json { render :show, status: :ok, location: @service_start } else @ser...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_service_start\n @service_start = ServiceStart.find(params[:id])\n end", "def update\n respond_to do |format|\n if @start.update(start_params)\n format.html { redirect_to @start, notice: 'Start was successfully updated.' }\n format.json { render :show, status: :ok, location: @sta...
[ "0.63314134", "0.62296546", "0.6172204", "0.6129222", "0.6042451", "0.6014964", "0.6014964", "0.6002739", "0.5993586", "0.59757847", "0.58922493", "0.58862036", "0.586763", "0.58465946", "0.58465946", "0.5830979", "0.58031845", "0.57702744", "0.5759671", "0.57433677", "0.5724...
0.55600446
50
DELETE /service_starts/1 DELETE /service_starts/1.json
def destroy @service_start.destroy respond_to do |format| format.html { redirect_to :delete, flash: { message: 'Service start was successfully deleted.' } } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @start.destroy\n respond_to do |format|\n format.html { redirect_to starts_url, notice: 'Start was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n #@service_request = ServiceRequest.find(params[:id])\n @service_request.destroy\n\n...
[ "0.69662976", "0.6929593", "0.68482274", "0.68307453", "0.6818783", "0.6818783", "0.6818783", "0.6809578", "0.676543", "0.67624384", "0.6750489", "0.6750489", "0.6750489", "0.6742838", "0.6726837", "0.67215794", "0.6713976", "0.67061406", "0.6692808", "0.6670506", "0.6624586"...
0.75571233
0
Use callbacks to share common setup or constraints between actions.
def set_service_start @service_start = ServiceStart.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163443", "0.604317", "0.5943409", "0.59143174", "0.5887026", "0.58335453", "0.57738566", "0.5701527", "0.5701527", "0.56534666", "0.5618685", "0.54237175", "0.5407991", "0.5407991", "0.5407991", "0.5394463", "0.5376582", "0.5355932", "0.53376216", "0.5337122", "0.5329516"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def service_start_params params.require(:service_start).permit(:usage_instructions, :call_to_action_type, :call_to_action_label, :call_to_action_content, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
You need to exec 'gem install epubparser' if you don't have it
def main if ARGV.empty? puts "Usage: ruby #{File.basename($0)} EPUBFILE [EPUBFILE ...]" exit 1 end puts make_catalog(ARGV) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_epub(options={})\n filename = manifest.filename\n zfname = filename + '.zip'\n base_file = \"#{zip} -X0 #{zfname} mimetype\"\n fullzip = \"#{zip} -rDXg9\"\n meta_info = \"#{fullzip} #{zfname} META-INF -x \\*.DS_Store -x mimetype\"\n main_info = \"#{fullzip} #{zfna...
[ "0.58555305", "0.57927734", "0.56760406", "0.563995", "0.54432905", "0.52459115", "0.5184365", "0.51759374", "0.50995356", "0.5096726", "0.5095839", "0.5070682", "0.5061313", "0.505713", "0.5052392", "0.49877384", "0.49838513", "0.4976186", "0.4969904", "0.49586692", "0.49502...
0.5437966
5
not useful for rspec tests
def send(tag) return "<#{tag}/>" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def spec; end", "def spec; end", "def private; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def testing\n # ...\n end", "def self_test; end", "def self_test; end", "def setup; end", "def setup; end", "def setup; end", "def setup; end", "...
[ "0.77072495", "0.77072495", "0.71351415", "0.7001788", "0.7001788", "0.7001788", "0.7001788", "0.6633083", "0.6572608", "0.6572608", "0.65125227", "0.65125227", "0.65125227", "0.65125227", "0.65125227", "0.65125227", "0.65125227", "0.65125227", "0.65125227", "0.65125227", "0....
0.0
-1
Responds to `POST /units`
def create @unit = Unit.new(unit_params) authorize @unit begin ActiveRecord::Base.transaction do @unit.save! end rescue => e render partial: "shared/validation_messages", locals: { object: @unit.errors.any? ? @unit : e }, status: :bad_request else ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def foods_units\n get('/foods/units.json')\n end", "def units\n @formulation = (params[:formulation] || '').upcase\n drug = Drug.find_by_name(@formulation) rescue nil\n render plain: \"per dose\" and return unless drug && !drug.units.blank?\n render plain: drug.units\n end", "def units=(va...
[ "0.67805576", "0.6592949", "0.6585414", "0.6302513", "0.62653387", "0.6188293", "0.61737293", "0.61737293", "0.6135894", "0.6132452", "0.61186755", "0.61186755", "0.6031568", "0.60086036", "0.5988794", "0.59885687", "0.59638375", "0.59638375", "0.59638375", "0.5956962", "0.59...
0.0
-1
Buriesdoes not deletea unit. Responds to `POST /units/:id/delete`
def delete unit_institution = @unit.institution ActiveRecord::Base.transaction do @unit.bury! end rescue => e flash['error'] = "#{e}" redirect_to @unit else RefreshOpensearchJob.perform_later toast!(title: "Unit deleted", message: "The unit \"#{@unit.title}\" has been ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n if @unit.blank?\n render json: {error: \"Can't delete unit\"}, status: :unprocessable_entity\n else\n @unit.destroy\n render json: {notice: \"Deleted!\"}, :status => 204\n end\n\n end", "def destroy\n @unit = Unit.find(params[:id])\n @unit.destroy\n\n respond_to do...
[ "0.837953", "0.8196695", "0.8196695", "0.8196695", "0.8196695", "0.8183765", "0.8178476", "0.8114186", "0.8087427", "0.7976308", "0.79750454", "0.79555875", "0.7949575", "0.79389733", "0.7848599", "0.78324986", "0.7745556", "0.76376784", "0.75844795", "0.7563648", "0.74916464...
0.7336655
26
Used for editing administering groups. Responds to `GET /units/:unit_id/editadministeringgroups` (XHR only)
def edit_administering_groups render partial: "units/administering_groups_form", locals: { unit: @unit } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_edit_groups(groups, eligible_groups)\n set_entities(:edit, :group, groups, eligible_groups)\n end", "def update\n @group = load_group\n @group_form = group_form\n\n if @group_form.valid? && @group_form.save\n redirect_to(admin_group_path(@group_form.id))\n else\n ...
[ "0.666713", "0.657378", "0.6538777", "0.65168226", "0.6502353", "0.64624816", "0.63963026", "0.639152", "0.63773173", "0.6368999", "0.6345811", "0.6318696", "0.62937427", "0.62695247", "0.6257944", "0.6232198", "0.61947364", "0.61894006", "0.61835074", "0.61688197", "0.614356...
0.8471153
0
Used for editing administering users. Responds to `GET /units/:unit_id/editadministeringusers` (XHR only)
def edit_administering_users render partial: "units/administering_users_form", locals: { unit: @unit } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def edit_admin\n user = User.find(params[:id])\n if user.is_admin?\n user.is_admin = false\n else\n user.is_admin = true\n end\n user.save!\n respond_to do |format|\n format.js {\n render :update do |page|\n page[\"user_#{user.id}\"].replace_html :partial => 'user',...
[ "0.66944057", "0.66295093", "0.6556854", "0.6556854", "0.647606", "0.64591634", "0.642177", "0.640549", "0.63731635", "0.62996", "0.6287363", "0.627573", "0.62556785", "0.6237398", "0.62351626", "0.622808", "0.61785454", "0.6159362", "0.61452067", "0.6129339", "0.6122913", ...
0.81438047
0
Used for editing unit membership. Responds to `GET /units/:unit_id/editmembership` (XHR only)
def edit_membership render partial: "units/membership_form", locals: { unit: @unit } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def edit_administering_users\n render partial: \"units/administering_users_form\", locals: { unit: @unit }\n end", "def update\n @membership ||= Membership.find(params[:id])\n\n respond_to do |format|\n if @membership.update_attributes(params[:membership])\n format.html { redirect_to @membe...
[ "0.65210617", "0.6416885", "0.63915926", "0.63517", "0.6314213", "0.6292684", "0.62745935", "0.62561077", "0.6253545", "0.6222177", "0.6222177", "0.6222177", "0.6222177", "0.6222177", "0.62194216", "0.6216177", "0.6203464", "0.6167377", "0.61528385", "0.6140805", "0.6115333",...
0.8251979
0
Used for editing basic properties. Responds to GET `/units/:unit_id/edit` (XHR only)
def edit_properties render partial: "units/properties_form", locals: { unit: @unit } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @unit.update(unit_params)\n format.html { redirect_to @unit, notice: 'Unit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @unit.errors, stat...
[ "0.7267749", "0.71548146", "0.71066535", "0.7032502", "0.69609755", "0.6943723", "0.69396126", "0.69294685", "0.6890386", "0.6864798", "0.6740487", "0.67321146", "0.6697118", "0.6673941", "0.6655118", "0.6602347", "0.6594281", "0.65877354", "0.6572851", "0.65591663", "0.65544...
0.79652494
0
Responds to `GET /units`
def index @units = Unit.search. institution(current_institution). include_children(false). order("#{Unit::IndexFields::TITLE}.sort"). limit(9999) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def foods_units\n get('/foods/units.json')\n end", "def index\n response = HTTParty.get(\"https://casa-core.herokuapp.com/api/units\", :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n @units = JSON.parse(response.body)\n return @units\n end", "def units\n @units = Item.select...
[ "0.8063973", "0.7458431", "0.7072488", "0.70169824", "0.6952454", "0.6934599", "0.67839456", "0.6752639", "0.67442524", "0.6635647", "0.6635647", "0.6635647", "0.6635647", "0.6635647", "0.6635647", "0.66315114", "0.65824956", "0.6518254", "0.64755017", "0.6430868", "0.6430868...
0.593217
61
Renders item download counts by month as HTML and CSV. Responds to `GET /units/:id/itemdownloadcounts`
def item_download_counts @items = MonthlyItemDownloadCount.unit_download_counts_by_item( unit: @unit, start_year: params[:from_year].to_i, start_month: params[:from_month].to_i, end_year: params[:to_year].to_i, end_month: params[:to_month].to_i) # The items array cont...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def month_by_month_csv\n CSV.generate do |csv|\n report_details.each { |a| csv.add_row(a) }\n csv.add_row [] # Blank row\n csv.add_row ['VIEWS']\n month_by_month_table(Statistic::VIEW).each { |a| csv.add_row(a) }\n csv.add_row [] # Blank row\n csv.add_ro...
[ "0.6422912", "0.6331618", "0.6068655", "0.60118693", "0.5850854", "0.57265127", "0.5720309", "0.5650501", "0.5600326", "0.5548036", "0.5547282", "0.55461866", "0.55161834", "0.5483863", "0.5430934", "0.5397423", "0.5384353", "0.53396857", "0.53268105", "0.53251827", "0.531459...
0.8442748
0
Renders results within the items tab in showunit view. Responds to `GET /units/:id/items`
def item_results set_item_results_ivars render partial: "items/listing" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @unit = Unit.find(params[:id])\n @item = Item.find(@unit.item_id)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unit }\n end\n end", "def show_items\n set_item_results_ivars\n respond_to do |format|\n format.html do\n rend...
[ "0.7502463", "0.74719316", "0.73330766", "0.6874926", "0.6838184", "0.6698547", "0.6658432", "0.6600831", "0.65251124", "0.6520479", "0.6480194", "0.64779615", "0.6471164", "0.6471164", "0.6471164", "0.6471164", "0.6471164", "0.6471164", "0.6459033", "0.64235", "0.6403164", ...
0.7838722
0
Renders the newunit form. A `parent_id` query argument is supported which will inject a parent unit ID into a hidden form input. Responds to `GET /units/new` (XHR only)
def new institution_id = params.dig(:unit, :institution_id) if institution_id.blank? render plain: "Missing institution ID", status: :bad_request return end @unit = Unit.new @unit.parent_id = params.dig(:unit, :parent_id) @unit.institution = Institution.find(institution...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @unit = Unit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @unit }\n end\n end", "def new\n @unit = Unit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @unit }\n end\n end", "d...
[ "0.6495678", "0.6495678", "0.6495678", "0.64859146", "0.64106023", "0.6253484", "0.62510365", "0.6218191", "0.6207222", "0.6177892", "0.6138855", "0.60244864", "0.5959126", "0.59348637", "0.5934751", "0.59126556", "0.5911178", "0.5911178", "0.59097224", "0.58720183", "0.58510...
0.72142744
0
Responds to GET /units/:id
def show if @unit.buried render "show_buried", status: :gone and return end @review_count = review_items(0, 0).count @submissions_in_progress_count = submissions_in_progress(0, 0).count end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n query = {\n 'id' => unit_params[:id]\n }\n response = HTTParty.get(\"https://casa-core.herokuapp.com/api/units/?id\", :query => query, :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n\n if response.code == 200\n @unit = JSON.parse(response.body)\n else\n redire...
[ "0.7670557", "0.74697876", "0.7460163", "0.7460163", "0.7460163", "0.7419457", "0.73735446", "0.7338022", "0.70483965", "0.70483965", "0.70483965", "0.70483965", "0.70483965", "0.70483965", "0.70259094", "0.70042807", "0.69794935", "0.68344676", "0.68191665", "0.6814356", "0....
0.0
-1
Renders HTML for the properties tab in showunit view. Responds to `GET /units/:id/about`
def show_about @metadata_profile = @unit.effective_metadata_profile @num_downloads = MonthlyUnitItemDownloadCount.sum_for_unit(unit: @unit) @num_submitted_items = @unit.submitted_item_count @collections = Collection.search. institution(@unit.institution). filter(Collection::...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def edit_properties\n render partial: \"units/properties_form\", locals: { unit: @unit }\n end", "def show\n @property = Property.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @property }\n end\n end", "def show\n ...
[ "0.7369877", "0.64562875", "0.63185185", "0.63185185", "0.63185185", "0.63185185", "0.6291258", "0.62668735", "0.62421256", "0.623183", "0.6185986", "0.61226165", "0.6096149", "0.6091707", "0.6091707", "0.6091707", "0.60777205", "0.6002586", "0.59999293", "0.5997187", "0.5979...
0.6792432
1
Renders HTML for the access tab in showunit view. Responds to `GET /units/:id/access`
def show_access render partial: "show_access_tab" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def access\n render :access\n end", "def show\n @access = Access.find(params[:id])\n end", "def show\n respond_with(@access)\n end", "def show\n @valid_access = ValidAccess.find(params[:id])\n end", "def show\n @access_right = AccessRight.find(params[:id])\n\n respond_to do |format|\n...
[ "0.7002734", "0.6277041", "0.62512094", "0.60035086", "0.5985533", "0.5871605", "0.57994986", "0.57862383", "0.57203704", "0.5719194", "0.567785", "0.566266", "0.5646861", "0.5600908", "0.5591486", "0.5571935", "0.5567346", "0.5563007", "0.55603313", "0.55564046", "0.5553674"...
0.72641855
0
Renders HTML for the items tab in showunit view. Responds to `GET /units/:id/items`
def show_items set_item_results_ivars respond_to do |format| format.html do render partial: "show_items_tab" end format.csv do authorize(@unit, policy_method: :export_items) send_data(CsvExporter.new.export_unit(@unit), type: "text/csv", ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @unit = Unit.find(params[:id])\n @item = Item.find(@unit.item_id)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @unit }\n end\n end", "def show\n @item_unit = ItemUnit.find(params[:id])\n\n respond_to do |format|\n format.html # s...
[ "0.7072799", "0.69774276", "0.66771233", "0.65917754", "0.6560081", "0.6395623", "0.62458783", "0.6224601", "0.62156063", "0.62119573", "0.6139491", "0.60870004", "0.60702705", "0.60629445", "0.6039896", "0.6031534", "0.59952915", "0.59919995", "0.59801275", "0.5973017", "0.5...
0.7236334
0
Renders HTML for the review submissions tab in showshow view. Responds to `GET /units/:id/reviewsubmissions`
def show_review_submissions @review_permitted_params = params.permit(Search::RESULTS_PARAMS) @review_start = @review_permitted_params[:start].to_i @review_window = window_size @review_items = review_items(@review_start, @review_window) @review_count = @revi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def view_reviews\n @submission = Submission.find(params[:id])\n @questions = @submission.assignment.questions.sort_by {|obj| obj.created_at }\n evaluation = @evaluations.where(:user_id => current_user.id)[0]\n @responses = @evaluations[0].responses.sort_by {|obj| obj.created_at }\n\n respond_to do |...
[ "0.66733104", "0.63257086", "0.6325646", "0.6276765", "0.62352127", "0.6195101", "0.61863804", "0.6159491", "0.6142392", "0.5957182", "0.5919183", "0.5917607", "0.58822656", "0.5869611", "0.5869611", "0.58663577", "0.5841467", "0.58197355", "0.58106416", "0.58008873", "0.5799...
0.79995346
0
Renders HTML for the statistics tab in showunit view. Responds to `GET /units/:id/statistics`
def show_statistics render partial: "show_statistics_tab" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def html_report_stats\n @report << '<div id=\"title\"> General Statistics</div>'\n stat_tab = Ruport::Data::Table(%w[Stat Value])\n stat_tab << ['Number of servers Seen', @num_servers]\n stat_tab << ['Number of clients Seen', @num_clients]\n @num_by_cipher.each do |cipher, num|\n stat_tab << ['...
[ "0.69241697", "0.66734856", "0.66170937", "0.6429524", "0.642606", "0.638978", "0.6376737", "0.6374107", "0.63641787", "0.63641787", "0.63641787", "0.6328836", "0.6328836", "0.63269836", "0.6323218", "0.6319391", "0.6251955", "0.6251955", "0.6251955", "0.6251955", "0.6251955"...
0.7404037
0
Renders HTML for the submissionsinprogress tab in showunit view. Responds to `GET /units/:id/submissionsinprogress`
def show_submissions_in_progress @permitted_params = params.permit(Search::RESULTS_PARAMS) @start = [@permitted_params[:start].to_i.abs, MAX_START].min @window = window_size @items = submissions_in_progress(@start, @window) @count = @items.count @curren...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n calculate_progress\n ##complete_goal\n end", "def ticket_progress_bar(progress)\n\n completed_hours = ticket_estimate_in_hours(progress.closed_estimated_minutes)\n total_hours = ticket_estimate_in_hours(progress.total_estimated_minutes)\n completed_percentage = if progress.total_ticket...
[ "0.618032", "0.6099466", "0.60419315", "0.57890755", "0.5723093", "0.5719561", "0.5668991", "0.56647795", "0.5619687", "0.55782366", "0.5573646", "0.5572366", "0.55416244", "0.5527327", "0.55171394", "0.5473196", "0.54709595", "0.5467046", "0.5445767", "0.5437804", "0.5435098...
0.6864775
0
Renders statistics within a date range as HTML and CSV. Responds to `GET /units/:id/statisticsbyrange`
def statistics_by_range begin from_time = TimeUtils.ymd_to_time(params[:from_year], params[:from_month], params[:from_day]) to_time = TimeUtils.ymd_to_time(params[:to_year], params[:...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strategy_stats date_range\n data = []\n current_user.reports.where(exam_date:date_range).each do |report|\n l1 = (report.l1_attended.to_f/(report.l1_total.to_f.nonzero? || 1 ))*100\n l2 = (report.l2_attended.to_f/(report.l2_total.to_f.nonzero? || 1 ))*100\n l3 = (report.l3_attended.to_f/(r...
[ "0.6337641", "0.6123475", "0.6054763", "0.60450697", "0.6026829", "0.6010782", "0.5972056", "0.58601165", "0.5852376", "0.5823053", "0.58163196", "0.58119243", "0.5771625", "0.573265", "0.5722893", "0.5696783", "0.56890327", "0.56655806", "0.5648963", "0.5646357", "0.561694",...
0.78482723
0
Exhumes a buried unit. Responds to `POST /units/:id/undelete`
def undelete ActiveRecord::Base.transaction do @unit.exhume! end rescue => e flash['error'] = "#{e}" else RefreshOpensearchJob.perform_later toast!(title: "Unit undeleted", message: "The unit \"#{@unit.title}\" has been undeleted.") ensure redirect_to @unit end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n unit_institution = @unit.institution\n ActiveRecord::Base.transaction do\n @unit.bury!\n end\n rescue => e\n flash['error'] = \"#{e}\"\n redirect_to @unit\n else\n RefreshOpensearchJob.perform_later\n toast!(title: \"Unit deleted\",\n message: \"The unit \\\"#{@...
[ "0.7151063", "0.6753562", "0.6684894", "0.6676798", "0.6676267", "0.6593077", "0.65773547", "0.65773547", "0.65773547", "0.65773547", "0.65732443", "0.65618724", "0.65308684", "0.6529045", "0.6529045", "0.6503384", "0.647248", "0.6468763", "0.64500904", "0.6425778", "0.641006...
0.77170825
0
Responds to `PATCH/PUT /units/:id`
def update if params[:unit][:parent_id].present? && !policy(@unit).change_parent?(params[:unit][:parent_id]) raise NotAuthorizedError,"Cannot move a unit into a unit of "\ "which you are not an effective administrator." end begin ActiveRecord::Base.transaction do assi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n params.require(%i[id units])\n retrieve_and_validate_put.update!(units: params[:units])\n head :no_content\n end", "def update\n respond_to do |format|\n if @unit.update(unit_params)\n format.html { redirect_to @unit, notice: 'Unit was successfully updated.' }\n forma...
[ "0.8301436", "0.7602729", "0.7554502", "0.7537423", "0.75073427", "0.739429", "0.7309709", "0.7294864", "0.72106856", "0.72063684", "0.7173939", "0.71582985", "0.71290547", "0.71189016", "0.71067697", "0.70754564", "0.7072564", "0.70637363", "0.70502484", "0.70407176", "0.704...
0.0
-1
allows creating competitors during lane assignment (only at NAUCC)
def can_create_competitors_at_lane_assignment? usa? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_from_candidates\n authorize @competition.competitors.new\n\n heat = params[:heat].to_i\n competitors = params[:competitors]\n begin\n LaneAssignment.transaction do\n competitors.each do |_, competitor|\n reg = Registrant.find_by!(bib_number: competitor[:bib_number])\n ...
[ "0.6798195", "0.57733536", "0.56439084", "0.54819787", "0.54411596", "0.5400478", "0.5377514", "0.53717166", "0.53710127", "0.5351384", "0.533577", "0.5321131", "0.53037965", "0.5272517", "0.524598", "0.5234441", "0.5217217", "0.52161247", "0.5195823", "0.5194796", "0.5187188...
0.6644464
2
Convert from stored string "en,fr" to [:en, :fr]
def enabled_locales self[:enabled_locales].split(",").map(&:to_sym) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def site_locales\n preferred_locales.split(/,\\s*/)\n end", "def site_locales\n preferred_locales.split(/,\\s*/)\n end", "def locale_to_name\n \t\t{'fr' => 'Français',\n 'en' => 'English',\n 'po' => 'portugues',\n 'sp' => 'Spanish',\n 'de' => 'Deutsch',\n 'it' => 'Italiano'}\n\tend", "...
[ "0.6010022", "0.6010022", "0.5673912", "0.5665214", "0.55706507", "0.5514233", "0.5456004", "0.5424291", "0.53837585", "0.53728276", "0.5357473", "0.53245425", "0.53193283", "0.5300597", "0.5297159", "0.5259846", "0.5238608", "0.52322745", "0.5207145", "0.52058065", "0.519040...
0.59245884
3
convert from passed in array ["", "en", "fr"] to "en,fr"
def enabled_locales=(values) languages = values.reject{|x| x.blank?} # add default, since it's the configured fallback it must exist languages = (languages << I18n.default_locale.to_s).uniq self[:enabled_locales] = languages.join(",") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def array_to_string(arr)\n arr.map { |e| \"'#{sanitize(e)}'\" }.join(\",\")\n end", "def query_translate(mixed_ary)\n rslt = \"\"\n sub = mixed_ary.collect {|a| \"(#{a.join(',')})\"}\n sub.join(\";\")\n end", "def to_s\n multiple ? value.map(&:to_s).join(', ') : value.to_...
[ "0.6746354", "0.6416918", "0.6353654", "0.6250323", "0.6239197", "0.62160206", "0.6171939", "0.6171135", "0.6128881", "0.6054407", "0.6031423", "0.60118514", "0.60109735", "0.5990503", "0.5983222", "0.59711397", "0.59528345", "0.59526265", "0.5937698", "0.59032255", "0.590044...
0.0
-1
before_action :authenticate_user! after_action :verify_authorized GET /profiles GET /profiles.json
def index @profiles = Profile.all #authorize Profile #@profiles = policy_scope(Profile) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def profile\n authorize @profile\n end", "def index\n @profiles = Profile.all\n authorize Profile\n end", "def verify_user!\n @profile = current_user.profile\n end", "def verify_user!\n @profile = current_user.profile\n end", "def authorize_user\n @profile = current_user.profile\n ...
[ "0.74503624", "0.71722484", "0.6820091", "0.6820091", "0.6755753", "0.6737981", "0.67029697", "0.66782886", "0.6662056", "0.66277826", "0.6623193", "0.65995055", "0.65858", "0.6580843", "0.65794194", "0.65794194", "0.65780073", "0.6577354", "0.6572222", "0.65187854", "0.65117...
0.6713309
6
GET /profiles/1 GET /profiles/1.json
def show @profile=Profile.find(params[:id]) authorize @profile #@profile=Profile.where(user==current_user) #authorize @profile #scope.where(:id => profile.id).exists? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_default_profile \n get(\"/profiles.json/default\")\nend", "def my_profiles\n @user = User.find(params[:user_id])\n @profiles = @user.profiles\n end", "def show\n profile = Profile.find(params[:id])\n render status: 200, json: profile\n end", "def index\n authorize Profile\n @profi...
[ "0.77750957", "0.7492967", "0.7487962", "0.7365612", "0.73054105", "0.730323", "0.7302192", "0.7245306", "0.7231901", "0.7231901", "0.7231901", "0.7218076", "0.7218076", "0.71648145", "0.7140797", "0.71136713", "0.7079478", "0.7045763", "0.7017897", "0.69909686", "0.6980009",...
0.0
-1
POST /profiles POST /profiles.json
def create @profile = Profile.new(profile_params) @profile.user=current_user respond_to do |format| if @profile.save format.html { redirect_to @profile, notice: 'Profile was successfully created.' } format.json { render :show, status: :created, location: @profile } else ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @profile = current_user.profiles.build(profile_params)\n\n respond_to do |format|\n if @profile.save\n format.html { redirect_to @profile, notice: 'Profile was successfully created.' }\n format.json { render action: 'show', status: :created, location: @profile }\n else\n ...
[ "0.73701555", "0.7367171", "0.72288865", "0.71786684", "0.7172963", "0.7170674", "0.71145105", "0.7096289", "0.707034", "0.7002038", "0.7002038", "0.7002038", "0.7002038", "0.7002038", "0.7002038", "0.7002038", "0.6997514", "0.69700205", "0.69617796", "0.6937631", "0.6937631"...
0.6656213
49
PATCH/PUT /profiles/1 PATCH/PUT /profiles/1.json
def update =begin @profile = Profile.find(params[:id]) authorize @profile if @profile.update(profile_params) #redirect_to @profile render :edit, notice: "Profile blah" else render :edit end =end authorize @profile respond_to do |format| if @profile.update(profile_pa...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @profiles = current_user.profiles.find(params[:id])\n\n respond_to do |format|\n if @profiles.update(profile_params)\n format.html { redirect_to profiles_path, notice: 'Profile was successfully updated.' }\n format.json { render :show, status: :ok, location: @profiles }\n ...
[ "0.7385554", "0.7121749", "0.7113102", "0.7096679", "0.7091465", "0.7091465", "0.7091465", "0.7076842", "0.707045", "0.7063198", "0.70600575", "0.7022012", "0.70120174", "0.699651", "0.6985236", "0.6985236", "0.6985236", "0.6985236", "0.6979028", "0.697453", "0.6968044", "0...
0.0
-1
DELETE /profiles/1 DELETE /profiles/1.json
def destroy @profile.destroy respond_to do |format| format.html { redirect_to profiles_url, notice: 'Profile was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @profile = Profile.find(params[:id])\n @profile.destroy\n\n respond_to do |format|\n format.html { redirect_to profiles_url }\n format.json { head :ok }\n end\n end", "def destroy\n @profile = Profile.find(params[:id])\n @profile.destroy\n\n respond_to do |format|\n ...
[ "0.77401114", "0.77401114", "0.77401114", "0.77085763", "0.77072567", "0.77071786", "0.77071786", "0.77071786", "0.77071786", "0.77071786", "0.77071786", "0.77071786", "0.77071786", "0.77048355", "0.7697158", "0.7688668", "0.7688453", "0.7688453", "0.7628023", "0.758936", "0....
0.7475511
50
Use callbacks to share common setup or constraints between actions.
def set_profile @profile = Profile.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163443", "0.604317", "0.5943409", "0.59143174", "0.5887026", "0.58335453", "0.57738566", "0.5701527", "0.5701527", "0.56534666", "0.5618685", "0.54237175", "0.5407991", "0.5407991", "0.5407991", "0.5394463", "0.5376582", "0.5355932", "0.53376216", "0.5337122", "0.5329516"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def profile_params params.require(:profile).permit(:name, :user_id, :id_no, :nationality, :tribe, :birth_place, :birth_date, :age, :height, :weight, :blood, :sex, :married, :religion, :id_address, :current_address, :email, :phone, :mobile_phone, languages_attributes: [:id, :name, :speec...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
For each payment transaction, compute next_retry date by joining with payment attempts
def build_transactions_next_retry_date! (transactions || []).each do |transaction| # Filter attempts matching that transaction and SCHEDULED for retry transaction.next_retry_date = (payment_attempts || []).select do |attempt| ((attempt.transaction_id && attempt.transaction_id == transact...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def retry_failed_payment\n end", "def retry_failed_payment\n pay_subscription.update(status: :active)\n end", "def calculate_retry_after(env); end", "def connect_retry_period\n NewRelic::CONNECT_RETRY_PERIODS[connect_attempts] || NewRelic::MAX_RETRY_PERIOD\n end", "def retr...
[ "0.63060164", "0.5869964", "0.57362664", "0.5598668", "0.547409", "0.54493165", "0.5443479", "0.53681946", "0.53515786", "0.5320229", "0.5283228", "0.52521306", "0.5246898", "0.51959753", "0.51182985", "0.5086357", "0.5073873", "0.5068836", "0.5057417", "0.5048785", "0.503475...
0.83332336
0
Upon intialization, sets the number of bits represented by the base system with bin_rep_length set_bit_vals is for later easy conversion between binary and base 10 the to_base10 and from_base10 tables are hashes for conversion between the Decoder's base system and base10
def initialize(bin_rep_length, values_table) @bin_rep_length = bin_rep_length @bit_vals = set_bit_vals @to_base10 = create_to_base10(values_table) @from_base10 = create_from_base10 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def from_bits(bin_num)\n base10_value = 0\n @bit_vals.each_with_index do |val,i|\n base10_value += val if bin_num[i] == '1'\n end\n base10_value\n end", "def initialize\n initialize__bit_set(BITS)\n end", "def base2to10(binary)\n\tresult = 0\n digits = binary.chars.reverse\n\n digit...
[ "0.6455914", "0.6381825", "0.6322617", "0.6304361", "0.62260205", "0.6159644", "0.61595136", "0.6039068", "0.60291755", "0.60240144", "0.597455", "0.59369975", "0.58854514", "0.5805435", "0.56567204", "0.563476", "0.5577113", "0.5563463", "0.55518574", "0.555148", "0.5495086"...
0.7518821
0
Converts base 10 number to its binary representation
def to_bits(base10_num) bits = @bit_vals.map do |b| if base10_num >= b base10_num -= b '1' else '0' end end bits.join end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_bin(number)\n number = Integer(number);\n if(number == 0)\n return 0;\n end\n ret_bin = \"\";\n ## Untill val is zero, convert it into binary format\n while(number != 0)\n ret_bin = String(number % 2) + ret_bin;\n number = number / 2;\n end\n return ret_b...
[ "0.7862223", "0.7731827", "0.76471907", "0.76293963", "0.73623765", "0.7323691", "0.73050916", "0.72874796", "0.7272941", "0.7258366", "0.7258366", "0.72337645", "0.71650064", "0.7147609", "0.71224064", "0.7052281", "0.7035411", "0.70352745", "0.70193446", "0.70161456", "0.69...
0.77469146
1
Converts binary number to its base 10 representation
def from_bits(bin_num) base10_value = 0 @bit_vals.each_with_index do |val,i| base10_value += val if bin_num[i] == '1' end base10_value end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def base2to10(binary)\n\tresult = 0\n digits = binary.chars.reverse\n\n digits.each_with_index do |bit, idx|\n result += bit.to_i * (2**idx)\n end\n\n result\nend", "def base2to10(binary)\n base_ten = 0\n binary.split(\"\").reverse.map {|digit| digit.to_i}.each_with_index {|digit, index| base_ten += dig...
[ "0.78407675", "0.75915766", "0.7482465", "0.74680126", "0.7451827", "0.7431397", "0.73943585", "0.738003", "0.73494256", "0.7219349", "0.7184033", "0.7166379", "0.7166379", "0.7137106", "0.71274215", "0.7101292", "0.70456356", "0.70428765", "0.70120853", "0.6955853", "0.69496...
0.7176821
11
Takes binary string and converts it to an array of base10 values corresponding to the Decoder's bitrepresentationallength
def from_bin(num_string) bin_vals = num_string.scan(eval("/.{#{@bin_rep_length}}/")) base10_vals = bin_vals.map{|bin_val| from_bits(bin_val)} convert_from_base10(base10_vals).join end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def binary_string_to_bit_array(string, minimum_binary_places = 0)\n number = binary_string_to_number(string)\n number_to_bit_array(number, minimum_binary_places)\n end", "def binarize(string)\n string.codepoints.to_a.map { |byte| byte.to_s(2).insert(0, '0') }\n end", "def to_bin(num_string)\n ...
[ "0.7126428", "0.70035106", "0.6751774", "0.6733262", "0.663262", "0.65680176", "0.65312564", "0.652504", "0.64213645", "0.6406656", "0.63898575", "0.6374789", "0.63716197", "0.6353512", "0.63373154", "0.63132143", "0.6307497", "0.62842107", "0.6283501", "0.6258818", "0.624932...
0.698176
2
Takes a collection of base10 values, converts each to binary strings, and than combines them into a long string of binary digits
def to_bin(num_string) digits = convert_to_base10(num_string) digits.map!{|char| to_bits(char)} digits.join end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def translate_to_binary(array_of_hex)\n array_of_binary = []\n array_of_hex.each do |num|\n array_of_binary << sprintf(\"%b\", num).rjust(32, '0')\n end\n array_of_binary\n end", "def binary_to_base_n(binaryarr, base)\n val = 0\n pow = 0\n while !binaryarr.empty?\n val += binaryarr.pop * ...
[ "0.7249088", "0.69703394", "0.68864954", "0.68641514", "0.6825285", "0.67661375", "0.6761984", "0.6748298", "0.6663248", "0.65849346", "0.6534985", "0.6488827", "0.64773303", "0.6441432", "0.6441403", "0.64386934", "0.64224255", "0.63790786", "0.6307707", "0.6304347", "0.6300...
0.67621416
6
previous and next elements with following exceptions. a) First element is replaced by multiplication of first and second. b) Last element is replaced by multiplication of last and second last. c) No additional space is available
def product_prev_next(array) previous = array.first array[0] = array[1]*array[2] (1..array.length - 2).to_a.each do |idx| current = array[idx] array[idx] = previous*array[idx + 1] previous = current end array[array.length - 1] = array[array.length - 1]*previous return array end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_products(arr)\n front_products_arr = [] # => [1, 1*7, 1*7*3, 1*7*3*4]\n back_products_arr = [] # => [4, 3*4, 7*3*4, 1*7*3*4]\n front_product = 1\n\n arr.each do |el|\n front_product *= el\n front_products_arr << front_product\n end\n\n back_product = 1\n (arr.length - 1).downto(0) do |el|\n ...
[ "0.5991394", "0.5815654", "0.5755412", "0.5639845", "0.5633176", "0.5625665", "0.5600123", "0.5600123", "0.55862105", "0.55420065", "0.5539502", "0.55339503", "0.5525219", "0.5512775", "0.5512775", "0.5512775", "0.5512775", "0.5512775", "0.5512775", "0.5512775", "0.5512775", ...
0.72741604
0
GET /chats GET /chats.json
def index @chats = Chat.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def chats(*args)\n @client.get \"#{@path}/chats\", Hash[*args]\n end", "def index\n @chats = Chat.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @chats }\n end\n end", "def index\n @chats = Chat.all\n render j...
[ "0.79146546", "0.78267837", "0.76089495", "0.7545856", "0.7382745", "0.7268848", "0.709166", "0.7038396", "0.70234394", "0.6981811", "0.6703983", "0.66710144", "0.66704315", "0.66272706", "0.66264606", "0.6612662", "0.6601793", "0.656423", "0.6473907", "0.6460072", "0.6409933...
0.74100566
7
GET /chats/1 GET /chats/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @chats = Chat.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @chats }\n end\n end", "def chats(*args)\n @client.get \"#{@path}/chats\", Hash[*args]\n end", "def index\n @chats = Chat.all\n render j...
[ "0.7665383", "0.7525226", "0.7379607", "0.7189698", "0.7189698", "0.7189698", "0.7189698", "0.715062", "0.71476597", "0.7104927", "0.70869774", "0.69691116", "0.6877022", "0.6864627", "0.68151164", "0.6800423", "0.6758586", "0.6733281", "0.6611941", "0.6574309", "0.6543439", ...
0.0
-1
POST /chats POST /chats.json
def create @chat = Chat.new(chat_params) @post = Post.find(@chat.post_id) respond_to do |format| if @chat.save notice_msg = 'Chat was successfully created.' if @post.alarmstat.nil? || @post.alarmstat =="대기" # 도로명 주소 체크 street_addr = street_address_check(@...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @chats = Chat.all\n render json: {\n messages: \"Request Successfull!\",\n is_success: true,\n data: { chats: @chats }\n }\n end", "def chats(*args)\n @client.get \"#{@path}/chats\", Hash[*args...
[ "0.67670375", "0.6633282", "0.65046585", "0.6174243", "0.6154161", "0.6154161", "0.6154161", "0.6154161", "0.6132711", "0.612273", "0.61213577", "0.60763067", "0.60693216", "0.6068579", "0.60097265", "0.59059495", "0.586816", "0.5838931", "0.58206654", "0.5751796", "0.5674825...
0.0
-1
PATCH/PUT /chats/1 PATCH/PUT /chats/1.json
def update @post = Post.find(@chat.post_id) respond_to do |format| if @chat.update(chat_params) format.html { redirect_to @post, notice: 'Chat was successfully updated.' } format.json { render :show, status: :ok, location: @chat } else format.html { render :edit } for...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @chat = Chat.find(params[:id])\n\n respond_to do |format|\n if @chat.update_attributes(params[:chat])\n format.html { redirect_to @chat, notice: 'Chat was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n ...
[ "0.6919387", "0.670133", "0.670133", "0.66508305", "0.6622718", "0.6622718", "0.6622718", "0.6620361", "0.6561504", "0.65305775", "0.6514072", "0.6399612", "0.6367317", "0.6335319", "0.6213637", "0.6130185", "0.6130185", "0.6038909", "0.6024623", "0.602163", "0.60097444", "...
0.5978874
23
DELETE /chats/1 DELETE /chats/1.json
def destroy @post = Post.find(@chat.post_id) @chat.destroy respond_to do |format| format.html { redirect_to @post, notice: 'Chat was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @chat = Chat.find(params[:id])\n @chat.destroy\n\n respond_to do |format|\n format.html { redirect_to chats_url }\n format.json { head :ok }\n end\n end", "def destroy\n @chat.destroy\n respond_to do |format|\n format.html { redirect_to chats_url }\n format.js...
[ "0.7667081", "0.7573413", "0.74805313", "0.741072", "0.737398", "0.7350283", "0.7299796", "0.7299511", "0.7299511", "0.7299511", "0.7227796", "0.71817446", "0.7088481", "0.7006677", "0.69708014", "0.69476014", "0.6943451", "0.6938919", "0.68676937", "0.67945397", "0.6765921",...
0.66853535
26
Use callbacks to share common setup or constraints between actions.
def set_chat @chat = Chat.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Only allow a list of trusted parameters through.
def chat_params params.require(:chat).permit(:post_id, :body) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end", "def param_whitelist\n [:role, :title]\...
[ "0.69490993", "0.6812977", "0.6801889", "0.67950445", "0.6745037", "0.6740698", "0.65270424", "0.6519444", "0.6492448", "0.6430671", "0.6430671", "0.6430671", "0.63992614", "0.6355569", "0.6354901", "0.63456345", "0.63430274", "0.63376623", "0.6327184", "0.6327184", "0.632718...
0.0
-1
kindly crafted by jeremyevans
def find(filters, &block) ds = db[:tokens.as(:t0)] f = filters[0] ds = ds.where(:t0__word_id=>f.word) if f.word ds = ds.where(:t0__tag_id=>f.tag) if f.tag i = 0 filters[1..-1].each do |f| as = "t#{i+=1}" h = {} h[:"#{as}__word_id"] = f.word if f.word h...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def probers; end", "def schubert; end", "def formation; end", "def anchored; end", "def terpene; end", "def stderrs; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def berlioz; end", "def suivre; end", "def rassoc(p0) end", "def ma...
[ "0.68047404", "0.65064085", "0.62896526", "0.6146195", "0.6130164", "0.61168534", "0.6093187", "0.6070439", "0.6070439", "0.6070439", "0.6070439", "0.59478784", "0.5934376", "0.59140325", "0.5900706", "0.5898032", "0.58777475", "0.58777475", "0.58777475", "0.58777475", "0.587...
0.0
-1
GET /kanjis/1 GET /kanjis/1.xml
def show @kanji = Kanji.find(params[:id]) @kanji_readings = @kanji.get_sorted_readings respond_to do |format| format.html # show.html.erb format.xml { render :xml => @kanji } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @kanjis = Kanji.all\n end", "def show\n @haiku = Haiku.find(params[:id])\n\n respond_to { |format|\n format.html # show.rhtml\n format.xml {\n\trender :xml => @haiku.to_xml\n }\n }\n end", "def index\n @kpis = Kpi.find(:all)\n\n respond_to do |format|\n forma...
[ "0.6297763", "0.62916285", "0.6185104", "0.5980898", "0.5882061", "0.58544034", "0.58006877", "0.5770563", "0.5749268", "0.5747057", "0.5743677", "0.573931", "0.5725725", "0.57237905", "0.5722759", "0.56978583", "0.56857616", "0.5677395", "0.5647206", "0.5632259", "0.5628366"...
0.66206336
0
Generate user structure and configure it
def generate_user(package_dir) system "rails generate devise:install" replace('config/environments/development.rb', "config.action_mailer.raise_delivery_errors \= false", "config.action_mailer.raise_delivery_errors = false\n\tconfig.action_mailer.default_url_options = { host: 'localhost:3000' }") system ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup\n make_config\n make_users_file\n end", "def generate_user_model\n template \"model.rb.erb\", \"app/models/#{file_name}.rb\"\n generate \"migration\", \"#{migration_name_for_array}\", \"login:string\", \"group_strings:string\", \"name:string\", \"ou_strings:string\"...
[ "0.7013916", "0.65522045", "0.6525142", "0.64941984", "0.6354751", "0.6323286", "0.6298813", "0.62824893", "0.6266576", "0.6248213", "0.6220059", "0.62139094", "0.6210572", "0.6191411", "0.6166987", "0.6138412", "0.6102421", "0.60926366", "0.6091937", "0.60723054", "0.6052486...
0.67875457
1
Add roles to user and create an admin
def add_role(package_dir) replace('app/models/user.rb', "Base", "Base\n enum role: [:default_user, :admin]\n before_validation :set_default_role, :if => :new_record?\n # Return true if User is an Admin\n def is_admin?\n self.role == \"admin\" ? true : false\n end\n # Define the default role\n def se...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_admin\n authorize! @user\n @user.roles = @user.roles + ['admin']\n @user.save\n redirect_to @user, notice: t('user.made_admin', name: @user.username)\n end", "def register_admin(attributes)\n user = register_user(attributes)\n user.add_role(Role::Admin)\n user.save\n user\n end...
[ "0.79850066", "0.75147414", "0.7320484", "0.72914666", "0.7223663", "0.71604145", "0.71301186", "0.7077511", "0.7067972", "0.70661885", "0.7064258", "0.70611984", "0.70423317", "0.70165455", "0.7002789", "0.6931116", "0.6922182", "0.6916024", "0.6898445", "0.689517", "0.68924...
0.7170056
5
Plug a browserid authentication into the project using it's generator
def auth_browserid(package_dir) replace('Gemfile', "gem 'devise'", "gem 'devise'\ngem 'devise_browserid_authenticatable'") Bundler.with_clean_env do system "bundle install" end system "rails g auth_browserid" system "git add -A" system "git commit -m 'Add browserid_authentication'" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def web\n _auth(false)\n end", "def web_auth\n\t\tauth ::UWeb\n\tend", "def new\n response.headers['WWW-Authenticate'] = Rack::OpenID.build_header(\n :identifier => \"https://www.google.com/accounts/o8/id\",\n :required => [\"http://axschema.org/contact/email\",\n \"ht...
[ "0.6048563", "0.5993108", "0.5965738", "0.58693814", "0.5864474", "0.5837727", "0.5837727", "0.5794243", "0.5701488", "0.5597572", "0.5569378", "0.5556136", "0.5540012", "0.55368984", "0.55179125", "0.5515923", "0.5511776", "0.55027103", "0.5492693", "0.5488175", "0.5485909",...
0.72877955
0
Plug a scaffoled angular object into the project using it's generator
def angular_scaffold object = get_stdin("What is the Object name to scaffold? ") puts "Describe your structure like a model generation :\nnom:string description:text prix:decimal rdv:date validation:boolean heure:time creation:datetime" parameters = get_stdin("What's the structure of the object? ") system "rail...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_angular_controller\n @AppName = Rails.application.class.name.split('::').first\n template \"assets/javascripts/controller.js.erb\", \"app/assets/javascripts/controllers/#{class_name.tableize}_ctrl.js\"\n template \"assets/javascripts/service.js.erb\", \"app/assets/javascripts/services/#{class_n...
[ "0.56999224", "0.5663377", "0.5541926", "0.5493649", "0.54750526", "0.5470581", "0.5412002", "0.54006815", "0.53086036", "0.52627856", "0.52448463", "0.52298653", "0.5183638", "0.5132325", "0.5103365", "0.5097883", "0.5087409", "0.5070811", "0.49673036", "0.4966328", "0.49579...
0.64812577
0
Prompt a message and return the user catched response
def get_stdin(message) print message STDIN.gets.chomp end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prompt(message)\n\tprint messaage\n\tgets.chomp # implicit return\nend", "def prompt(message)\n\tprint message\n\tgets.chomp #Implicit Return\nend", "def prompt( message )\n\tprint message\n\tgets.chomp\nend", "def prompt(message)\n puts(\"#{message}\")\nend", "def prompt message\n puts (\"=> #{messa...
[ "0.7648423", "0.7409657", "0.73927695", "0.7388678", "0.7362653", "0.73442054", "0.7316179", "0.7311742", "0.73011553", "0.72808814", "0.72229797", "0.72214437", "0.72214437", "0.72214437", "0.72214437", "0.72214437", "0.7213799", "0.7211394", "0.7211252", "0.72090876", "0.72...
0.0
-1
Ask a question to the user using the prompt until it can return one of the authorised response.
def ask(message, valid_options) if valid_options answer = get_stdin("#{message} #{valid_options.to_s.gsub(/"/, '').gsub(/, /,'/')} ") while !valid_options.include?(answer) else answer = get_stdin(message) end answer end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def confirm(prompt)\n return true if config[:yes]\n valid_responses = %w[yes no y n]\n response = nil\n 3.times do\n response = ui.ask(prompt).downcase\n break if valid_responses.include? response\n ui.warn \"Valid responses are #{valid_responses}\"\n e...
[ "0.7365857", "0.7196102", "0.71816814", "0.7175948", "0.7152766", "0.71187323", "0.7064117", "0.70335764", "0.6974391", "0.6971461", "0.69640243", "0.69330335", "0.6903226", "0.68922555", "0.6862046", "0.6834442", "0.6795738", "0.6767129", "0.67250943", "0.6712743", "0.670796...
0.61635065
89
Replace in a file the original text by the new one
def replace(file, original_text, new_text) text=File.open(file).read text.gsub!("#{original_text}", "#{new_text}") File.open(file, 'w') { |f| f.puts text } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def justLikeSed(file, text_to_replace, text_to_put_in_place)\n text = File.read(file)\n File.open(file, 'w+'){|f| f << text.gsub(text_to_replace, text_to_put_in_place)}\n end", "def rename_text_in_file(file, text1, text2)\n oldf = File.read(file)\n newf = oldf.gsub(text1, text2)\n File.open(f...
[ "0.83191043", "0.8151142", "0.7560415", "0.74405605", "0.74309146", "0.7344409", "0.7104795", "0.70728004", "0.70688164", "0.70381975", "0.7022374", "0.6970336", "0.6948689", "0.69333965", "0.69219095", "0.686725", "0.6849654", "0.67905086", "0.6759032", "0.6679743", "0.66449...
0.8757788
0
GET /authors GET /authors.json
def index @q = Author.ransack(params[:q]) # The sortable_name field gives the last name downcased with "ae" etc substituted for umlauted vowels @authors = @q.result.paginate(:page => params[:page], :per_page => 14).order(sortable_name: :asc, firstnames: :asc) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @authors = Author.all\n respond_with(@authors)\n end", "def books_author\n \t@books = Book.where(\"author = '#{params[:author]}'\")\n\n \trespond_to do |format|\n format.html # list_authors.html.erb\n format.json { render json: @books }\n end\n end", "def get_all_authors\n ...
[ "0.73789465", "0.734006", "0.7324713", "0.7206859", "0.71034527", "0.71034527", "0.71034527", "0.71034527", "0.7087016", "0.6994201", "0.6956097", "0.69255227", "0.69136065", "0.6901084", "0.68867576", "0.67938435", "0.67836034", "0.6724546", "0.67178446", "0.6680906", "0.664...
0.6068023
66
GET /authors/1 GET /authors/1.json
def show # Collect the performances for this author, omitting any where receipts = "NA", which would break sorting on that column performances = Event.includes(:works => :authors).where(authors: {id: @author.id}).where.not(receipts: "NA") case params[:column] when "date" @performances = perfo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def books_author\n \t@books = Book.where(\"author = '#{params[:author]}'\")\n\n \trespond_to do |format|\n format.html # list_authors.html.erb\n format.json { render json: @books }\n end\n end", "def show\n @author = Author.find(params[:id])\n\n respond_to do |format|\n format.html # s...
[ "0.7241471", "0.7194377", "0.71588534", "0.71517754", "0.7103072", "0.7009007", "0.69826216", "0.6974261", "0.6974261", "0.6974261", "0.6974261", "0.6854486", "0.68104583", "0.6734537", "0.6721363", "0.6721363", "0.6711179", "0.6661174", "0.66539526", "0.66314626", "0.6620286...
0.0
-1
POST /authors POST /authors.json
def create @author = Author.new(allowed_params) respond_to do |format| if @author.save format.html { redirect_to @author, notice: 'Author was successfully created.' } format.json { render :show, status: :created, location: @author } else format.html { render :new } f...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_authors\n text = params[:text]\n puts \"str:#{text}\"\n request = Net::HTTP::Post.new(\"/personality-api/1/add_authors.json\")\n request.basic_auth BmnPersonalityApiSkeletonRor::Application.config.user_name, BmnPersonalityApiSkeletonRor::Application.config.password\n request.set_form_data({ ...
[ "0.7052174", "0.6843918", "0.6771882", "0.6762638", "0.6762638", "0.6762638", "0.6762638", "0.6716757", "0.67149067", "0.67146254", "0.6694734", "0.66528314", "0.6534085", "0.6532489", "0.64764696", "0.640759", "0.6296298", "0.62807626", "0.62807626", "0.62635654", "0.6248924...
0.6489433
14
PATCH/PUT /authors/1 PATCH/PUT /authors/1.json
def update respond_to do |format| if @author.update(allowed_params) format.html { redirect_to @author, notice: 'Author was successfully updated.' } format.json { render :show, status: :ok, location: @author } else format.html { render :edit } format.json { render json: @a...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @book.authors = params[:book][:authors].delete_if { |x| x == '' }.map { |i| Author.find(i) } if params[:book][:authors].present?\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json ...
[ "0.70448047", "0.7006759", "0.69329786", "0.6877541", "0.679697", "0.679697", "0.67763484", "0.66874194", "0.66874194", "0.66874194", "0.66874194", "0.66874194", "0.65901077", "0.65720236", "0.64946705", "0.64946705", "0.6454627", "0.6431908", "0.63731015", "0.6362323", "0.63...
0.6345524
21
DELETE /authors/1 DELETE /authors/1.json
def destroy @author.destroy respond_to do |format| format.html { redirect_to authors_url, notice: 'Author was successfully deleted.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @author.destroy\n respond_to do |format|\n format.html { redirect_to authors_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @author.destroy\n respond_to do |format|\n format.html { redirect_to authors_url }\n format.json { head :no_content ...
[ "0.77081424", "0.77081424", "0.7663374", "0.7663374", "0.7537297", "0.7506595", "0.74627244", "0.74623126", "0.74623126", "0.74623126", "0.74623126", "0.74623126", "0.74623126", "0.74574333", "0.74574333", "0.7445493", "0.7271057", "0.72609174", "0.72482145", "0.72442526", "0...
0.75365525
5
Use callbacks to share common setup or constraints between actions.
def set_author @author = Author.friendly.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def author_params params.fetch(:author, {}) 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.69802505", "0.6781974", "0.67470175", "0.67430073", "0.67350477", "0.6593221", "0.6504263", "0.64988977", "0.6481794", "0.64800006", "0.64568025", "0.64411247", "0.6379476", "0.63765615", "0.6368045", "0.6320141", "0.6300363", "0.6300057", "0.62952244", "0.6294712", "0.629...
0.0
-1
White list for sortable columns
def sortable_columns ["date", "dow", "sortable_title", "receipts"] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sortable_columns\n @sortable_columns ||= ['Passport.name']\n end", "def sortable_columns\n # list columns inside the Array in string dot notation.\n # Example: 'users.email'\n # @sortable_columns ||= []\n @sortable_columns ||= ['users.name' ,'users.phone', 'users.address']\n end", "def __s...
[ "0.7323926", "0.6926004", "0.6776055", "0.67265266", "0.669787", "0.63959783", "0.6390987", "0.6388406", "0.63676506", "0.63198656", "0.63166183", "0.62066907", "0.61418295", "0.61016744", "0.6062134", "0.6061028", "0.6059048", "0.6031852", "0.60284984", "0.60255057", "0.6008...
0.7040319
1
GET /songs GET /songs.json
def index @songs = Song.all.order(:name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def songs\n \t@songs = Album.find(params[:id])\n songs = RSpotify::Track.search(@songs.name)\n \t@songs = songs.map do |s_songs|\n \tSong.new_from_spotify_song(s_songs)\n end\n render json: {data:@songs}\n end", "def index\n \n @songs = Song.order 'id'\n\n respond_to do |format|\n f...
[ "0.8023557", "0.772287", "0.7639002", "0.7577367", "0.7519796", "0.7518334", "0.74522924", "0.74318486", "0.7406608", "0.7387082", "0.7190135", "0.7173719", "0.7173719", "0.7173719", "0.7173719", "0.7109256", "0.70980364", "0.70968103", "0.7045383", "0.7045383", "0.7045383", ...
0.0
-1
GET /songs/1 GET /songs/1.json
def show @songtags = @song.tags.collect{ |t| t.name } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @song = Song.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @song }\n end\n end", "def getSong\n\t\tid = params[:songId]\n\t\tresult = GetSongFromSpotify.build.call(id)\n\t\trender json: result\n\tend", "def show\n @song = Song.find(params[:id])\n\n re...
[ "0.7938354", "0.7895859", "0.7706705", "0.7706705", "0.7706705", "0.7706705", "0.76346755", "0.7571089", "0.75562555", "0.75397277", "0.7520489", "0.7483983", "0.74218845", "0.7320445", "0.7221914", "0.7221914", "0.71899533", "0.7179004", "0.7111133", "0.7081457", "0.70678484...
0.0
-1
POST /songs POST /songs.json
def create params = song_params songkey = params['song_key'] params.delete('song_key') songtags = params['tags'] params.delete('tags') @song = Song.new(params) respond_to do |format| if @song.save if songkey.to_s.length > 0 @song.song_keys << SongKey.find(songkey) end ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def songs\n \t@songs = Album.find(params[:id])\n songs = RSpotify::Track.search(@songs.name)\n \t@songs = songs.map do |s_songs|\n \tSong.new_from_spotify_song(s_songs)\n end\n render json: {data:@songs}\n end", "def create\n puts params[:song]\n @song = Song.new params[:song]\n create_s...
[ "0.73076195", "0.7291439", "0.72278845", "0.7215545", "0.7178595", "0.71732724", "0.71732724", "0.7123151", "0.7123151", "0.7123151", "0.7095731", "0.7069204", "0.7063301", "0.70460635", "0.7038803", "0.7028207", "0.701447", "0.6972163", "0.69503105", "0.69500434", "0.6777388...
0.7317289
0
PATCH/PUT /songs/1 PATCH/PUT /songs/1.json
def update #require 'logger' params = song_params songkey = params['song_key'] params.delete('song_key') songtags = params['tags'] params.delete('tags') respond_to do |format| if @song.update(params) if songkey.to_s.length > 0 @song.song_keys = [SongKey.find(songkey)] else ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n \n \n respond_to do |format|\n updated_params = song_params\n if (@song.artist != song_params[:artist] || @song.songname != song_params[:songname])\n uri = 'http://developer.echonest.com/api/v4/song/search?api_key=6XUOAXHJOW28GGGRH&format=json&results=1&artist=' + Rack::Utils...
[ "0.73954433", "0.73340166", "0.72903585", "0.7279346", "0.72707385", "0.72707385", "0.72707385", "0.72455156", "0.72016114", "0.71914345", "0.7184574", "0.7184574", "0.7184574", "0.7184574", "0.7184574", "0.7184574", "0.7184574", "0.7184574", "0.7183858", "0.7183078", "0.7183...
0.73646814
1
DELETE /songs/1 DELETE /songs/1.json
def destroy @song.destroy respond_to do |format| format.html { redirect_to songs_url, notice: "#{@song.name} was successfully deleted!" } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @song = Song.find(params[:id])\n @song.destroy\n\n respond_to do |format|\n format.html { redirect_to songs_url }\n format.json { head :ok }\n end\n end", "def destroy\n @song = Song.find(params[:id])\n @song.destroy\n\n respond_to do |format|\n format.html { re...
[ "0.7993327", "0.79589206", "0.79589206", "0.79589206", "0.79589206", "0.79589206", "0.79589206", "0.7946083", "0.787302", "0.787302", "0.787302", "0.787302", "0.787302", "0.787302", "0.787302", "0.77688175", "0.7692386", "0.76777565", "0.76777565", "0.76777565", "0.76777565",...
0.77754766
15
Use callbacks to share common setup or constraints between actions.
def set_song @song = Song.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_...
[ "0.6163163", "0.6045976", "0.5946146", "0.591683", "0.5890051", "0.58349305", "0.5776858", "0.5703237", "0.5703237", "0.5652805", "0.5621621", "0.54210985", "0.5411113", "0.5411113", "0.5411113", "0.5391541", "0.53794575", "0.5357573", "0.53402257", "0.53394014", "0.53321576"...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def song_params params.require(:song).permit(:name, :author, :media_link, :lyrics, :composer, :song_key, tags: []) 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.69802505", "0.6781974", "0.67470175", "0.67430073", "0.67350477", "0.6593221", "0.6504263", "0.64988977", "0.6481794", "0.64800006", "0.64568025", "0.64411247", "0.6379476", "0.63765615", "0.6368045", "0.6320141", "0.6300363", "0.6300057", "0.62952244", "0.6294712", "0.629...
0.0
-1
You should be able to do this without looking at the input.
def non_comparison_sort(arr) result = [] i = 1 while i <= arr.length result << i i+=1 end p result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def input; end", "def input; end", "def input; end", "def input; @input; end", "def input; @input; end", "def input_string; end", "def input=(_arg0); end", "def preprocess_input(input)\n input\nend", "def preprocess_input(input)\nend", "def read_input; end", "def solution4(input)\n end", "d...
[ "0.7055296", "0.7055296", "0.7055296", "0.676751", "0.676751", "0.65413314", "0.6498853", "0.63986146", "0.6321144", "0.61060196", "0.6078253", "0.6077784", "0.6075009", "0.60634077", "0.60618997", "0.6042429", "0.60096794", "0.5983701", "0.59496987", "0.5922066", "0.57348776...
0.0
-1
Part 2: Say that I give you an array of length n with numbers in the range 1..N (N >= n). Sort this array in O(n + N) time. You may use O(N) memory.
def sort2(arr, upper_bound) hash = {} result = [] arr.each { |el| hash[el] = true } (1..upper_bound).each do |el| result << el if hash[el] end p result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sort2(num_array)\n n = num_array.length - 1\n for i in 0..n\n for j in 0..(n-i-1)\n if num_array[j] >= num_array[j+1]\n num_array[j], num_array[j+1] = num_array[j+1], num_array[j]\n end\n end\n end\n return num_array\nend", "def using_sort(array)...
[ "0.77659744", "0.7460219", "0.7460219", "0.7416416", "0.7412474", "0.73646533", "0.73511106", "0.73010695", "0.73010695", "0.73010695", "0.7284361", "0.72498137", "0.72494775", "0.7241375", "0.721438", "0.7192642", "0.7188209", "0.7148968", "0.7094817", "0.70917577", "0.70648...
0.0
-1
Part 3: Say I give you an array of n strings, each of length k. I claim that, using merge sort, you can sort this in O(knlog(n)), since comparing a pair of strings takes O(k) time. I want you to beat that. Sort the strings in O(kn). Hint: do not compare any two strings.assume all strings contain only lowercase letters ...
def sort3(strings, length) i = length - 1 letters = ("a".."z").to_a while i >= 0 # O(k) buckets = Array.new(26) {[]} strings.each do |string| buckets[letters.find_index(string[i])] << string # O(n) end strings = buckets.flatten i-=1 end...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def double_sort(arr)\n sorted_strings = []\n arr.each do |string|\n sorted_strings << string.sort\n end\n #O(n * m * log m, where m is the length of the longest string)\n sorted_strings.sort\n # there are n * log n comparisons in this sort, but each string\n # comparisons takes m time to perform.\n # Th...
[ "0.7765794", "0.7605322", "0.7224775", "0.7099543", "0.7074057", "0.7017791", "0.6964214", "0.6889369", "0.6830731", "0.6800979", "0.6795807", "0.67601585", "0.67323256", "0.6719761", "0.6711487", "0.6708793", "0.6705158", "0.66892576", "0.6686751", "0.6645355", "0.66282", ...
0.7524354
2
"car" "cat" "bat" "bat" "car" 'cat' Remove Duplicates from Sorted Array Given a SORTED array, remove the duplicates inplace such that each element appear only once and return the new length. Do not allocate extra space for another array, you must do this by modifying the input array inplace with O(1) extra memory. Exam...
def remove_duplicates(arr) (arr.length - 1).times do |i| next if arr[i] != arr[i+1] arr.delete_at(i) end p arr end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_duplicates(nums)\n counter = 0 # Establish a counter variable to keep track of the amount of duplicates\n original_length = nums.length # Hold a reference to the original length of the array because the array without duplicates will have less elements\n\n (1...nums.length).each do |i| # Iterate throu...
[ "0.7762954", "0.7672762", "0.75565696", "0.75481385", "0.75438446", "0.7525972", "0.73946226", "0.7334712", "0.7289712", "0.70155317", "0.7003661", "0.69927764", "0.69779295", "0.6965288", "0.69523156", "0.6951019", "0.69375664", "0.6865924", "0.68634593", "0.6810266", "0.680...
0.62960076
67
Finds the full path of the shell specified in "shell"
def shell_path value = shell_name.to_s if value.match(/^\//) # Absolute path already provided (starts with "/") value.p else # Shell name provided, use "which" to find the executable which(value).p end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shell_path\n Configuration.disable_bc_shell? ? nil : Pathname.new('/bin/bash')\n end", "def get_shell_name\n psout = cmd_exec('ps -p $$').to_s\n psout.split(\"\\n\").last.split(' ')[3]\n rescue\n raise 'Unable to gather shell name'\n end", "def get_path\n cmd_exec('echo $PATH').to_s\n...
[ "0.70136124", "0.6870929", "0.65042317", "0.63012505", "0.62616444", "0.62573415", "0.6212856", "0.6115998", "0.6051774", "0.60274786", "0.5952512", "0.5860124", "0.5799127", "0.5795498", "0.5774069", "0.57699484", "0.5764714", "0.5747936", "0.57305616", "0.57212096", "0.5721...
0.82979614
0
redefine your position_taken? method here, so that you can use it in the valid_move? method above.
def position_taken?(board,index) board[index] != "" and board[index] != " " and board[index] != nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def position_taken?(board, position)\n return false if valid_move?(board, position)\n return true unless valid_move?(board, position)\nend", "def position_taken?\nend", "def valid_move?(board, index)\n if index.between?(0, 8)\n # re-define your #position_taken? method here, so that you can use it in the #v...
[ "0.8409533", "0.8161412", "0.80915326", "0.802741", "0.80150443", "0.78980684", "0.7893883", "0.7886275", "0.78447807", "0.7843449", "0.7831682", "0.78148174", "0.7813732", "0.7810363", "0.78020334", "0.7801113", "0.7800951", "0.7789361", "0.7782831", "0.777421", "0.7774137",...
0.0
-1
Define display_board that accepts a board and prints out the current state.
def display_board(board) board.each_with_index { |e, i| if i % 3 != 2 print " #{e} |" else puts " #{e} " puts "-----------" end } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\n end", "def display_board(board)\n puts \" #{board[0]} | #{boar...
[ "0.8280137", "0.8280137", "0.8258388", "0.818917", "0.8147858", "0.8120013", "0.8105397", "0.8104125", "0.8104125", "0.80760556", "0.80672216", "0.806306", "0.80533534", "0.80533534", "0.80533534", "0.80533534", "0.80533534", "0.80533534", "0.80533534", "0.80533534", "0.80533...
0.0
-1
Jekyll::StaticFile doesn't expose a `site` accessor, so we require an explicit `site` argument here.
def initialize(page, site) @page = page @site = site end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate(site)\n site.static_files.clone.each do |sf|\n if sf.kind_of?(Jekyll::StaticFile) && sf.path =~ /\\.coffee$/\n site.static_files.delete(sf)\n name = File.basename(sf.path)\n destination = File.dirname(sf.path).sub(site.source, '')\n site.stat...
[ "0.6251668", "0.62361246", "0.61996055", "0.6151398", "0.615098", "0.6142073", "0.60596997", "0.5998823", "0.5967783", "0.59672064", "0.59641814", "0.5962222", "0.59601104", "0.595187", "0.5950132", "0.5936033", "0.593496", "0.59342164", "0.59121126", "0.5911418", "0.58624846...
0.0
-1
Make examples two_digit_sum(34) == 7 ==> 3 + 4 == 7 Draw the process Write the solution in english take two digits, split them? loop through them, then convert to integers. Next, add them. Write it in code
def two_digit_sum(nums) if nums.integer? string = nums.to_s.split(//) return string[0].to_i + string[1].to_i else print "Please pass a valid two-digit argument" end return end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def two_to_sum(n)\n result = 2 ** n\n \n result.to_s.split('').map {|x| x.to_i }.reduce(:+)\nend", "def sum(number)\n sum = 0\n str_digits = number.to_s.chars\n\n str_digits.each do |str_digit|\n sum += str_digit.to_i\n end\n\n sum\nend", "def sum(number)\n number.to_s.chars.map(&:to_i).reduce(:+)\...
[ "0.73497874", "0.73265696", "0.7322992", "0.7300539", "0.7297931", "0.72797984", "0.72797984", "0.7264478", "0.7261394", "0.7249407", "0.72274107", "0.7215314", "0.720967", "0.7199152", "0.7172494", "0.7172494", "0.7171864", "0.7159476", "0.71469545", "0.7135866", "0.7133503"...
0.74794143
0
two_digit_sum(52) Define a method, orders_of_magnitude, that accepts an integer as an argument. Your method should return the number of digits in the integer. Make examples orders_of_magnitude(99) == 2 orders_of_magnitude(1034) == 4 Draw the process
def orders_of_magnitude(int) if int.integer? # add regex express to remove decimals or commas to_arr = int.to_s.split(//) return to_arr.length else return "#{int}, please provide a valid integer" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum(integer)\n integer.digits.sum\nend", "def sum_digits(num)\n\nend", "def digit_sum(int)\n return int.digits.sum\nend", "def sum(n)\n n.digits.sum\nend", "def two_to_sum(n)\n result = 2 ** n\n \n result.to_s.split('').map {|x| x.to_i }.reduce(:+)\nend", "def sum(int)\n int.digits.sum\nend", ...
[ "0.68853694", "0.6868283", "0.6863253", "0.67975324", "0.6795401", "0.67766047", "0.67566323", "0.6713192", "0.6700735", "0.6697871", "0.6697871", "0.6678866", "0.66741264", "0.65938884", "0.6580835", "0.6578994", "0.6576654", "0.65708506", "0.65468144", "0.6534288", "0.65342...
0.6651032
13
Define a method, accurate_division, that accepts two integers as arguments. Your method should return the quotient of the two integers (rounding to 3 decimal places). Make examples accurate_division(3, 4) == 0.75 accurate_division(1, 3) == 0.333 accurate_division(7, 6) == 1.167
def accurate_division(int, int_two) int = int.to_f int_two = int_two q = int / int_two return q.round(3) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def division (first_number, second_number)\nfirst_number / second_number\nend", "def division num1, num2\n total = num1.to_i / num2.to_i\n puts \"--> The total is... #{total}\"\nend", "def divide(num1, num2)\n num2.to_f / num1.to_f;\nend", "def divide (a,b)\n f = a.to_i / b.to_i\n puts \"Division...
[ "0.76112026", "0.75696284", "0.75093406", "0.7463701", "0.7416173", "0.7416173", "0.7416173", "0.74113244", "0.7396878", "0.7376012", "0.7345859", "0.73123753", "0.7244091", "0.7216246", "0.71999913", "0.718264", "0.71754056", "0.7150109", "0.71248907", "0.7107175", "0.709793...
0.8236748
0
Define a method, two_digit_format, that accepts an integer, n, and returns a string version of that integer. If the integer has a single digit, you should append a 0. You can assume that n will always be two or fewer digits. Hint: try creating a string using '0' + n.to_s, then use slice to get the last two digits! Make...
def two_digit_format(n) arr = n.to_s.split(//) if arr.length == 0 return '0' + arr[0] elsif arr.length >=3 return else return n.to_i end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def two_digits_number(x)\n x < 10 ? \"0#{x}\" : x.to_s\n end", "def convertToTwoDigitString inInt\n if inInt < 10 \n return \"0\" + inInt.to_s;\n end\n inInt.to_s\n end", "def getTwoDigitNumberStr(twoDigitVal)\n\t\tnumStr = \"\"\n\t\tunless getNumberAsStr[twoDigitVal].blank?\n\t\t\tnumStr = ...
[ "0.73389786", "0.73176664", "0.7294786", "0.7174953", "0.70090145", "0.6983002", "0.69797456", "0.6830891", "0.6816162", "0.67322224", "0.67123574", "0.6665603", "0.6648584", "0.6633296", "0.6629678", "0.6599613", "0.65913236", "0.65913236", "0.6577778", "0.65761864", "0.6535...
0.828311
0
def two_digit_format(n) string_number = '0' + n.to_s string_number[2, 2] end Define a method, time_string that accepts 3 arguments: hours, minutes, and seconds (all integers). Convert these integers into one contiguous time string that has the following format: "hh:mm:ss" Use the method, two_digit_format, to help you d...
def time_string(h, m, s) n = [] n[0] = h n[1] = m n[2] = s # all greater than if n[0] >= 10 && n[1] >= 10 && n[2] >= 10 return "#{n[0]}:#{n[1]}:#{n[2]}" # less, greater, greater elsif n[0] < 10 && n[1] >= 10 && n[2] >= 10 return "0#{n[0]}:#{n[1]}:#{n[2]}" # less, less, greater elsif...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format_time(time)\n format('%02d', time)\nend", "def print_time(nbr_secs)\n secs = nbr_secs.to_i\n mins = secs / 60\n hours = mins / 60\n return \"#{hours}:#{sprintf('%.2d',mins % 60)}:#{sprintf('%.2d',secs % 60)}\"\n end", "def time_string\r\n clock = @seconds.divmod(60)\r\n if...
[ "0.7565398", "0.7321263", "0.73102796", "0.73098457", "0.7271003", "0.7263661", "0.72598815", "0.7256699", "0.72462815", "0.72343504", "0.7233823", "0.72326297", "0.72308224", "0.71990055", "0.71917284", "0.7189824", "0.7186776", "0.71730536", "0.7148406", "0.7087759", "0.708...
0.74540704
1
Get metric timeseries data Returns timeseries data for a specific metric
def get_metric_timeseries_data(metric_id, opts = {}) data, _status_code, _headers = get_metric_timeseries_data_with_http_info(metric_id, opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def metric\n\t\tc = current_user.company\n\t\tm = Metric.find(params[:metric]).class\n\t\td = m.get_datum(c)\n\t\tif d.nil?\n\t\t\trender :nothing => true, :status => 404\n\t\telse\n\t\t\trender :json => { :timestamp => d.created_at, :value => d.value }\n\t\tend\n\tend", "def get_metric_timeseries_data_with_http...
[ "0.6656324", "0.66536874", "0.6547818", "0.65278", "0.65147054", "0.63442576", "0.6281096", "0.6127694", "0.6117827", "0.6105542", "0.60731244", "0.6069837", "0.59900653", "0.5981118", "0.59429723", "0.5924849", "0.5905299", "0.5874431", "0.5867225", "0.5814606", "0.57975966"...
0.6660245
1
Get metric timeseries data Returns timeseries data for a specific metric
def get_metric_timeseries_data_with_http_info(metric_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsApi.get_metric_timeseries_data ...' end # verify the required parameter 'metric_id' is set if @api_client.config.client_side_validation...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_metric_timeseries_data(metric_id, opts = {})\n data, _status_code, _headers = get_metric_timeseries_data_with_http_info(metric_id, opts)\n data\n end", "def get_metric_timeseries_data(metric_id, opts = {})\n data, _status_code, _headers = get_metric_timeseries_data_with_http_info(metric...
[ "0.6660245", "0.6660245", "0.6656324", "0.66536874", "0.6547818", "0.65278", "0.65147054", "0.63442576", "0.6127694", "0.6117827", "0.6105542", "0.60731244", "0.6069837", "0.59900653", "0.5981118", "0.59429723", "0.5924849", "0.5905299", "0.5874431", "0.5867225", "0.5814606",...
0.6281096
8
Get Overall values Returns the overall value for a specific metric, as well as the total view count, watch time, and the Mux Global metric value for the metric.
def get_overall_values(metric_id, opts = {}) data, _status_code, _headers = get_overall_values_with_http_info(metric_id, opts) data end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_overall_values_with_http_info(metric_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: MetricsApi.get_overall_values ...'\n end\n # verify the required parameter 'metric_id' is set\n if @api_client.config.client_side_validation && me...
[ "0.6824738", "0.6272673", "0.62253237", "0.60547054", "0.5862908", "0.5590975", "0.55274624", "0.55248857", "0.55248857", "0.5517798", "0.551697", "0.5498269", "0.54755694", "0.5438259", "0.54236573", "0.54187846", "0.5392694", "0.53698164", "0.53668374", "0.5350503", "0.5297...
0.63988125
2
Get Overall values Returns the overall value for a specific metric, as well as the total view count, watch time, and the Mux Global metric value for the metric.
def get_overall_values_with_http_info(metric_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: MetricsApi.get_overall_values ...' end # verify the required parameter 'metric_id' is set if @api_client.config.client_side_validation && metric_id.ni...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_overall_values_with_http_info(metric_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: MetricsApi.get_overall_values ...'\n end\n # verify the required parameter 'metric_id' is set\n if @api_client.config.client_side_validation && me...
[ "0.68236285", "0.63958347", "0.63958347", "0.6271895", "0.6055727", "0.58638144", "0.55898225", "0.5527015", "0.55226856", "0.55226856", "0.552012", "0.5519058", "0.54984415", "0.54763705", "0.5439978", "0.54239625", "0.5419614", "0.5393777", "0.5370056", "0.53664815", "0.534...
0.622393
4