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
Prints matrix to Standard Output
def print_matrix width = @rows.flatten.max.to_s.size if width > 4 then width = width - 0.5 end puts @rows.map { |a| "|#{ a.map { |i| outp = "" num, den = i.to_fraction if den == 1 then outp += "#{num}" else outp += "#{num}/#{den}" end "#{outp.rjust(width)} |" }.join }" } puts "↓" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_matrix\n @matrix.each do |m|\n print \"#{m}\\n\"\n end\n end", "def print_matrix\n for i in 0...@number_of_rows\n for j in 0...@number_of_columns\n print @matrix[i][j]\n end\n puts ''\n end\n end", "def print\n @maze[:matrix].each do |line|\n puts ...
[ "0.8553344", "0.7839165", "0.7765039", "0.7291293", "0.72614694", "0.71777624", "0.7100341", "0.70865875", "0.70570606", "0.69582385", "0.6939778", "0.693125", "0.6866958", "0.67701817", "0.67550945", "0.6732928", "0.67040026", "0.66058517", "0.6577692", "0.6567373", "0.65575...
0.8034365
1
Modify this selected driver using a new helper method in Driver: Add the new trip to the collection of trips for that Driver Set the driver's status to :UNAVAILABLE
def update_status(new_status) raise ArgumentError.new"Invalid Status" unless new_status == :AVAILABLE || new_status == :UNAVAILABLE @status = new_status end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def driver_helper(new_trip)\n # ... adds the newly requested trip to the collection of trips for that driver\n @trips << new_trip\n # ... and sets the driver's status to :UNAVAILABLE\n @status = :UNAVAILABLE\n end", "def add_new_trip(trip)\n self.status = :UNAVAILABLE\n add_trip(...
[ "0.85093874", "0.7430142", "0.6868667", "0.64329904", "0.6225026", "0.6041754", "0.5967702", "0.5719129", "0.55887836", "0.5518418", "0.5495147", "0.5457348", "0.5443099", "0.5440385", "0.541422", "0.5326216", "0.5322127", "0.5311161", "0.52699053", "0.52699053", "0.52699053"...
0.0
-1
, only: [ :destroy, :edit, :update ]
def index @keys = ApiKey.where(user_id: current_user.id).order(id: :desc).page params[:page] # kaminari end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n end", "def edit\n\n en...
[ "0.7332429", "0.7332429", "0.7332429", "0.7332429", "0.7332429", "0.7332429", "0.7332429", "0.7332429", "0.7332429", "0.7332429", "0.7332429", "0.7332429", "0.7332429", "0.7332429", "0.7236012", "0.7236012", "0.7197508", "0.7197508", "0.7197508", "0.7197508", "0.7197508", "...
0.0
-1
should use strategy pattern via ServiceObject and super
def property_conversation property, account # super unless valid_conversation_target? account raise ArgumentError, "Account must be a tenant or system account, was: #{account}" end conversations_about(property).find_for(account).first end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def service; raise NotImplementedError; end", "def service\n raise \"Abstract method service in ModelBase was called\"\n end", "def service; end", "def strategy; end", "def across_service_state\n super\n end", "def create\n super(@@service)\n end", "def service\n a...
[ "0.7492396", "0.72055864", "0.70344293", "0.69078404", "0.6783043", "0.6523961", "0.65002406", "0.64547104", "0.63432515", "0.6265905", "0.6211264", "0.6209802", "0.61822385", "0.60989", "0.608119", "0.608119", "0.60805404", "0.60508704", "0.6022361", "0.6011483", "0.5990224"...
0.0
-1
this'll only work if run in an xsession
def xrandr_outputs x11_user = self[:nat][:username] || 'nat' xrandr_output = `su #{x11_user} -c "xrandr -q"`.split() displays = [] xrandr_output.each_with_index do |word, i| if word == 'connected' displays << xrandr_output[i - 1] end end displays end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gPXE; iPXE; end", "def orgX(x)\n return @device.orgX(x) ;\n end", "def private; end", "def xenapi_session\n @session\n end", "def xenapi_session\n @session\n end", "def xwininfo\n @xwininfo ||= `xwininfo -id #{@id}`\n end", "def global; end", "def session=(_arg0); end"...
[ "0.5556326", "0.53993505", "0.5367444", "0.53507286", "0.53507286", "0.53036565", "0.5296256", "0.52846456", "0.522453", "0.522453", "0.51919454", "0.51919454", "0.5191126", "0.5191126", "0.5158548", "0.51399696", "0.5114664", "0.5091032", "0.5088097", "0.5084292", "0.5084011...
0.0
-1
Get process information by command 'ps auxw | grep serverId | grep pid'
def get_ps_info args={}, &block return if OS.windows? pid = args[:pid] EM.system('sh', proc{ |process| process.send_data "ps auxw | grep " + pid.to_s + " | grep -v 'grep'\n" process.send_data "exit\n" }) { |output, status| if status.exitstatus == 0 format args, output, &block else block.call status, nil if block end } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def server_pids\n `lsof -wni | grep ruby | grep IPv4 | awk '{print $2}'`\n end", "def ps\n `ps haxo pid,ppid,cmd`\n end", "def determine_processes\n procs = @shell.query('PROCESSES', 'ps aux')\n @info[:processes] = procs.gsub(/\\r/, '').split(/\\n/)\n end", "def ps_running\n c...
[ "0.74520993", "0.7438365", "0.7126289", "0.71195465", "0.70977867", "0.7040693", "0.69930017", "0.69849795", "0.6941538", "0.6887157", "0.68529695", "0.68377346", "0.6791492", "0.6788745", "0.6778669", "0.67205286", "0.6692933", "0.666617", "0.66612226", "0.66494066", "0.6629...
0.744078
1
Convert process information into required format
def format args, data time = get_current_time data = data.gsub(/^\s+|\s+$/, '') data = data.split(/\s+/).select { |str| Float str rescue nil } ps_info = {} ps_info[:time] = time ps_info[:server_id] = args[:server_id] ps_info[:server_type] = args[:server_id].split('-')[0] pid = ps_info[:pid] = args[:pid] ps_info[:cpu_avg] = data[1] ps_info[:mem_avg] = data[2] ps_info[:vsz] = data[3] ps_info[:rss] = data[4] if OS.mac? ps_info[:usr] = ps_info[:sys] = ps_info[:gue] = '0' block_given? and yield nil, ps_info return end EM.system('pidstat -p ' + pid) { |output,status| if status.exitstatus == 0 data = output.gsub(/^\s+|\s+$/, '') data = data.split(/\s+/).select { |str| Float str rescue nil } ps_info[:usr] = data[1] ps_info[:sys] = data[2] ps_info[:gue] = data[3] block_given? and yield nil, ps_info else block_given? and yield status, nil end } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def collect_process_info\n process = {}\n cmdline_file = \"/proc/#{Process.pid}/cmdline\"\n\n # If there is a /proc filesystem, we read this manually so\n # we can split on embedded null bytes. Otherwise (e.g. OSX, Windows)\n # use ProcTable.\n if File.exist?(cmdline_file...
[ "0.7030795", "0.65685403", "0.6195479", "0.6195479", "0.6183281", "0.6039276", "0.5970406", "0.58084816", "0.5759076", "0.5759076", "0.5752947", "0.5752947", "0.57230866", "0.5687424", "0.56417674", "0.5616874", "0.5593775", "0.5573327", "0.5570639", "0.5551441", "0.5549775",...
0.59142554
7
Timecomplexity: O(n^2), Inplace will be using Knuth series :3n+1
def shell_sort(a) n=a.length h=1 while (h<n/3) #for computing increment factor "h" h= (3*h)+1 end while h>=1 # Logic of insertion sort with inrement steps of "h" for i in h...n j=i while j>=h if a[j-h]>a[j] temp=a[j] a[j]=a[j-h] a[j-h]=temp end j-=h end end h/=3 end return a end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solution(a)\r\n n=a.size\r\n i=1\r\n for k in a.sort do\r\n\tif k!=i \r\n\t then \r\n\t return 0\r\n\t break;\r\n\tend\r\n i+=1;\r\n end\t\r\n return 1 if a.inject(:+) ==n*(n+1)/2;\r\nend", "def josephus_survivor(n,k)\n result = 1\n for i in 1...n + 1\n...
[ "0.6438931", "0.6313318", "0.6169534", "0.6132016", "0.60377884", "0.5976135", "0.5955118", "0.5922008", "0.5896151", "0.5890872", "0.5864034", "0.5852935", "0.58461004", "0.5845946", "0.5842953", "0.5841691", "0.5818798", "0.58128834", "0.57915366", "0.57756793", "0.57729983...
0.0
-1
Warning: if somebody applies parameter values via JSON, this will compare that.... probably shouldn't be doing that though if it's NoEcho there's a good reason bother checking synthesized_value? that would be the indicator.....
def audit_impl(cfn_model) violating_rdsinstances = cfn_model.resources_by_type('AWS::RDS::DBInstance') .select do |instance| if instance.masterUsername.nil? false else !references_no_echo_parameter_without_default?(cfn_model, instance.masterUsername) end end violating_rdsinstances.map(&:logical_resource_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def value?(value); end", "def value?(value); end", "def value?(value) true end", "def has_value?(p0) end", "def is_value?\n true\n end", "def check_value(value)\n case value\n when 'true'\n true\n when 'false'\n false\n else\n val...
[ "0.64242643", "0.64242643", "0.6256839", "0.62534386", "0.61853254", "0.608591", "0.6059123", "0.603685", "0.5994732", "0.59817123", "0.5942141", "0.5918781", "0.5918781", "0.5898913", "0.5885031", "0.5875498", "0.5867212", "0.5864767", "0.58645684", "0.5843261", "0.5828332",...
0.0
-1
Available fetching options: fetch_shared_tables_count fetch_shared_maps_count fetch_users
def initialize(group, fetching_options = {}) @group = group @fetching_options = fetching_options end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def default_fetch_size\n 100\n end", "def fetch_users\n user_relational_query = get_model_query\n @total_filtered_users = user_relational_query.count\n\n return if @total_filtered_users < 1\n offset = 0\n offset = @page_size * (@page_number - 1) if @page_number ...
[ "0.63299304", "0.60855144", "0.6006225", "0.5989355", "0.5889129", "0.5881579", "0.57205945", "0.56973296", "0.56465566", "0.5623438", "0.5613248", "0.5575314", "0.55628705", "0.5471719", "0.5465353", "0.54437387", "0.5442435", "0.540514", "0.54021883", "0.5395425", "0.538075...
0.0
-1
GET /votes GET /votes.json
def index @votes = Vote.all @commitees = Commitee.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def votes(options = {})\n get('/votes', options)\n end", "def getvotes\n @the_question = Question.find(params[:id])\n render json: [{question: @the_question}, {votes: @the_question.votes_for}] and return\n end", "def get_votes\n @votes = Vote.all\n end", "def index\n @votes = Vote.a...
[ "0.84528613", "0.7669005", "0.7550046", "0.75408536", "0.75396514", "0.75396514", "0.75396514", "0.75396514", "0.75396514", "0.7527788", "0.7526703", "0.7353587", "0.7104424", "0.6984962", "0.6984962", "0.6984962", "0.6984962", "0.6984962", "0.6984962", "0.6984962", "0.698496...
0.0
-1
GET /votes/1 GET /votes/1.json
def show @vote = Vote.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def votes(options = {})\n get('/votes', options)\n end", "def getvotes\n @the_question = Question.find(params[:id])\n render json: [{question: @the_question}, {votes: @the_question.votes_for}] and return\n end", "def index\n @votes = Vote.all\n\n\n respond_to do |format|\n format.html...
[ "0.78972834", "0.74997", "0.74689794", "0.74660367", "0.74557495", "0.74557495", "0.74557495", "0.74557495", "0.74557495", "0.73750776", "0.72750264", "0.72750264", "0.72750264", "0.72750264", "0.72750264", "0.72750264", "0.72750264", "0.72750264", "0.72478855", "0.72051424", ...
0.6782198
36
POST /votes POST /votes.json
def create @vote = Vote.new(vote_params) respond_to do |format| if @vote.save format.html { redirect_to @vote, notice: 'Vote was successfully created.' } format.json { render :show, status: :created, location: @vote } else format.html { render :new } format.json { render json: @vote.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n votes = params[:vote]\n voter = params[:voter_id]\n\n if votes\n votes.each do |k,v|\n @vote = Vote.new({:voter_id => voter,\n :position_id => v,\n :candidate_id => k })\n @vote.save\n end\n end\n\n\n redirect_to '/...
[ "0.70822227", "0.7028233", "0.70230967", "0.69423336", "0.69423336", "0.6890193", "0.6846321", "0.6825699", "0.6821856", "0.6799433", "0.6770842", "0.6770842", "0.67705065", "0.67561966", "0.6693474", "0.66906375", "0.6684874", "0.6663655", "0.66523963", "0.6618081", "0.65851...
0.68469757
8
PATCH/PUT /votes/1 PATCH/PUT /votes/1.json
def update =begin respond_to do |format| if @vote.update(vote_params) format.html { redirect_to @vote, notice: 'Vote was successfully updated.' } format.json { render :show, status: :ok, location: @vote } else format.html { render :edit } format.json { render json: @vote.errors, status: :unprocessable_entity } end end =end if @vote.update(vote_params) flash[:notice] = 'Dane zostały zmienione!' redirect_to @vote else render :action => 'edit' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @vote = @votable.votes.find(params[:id])\n\n respond_to do |format|\n if @vote.update(vote_params)\n format.html { redirect_to build_path_vote(@vote), notice: 'Vote was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action...
[ "0.71522504", "0.70373183", "0.7028216", "0.7028216", "0.7028216", "0.7028216", "0.70155066", "0.70155066", "0.70155066", "0.70155066", "0.70155066", "0.70155066", "0.70152915", "0.6791049", "0.67769694", "0.67085785", "0.67085785", "0.67085785", "0.67085785", "0.6676926", "0...
0.6108921
54
DELETE /votes/1 DELETE /votes/1.json
def destroy @vote.destroy respond_to do |format| format.html { redirect_to votes_url, notice: 'Vote was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n\n\n\n @vote = Vote.find(params[:id])\n\n @vote.destroy\n\n respond_to do |format|\n format.html { redirect_to votes_url }\n format.json { head :ok }\n end\n end", "def destroy\n @vote = Vote.find(params[:id])\n @vote.destroy\n\n respond_to do |format|\n format.h...
[ "0.7982334", "0.78841865", "0.78841865", "0.78841865", "0.78626317", "0.7856752", "0.784971", "0.78488326", "0.78488326", "0.78488326", "0.78488326", "0.78488326", "0.78488326", "0.78488326", "0.78149915", "0.78149915", "0.7678894", "0.7565376", "0.7565376", "0.7565376", "0.7...
0.75354135
27
Use callbacks to share common setup or constraints between actions.
def set_vote @vote = Vote.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.61642385", "0.60448", "0.5945487", "0.5915654", "0.58890367", "0.58330417", "0.5776098", "0.5703048", "0.5703048", "0.5654613", "0.5620029", "0.5423114", "0.540998", "0.540998", "0.540998", "0.5393666", "0.53783023", "0.53568405", "0.53391176", "0.5339061", "0.53310865", ...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def vote_params params.require(:vote).permit(:vote, :district_id, :commitee_id) 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.6981606", "0.6784227", "0.6746523", "0.67439264", "0.67361516", "0.6593381", "0.6506166", "0.64994407", "0.6483518", "0.64797056", "0.64578557", "0.6441216", "0.63811713", "0.63773805", "0.6366333", "0.63217646", "0.6301816", "0.63009787", "0.6294436", "0.62940663", "0.629...
0.0
-1
Example For n = 29, the output should be addTwoDigits(n) = 11.
def addTwoDigits(n) result = 0 n.to_s.split("").each {|number| result += number.to_i } result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_digits(num)\n return num if num.to_s.length == 1\n add_digits(num.to_s[0].to_i + add_digits(num.to_s[1..-1]).to_i)\nend", "def add_digits(num)\n return num if num.to_s.length == 1\n int_array = split_digits(num)\n sum = add_array_ints(int_array)\n return add_digits(sum)\n end", "def add_...
[ "0.7786175", "0.76464266", "0.7602193", "0.7565762", "0.74024767", "0.72868913", "0.721501", "0.71777153", "0.7091348", "0.70408916", "0.7022131", "0.69648373", "0.695648", "0.6947659", "0.6940182", "0.6890425", "0.68735445", "0.6858815", "0.68503183", "0.6840207", "0.6831636...
0.8303512
0
Just get the class methods defined in this module (or class) itself, omitting inherited ones. Equivalent to class_method_objects false
def own_class_method_objects sort: true class_method_objects false, sort: sort end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all_methods\n self.all_classes_and_modules.map do |klassmod|\n klassmod.own_methods.as_array\n end.flatten\n end", "def class_methods\n all_methods().find_all{|m| m.singleton && (@options.show_all || m.visibility == :public || m.visibility == :protected)}.collect{|m| method_hash(m)}\n end...
[ "0.7824683", "0.7650531", "0.7537689", "0.7418514", "0.7371132", "0.73499846", "0.7103591", "0.71016335", "0.701458", "0.6966601", "0.69482386", "0.6905873", "0.6902744", "0.68876094", "0.6874491", "0.6871948", "0.6871948", "0.68606853", "0.686001", "0.683219", "0.6804061", ...
0.6200593
65
Use callbacks to share common setup or constraints between actions.
def set_bank @bank = Bank.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.61642385", "0.60448", "0.5945487", "0.5915654", "0.58890367", "0.58330417", "0.5776098", "0.5703048", "0.5703048", "0.5654613", "0.5620029", "0.5423114", "0.540998", "0.540998", "0.540998", "0.5393666", "0.53783023", "0.53568405", "0.53391176", "0.5339061", "0.53310865", ...
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def bank_params params.require(:bank).permit(:name, :shortname, :image, :description, :website, :email, :facebook, :twitter, :linkedin, :youtube, :size, :geography, :industries, :products, :founded, :internship, :diversity, :underclass, :charity, :revenue, :stock, :employees, :ceo, :headquarters) 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.6981606", "0.6784227", "0.6746523", "0.67439264", "0.67361516", "0.6593381", "0.6506166", "0.64994407", "0.6483518", "0.64797056", "0.64578557", "0.6441216", "0.63811713", "0.63773805", "0.6366333", "0.63217646", "0.6301816", "0.63009787", "0.6294436", "0.62940663", "0.629...
0.0
-1
GET /session_replicas GET /session_replicas.json
def index @session_replicas = SessionReplica.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_session_replica\n @session_replica = SessionReplica.find(params[:id])\n end", "def get_all_replicas(id, options = GetAllReplicasOptions.new) end", "def replicas; end", "def destroy\n @session_replica.destroy\n respond_to do |format|\n format.html { redirect_to session_replicas_url ...
[ "0.68597347", "0.66880745", "0.6502734", "0.6378547", "0.62445986", "0.6064645", "0.5996224", "0.5950158", "0.5847749", "0.5792938", "0.57326543", "0.5591757", "0.54726493", "0.5337873", "0.533406", "0.53334785", "0.5249959", "0.5239103", "0.51504034", "0.51504034", "0.514155...
0.82171476
0
GET /session_replicas/1 GET /session_replicas/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @session_replicas = SessionReplica.all\n end", "def set_session_replica\n @session_replica = SessionReplica.find(params[:id])\n end", "def destroy\n @session_replica.destroy\n respond_to do |format|\n format.html { redirect_to session_replicas_url }\n format.json { head ...
[ "0.8026325", "0.69743365", "0.6514398", "0.638829", "0.6353358", "0.6348696", "0.6197808", "0.6080882", "0.5952667", "0.57447505", "0.5667694", "0.5655303", "0.5499601", "0.5386497", "0.53642917", "0.5296435", "0.52864754", "0.52624065", "0.52269536", "0.5157514", "0.51547253...
0.0
-1
POST /session_replicas POST /session_replicas.json
def create @session_replica = SessionReplica.new(session_replica_params) respond_to do |format| if @session_replica.save format.html { redirect_to @session_replica} format.json { render :show, status: :created, location: @session_replica } else format.html { render :new } format.json { render json: @session_replica.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @session_replicas = SessionReplica.all\n end", "def set_session_replica\n @session_replica = SessionReplica.find(params[:id])\n end", "def destroy\n @session_replica.destroy\n respond_to do |format|\n format.html { redirect_to session_replicas_url }\n format.json { head ...
[ "0.72132355", "0.68021774", "0.639382", "0.638609", "0.6376838", "0.63217497", "0.60546887", "0.57516086", "0.5648277", "0.555512", "0.53954935", "0.53938895", "0.51999646", "0.5123359", "0.5002693", "0.49794427", "0.49644673", "0.4958506", "0.49353305", "0.49186015", "0.4895...
0.7139926
1
PATCH/PUT /session_replicas/1 PATCH/PUT /session_replicas/1.json
def update respond_to do |format| if @session_replica.update(session_replica_params) format.html { redirect_to @session_replica} format.json { render :show, status: :ok, location: @session_replica } else format.html { render :edit } format.json { render json: @session_replica.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_session_replica\n @session_replica = SessionReplica.find(params[:id])\n end", "def update!(**args)\n @max_replicas = args[:max_replicas] if args.key?(:max_replicas)\n @min_replicas = args[:min_replicas] if args.key?(:min_replicas)\n end", "def increment_replica_count\n ...
[ "0.65559", "0.6220529", "0.6152326", "0.61337984", "0.6014983", "0.5835703", "0.5744421", "0.56974447", "0.5681056", "0.56587446", "0.56110454", "0.55506253", "0.5516534", "0.5504615", "0.5400901", "0.5381052", "0.5347868", "0.5278142", "0.52709705", "0.52651864", "0.52610946...
0.6951087
0
DELETE /session_replicas/1 DELETE /session_replicas/1.json
def destroy @session_replica.destroy respond_to do |format| format.html { redirect_to session_replicas_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_session\n request.method = :get\n request.uri = '_session'\n Couchdbtools.execute(request)\n end", "def decrement_replica_count\n self.original['spec']['replicas'] -= 1\n end", "def destroy\n @shard = Shard.find(params[:id])\n @shard.destroy\n\n respond_t...
[ "0.630367", "0.61659247", "0.60246676", "0.6015206", "0.60112727", "0.5996535", "0.5980484", "0.5930732", "0.5909079", "0.586176", "0.5851236", "0.58501256", "0.5843635", "0.5799133", "0.57767534", "0.57584006", "0.57451165", "0.5726068", "0.5711957", "0.56949353", "0.5693736...
0.80110145
0
Use callbacks to share common setup or constraints between actions.
def set_session_replica @session_replica = SessionReplica.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 session_replica_params params.require(:session_replica).permit(:origin_id, :start_date) 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.6981606", "0.6784227", "0.6746523", "0.67439264", "0.67361516", "0.6593381", "0.6506166", "0.64994407", "0.6483518", "0.64797056", "0.64578557", "0.6441216", "0.63811713", "0.63773805", "0.6366333", "0.63217646", "0.6301816", "0.63009787", "0.6294436", "0.62940663", "0.629...
0.0
-1
Method to sign out users
def destroy session[:user_id] = nil redirect_to root_path end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sign_out\n logout\n end", "def sign_out\n session.sign_out\n end", "def sign_out\n @current_user = nil\n end", "def sign_out\n reset_session\n @current_user = nil\n end", "def sign_out\n reset_session\n end", "def sign_out\n post \"api/logout\"\n @me = nil\n en...
[ "0.83403504", "0.811225", "0.800834", "0.79289275", "0.7926181", "0.7911633", "0.7906238", "0.7902193", "0.78967714", "0.7841798", "0.7834379", "0.7832315", "0.7823483", "0.7814066", "0.77722275", "0.7761914", "0.776026", "0.7754297", "0.7732997", "0.77241147", "0.77138615", ...
0.0
-1
Create a new participant under this account. Participants are idempotent, so relevant parameters must be set in this function if desired.
def create_participant(account_id, body: nil) # Prepare query url. _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT) _query_builder << '/accounts/{accountId}/participants' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'accountId' => { 'value' => account_id, 'encode' => false } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'content-type' => 'application/json; charset=utf-8' } # Prepare and execute HttpRequest. _request = config.http_client.post( _query_url, headers: _headers, parameters: body.to_json ) WebRtcBasicAuth.apply(config, _request) _response = execute_request(_request) # Validate response against endpoint and global error codes. case _response.status_code when 400 raise APIException.new( 'Bad Request', _response ) when 401 raise APIException.new( 'Unauthorized', _response ) when 403 raise APIException.new( 'Access Denied', _response ) end unless _response.status_code.between?(200, 208) raise ErrorException.new( 'Unexpected Error', _response ) end validate_response(_response) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) ApiResponse.new( _response, data: AccountsParticipantsResponse.from_hash(decoded) ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_participant(safebox_guid, participant_params)\n handle_error { sendsecure_connection.post(\"api/v2/safeboxes/#{safebox_guid}/participants.json\", participant_params) }\n end", "def create\n \n @participant = current_user.build_participant(participant_params)\n \n respond_to do ...
[ "0.8053179", "0.76407427", "0.7483264", "0.74713874", "0.74713874", "0.74632746", "0.7445831", "0.7445831", "0.7269123", "0.7234513", "0.71342874", "0.71215737", "0.7111744", "0.698187", "0.69366145", "0.68862873", "0.6873858", "0.68725973", "0.6863236", "0.6842878", "0.68119...
0.70873135
13
Get participant by ID.
def get_participant(account_id, participant_id) # Prepare query url. _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT) _query_builder << '/accounts/{accountId}/participants/{participantId}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'accountId' => { 'value' => account_id, 'encode' => false }, 'participantId' => { 'value' => participant_id, 'encode' => false } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.get( _query_url, headers: _headers ) WebRtcBasicAuth.apply(config, _request) _response = execute_request(_request) # Validate response against endpoint and global error codes. case _response.status_code when 401 raise APIException.new( 'Unauthorized', _response ) when 403 raise APIException.new( 'Access Denied', _response ) when 404 raise APIException.new( 'Not Found', _response ) end unless _response.status_code.between?(200, 208) raise ErrorException.new( 'Unexpected Error', _response ) end validate_response(_response) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) ApiResponse.new( _response, data: Participant.from_hash(decoded) ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_participants(id, params = {})\n get \"/api/v2/projects/#{id}/participants\", params\n end", "def show\n @participant = Participant.find(params[:id])\n end", "def participant_id\n return @participant_id\n end", "def participant_id\n return @part...
[ "0.6766038", "0.6747537", "0.67231965", "0.67231965", "0.6620221", "0.66014564", "0.65296113", "0.6413168", "0.6413168", "0.64080566", "0.64080566", "0.64080566", "0.64080566", "0.64080566", "0.64080566", "0.64080566", "0.64080566", "0.64080566", "0.64080566", "0.64080566", "...
0.6646042
4
Delete participant by ID.
def delete_participant(account_id, participant_id) # Prepare query url. _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT) _query_builder << '/accounts/{accountId}/participants/{participantId}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'accountId' => { 'value' => account_id, 'encode' => false }, 'participantId' => { 'value' => participant_id, 'encode' => false } ) _query_url = APIHelper.clean_url _query_builder # Prepare and execute HttpRequest. _request = config.http_client.delete( _query_url ) WebRtcBasicAuth.apply(config, _request) _response = execute_request(_request) # Validate response against endpoint and global error codes. case _response.status_code when 401 raise APIException.new( 'Unauthorized', _response ) when 403 raise APIException.new( 'Access Denied', _response ) when 404 raise APIException.new( 'Not Found', _response ) end unless _response.status_code.between?(200, 208) raise ErrorException.new( 'Unexpected Error', _response ) end validate_response(_response) # Return appropriate response type. ApiResponse.new(_response) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @participant = Participant.find(params[:id])\n @participant.destroy\n\n respond_to do |format|\n format.html { redirect_to participants_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @participant = Participant.find(params[:id])\n @participant.des...
[ "0.72154033", "0.7198045", "0.7198045", "0.71091694", "0.7099698", "0.70190936", "0.70072484", "0.69691104", "0.6938913", "0.69336134", "0.6904828", "0.6866794", "0.6866794", "0.68004376", "0.6768609", "0.67427915", "0.6705309", "0.66963917", "0.66963917", "0.66963917", "0.66...
0.74030274
0
Create a new session. Sessions are idempotent, so relevant parameters must be set in this function if desired.
def create_session(account_id, body: nil) # Prepare query url. _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT) _query_builder << '/accounts/{accountId}/sessions' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'accountId' => { 'value' => account_id, 'encode' => false } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json', 'content-type' => 'application/json; charset=utf-8' } # Prepare and execute HttpRequest. _request = config.http_client.post( _query_url, headers: _headers, parameters: body.to_json ) WebRtcBasicAuth.apply(config, _request) _response = execute_request(_request) # Validate response against endpoint and global error codes. case _response.status_code when 400 raise APIException.new( 'Bad Request', _response ) when 401 raise APIException.new( 'Unauthorized', _response ) when 403 raise APIException.new( 'Access Denied', _response ) end unless _response.status_code.between?(200, 208) raise ErrorException.new( 'Unexpected Error', _response ) end validate_response(_response) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) ApiResponse.new( _response, data: Session.from_hash(decoded) ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_session\n @connection.create_session(@config || {})\n end", "def create!(*args)\n session = new(*args)\n session.save!\n session\n end", "def create!(*args)\n session = new(*args)\n session.save!\n end", "def create!(*args)...
[ "0.84279007", "0.79473907", "0.782255", "0.782255", "0.7791551", "0.7677732", "0.7632679", "0.7626174", "0.7523134", "0.73476195", "0.73223513", "0.729912", "0.7256545", "0.72282434", "0.72026724", "0.7196217", "0.7166488", "0.71363103", "0.7125027", "0.7000495", "0.69899964"...
0.0
-1
Get session by ID.
def get_session(account_id, session_id) # Prepare query url. _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT) _query_builder << '/accounts/{accountId}/sessions/{sessionId}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'accountId' => { 'value' => account_id, 'encode' => false }, 'sessionId' => { 'value' => session_id, 'encode' => false } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.get( _query_url, headers: _headers ) WebRtcBasicAuth.apply(config, _request) _response = execute_request(_request) # Validate response against endpoint and global error codes. case _response.status_code when 401 raise APIException.new( 'Unauthorized', _response ) when 403 raise APIException.new( 'Access Denied', _response ) when 404 raise APIException.new( 'Not Found', _response ) end unless _response.status_code.between?(200, 208) raise ErrorException.new( 'Unexpected Error', _response ) end validate_response(_response) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) ApiResponse.new( _response, data: Session.from_hash(decoded) ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def session_get(id)\n sessions.select {|s| s.SessionId().to_s == id.to_s}\n end", "def session(id)\n search_sessions(xml_doc, id).first\n end", "def get_session(session_id)\n session = Session.find(:first, :conditions => ['session_id=?', session_id])\n return sessi...
[ "0.85440904", "0.82807875", "0.79861295", "0.78630334", "0.7602142", "0.7514217", "0.7400442", "0.7292203", "0.71992344", "0.71649617", "0.7164787", "0.7164787", "0.71492904", "0.7062619", "0.7062619", "0.7026547", "0.6966625", "0.6848968", "0.6848968", "0.6848968", "0.684896...
0.6230211
73
Delete session by ID.
def delete_session(account_id, session_id) # Prepare query url. _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT) _query_builder << '/accounts/{accountId}/sessions/{sessionId}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'accountId' => { 'value' => account_id, 'encode' => false }, 'sessionId' => { 'value' => session_id, 'encode' => false } ) _query_url = APIHelper.clean_url _query_builder # Prepare and execute HttpRequest. _request = config.http_client.delete( _query_url ) WebRtcBasicAuth.apply(config, _request) _response = execute_request(_request) # Validate response against endpoint and global error codes. case _response.status_code when 401 raise APIException.new( 'Unauthorized', _response ) when 403 raise APIException.new( 'Access Denied', _response ) when 404 raise APIException.new( 'Not Found', _response ) end unless _response.status_code.between?(200, 208) raise ErrorException.new( 'Unexpected Error', _response ) end validate_response(_response) # Return appropriate response type. ApiResponse.new(_response) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_session(session_id)\n delete(\"session:#{session_id}\")\n end", "def deleteSession(sessionID)\n call :deleteSession, :sessionID => sessionID\n end", "def delete\n if @session\n @session.destroy\n @session = nil\n end\n end", "def delete_session(env, sid, options); end"...
[ "0.82746494", "0.8213924", "0.78407186", "0.77177083", "0.77132183", "0.7480458", "0.74661034", "0.7442562", "0.7431306", "0.73627746", "0.72922283", "0.72196", "0.72133327", "0.72098905", "0.72053957", "0.7161604", "0.71371156", "0.7125123", "0.7071327", "0.70678574", "0.706...
0.68834496
27
List participants in a session.
def list_session_participants(account_id, session_id) # Prepare query url. _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT) _query_builder << '/accounts/{accountId}/sessions/{sessionId}/participants' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'accountId' => { 'value' => account_id, 'encode' => false }, 'sessionId' => { 'value' => session_id, 'encode' => false } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.get( _query_url, headers: _headers ) WebRtcBasicAuth.apply(config, _request) _response = execute_request(_request) # Validate response against endpoint and global error codes. case _response.status_code when 401 raise APIException.new( 'Unauthorized', _response ) when 403 raise APIException.new( 'Access Denied', _response ) when 404 raise APIException.new( 'Not Found', _response ) end unless _response.status_code.between?(200, 208) raise ErrorException.new( 'Unexpected Error', _response ) end validate_response(_response) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) ApiResponse.new( _response, data: decoded.map { |element| Participant.from_hash(element) } ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_session_participants(account_id, session_id, opts = {})\n data, _status_code, _headers = list_session_participants_with_http_info(account_id, session_id, opts)\n data\n end", "def get_participants\n user = self.load_user(params)\n meeting = self.load_meeting(params)\n\n if us...
[ "0.6977873", "0.67511976", "0.67085135", "0.6699871", "0.6695217", "0.6586641", "0.65847737", "0.65847737", "0.6551789", "0.6521923", "0.6515579", "0.6515579", "0.6501313", "0.6495838", "0.6495838", "0.6495838", "0.6495838", "0.6495838", "0.6495838", "0.6477563", "0.6468465",...
0.7196438
0
Add a participant to a session. Subscriptions can optionally be provided as part of this call.
def add_participant_to_session(account_id, session_id, participant_id, body: nil) # Prepare query url. _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT) _query_builder << '/accounts/{accountId}/sessions/{sessionId}/participants/{participantId}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'accountId' => { 'value' => account_id, 'encode' => false }, 'sessionId' => { 'value' => session_id, 'encode' => false }, 'participantId' => { 'value' => participant_id, 'encode' => false } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'content-type' => 'application/json; charset=utf-8' } # Prepare and execute HttpRequest. _request = config.http_client.put( _query_url, headers: _headers, parameters: body.to_json ) WebRtcBasicAuth.apply(config, _request) _response = execute_request(_request) # Validate response against endpoint and global error codes. case _response.status_code when 401 raise APIException.new( 'Unauthorized', _response ) when 403 raise APIException.new( 'Access Denied', _response ) when 404 raise APIException.new( 'Not Found', _response ) end unless _response.status_code.between?(200, 208) raise ErrorException.new( 'Unexpected Error', _response ) end validate_response(_response) # Return appropriate response type. ApiResponse.new(_response) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_participant_to_session(account_id, session_id, participant_id, opts = {})\n add_participant_to_session_with_http_info(account_id, session_id, participant_id, opts)\n nil\n end", "def add_participant\n user = self.load_user(params)\n meeting = self.load_meeting(params)\n partic...
[ "0.69242907", "0.6579323", "0.64100623", "0.6259223", "0.6197239", "0.61822116", "0.6081688", "0.60389733", "0.60210556", "0.599112", "0.5919563", "0.58165616", "0.57802224", "0.5687276", "0.55658764", "0.5538888", "0.55289817", "0.54701144", "0.5463343", "0.5450351", "0.5439...
0.6828904
1
Remove a participant from a session. This will automatically remove any subscriptions the participant has associated with this session.
def remove_participant_from_session(account_id, session_id, participant_id) # Prepare query url. _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT) _query_builder << '/accounts/{accountId}/sessions/{sessionId}/participants/{participantId}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'accountId' => { 'value' => account_id, 'encode' => false }, 'sessionId' => { 'value' => session_id, 'encode' => false }, 'participantId' => { 'value' => participant_id, 'encode' => false } ) _query_url = APIHelper.clean_url _query_builder # Prepare and execute HttpRequest. _request = config.http_client.delete( _query_url ) WebRtcBasicAuth.apply(config, _request) _response = execute_request(_request) # Validate response against endpoint and global error codes. case _response.status_code when 401 raise APIException.new( 'Unauthorized', _response ) when 403 raise APIException.new( 'Access Denied', _response ) when 404 raise APIException.new( 'Not Found', _response ) end unless _response.status_code.between?(200, 208) raise ErrorException.new( 'Unexpected Error', _response ) end validate_response(_response) # Return appropriate response type. ApiResponse.new(_response) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_participant_from_session(account_id, session_id, participant_id, opts = {})\n remove_participant_from_session_with_http_info(account_id, session_id, participant_id, opts)\n nil\n end", "def remove_participant\n user = self.load_user(params)\n meeting = self.load_meeting(params)\...
[ "0.75884026", "0.6380433", "0.624602", "0.60856694", "0.6079354", "0.60488826", "0.60285354", "0.59954965", "0.59787464", "0.5914275", "0.5896921", "0.5887634", "0.58749133", "0.586737", "0.5838793", "0.57602346", "0.5759116", "0.57585454", "0.57508636", "0.57487637", "0.5723...
0.7534986
1
Get a participant's subscriptions.
def get_participant_subscriptions(account_id, session_id, participant_id) # Prepare query url. _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT) _query_builder << '/accounts/{accountId}/sessions/{sessionId}/participants/{participantId}/subscriptions' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'accountId' => { 'value' => account_id, 'encode' => false }, 'sessionId' => { 'value' => session_id, 'encode' => false }, 'participantId' => { 'value' => participant_id, 'encode' => false } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'accept' => 'application/json' } # Prepare and execute HttpRequest. _request = config.http_client.get( _query_url, headers: _headers ) WebRtcBasicAuth.apply(config, _request) _response = execute_request(_request) # Validate response against endpoint and global error codes. case _response.status_code when 401 raise APIException.new( 'Unauthorized', _response ) when 403 raise APIException.new( 'Access Denied', _response ) when 404 raise APIException.new( 'Not Found', _response ) end unless _response.status_code.between?(200, 208) raise ErrorException.new( 'Unexpected Error', _response ) end validate_response(_response) # Return appropriate response type. decoded = APIHelper.json_deserialize(_response.raw_body) ApiResponse.new( _response, data: Subscriptions.from_hash(decoded) ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_subscriptions\n get_subscriptions_from(@nodename)\n end", "def all_subscriptions\n get(url_(\"subscription\"))\n end", "def subscriptions\n url = url_with_api_version(@base_url, 'subscriptions')\n resp = rest_get(url)\n JSON.parse(resp.body)[\"value\"]\n ...
[ "0.73605067", "0.7262282", "0.7177072", "0.71370053", "0.70708144", "0.7036096", "0.7030234", "0.6889275", "0.687437", "0.6863825", "0.68365085", "0.6836278", "0.6778858", "0.67383724", "0.67221636", "0.6709729", "0.66607046", "0.6650482", "0.6644378", "0.66291213", "0.661985...
0.73398226
1
Update a participant's subscriptions. This is a full update that will replace the participant's subscriptions. First call `getParticipantSubscriptions` if you need the current subscriptions. Call this function with no `Subscriptions` object to remove all subscriptions.
def update_participant_subscriptions(account_id, session_id, participant_id, body: nil) # Prepare query url. _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT) _query_builder << '/accounts/{accountId}/sessions/{sessionId}/participants/{participantId}/subscriptions' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'accountId' => { 'value' => account_id, 'encode' => false }, 'sessionId' => { 'value' => session_id, 'encode' => false }, 'participantId' => { 'value' => participant_id, 'encode' => false } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'content-type' => 'application/json; charset=utf-8' } # Prepare and execute HttpRequest. _request = config.http_client.put( _query_url, headers: _headers, parameters: body.to_json ) WebRtcBasicAuth.apply(config, _request) _response = execute_request(_request) # Validate response against endpoint and global error codes. case _response.status_code when 400 raise APIException.new( 'Bad Request', _response ) when 401 raise APIException.new( 'Unauthorized', _response ) when 403 raise APIException.new( 'Access Denied', _response ) when 404 raise APIException.new( 'Not Found', _response ) end unless _response.status_code.between?(200, 208) raise ErrorException.new( 'Unexpected Error', _response ) end validate_response(_response) # Return appropriate response type. ApiResponse.new(_response) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_participant_subscriptions(account_id, session_id, participant_id, opts = {})\n update_participant_subscriptions_with_http_info(account_id, session_id, participant_id, opts)\n nil\n end", "def update_subscriptions(opts = {})\n data, _status_code, _headers = update_subscriptions_with_h...
[ "0.7673749", "0.7155982", "0.67502654", "0.6652334", "0.6607356", "0.6371448", "0.624291", "0.62138253", "0.6094653", "0.6083461", "0.60051227", "0.60031813", "0.5951139", "0.58575505", "0.5813624", "0.5774981", "0.57129824", "0.56561977", "0.5618912", "0.5617216", "0.5555525...
0.731687
1
GET /computers GET /computers.json
def index if signed_in? @computers = current_user.computers.all.decorate @computer = current_user.computers.new end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list\n \t\tuser = User.find(current_user.id)\n \t @computers = user.computer.all\n end", "def show\n @computer = Computer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @computer }\n end\n end", "def show\n @computer = Co...
[ "0.67311513", "0.66616935", "0.66616935", "0.64807296", "0.6431978", "0.64173335", "0.62085265", "0.61089754", "0.6072001", "0.5942813", "0.5939837", "0.58973014", "0.58893174", "0.58778757", "0.5870756", "0.58282804", "0.58281624", "0.581224", "0.581224", "0.58016986", "0.58...
0.62725574
6
GET /computers/1 GET /computers/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show\n @computer = Computer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @computer }\n end\n end", "def show\n @computer = Computer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n forma...
[ "0.6924024", "0.6924024", "0.6357132", "0.63052154", "0.61541355", "0.6121647", "0.6106257", "0.61024415", "0.60811013", "0.6075338", "0.6075338", "0.5999612", "0.59883416", "0.59883416", "0.59883416", "0.59883416", "0.5907304", "0.58208865", "0.5792714", "0.576821", "0.57496...
0.0
-1
POST /computers POST /computers.json
def create @computer = current_user.computers.new(computer_params) respond_to do |format| if @computer.save current_user.add_role :owner, @computer format.html { redirect_to computers_path, notice: t('computer.created') } format.json { render action: 'show', status: :created, location: @computer } else format.html { render action: 'new' } format.json { render json: @computer.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @computer = Computer.new(params[:computer])\n\n respond_to do |format|\n if @computer.save\n format.html { redirect_to @computer, notice: 'Computer was successfully created.' }\n format.json { render json: @computer, status: :created, location: @computer }\n else\n ...
[ "0.64897925", "0.64897925", "0.6039501", "0.5775147", "0.5775147", "0.5757551", "0.5744683", "0.5735534", "0.57079923", "0.5691522", "0.5655635", "0.559592", "0.5590071", "0.5556231", "0.5546339", "0.5534325", "0.54972136", "0.5479081", "0.5447243", "0.53298336", "0.5300725",...
0.6087589
2
PATCH/PUT /computers/1 PATCH/PUT /computers/1.json
def update respond_to do |format| @computer.versionless do |doc| if doc.update(computer_params) format.html { redirect_to computers_path, notice: t('computer.updated') } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render json: @computer.errors, status: :unprocessable_entity } end end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @computer = Computer.find(params[:id])\n\n respond_to do |format|\n if @computer.update_attributes(params[:computer])\n format.html { redirect_to @computer, notice: 'Computer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { ren...
[ "0.65186167", "0.6512862", "0.6054839", "0.60220796", "0.59716916", "0.5971474", "0.59525293", "0.5926014", "0.59202605", "0.58949536", "0.58347315", "0.58220094", "0.5798602", "0.5782536", "0.57804316", "0.57764715", "0.57568485", "0.5729036", "0.5724011", "0.5712803", "0.57...
0.647093
2
DELETE /computers/1 DELETE /computers/1.json
def destroy @computer.destroy respond_to do |format| format.html { redirect_to computers_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @computer = Computer.find(params[:id])\n @computer.destroy\n\n respond_to do |format|\n format.html { redirect_to computers_url }\n format.json { head :ok }\n end\n end", "def destroy\n @computer = Computer.find(params[:id])\n @computer.destroy\n\n respond_to do |for...
[ "0.7075332", "0.7073891", "0.6769502", "0.6759127", "0.6672537", "0.6650148", "0.66151136", "0.6583461", "0.65668356", "0.65420014", "0.65370816", "0.6536434", "0.6529319", "0.6506546", "0.64749974", "0.6459115", "0.64537036", "0.6432832", "0.6425489", "0.6417039", "0.641132"...
0.7023989
2
Use callbacks to share common setup or constraints between actions.
def set_computer @computer = Computer.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 computer_params params.require(:computer).permit(:name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n...
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076",...
0.0
-1
Helper method for error_classes
def status_to_error(status) case status when 1 'InvalidRequest' when 2 'InvalidCredentials' when 3 'NonExistentOrder' when 4 'NonExistentOrderItem' when 5 'InvalidStateChange' when 6 'InvalidStorno' when 7 'AnotherError' when 8 'OrderNotExported' when 9 'AutomaticDeliveryError' end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def original_error; end", "def original_error; end", "def error_message; end", "def error_class_constant(error_code); end", "def error(ex) [:error, ex]; end", "def error; end", "def error; end", "def error; end", "def error; end", "def error; end", "def error; end", "def error; end", "def e...
[ "0.757518", "0.757518", "0.7567129", "0.7501133", "0.7383669", "0.73776627", "0.73776627", "0.73776627", "0.73776627", "0.73776627", "0.73776627", "0.73776627", "0.73201376", "0.73012877", "0.71660274", "0.7143055", "0.7143055", "0.7143055", "0.7143055", "0.7127042", "0.71270...
0.0
-1
separate action, as this one makes a stripe API call
def payment_transfers authorize :report @transfers = company.transfers(start_param, end_param) # @transfers = company.transfers(300.days.ago.to_s, Date.current.to_s) respond_to do |format| format.json format.pdf { render '/companies/report' } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stripe_payment\n if params[:stripe_token].blank?\n @error = I18n.t('order.stripe_token_blank')\n render \"api/v1/shared/error\"\n return\n end\n\n begin\n if my_stripe_customer = StripeCustomer.where(:token => params[:stripe_token]).first\n my...
[ "0.6696342", "0.6291564", "0.62733585", "0.6211091", "0.61686", "0.6157328", "0.6155153", "0.6155148", "0.6149929", "0.61406296", "0.61396617", "0.613404", "0.61200106", "0.60977656", "0.60968477", "0.6092011", "0.6063209", "0.60606515", "0.6047602", "0.6030292", "0.6026652",...
0.0
-1
other sport name actions are scoped to venue; we need all possible sport names for all venues
def sport_name_options authorize :report sport_names = company.venues. flat_map { |venue| venue.supported_sports_options }. uniq { |hash| hash[:value] } render json: sport_names end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unusual_sport; end", "def venue_name\n venue.name if venue\n end", "def national_sport; end", "def unusual_sport\n fetch('sport.unusual')\n end", "def summon_captain_planet(planeteer_calls)\n planeteer_calls.collect{|item| \"#{item.capitalize}!\" }\nend", "def select_options_for_cour...
[ "0.68725216", "0.64305365", "0.6364664", "0.6239143", "0.6028444", "0.5989123", "0.59350896", "0.5926912", "0.5918938", "0.5874233", "0.5868325", "0.58343124", "0.5799144", "0.57866204", "0.57598597", "0.5754906", "0.57469916", "0.5715616", "0.5698548", "0.56727165", "0.56646...
0.672665
1
Add more helper methods to be used by all extension tests here...
def assert_included(collection, item) assert_block "#{collection} was expected to include #{item} but does not." do collection.include?(item) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_legacy_helpers\n assert_equal @patron.primary_phone, @patron.primary_address_phone\n assert_equal @patron.secondary_phone, @patron.secondary_address_phone\n assert_nil @patron.primary_address_mobile_phone\n assert_nil @patron.secondary_address_mobile_phone\n end", "def helpers; end", "def...
[ "0.6967062", "0.6659195", "0.6659195", "0.6659195", "0.6358651", "0.6245406", "0.6243533", "0.60632026", "0.6008646", "0.6008646", "0.5974782", "0.5950157", "0.5950157", "0.5921214", "0.5915907", "0.5897097", "0.5883888", "0.5813109", "0.58130866", "0.57578146", "0.57578146",...
0.0
-1
Override the == to check meta information class.
def ==(other) info == other.info rescue false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ==(o)\n return true if self.equal?(o)\n self.class == o.class &&\n class_id == o.class_id &&\n object_type == o.object_type &&\n description == o.description &&\n name == o.name &&\n type == o.type &&\n system == o.system\n end", "def meta?\r...
[ "0.678994", "0.6736585", "0.66741955", "0.6668646", "0.6637086", "0.6630656", "0.66192955", "0.6601734", "0.65938324", "0.65807176", "0.6580404", "0.6569267", "0.65652585", "0.65626097", "0.6532882", "0.65273446", "0.65181917", "0.6510914", "0.6507518", "0.64653176", "0.64574...
0.6699941
2
Doesn't work 1 Step one + two def oauth
def xauth_token consumer = oauth_consumer request_token = consumer.get_request_token consumer.get_access_token( request_token, {}, { :x_auth_mode => 'client_auth', :x_auth_username => cred['username'], :x_auth_password => cred['password'] } ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def oauth_authentication; end", "def oauth\n login_at(auth_params[:provider])\n end", "def oauth\n login_at(auth_params[:provider])\n end", "def use_oauth\n\t\t\t\n\t\tend", "def exchange_oauth_tokens\n end", "def finish_oauth\n\tRails.logger.warn 'here'\n\n @consumer = OAuth::Consumer.ne...
[ "0.8049021", "0.7187448", "0.7187448", "0.71234417", "0.7036954", "0.6910445", "0.689526", "0.6874275", "0.6873518", "0.6865121", "0.6848702", "0.6803173", "0.6740005", "0.6731169", "0.67184645", "0.6690623", "0.66871554", "0.6673406", "0.66719854", "0.66177344", "0.6616024",...
0.0
-1
Copied private helpers from lazy_high_charts/lib/lazy_high_charts/layout_helper.rb
def generate_json_from_value(value) if value.is_a? Hash %({ #{generate_json_from_hash value} }) elsif value.is_a? Array %([ #{generate_json_from_array value} ]) elsif value.respond_to?(:js_code) && value.js_code? value else value.to_json end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_layout(historical_orders)\r\n # first we have to create a ranking of all the historical order\r\n historical_orders=historical_orders\r\n\r\n hist_order_flatten = historical_orders.flatten\r\n # uniq_order = hist_order.uniq\r\n #Create a hash table to store the frequency of the items\r\n # h=Hash.new...
[ "0.62270296", "0.6205541", "0.6055754", "0.60324526", "0.59804726", "0.59769464", "0.59614563", "0.59038866", "0.5829682", "0.58250576", "0.57558066", "0.5755558", "0.5738169", "0.5706015", "0.5700915", "0.5688048", "0.56782794", "0.56724465", "0.56724465", "0.5668606", "0.56...
0.0
-1
TODO add the rest based methods
def edit # @postalAddress = PostalAddress.find(params[:id]) render :layout => 'content' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def apis; end", "def get; end", "def get()\n \n end", "def api; end", "def api; end", "def endpoint; end", "def endpoint; end", "def endpoint; end", "def endpoint; end", "def respond(); end", "def parent_api; end", "def parent_api; end", "def request; end", ...
[ "0.70525354", "0.6641224", "0.65778184", "0.63527584", "0.63467914", "0.63467914", "0.62161964", "0.62161964", "0.62161964", "0.62161964", "0.6211875", "0.6197219", "0.6197219", "0.61677575", "0.61677575", "0.61677575", "0.61677575", "0.61677575", "0.61677575", "0.61677575", ...
0.0
-1
GET /trips GET /trips.xml
def explore @center = Geocoder.coordinates(params[:city]) @trips = Trip.nearest_with_index(@center) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def trips\n get '/gtfs/trips'\n end", "def index\n @trips = Trip.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @trips }\n end\n end", "def index\n @trips = Trip.all\n\n respond_to do |format|\n format.html # index.html.erb\n ...
[ "0.80714715", "0.75858504", "0.75858504", "0.757641", "0.7477425", "0.70685476", "0.6992922", "0.6992922", "0.6992922", "0.6992922", "0.6992922", "0.6992922", "0.6992922", "0.6989182", "0.6943742", "0.68573016", "0.66799456", "0.66799456", "0.66767234", "0.6628429", "0.659922...
0.0
-1
GET /trips/1 GET /trips/1.xml
def show @trip = Trip.find(params[:id]) respond_to do |format| if @trip @owner = user_can_modify(@trip) format.html # show.html.erb format.xml { render :xml => @trip } else format.html { redirect_to root_url, :status => 301} # show.html.erb format.xml { render :xml => @trip } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def trips\n get '/gtfs/trips'\n end", "def index\n @trips = Trip.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @trips }\n end\n end", "def index\n @trips = Trip.all\n\n respond_to do |format|\n format.html # index.html...
[ "0.75066376", "0.74006474", "0.73905426", "0.73905426", "0.7244806", "0.6716845", "0.66819704", "0.66819704", "0.6571074", "0.65355915", "0.65111315", "0.65111315", "0.65111315", "0.65111315", "0.65111315", "0.65111315", "0.65111315", "0.64055055", "0.63193667", "0.62750876", ...
0.0
-1
GET /trips/new GET /trips/new.xml
def new @trip = Trip.new respond_to do |format| format.html # { redirect_to edit_trip_path(@trip) } format.xml { render :xml => @trip } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @trip = Trip.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @trip }\n end\n end", "def new\n @trip = Trip.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @trip }\n end\n end", ...
[ "0.7394252", "0.7394252", "0.7394252", "0.69261056", "0.68196785", "0.6739118", "0.6737067", "0.6732369", "0.66951734", "0.66224825", "0.66224825", "0.65944386", "0.65944386", "0.6537531", "0.65359807", "0.6525924", "0.6495073", "0.64941627", "0.64913", "0.6484872", "0.644816...
0.6791647
5
POST /trips POST /trips.xml
def create @trip = Trip.new(params[:trip]) @trip.user = @current_user r = Request.find_by_url(@trip.url) if r; r.destroy; end respond_to do |format| if @trip.save format.html { redirect_to(@trip, :notice => 'Trip was successfully created.') } format.xml { render :xml => @trip, :status => :created, :location => @trip } format.json { render :json => @trip } else format.html { render :action => "new" } format.xml { render :xml => @trip.errors, :status => :unprocessable_entity } format.json { render :json => @trip.errors.full_messages, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def trips\n get '/gtfs/trips'\n end", "def create\n @user = current_user()\n @trip = @user.own_trips.new(params[:trip])\n\n respond_to do |format|\n if @trip.save\n flash[:notice] = 'Trip was successfully created.'\n format.html { redirect_to(@trip) }\n format.xml { re...
[ "0.69789785", "0.63354826", "0.63348866", "0.63348866", "0.6160354", "0.60880387", "0.60880387", "0.60462004", "0.6016248", "0.59629536", "0.59593844", "0.5951899", "0.5945519", "0.5935993", "0.5928302", "0.59043634", "0.58977807", "0.5896994", "0.5795958", "0.5795958", "0.57...
0.58467597
18
PUT /trips/1 PUT /trips/1.xml
def update @trip = Trip.find(params[:id]) respond_to do |format| if user_can_modify(@trip) and @trip.update_attributes(params[:trip]) format.html { redirect_to(@trip, :notice => 'Trip was successfully updated.') } format.xml { head :ok } format.json { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @trip.errors, :status => :unprocessable_entity } format.json { render :json => @trip.errors.full_messages, :status => :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @trip = Trip.find(params[:id])\n\n respond_to do |format|\n if @trip.update_attributes(params[:trip])\n format.html { redirect_to(@trip, :notice => 'Trip was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n ...
[ "0.6216352", "0.6210457", "0.6210457", "0.6115239", "0.6048212", "0.5921058", "0.58874875", "0.5873431", "0.5873431", "0.58534455", "0.57654846", "0.5761491", "0.57256335", "0.57152385", "0.57075423", "0.5695536", "0.5679363", "0.5652797", "0.5652144", "0.56412137", "0.559641...
0.5560466
21
DELETE /trips/1 DELETE /trips/1.xml
def destroy @trip = Trip.find(params[:id]) respond_to do |format| if user_can_modify(@trip) and @trip.destroy format.html { redirect_to(trips_url) } format.xml { head :ok } else flash[:error] = "It appears you attempted to delete a suggestion that you did not create. Perhaps you need to log in?" format.html { redirect_to root_path } format.xml { head :ok } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @trip = Trip.find(params[:id])\n @trip.destroy\n\n respond_to do |format|\n format.html { redirect_to(trips_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @trip = Trip.find(params[:id])\n @trip.destroy\n\n respond_to do |format|\n format.html { r...
[ "0.7081429", "0.7081429", "0.7081429", "0.6829502", "0.65826833", "0.6540821", "0.65368223", "0.6535535", "0.64503074", "0.6418653", "0.6414347", "0.6414347", "0.639877", "0.6387876", "0.6387876", "0.6387876", "0.63117677", "0.62694466", "0.62405735", "0.62405735", "0.6240573...
0.60874635
44
alive PRs above =============
def test_library_book_shop_prs CartoCSSHelper::VisualDiff.visualise_on_synthethic_data({ 'shop' => 'books', 'name' => 'ÉÉÉÉÉÉ ÉÉÉÉÉÉ' }, 'node', false, 22..22, 'also_shop', 'master') n = 6 skip = 3 locator = CartoCSSHelper::LocateTagsInsideLoadedDatabases.new({ 'shop' => 'books' }, skip: skip) diff_on_loaded_database(location_provider: locator, to: 'also_shop', from: 'master', zlevels: 16..19, image_size: 375, count: n) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pending?; end", "def query_pull_requests\n # This line is where we want to add :accept => 'application/vnd.github.shadow-cat-preview+json' for draft PRs\n pull_requests = github_query(@client) { @client.pull_requests(@repository, :state => 'open', :per_page => 50) }\n\n @pull_request_details = []\n\...
[ "0.59928346", "0.5909363", "0.5828025", "0.5828025", "0.5815445", "0.5733575", "0.5733575", "0.5733575", "0.56719023", "0.56679404", "0.5664198", "0.56412005", "0.55904794", "0.5586841", "0.55595", "0.55595", "0.55497", "0.554329", "0.5538355", "0.55316156", "0.552992", "0....
0.0
-1
Reload the underlying data for model
def reload clear_memoizations! perform_reload self end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def refresh\n # re-download the model from the server\n set_model\n end", "def reload\n self.data = self.class.load_data\n self\n end", "def reload\n old_data = @data.dup\n self.load\n @data = old_data.merge! @data\n end", "def reload_data\n ...
[ "0.8155662", "0.8036726", "0.7791224", "0.77850884", "0.771851", "0.76245904", "0.7586572", "0.7567339", "0.75409615", "0.7474968", "0.7447054", "0.7446313", "0.7319621", "0.72099227", "0.71944374", "0.71546984", "0.7146751", "0.7128838", "0.71270347", "0.7120487", "0.7120487...
0.71832895
15
Adds an HTTP header to the request
def add_http_header(key, value) @http_headers[key] = value end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_headers\n @headers.each do |field, value|\n @request_header << \"#{field}: #{value}\"\n end\n end", "def add_header(header)\n @headers.merge!(header)\n end", "def add_headers; end", "def add_header(name, value)\n end", "def add_header key, value\n\t\t\t@headers ...
[ "0.78114223", "0.7737657", "0.76608366", "0.74980533", "0.74719864", "0.72978187", "0.71946865", "0.71307015", "0.71052104", "0.7026713", "0.70074236", "0.6964078", "0.6944201", "0.6932701", "0.6866111", "0.6844005", "0.6833592", "0.68277824", "0.6827778", "0.6726953", "0.671...
0.8141636
0
exercise 2 answer nothing because you have not called the block inside the method. Exercise 3 answer It handles predicted errors by providing an alternative to just havin your code error out and thus allows it to continue to execute. Exercise 4
def execute(&block) block.call end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def demonstrate_early_return\n return\n puts \"You will never see this, because we never get here.\"\nend", "def sample()\n begin\n puts \"do something\"\n rescue # can define type of error here if wanted\n puts \"we hit an error!\"\n retry # this will restart from the beginning of t...
[ "0.6389173", "0.63852507", "0.62006825", "0.6045894", "0.6045894", "0.60418856", "0.6027486", "0.6025705", "0.6014116", "0.59757215", "0.5950362", "0.5926385", "0.5924686", "0.5904691", "0.58994627", "0.58215135", "0.58161676", "0.581205", "0.5810828", "0.5809832", "0.5805388...
0.0
-1
For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically, we call it lexicographic order. The lexicographic permutations of 0, 1 and 2 are: 012 021 102 120 201 210 What is the millionth lexicographic permutation of the digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9? solution:
def factorial(n) f = 1 (1..n).each do |i| f *= i end f end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def min_permutation n\n n.to_s.chars.sort.join.to_i\nend", "def lex_permutation(n, digits)\n fact = factorial(digits.size-1)\n lead_digit = n / fact\n count = lead_digit * fact\n perms = (digits - [lead_digit]).permutation.to_a\n ([lead_digit] + perms[n - count - 1]).join\nend", "def permuted_nums()\r\n\...
[ "0.78991705", "0.788584", "0.7527743", "0.75146693", "0.73972195", "0.7318816", "0.72107565", "0.7191309", "0.71533126", "0.71504533", "0.7063112", "0.70089173", "0.70088434", "0.6856708", "0.68285215", "0.6803354", "0.6779732", "0.6748386", "0.67239904", "0.67181057", "0.666...
0.0
-1
load the workflow view
def show name = params[:name] action = params[:id] ? "show" : "index" action = params[:view] if params[:view].present? @page = ("Workflows::#{name.to_s.capitalize}::#{action.capitalize}").constantize.new(params, { user: current_user, cookies: cookies }) render(html: @page.item.display) and return if params[:view].present? render :template => "#{name}/#{action}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_view\r\n @view = XamlReader.load_from_path view_path if File.exists? view_path\r\n @view ||= view_name.to_s.gsub(/(.*::)+/, '').classify.new \r\n @view\r\n end", "def show\n workflow_steps = WorkflowStep.where(\n repository: params[:repo],\n druid: params[:druid],\n w...
[ "0.7102376", "0.63925046", "0.6367075", "0.61744845", "0.6164956", "0.61139506", "0.60870904", "0.60870904", "0.60870904", "0.6032993", "0.6004404", "0.60043406", "0.6003554", "0.59932077", "0.59932077", "0.59932077", "0.59932077", "0.5955843", "0.592802", "0.5923831", "0.591...
0.65805703
1
GET /evolutions/1 GET /evolutions/1.json
def show @evolution = Evolution.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @devolutions = Devolution.all\n end", "def evolution_request(species, name)\n\t\tevolution_request = HTTParty.get(\"http://pokeapi.co/api/v2/evolution-chain/#{species.evolution_id}\")\n\t\tevolutions = PokeapiEvolutions.new(evolution_request, name)\n\t\treturn evolutions\n\tend", "def show\n ...
[ "0.6348234", "0.6341934", "0.62985355", "0.6251146", "0.60362124", "0.60007274", "0.59500164", "0.59396225", "0.5922972", "0.5891881", "0.5885376", "0.5884324", "0.5884324", "0.5884324", "0.58804417", "0.5861999", "0.5842792", "0.58417", "0.58361787", "0.5817218", "0.58170485...
0.6410378
0
Reescreve o to_s da classe String (Polimorfismo)
def to_s puts "#{@autor}, #{@numero_paginas}, #{@isbn}, #{@valor}, #{@categoria}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_string\n s = ''\n reconstruir(s)\n s\n end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s()...
[ "0.80489784", "0.80455995", "0.80455995", "0.80455995", "0.80455995", "0.80455995", "0.80455995", "0.80455995", "0.80455995", "0.80455995", "0.80455995", "0.80455995", "0.80455995", "0.80455995", "0.80455995", "0.80455995", "0.80455995", "0.80455995", "0.80455995", "0.8041498",...
0.0
-1
If you wish override this method or use it in block form to add a notifier, callback routine or webhook, whenever a new record is added.
def on_add(xmlpath, id) yield(xmlpath, id) if block_given? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_notification; end", "def on_create(&block)\n @on_create_hook = block\n self\n end", "def on_add(&block)\n @add_proc = block\n end", "def action_add\n notifying_block do\n create_config\n end\n end", "def notifier; end", "def ...
[ "0.6626915", "0.65061176", "0.64741826", "0.64502454", "0.62697786", "0.62697786", "0.6259186", "0.62253284", "0.618931", "0.6101302", "0.6089297", "0.60891974", "0.60859466", "0.6040443", "0.6040443", "0.6016452", "0.59876955", "0.5972888", "0.59559053", "0.5929862", "0.5898...
0.0
-1
configures the target page (using a Dynarex document) for a new day
def new_day() puts 'inside new_day' if @debug @archive_path = Time.now.strftime("%Y/%b/%-d").downcase @indexpath = File.join(@filepath, @archive_path, 'index.xml') FileX.mkdir_p File.dirname(@indexpath) if FileX.exists? @indexpath then @dx = Dynarex.new @indexpath else puts 'creating a new dx file' if @debug @dx = Dynarex.new @schema, debug: @debug @dx.order = 'descending' @dx.default_key = @default_key @dx.xslt = @dx_xslt @dx.title = @title @dx.identifier = @identifier end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def go_to_date_link(user)\n\t\tdynamic_range\n\t\t@base_path = root_path+\"users/#{user.id}/scrapbook/#{@destination}\"\n\tend", "def set_page\n end", "def setPageTimer\n\t\t@pageTimer= Time.now.to_i+ @pageTimeOut\n\t\treturn OK\n\tend", "def twenty_pct_release_date=(rd=Time.now)\n update_values([:twen...
[ "0.5742993", "0.57319957", "0.5424249", "0.5418482", "0.5353863", "0.52722067", "0.52563167", "0.52300715", "0.5229549", "0.52201146", "0.52026075", "0.520027", "0.5166835", "0.51458937", "0.51351106", "0.5115724", "0.5098779", "0.5086328", "0.5086247", "0.5069055", "0.506691...
0.6240864
0
will return the length of the picked word
def pick_mystery_word @picked_word = self.dict.sample self.picked_word.length end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def word_length\n @word.length\n end", "def word_length\n\t\t@ans_word.length\n\tend", "def pick_secret_word\n\t\t@secret_word.length\n\tend", "def count_chars word3\n word3.length\nend", "def count_chars word\n word.length\nend", "def count_chars word\n word.length\nend", "def count_chars word\...
[ "0.80507606", "0.7831307", "0.770098", "0.76787126", "0.75193274", "0.75193274", "0.75193274", "0.75193274", "0.7516375", "0.7478823", "0.7358308", "0.7358308", "0.73345184", "0.73345184", "0.73345184", "0.73345184", "0.72843176", "0.7255777", "0.722342", "0.7199076", "0.7159...
0.71159375
21
guesses random word of appropriate length
def guess_word(word_length) self.sample(dict.select { |word| word.length == word_length } ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pick_mystery_word\n @picked_word = self.dict.sample\n self.picked_word.length\n end", "def pick_secret_word\n\t\t@secret_word = @dictionary.sample.chomp.downcase\n\t\t@secret_word.length\n\tend", "def get_word(difficulty)\n WORDS.select{|word| word.length == difficulty}.sample\nend", "def random_...
[ "0.7428584", "0.7291276", "0.72800356", "0.724955", "0.724955", "0.724955", "0.724955", "0.7227071", "0.7218384", "0.721788", "0.71920466", "0.7160873", "0.71190596", "0.7070547", "0.70439917", "0.70407236", "0.7022391", "0.70084393", "0.7008256", "0.6977465", "0.6966264", ...
0.80783665
0
GET /congresos/1 GET /congresos/1.json
def show @congreso = Congreso.find(params[:id]) @datos_lucrativos = false @datos_lucrativos = true if @congreso.talleres.where("precio > 0").count > 0 || @congreso.precio > 0 respond_to do |format| format.html # show.html.erb format.json { render json: @congreso } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @concursos = Concurso.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @concursos }\n end\n end", "def show\n @concurso = Concurso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { r...
[ "0.6697806", "0.65125185", "0.64398843", "0.63595873", "0.62354386", "0.6121831", "0.61186135", "0.6047988", "0.6042519", "0.5993772", "0.5972588", "0.5969116", "0.5951245", "0.594815", "0.58813465", "0.5852067", "0.58420634", "0.5840006", "0.5830641", "0.58245087", "0.58184"...
0.0
-1
GET /congresos/new GET /congresos/new.json
def new @congreso = Congreso.new @campos = Campo.all respond_to do |format| format.html # new.html.erb format.json { render json: @congreso } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @concurso = Concurso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @concurso }\n end\n end", "def new\n @colegio = Colegio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @colegio }\n...
[ "0.74713045", "0.70107067", "0.6976883", "0.6945237", "0.69343054", "0.69343054", "0.6914303", "0.68775076", "0.6869421", "0.68637633", "0.6854113", "0.68336725", "0.68263036", "0.6813396", "0.6809358", "0.678931", "0.67794216", "0.6778932", "0.6757828", "0.67484754", "0.6747...
0.7000083
2
POST /congresos POST /congresos.json
def create @congreso = Congreso.new(params[:congreso]) @congreso.user_id = current_user.id respond_to do |format| if @congreso.save crear_campos_congreso(params, @congreso.id) CongresosUser.create(:user_id => current_user.id, :congreso_id => @congreso.id) format.html { redirect_to @congreso, notice: 'Congreso registrado correctamente.' } format.json { render json: @congreso, status: :created, location: @congreso } else @campos = Campo.all format.html { render action: "new" } format.json { render json: @congreso.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @congresso = Congresso.new(congresso_params)\n\n respond_to do |format|\n if @congresso.save\n format.html { redirect_to @congresso, notice: 'Congresso was successfully created.' }\n format.json { render :show, status: :created, location: @congresso }\n else\n form...
[ "0.62635475", "0.5906436", "0.58704984", "0.5831011", "0.5774856", "0.57726395", "0.5721691", "0.5716602", "0.5667895", "0.5661955", "0.56610394", "0.56305397", "0.560854", "0.5562463", "0.55603874", "0.55582553", "0.55535257", "0.5546197", "0.5546114", "0.55394244", "0.55352...
0.57969195
4
PUT /congresos/1 PUT /congresos/1.json
def update @congreso = Congreso.find(params[:id]) @datos_lucrativos = false @datos_lucrativos = true if @congreso.talleres.where("precio > 0").count > 0 || @congreso.precio > 0 if params[:congreso][:pago] == "1" or @datos_lucrativos @congreso.personas_confirmadas.each do |persona| persona.update_attribute("pago", false) end else @congreso.personas_sin_confirmar.each do |persona| persona.update_attribute("pago", true) end end respond_to do |format| if @congreso.update_attributes(params[:congreso]) format.html do eliminar_campos_anteriores(params[:id]) crear_campos_congreso(params, params[:id]) redirect_to @congreso, notice: 'Congreso actualizado correctamente.' end format.json { head :ok } else @campos = Campo.all format.html { render action: "edit" } format.json { render json: @congreso.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def putFactura(oc)\n\n facturax= JSON.parse(HTTP.headers(:\"Content-Type\" => \"application/json\").put(\"http://\"+ $url +\"...
[ "0.6241737", "0.5864449", "0.58027565", "0.57813084", "0.56874776", "0.5687088", "0.5673597", "0.5670666", "0.56420213", "0.56092703", "0.55706835", "0.5558271", "0.5552865", "0.5534795", "0.55268055", "0.5517727", "0.54068106", "0.5404271", "0.54041106", "0.5396221", "0.5359...
0.0
-1
DELETE /congresos/1 DELETE /congresos/1.json
def destroy @congreso = Congreso.find(params[:id]) if congreso_propio?(@congreso) or current_user.is_admin? @congreso.destroy respond_to do |format| format.html { redirect_to congresos_url } format.json { head :ok } end else flash[:notice] = "Solo puedes eliminar tus propios congresos" redirect_to congresos_url end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def delete\n client.delete(\"/#{id}\")\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def delete(options={})\n connection.dele...
[ "0.7012341", "0.68018055", "0.6784304", "0.66289306", "0.6596985", "0.65949535", "0.6539506", "0.6537963", "0.65371597", "0.65371597", "0.65371597", "0.65371597", "0.6535508", "0.65319735", "0.6487854", "0.6480932", "0.6403726", "0.6401367", "0.6372781", "0.6365964", "0.63621...
0.64494455
16
The maximum sum subarray problem consists in finding the maximum sum of a contiguous subsequence in an array or list of integers: maxSequence [2, 1, 3, 4, 1, 2, 1, 5, 4] should be 6: [4, 1, 2, 1] Easy case is when the list is made up of only positive numbers and the maximum sum is the sum of the whole array. If the list is made up of only negative numbers, return 0 instead. Empty list is considered to have zero greatest sum. Note that the empty list or array is also a valid sublist/subarray. My solution
def max_sequence(arr) return arr.first if arr.size == 1 return 0 if arr.all? { |num| num < 0 } || arr.empty? current_sum = arr.first maximum = arr.first arr[1..-1].each do |num| current_sum = 0 if current_sum < 0 current_sum += num maximum = current_sum if current_sum > maximum end maximum end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def max_sequence(arr)\r\n return 0 if arr.all? { |el| el < 0 }\r\n return arr.sum if arr.all? { |el| el > 0 }\r\n return 0 if arr.empty?\r\n \r\n sub_arrs = []\r\n (0...arr.size).each do |start_index|\r\n # p \"start #{start_index}\"\r\n (1..arr.size - start_index).each do |length|\r\n # p \"lengt...
[ "0.83495635", "0.8146975", "0.81459254", "0.8106213", "0.81001323", "0.8093179", "0.8089693", "0.8069191", "0.80396765", "0.80394524", "0.8032638", "0.8007893", "0.797759", "0.79606885", "0.79575217", "0.7911105", "0.79095554", "0.78898185", "0.7887423", "0.7880399", "0.78781...
0.79979557
12
Another solution provided by another Codewars user
def max_sequence(arr) sum = arr.first ? arr.first : 0 arr.each do |num| sum_to_here = [(num), (sum_to_here + num)].max sum = [sum, sum_to_here].max end sum end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def anchored; end", "def probers; end", "def schubert; end", "def formation; end", "def suivre; end", "def terpene; end", "def intensifier; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def stderrs; end", "def berlioz; end", "def ...
[ "0.6335019", "0.6029032", "0.5975171", "0.5794461", "0.57909715", "0.5684158", "0.5682504", "0.56194514", "0.5576231", "0.5576231", "0.5576231", "0.5576231", "0.5521634", "0.55044806", "0.54941624", "0.5480229", "0.5457288", "0.5390539", "0.5378593", "0.536802", "0.5358155", ...
0.0
-1
recursive using splat operator:
def zip(*arrs) return [] if arrs.any?(&:empty?) [arrs.map(&:first)] + zip(arrs.first.drop(1), arrs.last.drop(1)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def splat_mth(*mult_arg)\n p mult_arg #it's array :) !\n p mult_arg.class\n p mult_arg.object_id\n mult_arg.map {|arg| }\n end", "def __splat(x) end", "def xargs *args\r\n m = args.shift\r\n args.slice!(-1).each {|a|\r\n method(m).call(*(args + [a]))\r\n }\r\nend", "def [](*args)\n\t\t\tdont_sp...
[ "0.70947117", "0.68416244", "0.64176214", "0.6258929", "0.61434114", "0.6136593", "0.6010784", "0.5987226", "0.5986348", "0.59125274", "0.58904517", "0.58672816", "0.5854529", "0.5827203", "0.5824475", "0.5798848", "0.5792286", "0.57868606", "0.5745624", "0.57324916", "0.5722...
0.0
-1
def zip(arrs) arrs.transpose end using Enumerablereduce:
def zip(arr1, arr2) arr1.each_with_index.reduce([]) { |result, (el, idx)| result << [el, arr2[idx]] } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def zip(*rest) end", "def my_zip(*arrs)\n zipped = []\n self.each_with_index do |ele, i|\n sub = [ele]\n arrs.each do |arr|\n sub << arr[i]\n end\n zipped << sub\n end\n zipped\n end", "def zip(*arrs)\n return [] if arrs...
[ "0.7571705", "0.7415248", "0.7187294", "0.7150408", "0.6961229", "0.6958176", "0.68624747", "0.6765536", "0.66734755", "0.6670809", "0.6627896", "0.66239977", "0.65949893", "0.65732735", "0.65641654", "0.64650285", "0.64628506", "0.64499116", "0.6448578", "0.642767", "0.64098...
0.64506775
17
metodele pot avea semnul intrebarii in nume, si sunt utile pentru teste si booleene
def over_five?(value=nil) return "Exactly 5" if value.to_i == 5 if value.to_i > 5 return "Over 5" else return "Under 5" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cuadrada\n @n==@m\n end", "def verificaesonitre (primo, secondo, terzo)\n\tesonicomuni=0\n\t#se il secondo e il terzo includono lo stesso esone lo conto come comune\n\tprimo.each do |v|\n\t\tif secondo.include?(v) then\n\t\t\tif terzo.include?(v) then \n\t\t\t\tesonicomuni=esonicomuni+1\n\t\t\tend\n\t\te...
[ "0.6641832", "0.6495455", "0.6424004", "0.6386927", "0.63541365", "0.63343424", "0.6143551", "0.61426187", "0.6068163", "0.6068163", "0.5986444", "0.5906948", "0.5846855", "0.5841875", "0.58397985", "0.58326954", "0.5832222", "0.582836", "0.57880646", "0.5786467", "0.57599753...
0.0
-1
Example shows touch emulation via mouse (Limited to one finger due to how mouse input works...) This example also works with touch input.
def tick args drtouch = DRTouch.new drtouch.init drtouch.update args.outputs.background_color = [ 0, 0, 0, 255 ] args.outputs.primitives << { x: 320, y: 16.from_top, text: "TAP AND MOVE YOUR FINGER OVER THE SCREEN", size_enum: 6, r: 255, g: 255, b: 255, a: 255, }.label if drtouch.down(0) pos = drtouch.pos(0) args.outputs.primitives << { x: pos.x, y: pos.y, w: 50, h: 50, r: 34, g: 155, b: 255, a: 255, }.solid args.outputs.primitives << { x: 16, y: 8.from_top, text: "x1: #{pos.x}, y1: #{pos.y}", size_enum: 2, r: 255, g: 0, b: 0, a: 255 }.label end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def emulate_touch_from_mouse_event(type:, x:, y:, button:, timestamp: nil, delta_x: nil, delta_y: nil, modifiers: nil, click_count: nil)\n {\n method: \"Input.emulateTouchFromMouseEvent\",\n params: { type: type, x: x, y: y, button: button, timestamp: timestamp, deltaX: delta_x, deltaY: de...
[ "0.70344335", "0.66133666", "0.63074625", "0.61381793", "0.60940593", "0.58070683", "0.5750648", "0.5720025", "0.5717996", "0.56786686", "0.5646187", "0.563888", "0.5625886", "0.5617192", "0.55725396", "0.5548815", "0.5545369", "0.5527475", "0.5505151", "0.5497132", "0.548487...
0.5853712
5
recursively calculates the sum of an array of values
def sum_rec(nums) return 0 if nums.empty? nums[0] + sum_rec(nums[1..-1]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum_recur(array)\n#for array = []\n return 0 if array == []\n\n first_el = array.shift\n recursive_call = sum_recur(array)\n first_el + recursive_call\n\nend", "def sum_recur(array)\n #base case\n return 0 if array.empty?\n #iterative step\n array.first + sum_recur(array[1..-1])\nend", "def sum_rec...
[ "0.7986957", "0.79828656", "0.7939578", "0.7920229", "0.7911069", "0.7871189", "0.78689075", "0.78400886", "0.78203493", "0.7754614", "0.7750766", "0.7742184", "0.77360535", "0.76485944", "0.7594101", "0.75603014", "0.75281996", "0.74930584", "0.74851376", "0.7479249", "0.746...
0.0
-1
FIXME make work for nested offsets
def [](*args) case args.size when 1 index = args[0] if index.kind_of?(Range) offset = index.begin limit = index.end - index.begin limit += 1 unless index.exclude_end? self.limit(limit, offset) else by_id(ids[index]) end when 2 offset, limit = args self.limit(limit, offset) else raise ArgumentError.new("wrong number of arguments (#{args.size} for 1 or 2)") end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def offset(*) end", "def normalize_offset(offset); end", "def offset; end", "def offset; end", "def offset; end", "def first_offset; end", "def first_offset; end", "def current_offset; end", "def x_offset; end", "def offset(arg0)\n end", "def derive_offsets(transitions, offsets); end", "def ...
[ "0.7270089", "0.7125723", "0.70936626", "0.70936626", "0.70936626", "0.7032432", "0.7032432", "0.68590117", "0.6700892", "0.6677489", "0.66478765", "0.66478765", "0.6264708", "0.6193879", "0.61311305", "0.6130964", "0.6130964", "0.6130964", "0.6130964", "0.60879034", "0.60870...
0.0
-1
This method is used above (sixty_four, thirty_two) so we know whether to specify the architecture as part of the path name.
def old_version? case @node['platform'] when 'ubuntu' Chef::VersionConstraint.new("< 11.0").include?(@node['platform_version']) when 'debian' Chef::VersionConstraint.new("< 7.0").include?(@node['platform_version']) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def architecture # rubocop:disable Lint/DuplicateMethods\n @architecture ||= @name.match(PLATFORM_REGEX)[3]\n end", "def get_p4_os_directory\n architecture = new_resource.sixty_four ? \"x86_64\" : \"x86\"\n case node[:os]\n when \"linux\"\n os = \"linux26#{architecture}\"\n when \"darwin\"\n os...
[ "0.7343044", "0.68008155", "0.6767918", "0.6751836", "0.6549634", "0.64888793", "0.6461936", "0.64119744", "0.63984734", "0.6347267", "0.63118386", "0.6305536", "0.6275302", "0.62577486", "0.62538505", "0.624295", "0.624295", "0.6235481", "0.6222411", "0.6207273", "0.6184887"...
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_club_info @club_info = ClubInfo.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.61642385", "0.60448", "0.5945487", "0.5915654", "0.58890367", "0.58330417", "0.5776098", "0.5703048", "0.5703048", "0.5654613", "0.5620029", "0.5423114", "0.540998", "0.540998", "0.540998", "0.5393666", "0.53783023", "0.53568405", "0.53391176", "0.5339061", "0.53310865", ...
0.0
-1
Only allow a trusted parameter "white list" through.
def club_info_params params.require(:club_info).permit(:club_id, :date, :males, :females, :lowerage, :upperage, :disability, :ethnicity, :mentalhealth, :depravation, :drugsandabs, :neets, :volnum, :volhours, :volachievetraining) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", ...
[ "0.7123669", "0.7054077", "0.69472784", "0.6902165", "0.6736001", "0.671985", "0.6687218", "0.6676269", "0.66602534", "0.6556639", "0.6527985", "0.645892", "0.645072", "0.64494324", "0.6445436", "0.64350927", "0.6415061", "0.6415061", "0.6393001", "0.6378958", "0.6378958", ...
0.0
-1
=begin 1. Print a welcome message < 2. Print a promp for p/r/s < 3. Get user input < 4. Have program randomly choose p/r/s < 5. Do comparison between user input and computer input 6. Tell what each chose. 7. Tell result (paper wraps rock, etc) 8. Tell who wins/loses 9. Ask to play again =end
def play_again() puts "Do you want to play again? (yes, no)" play_again = gets.chomp.downcase if play_again == "yes" play_game() end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def paper_scissors_rock\n clear_screen\n draw_shovel_line\n\tputs \"\\n Play with the Sphinx's stomach to get out!\\n\"\n sleep(1)\n\tresult = rand(3).floor\n\task_user \"\\n What have you got?:\" , \" \\n\\n 1| for paper \\u{1F4C3}\\n 2| for scissors \\u{2702}\\n 3| for rock \\u{270A}\\n\\n\"\n\tsleep(0...
[ "0.79446936", "0.75527847", "0.75349027", "0.7512115", "0.75055546", "0.7451891", "0.7248234", "0.71866965", "0.717533", "0.71686935", "0.71383506", "0.7125307", "0.7117587", "0.7108755", "0.70825565", "0.7061152", "0.7060648", "0.704767", "0.7039294", "0.692148", "0.6889509"...
0.0
-1
Finds Single match via the supplied ID Usage: match = PUBG::Match(1337) Arguments: id: (Integer)
def match(id) self.get("/matches/#{id}") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def match(match_id)\n get_request(shard_endpoint_uri(\"matches/#{match_id}\"))\n end", "def find options={}, match_id:\n DynamicModel.new perform_request api_url \"matches/#{match_id}\", options\n end", "def get_match\n @match = Match.find( params[:match_id] )\n raise ActiveRecord::Record...
[ "0.7601857", "0.7325076", "0.687629", "0.6634679", "0.6585606", "0.65841526", "0.65738595", "0.6571568", "0.6571568", "0.6571568", "0.6571568", "0.6571568", "0.6571568", "0.6571568", "0.6571568", "0.6571568", "0.6571568", "0.6571568", "0.6571568", "0.6571568", "0.6571568", ...
0.79567343
0
Builds the query that will be passed to the matches request, based on what options are supplied (if any)
def query_builder(options) parsed_options = [] options.each do |key,value| case key when :offset parsed_options << "page[offset]=#{value}" when :limit parsed_options << "page[limit]=#{value}" when :sort parsed_options << "sort=#{value}" when :created_at_start parsed_options << "filter[createdAt-start]=#{value}" when :created_at_end parsed_options << "filter[createdAt-end]=#{value}" when :player_ids parsed_options << "filter[playerIds]=#{value.join(',')}" when :game_mode parsed_options << "filter[gameMode]=#{value}" end end if options.empty? "/matches" else queries = parsed_options.join("&") "/matches?#{queries}" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_query(options)\n array = []\n\n options.each do |key, value|\n next if key == :all\n if [:filter, :select, :top].include?(key)\n array << \"$#{key}=#{value}\" if value\n elsif key == :continuation_token\n value.each { |k, token| array << \"#{...
[ "0.72319084", "0.6983082", "0.6948496", "0.6912919", "0.6810623", "0.6707633", "0.6572565", "0.65251833", "0.648483", "0.6458556", "0.6419039", "0.64018494", "0.6397483", "0.63915026", "0.6379985", "0.6338988", "0.6320643", "0.6273354", "0.6254824", "0.62426573", "0.6222928",...
0.80172116
0
overrides documents with the same url
def elastics_id Digest::MD5.hexdigest url end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def override\n document_id = params[:document_id]\n document = params[:document]\n document_type = params[:document_type]\n ticket = Document.ticket(Alfresco::Document::ALFRESCO_USER, Alfresco::Document::ALFRESCO_PASSWORD)\n\n builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|\n ...
[ "0.6641335", "0.6539788", "0.65353876", "0.65353876", "0.6282879", "0.6169774", "0.6070363", "0.6063825", "0.60279983", "0.59925115", "0.59925115", "0.59732217", "0.5966653", "0.5940291", "0.59290653", "0.59290653", "0.5928588", "0.58986956", "0.58986956", "0.58986956", "0.58...
0.0
-1
returns the original title of the document or missing_title
def attachment_title orig_title = super orig_title.blank? ? missing_title : orig_title rescue NoMethodError missing_title end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def original_title\n document[\"originalTitle\"] rescue nil\n end", "def title\n @doc.title || DEFAULT_TITLE\n end", "def title\n @title ||= Utilities.longest_common_substring_in_array(titles.values) \n @title = titles[:og_title] unless title_ok?\n @title = titles[:html_title] un...
[ "0.8779934", "0.79077226", "0.77170014", "0.75443035", "0.7420337", "0.738242", "0.7377188", "0.73455167", "0.73398316", "0.73380643", "0.7327446", "0.72898304", "0.72233427", "0.71817076", "0.713298", "0.7102444", "0.7089676", "0.7065898", "0.701621", "0.69968915", "0.698647...
0.7502274
4
Makes a Web Scrapper to get the twitter description
def fetch_twitter_informations unparsed_html = Nokogiri::HTML(open(twitter_profile_address)) self.twitter_username = fetch_twitter_username(unparsed_html) self.twitter_description = fetch_twitter_description(unparsed_html) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getTwitters(searchTerm)\n # url encoding the searchterm\n searchTerm = CGI::escape(searchTerm)\n \n # grabbing the search results for the given searchTerm from summize as a REXML document\n doc = REXML::Document.new open(\"http://summize.com/search.atom?lang=en&rpp=100&q=#{searchTerm}\").read\n ...
[ "0.66195697", "0.65626043", "0.6519734", "0.6477642", "0.64733297", "0.64159995", "0.6252092", "0.62426245", "0.61802083", "0.6168861", "0.6164772", "0.6151207", "0.6137684", "0.60889065", "0.6015941", "0.60034657", "0.5990987", "0.5990987", "0.59700227", "0.59684956", "0.596...
0.6654091
0
Return all the elements containing currency input text field
def get_currency_input_field_elements elements(xpath: './/label[contains(text(),"Limit") or contains(text(), "Accounts Receivable") or contains(text(), "On Premises") or contains(text(), "Off Premises")]//following-sibling::app-currency-input/input[1]') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear_currency_input_field_elements\n get_currency_input_field_elements.each do |ele|\n # This is a temporary work around for clearing the currency input field as '.clear' on element is not working\n ele.send_keys(:control, a)\n end\n end", "def get_all_price\n page = Nokogiri::HTML(open(...
[ "0.6336415", "0.58622056", "0.56495047", "0.5637705", "0.55859274", "0.55801743", "0.557341", "0.5567995", "0.55606097", "0.55167186", "0.54955214", "0.54481405", "0.5432425", "0.54159683", "0.53988266", "0.53815293", "0.53564405", "0.53067076", "0.5246456", "0.5239302", "0.5...
0.7382589
0
Clear input field of all the elements containing currency input text field
def clear_currency_input_field_elements get_currency_input_field_elements.each do |ele| # This is a temporary work around for clearing the currency input field as '.clear' on element is not working ele.send_keys(:control, a) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear_text_field(locator)\n find(locator).clear\n end", "def clear\n set ' '\n # PhoneNumber inputs have country dial code pre-populated on focus. To have\n # it fully cleared, need more than one \"backspace\" hit\n wait_until_true do\n native.send_keys :backspace\n value.empty?\n ...
[ "0.6813654", "0.65169317", "0.6312544", "0.6279329", "0.6050338", "0.60489315", "0.59699625", "0.5887981", "0.58871186", "0.5874187", "0.5860212", "0.58410794", "0.57665896", "0.5751195", "0.5736496", "0.5716399", "0.5713885", "0.5687539", "0.5665564", "0.5622061", "0.5588736...
0.8816248
0
DNA to RNA Conversion Deoxyribonucleic acid, DNA is the primary information storage molecule in biological systems. It is composed of four nucleic acid bases Guanine ('G'), Cytosine ('C'), Adenine ('A'), and Thymine ('T'). Ribonucleic acid, RNA, is the primary messenger molecule in cells. RNA differs slightly from DNA its chemical structure and contains no Thymine. In RNA Thymine is replaced by another nucleic acid Uracil ('U'). Create a funciton which translates a given DNA string into RNA. For example: DNAtoRNA("GCAT") returns ("GCAU") The input string can be of arbitrary length in particular, it may be empty. All input is guaranteed to be valid, i.e. each input string will only ever consist of 'G', 'C', 'A' and/or 'T'.
def DNAtoRNA(dna) dna.gsub("T", "U") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dna_to_rna(string)\n index = 0\n rna_strand = \"\"\n while index < string.length\n if string[index] == \"G\"\n rna_strand << \"C\"\n elsif string[index] == \"C\"\n rna_strand << \"G\"\n elsif string[index] == \"T\"\n rna_strand << \"A\"\n elsif string[index] == \"A\"\n rna_st...
[ "0.77877134", "0.75076234", "0.7242171", "0.72287625", "0.6791206", "0.6569357", "0.63117486", "0.6245453", "0.61811334", "0.6178439", "0.6146539", "0.6055493", "0.57858807", "0.5694598", "0.56432116", "0.5634003", "0.5576411", "0.5539162", "0.53444237", "0.53415924", "0.5328...
0.7727879
1
Password not required when using omniauth
def password_required? super && identities.empty? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def password_required?\n super unless has_facebook_auth\n end", "def password_required?\n if new_record? && oauth_account\n false\n else\n super\n end\n end", "def password_required?; end", "def password_required?; false; end", "def password_required?\n return false if provider.t...
[ "0.7306579", "0.70609087", "0.69560224", "0.69510645", "0.69500375", "0.69206387", "0.6811992", "0.68007916", "0.6742667", "0.6742667", "0.6742667", "0.6742667", "0.6742667", "0.6742667", "0.6742667", "0.6742667", "0.6742667", "0.6742667", "0.6742667", "0.6742667", "0.6742667...
0.63136417
95
PATCH /project_evaluations?id=2 only for lecturers
def update if @pe.update(update_project_evaluation_params) render json: @pe, status: :ok else render json: format_errors(@pe.errors), status: :unprocessable_entity end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n redirect_to(root_url) && return unless current_user.can_edit_patient_laboratories?\n\n lab = Laboratory.find_by(id: params.permit(:id)[:id])\n lab.update!(lab_type: params.permit(:lab_type)[:lab_type],\n specimen_collection: params.permit(:specimen_collection)[:specimen_collect...
[ "0.6515963", "0.6326488", "0.62572396", "0.6192949", "0.6171399", "0.61149895", "0.60738885", "0.60724336", "0.6042404", "0.6032275", "0.60265213", "0.6025714", "0.60237044", "0.59762067", "0.5975909", "0.59741354", "0.59681755", "0.59662396", "0.59509355", "0.5947667", "0.59...
0.5961496
18