query
stringlengths
7
9.5k
document
stringlengths
10
1.07M
negatives
listlengths
19
19
metadata
dict
author ahmed jihad called to show answer view for questionnaires finds the selected questionnaire Args :
def answer_show @questionnaire = Questionnaire.find(params[:id]) answer = @questionnaire.answer_questionnaires.build render 'answer_show' end
[ "def view_quiz\n @questionnaire = Questionnaire.find(params[:id])\n @participant = Participant.find(params[:pid]) #creating an instance variable since it needs to be sent to submitted_content/edit\n render :view\n end", "def index\n @selection_items_questionnaires = SelectionItemsQuestionnaire.all\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Send to reviewer Questionnaire Args :
def sendQuestionnaire email=params[:email] emails=email.split(",") description=params[:description] questionnaire_id = params[:questionnaire_id] emails.each do |one| ReviewerInviter.task_invitation(one, description, "http://localhost:3000/questionnaires/answer_show?id="+questionnaire_id).deliv...
[ "def create_reply\n @realtor = Realtor.find(params[:id])\n @inquiry = Inquiry.find(params[:inquiry_id])\n @inquiry.response = params[:response][0]\n @inquiry.save\n\n ApplicationMailer.email_notify(@inquiry.hunter.user).deliver\n\n flash[:notice] = 'Reply was successfully sent.'\n redirect_to v...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /test_results/1 GET /test_results/1.json
def show @test_result = TestResult.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @test_result } end end
[ "def results\n vars = {\"trt_id\"=> @test_id}\n vars[\"type\" => @results_type] if @results_type\n\n path = \"test/results\"\n path = \"try_it_now/results\" if login_name == \"try_it_now\"\n response = api_request path, vars\n response[\"results\"]\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /test_results/new GET /test_results/new.json
def new @test_result = TestResult.new respond_to do |format| format.html # new.html.erb format.json { render json: @test_result } end end
[ "def new\n @test_result = TestResult.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @test_result }\n end\n end", "def new\n @newtest = Newtest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @ne...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /test_results/1 PUT /test_results/1.json
def update @test_result = TestResult.find(params[:id]) respond_to do |format| if @test_result.update_attributes(params[:test_result]) format.html { redirect_to @test_result, notice: 'Test result was successfully updated.' } format.json { head :no_content } else format.html {...
[ "def update\n @testresult = Testresult.find(params[:id])\n\n respond_to do |format|\n if @testresult.update_attributes(params[:testresult])\n format.html { redirect_to @testresult, notice: 'Testresult was successfully updated.' }\n format.json { head :no_content }\n else\n forma...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /test_results/1 DELETE /test_results/1.json
def destroy @test_result = TestResult.find(params[:id]) @test_result.destroy respond_to do |format| format.html { redirect_to test_results_url } format.json { head :no_content } end end
[ "def destroy\n @testresult = Testresult.find(params[:id])\n @testresult.destroy\n\n respond_to do |format|\n format.html { redirect_to testresults_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @test_run.destroy\n respond_to do |format|\n format.html { redi...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /schools/1 GET /schools/1.xml
def show @school = School.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @school } end end
[ "def index\n @schools = School.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @schools }\n end\n end", "def index\n @schools = School.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :x...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /schools/1 DELETE /schools/1.xml
def destroy @school = School.find(params[:id]) @school.destroy respond_to do |format| format.html { redirect_to(schools_url) } format.xml { head :ok } end end
[ "def destroy\n @school.destroy\n\n respond_to do |format|\n format.html { redirect_to(schools_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @school = School.find_by_param(params[:id])\n @school.destroy\n\n respond_to do |format|\n format.html { redirect_to(school...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Makes this session handle cookies and store them in in +file+. If file is nil they will be stored in memory. Otherwise the +file+ must be readable and writable. Calling multiple times will add more files.
def handle_cookies(file = nil) if file path = Pathname(file).expand_path unless File.exists?(file) and File.writable?(path.dirname) raise ArgumentError, "Can't create file #{path} (permission error)" end unless File.readable?(file) or File.writable?(path) raise ...
[ "def handle_cookies(file_path = nil)\n if file_path\n path = Pathname(file_path).expand_path\n \n if !File.exist?(file_path) && !File.writable?(path.dirname)\n raise ArgumentError, \"Can't create file #{path} (permission error)\"\n elsif File.exist?(file_path) && !File.writ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Enable debug output to stderr or to specified +file+.
def enable_debug(file = nil) set_debug_file(file.to_s) end
[ "def enable_debug(file = nil)\n set_debug_file(file.to_s)\n self\n end", "def puppet_debug_override\n Puppet::Util::Log.level = :debug\n Puppet::Util::Log.newdestination(:console)\n end", "def debug_output_file\n \"debug.log\"\nend", "def set_debug_output(arg); end", "def debug!\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Uploads the passed +data+ to the specified +url+ using HTTP PUT. +data+ must be a string.
def put(url, data, headers = {}) request(:put, url, headers, :data => data) end
[ "def http_put(url, data, initheader = nil, &block)\n uri =uri(url)\n res = Net::HTTP.start(uri.hostname, uri.port) do |http|\n http.request_put(uri, data, initheader, &block)\n end\n res.body\n end", "def upload_part(url, data)\n conn = Faraday.new(url: url) do |faraday|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Uploads the contents of a file to the specified +url+ using HTTP PUT.
def put_file(url, filename, headers = {}) request(:put, url, headers, :file => filename) end
[ "def put(url)\n authsub_http_request(Net::HTTP::Put,url)\n end", "def put(url, data, headers = {})\n request(:put, url, headers, :data => data)\n end", "def put(url, vars={})\n send_request url, vars, 'PUT'\n end", "def put url, body, headers = {}\n http_request(url, Net::HTTP::Put, b...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Uploads the passed +data+ to the specified +url+ using HTTP POST. +data+ must be a string.
def post(url, data, headers = {}) request(:post, url, headers, :data => data) end
[ "def upload_part(url, data)\n conn = Faraday.new(url: url) do |faraday|\n faraday.adapter :net_http\n end\n resp = conn.put do |req|\n req.body = data\n # to prevent Faraday from adding garbage header\n req.headers['Content-Type'] = ''\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Uploads the contents of a file to the specified +url+ using HTTP POST.
def post_file(url, filename, headers = {}) request(:post, url, headers, :file => filename) end
[ "def submit_file_by_url(**options)\n post_request(\"/submit/url-to-file\", options)\n end", "def upload_url(url, options = {})\n params = upload_params(options).for_url_upload(url)\n file_upload_response = request_file_upload(params)\n\n handle_response(file_upload_response)\n end", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
WebDAV methods Sends a WebDAV COPY request to the specified +url+.
def copy(url, dest, headers = {}) headers['Destination'] = dest request(:copy, url, headers) end
[ "def copy(path, options = {}, &block)\n perform_request Net::HTTP::Copy, path, options, &block\n end", "def http_copy(request, response)\n path = request.path\n\n copy_info = @server.copy_and_move_info(request)\n\n return false unless @server.emit('beforeBind', [copy_info['destination...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Looking for all Helper checks, which by convention start with attribute 'helper_start_with' value. Returns a array of strings, method names.
def __list_helper_methods # avoiding '__self__' and '__id__' symbols with last regex part methods.grep(/^#{@@helper_start_with}.*?[^__]$/) do |method| method.to_s end end
[ "def extract_helper_methods\n @helper_methods ||= __list_helper_methods\n @check_methods ||= __list_check_methods\n end", "def helpers\n [\"default_helper\",\"#{name}_helper\"]\n end", "def __list_check_methods\n methods.grep(/^#{@@checks_start_with}/) do |method|\n method.to_s\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Look for method names that start with attribute 'checks_start_with' value. Returns a array of strings.
def __list_check_methods methods.grep(/^#{@@checks_start_with}/) do |method| method.to_s end end
[ "def list_methods_matching name\n found = []\n\n find_methods name do |store, klass, ancestor, types, method|\n if types == :instance or types == :both then\n methods = store.instance_methods[ancestor]\n\n if methods then\n matches = methods.grep(/^#{Regexp.escape method.to_s}/)\n\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Similar to match_at, but returns true/false instead of MatchData.
def match_at? rexp, pos = 0 MatchAt.match_at? self, rexp, pos end
[ "def match_at? str, pos = 0\n MatchAt.match_at? str, self, pos\n end", "def match?\n @match\n end", "def is_matched(ind)\n\t\treturn @tile_Array[ind].return_match\n\tend", "def matches?(cell); end", "def matches?(value, context); end", "def matches?(actual); end", "def matches?\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Similar to match_at, but returns true/false instead of MatchData.
def match_at? str, pos = 0 MatchAt.match_at? str, self, pos end
[ "def match_at? rexp, pos = 0\n MatchAt.match_at? self, rexp, pos\n end", "def match?\n @match\n end", "def is_matched(ind)\n\t\treturn @tile_Array[ind].return_match\n\tend", "def matches?(cell); end", "def matches?(value, context); end", "def matches?(actual); end", "def matches?\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
I worked on this challenge by myself. longest_string is a method that takes an array of strings as its input and returns the longest string +list_of_words+ is an array of strings longest_string(list_of_words) should return the longest string in +list_of_words+ If +list_of_words+ is empty the method should return nil In...
def longest_string(list_of_words) if list_of_words.length > 0 longest_word = list_of_words[0] for word in list_of_words if word.length > longest_word.length longest_word = word end end return longest_word end end
[ "def longest_string(list_of_words)\n if list_of_words.length == []\n nil\n else\n longest = list_of_words.pop\n list_of_words.each do |word|\n if word.length > longest.length\n longest = word\n end\n end\n return longest\n end\nend", "def longest_string(list_of_words)\n length...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /item_types/1 GET /item_types/1.xml
def show @item_type = ItemType.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @item_type } end end
[ "def show\n @item_type = ItemType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @item_type }\n end\n end", "def index\n @types = Type.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /item_types/new GET /item_types/new.xml
def new @item_type = ItemType.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @item_type } end end
[ "def new\n @item_type = ItemType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item_type }\n end\n end", "def new\n @item_type = ItemType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /item_types POST /item_types.xml
def create @item_type = ItemType.new(params[:item_type]) respond_to do |format| if @item_type.save flash[:notice] = 'ItemType was successfully created.' format.html { redirect_to(@item_type) } format.xml { render :xml => @item_type, :status => :created, :location => @item_...
[ "def create\n @item_type = ItemType.new(item_type_params)\n\n if @item_type.save\n render json: @item_type, status: :created, location: @item_type\n else\n render json: @item_type.errors, status: :unprocessable_entity\n end\n end", "def create\n @itemtype = Itemtype.new(itemtype_params)\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PUT /item_types/1 PUT /item_types/1.xml
def update @item_type = ItemType.find(params[:id]) respond_to do |format| if @item_type.update_attributes(params[:item_type]) flash[:notice] = 'ItemType was successfully updated.' format.html { redirect_to(@item_type) } format.xml { head :ok } else format.h...
[ "def update\n @item_type = ItemType.find(params[:id])\n\n respond_to do |format|\n if @item_type.update_attributes(params[:item_type])\n format.html { render :action => 'edit', :notice => 'Item type was successfully updated.' }\n format.xml { head :ok }\n else\n format.html { r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /item_types/1 DELETE /item_types/1.xml
def destroy @item_type = ItemType.find(params[:id]) @item_type.destroy respond_to do |format| format.html { redirect_to(item_types_url) } format.xml { head :ok } end end
[ "def destroy\n @item_type = ItemType.find(params[:id])\n # You cannot destroy item types\n respond_to do |format|\n format.html { redirect_to(item_types_url) }\n format.xml { head :ok }\n end\n end", "def delete\n api_xml(category(target),:delete) if options.data or options.category\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /computer_cases GET /computer_cases.json
def index @computer_cases = ComputerCase.all end
[ "def index\n @it_cases = ItCase.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @it_cases }\n end\n end", "def index\n if params[:problems].blank?\n @cases = Case.all\n else\n @cases = Case.as(:c).where('c.stock <= 1').pluck(:c)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /computer_cases POST /computer_cases.json
def create @computer_case = ComputerCase.new(computer_case_params) respond_to do |format| if @computer_case.save format.html { redirect_to @computer_case, notice: 'Computer case was successfully created.' } format.json { render :show, status: :created, location: @computer_case } els...
[ "def create\n\n @case = Case.new(case_params)\n\n respond_to do |format|\n if @case.save\n format.html { redirect_to cases_path, notice: 'Case was successfully created.' }\n format.json { render action: 'show', status: :created, location: @cases_path }\n else\n format.html { ren...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /computer_cases/1 PATCH/PUT /computer_cases/1.json
def update respond_to do |format| if @computer_case.update(computer_case_params) format.html { redirect_to @computer_case, notice: 'Computer case was successfully updated.' } format.json { render :show, status: :ok, location: @computer_case } else format.html { render :edit } ...
[ "def update\n @clientcase = Clientcase.find(params[:id])\n\n respond_to do |format|\n if @clientcase.update_attributes(params[:clientcase])\n format.html { redirect_to @clientcase, :notice => 'Clientcase was successfully updated.' }\n format.json { head :ok }\n else\n format.htm...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /computer_cases/1 DELETE /computer_cases/1.json
def destroy @computer_case.destroy respond_to do |format| format.html { redirect_to computer_cases_url, notice: 'Computer case was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @clientcase = Clientcase.find(params[:id])\n @clientcase.destroy\n\n respond_to do |format|\n format.html { redirect_to clientcases_url }\n format.json { head :ok }\n end\n end", "def delete_floor_plan(args = {}) \n delete(\"/files.json/floorplan/images\", args)\nend", "def...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Track an event for a previously identified user
def track_user_event(event, user, props=nil) analytics_provider_instance.track_user_event(event, user, props) if analytics_provider_instance && Rails.configuration.analytics[:enabled] end
[ "def track_server_event(name, user, properties = {})\n user_id = user ? user.id : 'anonymous'\n @last_event = { name: name, user_id: user_id, properties: properties }\n\n if enabled?\n @segment_io.track(\n user_id: user_id,\n event: name,\n properties: properties\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Does PostgreSQL support migrations?
def supports_migrations? true end
[ "def supports_migrations? #:nodoc:\n true\n end", "def supports_migrations?\n false\n end", "def migrate\n raise NotImplementedError\n end", "def run_migration; end", "def target_postgresql_version; end", "def migrate?\n raise NotImplementedError\n end", "def migr...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the configured supported identifier length supported by PostgreSQL, or report the default of 63 on PostgreSQL 7.x.
def table_alias_length @table_alias_length ||= ( postgresql_version >= 80000 ? select_one('SHOW max_identifier_length')['max_identifier_length'].to_i : 63 ) end
[ "def max_identifier_length\n @max_identifier_length ||= query_value(\"SHOW max_identifier_length\", \"SCHEMA\").to_i\n end", "def max_identifier_length\n @max_identifier_length ||= select_one('SHOW max_identifier_length', 'SCHEMA'.freeze)['max_identifier_length'].to_i\n end", "def max_identifier...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns an array of schema names.
def schema_names select_values( "SELECT nspname FROM pg_namespace" << " WHERE nspname !~ '^pg_.*' AND nspname NOT IN ('information_schema')" << " ORDER by nspname;", 'SCHEMA') end
[ "def schema_names\n select_value(<<-SQL, 'SCHEMA')\n SELECT nspname\n FROM pg_namespace\n WHERE nspname !~ '^pg_.*'\n AND nspname NOT IN ('information_schema')\n ORDER by nspname;\n SQL\n end", "def schema_names\n sele...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns true if schema exists.
def schema_exists?(name) select_value("SELECT COUNT(*) FROM pg_namespace WHERE nspname = '#{name}'", 'SCHEMA').to_i > 0 end
[ "def schema_exists?(name); end", "def schema?\n !schema.empty?\n end", "def schema?\n ! schema.empty?\n end", "def schema_exists?(schema) \n db.query('SHOW DATABASES').any? { |d| d['Database'] == schema }\n end", "def schema_exists?(schema_name, db_name)\n psql_cmd([\"-d '#{db_nam...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the current database encoding format.
def encoding select_value( "SELECT pg_encoding_to_char(pg_database.encoding)" << " FROM pg_database" << " WHERE pg_database.datname LIKE '#{current_database}'", 'SCHEMA') end
[ "def encoding\n query(<<-end_sql, 'SCHEMA')[0][0]\n SELECT pg_encoding_to_char(pg_database.encoding) FROM pg_database\n WHERE pg_database.datname LIKE '#{current_database}'\n end_sql\n end", "def encoding\n select_value(\"SELECT pg_encoding_to_char(encoding) FROM pg_d...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the current database ctype.
def ctype select_value( "SELECT pg_database.datctype FROM pg_database WHERE pg_database.datname LIKE '#{current_database}'", 'SCHEMA') end
[ "def ctype\n query_value(\"SELECT datctype FROM pg_database WHERE datname = current_database()\", \"SCHEMA\")\n end", "def ctype\n select_value(\"SELECT datctype FROM pg_database WHERE datname LIKE '#{current_database}'\", 'SCHEMA')\n end", "def db_type\n @db_type || sel...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Drops the schema for the given schema name.
def drop_schema schema_name execute "DROP SCHEMA #{schema_name} CASCADE" end
[ "def drop_schema(schema_name)\n execute(\"DROP SCHEMA \\\"#{schema_name}\\\"\")\n end", "def drop_schema_if_exists(schema_name)\n ::PgSaurus::Tools.drop_schema_if_exists(schema_name)\n end", "def delete_schema(schema_name)\n send_request delete(build_path(\n API_PATHS[:schema],\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Set the client message level.
def client_min_messages=(level) # NOTE: for now simply ignore the writer (no warn on Redshift) so that # the AR copy-pasted PpstgreSQL parts stay the same as much as possible return nil if redshift? # not supported on Redshift execute("SET client_min_messages TO '#{level}'", 'SCHEMA') end
[ "def client_min_messages=(level)\n execute(\"SET client_min_messages TO '#{level}'\")\n end", "def set_level(level)\n @level = level\n end", "def set_modchat(level)\n send \"/modchat #{level}\"\n end", "def level=(value)\n @level = value\n end", "def log...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns true if table exists. If the schema is not specified as part of +name+ then it will only find tables within the current schema search path (regardless of permissions to access tables in other schemas)
def table_exists?(name) schema, table = extract_schema_and_table(name.to_s) return false unless table binds = [[nil, table]] binds << [nil, schema] if schema sql = "#{TABLE_EXISTS_SQL_PREFIX} AND n.nspname = #{schema ? "?" : 'ANY (current_schemas(false))'}" log(sql, 'SCHEMA', bind...
[ "def table_exists?(name)\n schema, table = Utils.extract_schema_and_table(name.to_s)\n return false unless table\n\n binds = [[nil, table]]\n binds << [nil, schema] if schema\n\n exec_query(<<-SQL, 'SCHEMA').rows.first[0].to_i > 0\n SELECT COUNT(*)\n FROM pg_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Attempt to authorize using the given authorization code, return access token TODO: Determine what errors this can throw
def authorize(authcode) @client.authorization.code = authcode @client.authorization.fetch_access_token! @client.authorization.access_token end
[ "def fetch_access_token code\n access_token_from_response https_post(auth_host, auth_token_path, token_req_params(code))\n end", "def authenticate(code)\n request_access('authorization_code', code: code, redirect_uri: @redirect_uri)\n end", "def get_access_token\n unless params[:code]...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return current user info, fetch if it does not exist
def user_info @user_info ||= fetch_latest_user_info end
[ "def get_user_info\n response = send_method(:get_user_info)\n user_from(response)\n end", "def get_user_info\n request :get_user_info\n end", "def user_info\n get(api_get.body.identity).body\n end", "def user_details\n user_details_for(@qualified_username).first\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Fetch and return latest user info
def fetch_latest_user_info @user_info = @client.execute(api_method: @info.userinfo.get).data end
[ "def user_info\n\t\t@user_info ||= fetch_latest_user_info\n\tend", "def latest_data\n user = current_user\n\n json_response(Sync.latest_data(user))\n end", "def get_updated_by_user_info\n return User.find_by_id(self.updated_by)\n end", "def fetch_user_extended_detail\n @user_extended_d...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return current task lists, fetch if it does not exist
def task_lists @task_lists ||= fetch_latest_task_lists end
[ "def get_tasklists\n @tasklists = []\n array = @client.execute(@api.tasklists.list).data.to_hash[\"items\"]\n array.each { |h|\n @tasklists.push Tasklist[h]\n }\n end", "def task_lists(current_token)\n session = RedboothRuby::Session.new(token: current_token)\n client = Redboot...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Fetch and return latest task lists
def fetch_latest_task_lists response = @client.execute(api_method: @gtasks.tasklists.list) puts "***************** ERROR FETCHING TASK LISTS *****************" if response.status != 200 puts response.body @task_lists = response.data.items end
[ "def task_lists\n\t\t@task_lists ||= fetch_latest_task_lists\n\tend", "def fetch_latest_everything\n\t\t@user_info = @client.execute(api_method: @info.userinfo.get).data\n\t\t@task_lists = @client.execute(api_method: @gtasks.tasklists.list).data.items\n\t\t@tasks = Hash.new\n\t\t@task_lists.each do |list|\n\t\t\t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return the tasks for a list, fetch if it does not exist
def tasks_for(list) @tasks[list] ||= fetch_latest_tasks_for(list) end
[ "def fetch_latest_tasks_for(list)\n\t\t@tasks[list] = @client.execute(api_method: @gtasks.tasks.list, parameters: { 'tasklist' => list.id }).data.items\n\tend", "def tasks(list)\n list_obj = list.is_a?(Wunderlist::List) ? list : lists[list]\n list = list.id if list.is_a? Wunderlist::List\n\n reques...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Fetch and return latest tasks for a list
def fetch_latest_tasks_for(list) @tasks[list] = @client.execute(api_method: @gtasks.tasks.list, parameters: { 'tasklist' => list.id }).data.items end
[ "def fetch_latest_task_lists\n\t\tresponse = @client.execute(api_method: @gtasks.tasklists.list)\n\t\tputs \"***************** ERROR FETCHING TASK LISTS *****************\" if response.status != 200\n\t\tputs response.body\n\t\t@task_lists = response.data.items\n\tend", "def tasks_for(list)\n\t\t@tasks[list] ||= ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Not sure if the functions below are still needed Fetch user information, task lists, and tasks
def fetch_latest_everything @user_info = @client.execute(api_method: @info.userinfo.get).data @task_lists = @client.execute(api_method: @gtasks.tasklists.list).data.items @tasks = Hash.new @task_lists.each do |list| @tasks[list] = @client.execute(api_method: @gtasks.tasks.list, parameters: { 'tasklist' => li...
[ "def list_user_tasks\n\t\t@tasks = current_user.get_developer_tasks\n\tend", "def index\n secretary = is_secretary?\n if secretary\n user_ids = [current_user.id]\n cluster_livian_user_ids = @cluster_livian_users.map(&:id)\n else\n cluster_livian_user_ids = @user_ids\n user_ids = get_u...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /rate_ups GET /rate_ups.json
def index @rate_ups = RateUp.all end
[ "def ups_rates\n ups = ActiveShipping::UPS.new(login: UPS_LOGIN, password: UPS_PASSWORD, key: UPS_KEY)\n response = ups.find_rates(origin, destination, package)\n response.rates.each do |rate|\n rates << Rate.create(shipment_id: id, service_name: rate.service_name, total_price: rate.total_price)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /rate_ups/1 PATCH/PUT /rate_ups/1.json
def update respond_to do |format| if @rate_up.update(rate_up_params) format.html { redirect_to @rate_up, notice: 'Rate up was successfully updated.' } format.json { render :show, status: :ok, location: @rate_up } else format.html { render :edit } format.json { render json...
[ "def update\n @rate = Rate.find(params[:id])\n\n if @rate.update(rate_params)\n #head :no_content\n render json: @rate, status: :accepted, location: @rate #sera? status accepted? \n else\n render json: @rate.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /rate_ups/1 DELETE /rate_ups/1.json
def destroy @rate_up.destroy respond_to do |format| format.html { redirect_to rate_ups_url, notice: 'Rate up was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @rate.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @rate_down.destroy\n respond_to do |format|\n format.html { redirect_to rate_downs_url, notice: 'Rate down was successfully destroyed.' }\n format.json { head :no_co...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
GET /capitals GET /capitals.json
def index @capitals = Capital.all end
[ "def index\n @human_capitals = HumanCapital.all\n end", "def get_capitals(countries)\n capitals =[]\n for country in countires.keys\n capitals.push(countries[country][:capital])\n end\n return capitals\nend", "def show\n @cap = Cap.find(params[:id])\n\n respond_to do |format|\n format.html...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
POST /capitals POST /capitals.json
def create @capital = Capital.new(capital_params) respond_to do |format| if @capital.save format.html { redirect_to @capital, notice: 'Capital was successfully created.' } format.json { render :show, status: :created, location: @capital } else format.html { render :new } ...
[ "def create\n @human_capital = HumanCapital.new(human_capital_params)\n\n respond_to do |format|\n if @human_capital.save\n format.html { redirect_to @human_capital, notice: 'Human capital was successfully created.' }\n format.json { render :show, status: :created, location: @human_capital ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
PATCH/PUT /capitals/1 PATCH/PUT /capitals/1.json
def update respond_to do |format| if @capital.update(capital_params) format.html { redirect_to @capital, notice: 'Capital was successfully updated.' } format.json { render :show, status: :ok, location: @capital } else format.html { render :edit } format.json { render json...
[ "def update\n @cap = Cap.find(params[:id])\n\n respond_to do |format|\n if @cap.update_attributes(params[:cap])\n format.html { redirect_to @cap, notice: 'Cap was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /capitals/1 DELETE /capitals/1.json
def destroy @capital.destroy respond_to do |format| format.html { redirect_to capitals_url, notice: 'Capital was successfully destroyed.' } format.json { head :no_content } end end
[ "def destroy\n @cap = Cap.find(params[:id])\n @cap.destroy\n\n respond_to do |format|\n format.html { redirect_to caps_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @capacitacion = Capacitacion.find(params[:id])\n @capacitacion.destroy\n\n respond_to do |for...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
This method gets called when your app is installed. setup any webhooks or services you need on Shopify inside here.
def install shopify_session do # create an uninstall webhook, this webhook gets sent # when your app is uninstalled from a shop. It is good # practice to clean up any data from a shop when they # uninstall your app. uninstall_webhook = ShopifyAPI::Webhook.new({ topic: "app/unin...
[ "def setup_shopify_webhooks\n setup_shopify_webhook 'orders/create', :new_order\n setup_shopify_webhook 'carts/create', :new_cart\n setup_shopify_webhook 'carts/update', :updated_cart\n setup_shopify_webhook 'app/uninstalled', :app_uninstalled\n end", "def setup_shopify_shop\n with_shopify_session...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Helper to get filtering backends, defaulting to no backends.
def get_filter_backends return self.class.filter_backends || [] end
[ "def get_filter_backends\n return self.class.filter_backends || [\n RESTFramework::ModelFilter, RESTFramework::ModelOrderingFilter\n ]\n end", "def backends\n @backends ||= []\n end", "def backends\n @backends ||= Support::Registry.new\n end", "def backends; end", "def ch...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Helper to filter an arbitrary data set over all configured filter backends.
def get_filtered_data(data) self.get_filter_backends.each do |filter_class| filter = filter_class.new(controller: self) data = filter.get_filtered_data(data) end return data end
[ "def get_filter_backends\n return self.class.filter_backends || []\n end", "def apply_data_filters(data)\n @data_filters.reduce(data) do |data_, filter|\n filter.(data_)\n end\n end", "def get_filter_backends\n return self.class.filter_backends || [\n RESTFramework::ModelFilter, RESTFram...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DELETE /owners/1 DELETE /owners/1.json
def destroy @owner.destroy respond_to do |format| format.html { redirect_to owners_url } format.json { head :no_content } end end
[ "def destroy\n @owner = Owner.find(params[:id])\n @owner.destroy\n\n respond_to do |format|\n format.html { redirect_to owners_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @owner = Owner.find(params[:id])\n @owner.destroy\n\n respond_to do |format|\n f...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
get styles sorted by size from largest to smallest :original if it exists is always first
def weighted_styles(input) Hash[input.sort_by do |meta_style_name,meta_style| r = if meta_style_name == :original -9999999999999 else 0 - (meta_style[:width].to_i + meta_style[:height].to_i) end end] end
[ "def closest_size(object, size)\n sizes = object.options[:styles].values.collect{ |x| { x => parse_size(x) } }.sort_by{ |x| x.values }\n closest_size_hash = sizes.min_by { |x| ( x.values.first.to_f - Column.sizes[size] ).abs }\n style = object.options[:styles].key(closest_size_hash.keys.first)\n e...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the abandon_instances REST call
def abandon_instances request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, body, query_string_params = transcode_abandon_instances_request request_pb response = @client_stub.make_post_request( uri: uri,...
[ "def abandon_instances request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_abandon_instances_request request_pb\n query_string_params = if query_string_params....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the aggregated_list REST call
def aggregated_list request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, _body, query_string_params = transcode_aggregated_list_request request_pb response = @client_stub.make_get_request( uri: uri, ...
[ "def aggregated_list request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n uri, _body, query_string_params = transcode_aggregated_list_request request_pb\n response = @client_stub.make_get_request(\n uri: ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the apply_updates_to_instances REST call
def apply_updates_to_instances request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, body, _query_string_params = transcode_apply_updates_to_instances_request request_pb response = @client_stub.make_post_request( ...
[ "def apply_updates_to_instances request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_apply_updates_to_instances_request request_pb\n query_string_params = if qu...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the create_instances REST call
def create_instances request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, body, query_string_params = transcode_create_instances_request request_pb response = @client_stub.make_post_request( uri: uri, ...
[ "def create_instances(instances, optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'CreateInstances'\n\t\targs[:query]['Instances'] = instances\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be G...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the delete_instances REST call
def delete_instances request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, body, query_string_params = transcode_delete_instances_request request_pb response = @client_stub.make_post_request( uri: uri, ...
[ "def instance_delete_req(name)\n { :api_method => @compute.instances.delete,\n :parameters => { 'project' => @options[:gce_project], 'zone' => DEFAULT_ZONE_NAME, 'instance' => name } }\n end", "def delete\n stop\n [ @resource['instances_dir'] + \"/\" + @resource[:name],\n @resource['in...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the delete_per_instance_configs REST call
def delete_per_instance_configs request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, body, _query_string_params = transcode_delete_per_instance_configs_request request_pb response = @client_stub.make_post_request( ...
[ "def delete_per_instance_configs request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_delete_per_instance_configs_request request_pb\n query_string_params = if ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the list_managed_instances REST call
def list_managed_instances request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, _body, query_string_params = transcode_list_managed_instances_request request_pb response = @client_stub.make_post_request( ur...
[ "def list_managed_instances request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n uri, _body, query_string_params = transcode_list_managed_instances_request request_pb\n response = @client_stub.make_post_request(\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the list_per_instance_configs REST call
def list_per_instance_configs request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, _body, query_string_params = transcode_list_per_instance_configs_request request_pb response = @client_stub.make_post_request( ...
[ "def list_per_instance_configs request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n uri, _body, query_string_params = transcode_list_per_instance_configs_request request_pb\n response = @client_stub.make_post_request(\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the patch_per_instance_configs REST call
def patch_per_instance_configs request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, body, query_string_params = transcode_patch_per_instance_configs_request request_pb response = @client_stub.make_post_request( ...
[ "def patch_per_instance_configs request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_patch_per_instance_configs_request request_pb\n query_string_params = if qu...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the recreate_instances REST call
def recreate_instances request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, body, query_string_params = transcode_recreate_instances_request request_pb response = @client_stub.make_post_request( uri: ur...
[ "def recreate_instances request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_recreate_instances_request request_pb\n query_string_params = if query_string_param...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the set_instance_template REST call
def set_instance_template request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, body, query_string_params = transcode_set_instance_template_request request_pb response = @client_stub.make_post_request( uri: ...
[ "def set_instance_template request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_set_instance_template_request request_pb\n query_string_params = if query_string...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the set_target_pools REST call
def set_target_pools request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, body, query_string_params = transcode_set_target_pools_request request_pb response = @client_stub.make_post_request( uri: uri, ...
[ "def set_target_pools request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_set_target_pools_request request_pb\n query_string_params = if query_string_params.an...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Baseline implementation for the update_per_instance_configs REST call
def update_per_instance_configs request_pb, options = nil raise ::ArgumentError, "request must be provided" if request_pb.nil? uri, body, query_string_params = transcode_update_per_instance_configs_request request_pb response = @client_stub.make_post_request( ...
[ "def update_per_instance_configs request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_update_per_instance_configs_request request_pb\n query_string_params = if ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
convert Kata in input to Hira in output
def convertFile(inputName, outputName) # output file outputFile = File.open(outputName, "w") # input file File.open(inputName, "r") do |inputFile| pattern = /^(\S+?,){#{READ_FORM_INDEX}}/ while line = inputFile.gets startIndex = line[pattern].size endIndex = line...
[ "def preprocess(input); end", "def to_hiragana\n new_str = ''\n split('').each do |ch|\n if KATAKANA_TO_HIRAGANA.has_key?(ch)\n new_str += KATAKANA_TO_HIRAGANA[ch]\n else\n new_str += ch\n end\n end\n self.class.new(new_str)\n end", "def corak kata\n corak = String.new...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
inits a new FormVersion with same form_id increments sequence sets self.is_current = false
def upgrade! upgraded = self.class.new(form_id: form_id, is_current: true) self.is_current = false save upgraded.save! upgraded end
[ "def build_new_revision\n new_revision = Form.new(version_independent_id: version_independent_id,\n description: description, parent_id: parent_id, status: status,\n version: version + 1, name: name, oid: oid,\n created_by: created_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
double checks that code is still unique
def ensure_unique_code # keep trying new random codes until no match while self.class.find_by_code(self.code = Random.letters(CODE_LENGTH)); end true end
[ "def ensure_unique_code\n # keep trying new random codes until no match\n while self.class.find_by_code(self.code = Random.letters(CODE_LENGTH)); end\n return true\n end", "def code_should_not_repeat_in_a_resource\n \talready_existing = ResourceAction.where('resource_id = ? and code = ?', self....
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Updates the portlets hash from the routes and configuration options. Changes the path variables to a format supported by the Railsportlet.
def portlets(routes=@routes) raise 'No configuration' unless @config portlets = [] @config.instances.flatten.each do |portlet| ### route to path if portlet[:path] # take user-given path & do not parse routes path = portlet[:path] # # parse the ...
[ "def update_routes!\n @sections.each_with_index do |section, index|\n next unless section.is_a?(Hash)\n \n # make sense of the key/value pair\n tab, route = section.keys.first, section.values.first\n \n # set the custom route\n ROUTES[tab] = rout...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Moves the :max, :min, :before, and :after options to data attributes, formats the value, and merges this with any other options.
def input_html_options data = {} data[:min] = options[:min] if options[:min].present? data[:max] = options[:max] if options[:max].present? data[:before] = options[:before] if options[:before].present? data[:after] = options[:after] if options[:after].present? super.deep_merge( value: form...
[ "def input_html_options\n value = object && object.public_send(attribute_name)\n super.merge({ data: { 'iso-date' => value.present? ? value.iso8601 : '' } })\n end", "def normalize_options\n copy_options_to_attributes(ATTRIBUTE_OPTIONS)\n copy_boolean_options_to_attributes(ATTRIBUTE_BOOLEAN_OPTIO...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Remove specific conflicts from the conflict_list. Use the :parse option to add an unparsed conflict string. Example: conflict_list.remove("Sad", "Lonely") conflict_list.remove("Sad, Lonely", :parse => true)
def remove(*names) extract_and_apply_options!(names) delete_if { |name| names.include?(name) } self end
[ "def delete slist, err = true\n list = parse slist\n list.each { |opt| del opt, err }\n return self\n end", "def remove_species_list(spl)\n return unless species_lists.include?(spl)\n\n species_lists.delete(spl)\n update_attribute(:updated_at, Time.zone.now)\n end", "def removeTag\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Transform the conflict_list into a conflict string suitable for edting in a form. The conflicts are joined with conflictList.delimiter and quoted if necessary. Example: conflict_list = conflictList.new("Round", "Square,Cube") conflict_list.to_s 'Round, "Square,Cube"'
def to_s conflicts = frozen? ? self.dup : self conflicts.send(:clean!) conflicts.map do |name| name.include?(delimiter) ? "\"#{name}\"" : name end.join(delimiter.ends_with?(" ") ? delimiter : "#{delimiter} ") end
[ "def list_to_comma_quoted_string(list)\n quote_string list.join(',')\n end", "def list_to_space_quoted_string(list)\n quote_string list.join(' ')\n end", "def to_s\n spoonerize.join(\" \")\n end", "def to_s\n items = map(&:to_s).join(\", \")\n \"LL(#{items})\"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Remove whitespace, duplicates, and blanks.
def clean! reject!(&:blank?) map!(&:strip) uniq! end
[ "def clean!\n reject!(&:blank?)\n map!(&:strip)\n uniq!\n end", "def clean!\r\n reject!(&:blank?)\r\n map!(&:strip)\r\n uniq!\r\n end", "def strip\n lambda do |rec, acc|\n acc.collect! do |v|\n # unicode whitespace class aware\n v.sub(/\\A[[:spac...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Configure how to run remote SSH commmands on server.
def config_ssh(username, host, options = nil) @ssh = SSH.new(username, host, options) end
[ "def run_ssh(server, hParams, cmd, msg = nil)\n server_name, user, pubip, keypair = _server_info_params(server, hParams)\n\n identity = keypair[:keys]\n\n ssh_options = '-o StrictHostKeyChecking=no -o ServerAliveInterval=180'\\\n \" -i #{identity} \"\n ssh_connect = \"#{user}@#{pubip}\"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Configure how to communicate with Travis
def config_travis(api_key, private_repo) @travis = TravisCI.new(api_key: api_key, private_repo: private_repo) end
[ "def define_travis_tasks\n desc \"Runs your tests for travis\"\n task :travis => %w[test check_manifest]\n\n namespace :travis do\n desc \"Run by travis-ci after running the default checks\"\n task :after => %w[\n travis:fake_config\n ]\n\n desc \"Run by travis-ci before running ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get instance of GitHub class to run commands against GitHub
def github Log.fatal('You did not configure GitHub yet.') unless @github @github end
[ "def github_client\n @auth = token\n @expires_at = @auth[:expires_at]\n @gh = Octokit::Client.new access_token: @auth[:token]\n end", "def init_github\n return self.github_client if self.github_client.present?\n per_page = slack_command? ? 25 : 1\n\n self.github_client = Octokit::Client.new(acc...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Generate a sitemap.xml file We reimplement the default Jekyll sitemap generator, because we want to leverage the GTN::ModificationTimes class to obtain the last modification date of a page, in a more efficient way than the default Jekyll sitemap Params: +site+:: The +Jekyll::Site+ object
def generate(site) puts '[GTN/Sitemap] Generating' result = '<?xml version="1.0" encoding="UTF-8"?>' result += '<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' \ 'xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 ' \ 'http://www.sitemaps.or...
[ "def build_site(page_count, sitebuildtime, url, sitemap_url)\n # write all the HTML pages to files and build the site map\n sitemap = %(<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset\n xmlns=\"#{sitemap_url}\"\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"#{sitemap_url}\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
SQL to COMMIT a transaction.
def commit_transaction_sql SQL_COMMIT end
[ "def commit_transaction_sql\n 'COMMIT'\n end", "def commit_transaction_sql\n \"COMMIT TRANSACTION\"\n end", "def commit_transaction(conn)\n log_info(TRANSACTION_COMMIT)\n conn.commit\n end", "def commit_prepared_transaction(transaction_id, opts=OPTS)\n run...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
SQL to ROLLBACK a transaction.
def rollback_transaction_sql SQL_ROLLBACK end
[ "def rollback_db_transaction\n execute(\"ROLLBACK\")\n end", "def rollback\n query 'rollback'\n self\n end", "def rollback_savepoint_sql(depth)\n \"ROLLBACK TO SAVEPOINT autopoint_#{depth}\"\n end", "def rollback_savepoint_sql(depth)\n SQL_ROLLBACK_TO_SAVEPOINT % depth\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Allows you to do .nolock on a query
def nolock clone(:with => "(NOLOCK)") end
[ "def nolock\n clone(:table_options => \"(NOLOCK)\")\n end", "def without_locking(&block)\n current = ActiveRecord::Base.lock_optimistically\n ActiveRecord::Base.lock_optimistically = false if current\n begin\n block.call\n ensure\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Load template and install it. Removes temporary files during transfer and ensures desination directory is created before install. See template plugin for where template paths are loaded from. ==== Options +template_path+:: Path to template +destination+:: Remote path to evaluated template +options+:: Options (see Insta...
def install_template(template_path, destination, options = {}) # Truncate extension tmp_file_path = template_path.gsub("/", "_").gsub(/.erb$/, "") tmp_path = "/tmp/#{tmp_file_path}" options[:user] ||= "root" install_options = [] install_options << "-o #{options[:user]}" install...
[ "def install_processed_template(processed_template, destination, options = {})\n # Truncate extension\n tmp_file_path = destination.gsub(\"/\", \"_\").gsub(/.erb$/, \"\")\n tmp_path = \"/tmp/#{tmp_file_path}\"\n \n options[:user] ||= \"root\"\n \n install_options = []\n install_options << \"-o #{options[:us...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Grep file for regex. Returns true if found, false otherwise. ==== Options +grep+:: Regular expression +path+:: Path to file ==== Example utils.egrep("^mail.\\", "/etc/syslog.conf") => true
def egrep(grep, path) found = true run_via %{egrep '#{grep}' #{path} || echo $?} do |channel, stream, data| if data =~ /^(\d+)/ if $1.to_i > 0 logger.trace "Not found" found = false end end end found end
[ "def qgrep(pattern, file)\n return file.exist? && File.open(file).grep(/#{pattern}/).any?\nend", "def grep_file(file_path, grep_pattern)\n logc(\"method: #{__method__}, params: #{file_path}, #{grep_pattern}\")\n\n # with File.open(file_path, 'r').each.grep(grep_pattern) possible invalid byte sequence in UTF-8 ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Append data to a file. Optionally check that it exists before adding. ==== Options +path+:: Path to file to append to +data+:: String data to append +check+:: If not nil, will check to see if egrep matches this regex and will not reappend +left_strip+:: If true (default), remove whitespace before lines +should_exist+::...
def append_to(path, data, check = nil, left_strip = true, should_exist = true) # If checking and found expression then abort append return if check and egrep(check, path) # If should exist and doesn't then abort append raise "Can't append to file. File should exist: #{path}" if should_exist and !exist?...
[ "def append_file(path, data=nil, log_status=true, &block)\n path = File.expand_path(path, root)\n say_status :append, relative_to_absolute_root(path), log_status\n\n File.open(path, 'ab') { |file| file.write(data || block.call) } unless options[:pretend]\n end", "def append_to_file(path, *args, ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Updates the project's config/stations.yml with the latest data
def update_station_list log('This script overwrites your local copy of config/stations.yml with the latest data from nationalrail.co.uk and '\ 'railwaycodes.org.uk') log('Press [ENTER] to continue or [Ctrl+c] to quit') gets # Fetch data from the web stations = fetch_stations locations = fetch_locations...
[ "def update_stations\n\n State.all.each do |s|\n fetch_stations(s)\n end\n\n end", "def update\n\t\t\tpath = File.join(Config[:lists_directory], @name.downcase.gsub(/ /, '_') +'.yml')\n\t\t\tFile.open(path, 'w') do |fh|\n\t\t\t\tfh.puts(self.to_yaml)\n\t\t\tend\n\t\tend", "def update_config(watchers...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the current list of stations from the national rail website's station codes csv file
def fetch_stations log(' - Fetching station list...', false) results = {} response = get_response('https://www.nationalrail.co.uk/static/documents/content/station_codes.csv') CSV.new(response, headers: true).each do |row| results[row['CRS Code']] ||= {} results[row['CRS Code']][:name] = row['Station Nam...
[ "def get_stations\n CF::Station.get(\"/lines/#{ACCOUNT_NAME}/#{self.title.downcase}/stations.json\")\n end", "def get_station_list\n uri = URI.parse(\"http://www.citibikenyc.com/stations/json\")\n res = Net::HTTP.get_response(uri)\n json_response = JSON.parse(res.body)\n json_response[\"statio...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Scrapes location data for stations from the railwaycodes.org.uk website
def fetch_locations log(' - Fetching location data (takes ~25s)...', false) results = {} ('a'..'z').to_a.each do |letter| response = get_response("http://www.railwaycodes.org.uk/stations/station#{letter}.shtm") Nokogiri::HTML(response).xpath('//table/tr').each do |row| cols = row.xpath('./td').map(&...
[ "def fetch_stations\n log(' - Fetching station list...', false)\n results = {}\n response = get_response('https://www.nationalrail.co.uk/static/documents/content/station_codes.csv')\n CSV.new(response, headers: true).each do |row|\n results[row['CRS Code']] ||= {}\n results[row['CRS Code']][:name] = row['...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Write the stations.yml to disk
def write_yaml(stations) log(' - Writing YAML...', false) File.open(YAML_PATH.to_s, 'w') { |file| file.write(stations.to_yaml) } log('DONE') end
[ "def save\n open @config_path, 'w' do |io|\n io.write({'files' => @files.collect(&:to_hash)}.to_yaml)\n end\n end", "def write()\n storage_file = File.new(@yaml_path, \"w\")\n storage_file.write(@episode_hash.to_yaml)\n storage_file.close\n end", "def save_set...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get tags for an S3 bucket
def get_bucket_tagging(bucket_name) unless bucket_name raise ArgumentError.new('bucket_name is required') end request({ :expects => 200, :headers => {}, :bucket_name => bucket_name, :idempotent => true, :method ...
[ "def list\n ::Taxi::S3.instance.list_buckets\n end", "def keys(bucket_name, options = {})\n paramters = {}\n paramters['prefix'] = options[:prefix] if options[:prefix]\n paramters['marker'] = options[:marker] if options[:marker]\n paramters['max_keys'] = options[:max_keys] if optio...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
DB Here we can actually make an efficient query with both the domain and locale at the same time
def query_request db = PhoneDNS::DB.new return db.find(@domain, @locale) end
[ "def website_locales\n WebsiteLocale.where(locale: self.code)\n end", "def apply_locale_filter\n locales, self.locale_values = self.locale_values, nil\n return unless locales.present?\n\n # build locale restrictions\n locale_options = locales.extract_options!\n all_locales =...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return boolean indicating if spec has a %check section
def has_check? @metadata.has_key?(:has_check) && @metadata[:has_check] end
[ "def has_check?\n open(spec, \"r\") do |spec|\n spec.lines.any? { |line| line.include?(\"%check\") }\n end \n end", "def details?\n [expected_section, provided_sections].any? { |a| !a.nil? }\n end", "def has_knowledge_check?\n knowledge_check_filename.present?\n end", "def section_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return all the Requires for the specified gem
def requirements_for_gem(gem_name) @metadata[:requires].nil? ? [] : @metadata[:requires].select { |r| r.gem_name == gem_name } end
[ "def gem_requirements\n requires.select { |r| r.gem? }\n end", "def gem_requirements\n @metadata[:requires].nil? ? [] :\n @metadata[:requires].select { |r| r.gem? }\n end", "def build_requirements_for_gem(gem_name)\n @metadata[:build_requires].nil? ? [] :\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return all the BuildRequires for the specified gem
def build_requirements_for_gem(gem_name) @metadata[:build_requires].nil? ? [] : @metadata[:build_requires].select { |r| r.gem_name == gem_name } end
[ "def build_requirements_for_gem(gem_name)\n build_requires.select { |r| r.gem_name == gem_name }\n end", "def gem_build_requirements\n @metadata[:build_requires].nil? ? [] :\n @metadata[:build_requires].select { |r| r.gem? }\n end", "def gem_build_requirements\n build...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return bool indicating if this spec specifies all the requirements in the specified gem dependency
def has_all_requirements_for?(gem_dep) reqs = self.requirements_for_gem gem_dep.name # create a spec requirement dependency for each expanded subrequirement, # verify we can find a match for that gem_dep.requirement.to_s.split(',').all? { |greq| Gem2Rpm::Helpers.expan...
[ "def has_all_requirements_for?(gem_dep)\n require 'gem2rpm'\n\n reqs = requirements_for_gem gem_dep.name\n # create a spec requirement dependency for each expanded subrequirement,\n # verify we can find a match for that\n gem_dep.requirement.to_s.split(',').all? do |greq|\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }