_id
stringlengths
2
6
title
stringlengths
9
130
partition
stringclasses
3 values
text
stringlengths
30
4.3k
language
stringclasses
1 value
meta_information
dict
q5100
ErbLatex.Template.compile_latex
train
def compile_latex begin context = @context.new( @partials_path || @view.dirname, @data ) content = ErbLatex::File.evaluate(@view, context.getBinding) if layout ErbLatex::File.evaluate(layout_file, context.getBinding{ content }) ...
ruby
{ "resource": "" }
q5101
ErbLatex.Template.execute_xelatex
train
def execute_xelatex( latex, dir ) success = false @log = '' if @packages_path ENV['TEXINPUTS'] = "#{@packages_path}:" end Open3.popen2e( ErbLatex.config.xelatex_path,
ruby
{ "resource": "" }
q5102
SQLTree::Node.UpdateQuery.to_sql
train
def to_sql(options = {}) sql = "UPDATE #{table.to_sql(options)} SET " sql << updates.map { |u| u.to_sql(options) }.join(', ')
ruby
{ "resource": "" }
q5103
Ldaptic.Entry.attributes
train
def attributes (@original_attributes||{}).merge(@attributes).keys.inject({}) do |hash, key|
ruby
{ "resource": "" }
q5104
Ldaptic.Entry.modify_attribute
train
def modify_attribute(action, key, *values) key = Ldaptic.encode(key) values.flatten!.map! {|v| Ldaptic.encode(v)} @original_attributes[key] ||= [] virgin = @original_attributes[key].dup original = Ldaptic::AttributeSet.new(self, key, @original_attributes[key]) original.__send__(act...
ruby
{ "resource": "" }
q5105
Ldaptic.Entry.method_missing
train
def method_missing(method, *args, &block) attribute = Ldaptic.encode(method) if attribute[-1] == ?= attribute.chop! if may_must(attribute) return write_attribute(attribute, *args, &block) end elsif attribute[-1] == ?? attribute.chop! if may_must(attrib...
ruby
{ "resource": "" }
q5106
Ldaptic.Entry.reload
train
def reload new = search(:scope => :base, :limit => true) @original_attributes = new.instance_variable_get(:@original_attributes) @attributes = new.instance_variable_get(:@attributes)
ruby
{ "resource": "" }
q5107
Tableau.TimetableParser.sort_classes
train
def sort_classes(timetable, classes) classes.each do |c| if !(cmodule = timetable.module_for_code(c.code)) cmodule = Tableau::Module.new(c.code)
ruby
{ "resource": "" }
q5108
ITunesIngestion.Fetcher.fetch
train
def fetch(options={}) params = { :USERNAME => @username, :PASSWORD => @password, :VNDNUMBER => @vadnumber } params[:TYPEOFREPORT] = options[:type_of_report] || REPORT_TYPE_SALES params[:DATETYPE] = options[:date_type] || DATE_TYPE_DAILY params[:REPORTTYPE] = options[:report_type] |...
ruby
{ "resource": "" }
q5109
ErbLatex.Context.partial
train
def partial( template, data={} ) context = self.class.new( @directory, data )
ruby
{ "resource": "" }
q5110
Languages.ClassData.add_attribute
train
def add_attribute(pAttribute) pAttribute.each do |attributeElement|
ruby
{ "resource": "" }
q5111
WWW.Delicious.bundles_set
train
def bundles_set(bundle_or_name, tags = []) params = prepare_bundles_set_params(bundle_or_name, tags) response =
ruby
{ "resource": "" }
q5112
WWW.Delicious.tags_rename
train
def tags_rename(from_name_or_tag, to_name_or_tag) params = prepare_tags_rename_params(from_name_or_tag, to_name_or_tag) response =
ruby
{ "resource": "" }
q5113
WWW.Delicious.posts_recent
train
def posts_recent(options = {}) params = prepare_posts_params(options.clone, [:count, :tag]) response
ruby
{ "resource": "" }
q5114
WWW.Delicious.posts_all
train
def posts_all(options = {}) params = prepare_posts_params(options.clone, [:tag]) response =
ruby
{ "resource": "" }
q5115
WWW.Delicious.posts_dates
train
def posts_dates(options = {}) params = prepare_posts_params(options.clone, [:tag]) response =
ruby
{ "resource": "" }
q5116
WWW.Delicious.posts_delete
train
def posts_delete(url) params = prepare_posts_params({ :url => url }, [:url]) response = request(API_PATH_POSTS_DELETE,
ruby
{ "resource": "" }
q5117
WWW.Delicious.init_http_client
train
def init_http_client(options) http = Net::HTTP.new(@base_uri.host, 443) http.use_ssl = true if @base_uri.scheme == "https"
ruby
{ "resource": "" }
q5118
WWW.Delicious.http_build_query
train
def http_build_query(params = {}) params.collect do |k,v|
ruby
{ "resource": "" }
q5119
WWW.Delicious.request
train
def request(path, params = {}) raise Error, 'Invalid HTTP Client' unless http_client wait_before_new_request uri = @base_uri.merge(path) uri.query = http_build_query(params) unless params.empty? begin @last_request = Time.now # see #wait_before_new_request ...
ruby
{ "resource": "" }
q5120
WWW.Delicious.make_request
train
def make_request(uri) http_client.start do |http| req = Net::HTTP::Get.new(uri.request_uri, @headers)
ruby
{ "resource": "" }
q5121
WWW.Delicious.parse_update_response
train
def parse_update_response(body) dom = parse_and_validate_response(body, :root_name => 'update')
ruby
{ "resource": "" }
q5122
WWW.Delicious.prepare_tags_rename_params
train
def prepare_tags_rename_params(from_name_or_tag, to_name_or_tag) from, to = [from_name_or_tag, to_name_or_tag].collect do |v|
ruby
{ "resource": "" }
q5123
WWW.Delicious.prepare_param_post
train
def prepare_param_post(post_or_values, &block) post = case post_or_values when WWW::Delicious::Post post_or_values when Hash Post.new(post_or_values) else raise ArgumentError, 'Expected `args` to be `WWW::Delicious::Post` or `Hash`' end
ruby
{ "resource": "" }
q5124
WWW.Delicious.prepare_param_bundle
train
def prepare_param_bundle(name_or_bundle, tags = [], &block) # :yields: bundle bundle = case name_or_bundle when WWW::Delicious::Bundle name_or_bundle else Bundle.new(:name => name_or_bundle,
ruby
{ "resource": "" }
q5125
WWW.Delicious.prepare_param_tag
train
def prepare_param_tag(name_or_tag, &block) # :yields: tag tag = case name_or_tag when WWW::Delicious::Tag name_or_tag else Tag.new(:name => name_or_tag.to_s) end
ruby
{ "resource": "" }
q5126
WWW.Delicious.compare_params
train
def compare_params(params, valid_params) raise ArgumentError, "Expected `params` to be a kind of `Hash`" unless params.kind_of?(Hash) raise ArgumentError, "Expected `valid_params` to be a kind of `Array`" unless valid_params.kind_of?(Array)
ruby
{ "resource": "" }
q5127
Groupon.Client.deals
train
def deals(query={}) division = query.delete(:division) query.merge! :client_id => @api_key path = division ? "/#{division}" : ""
ruby
{ "resource": "" }
q5128
Sycl.Array.[]=
train
def []=(*args) # :nodoc: raise ArgumentError => 'wrong number of arguments' unless args.size > 1 unless args[-1].is_a?(Sycl::Hash)
ruby
{ "resource": "" }
q5129
Sycl.Hash.[]=
train
def []=(k, v) # :nodoc: unless v.is_a?(Sycl::Hash) || v.is_a?(Sycl::Array)
ruby
{ "resource": "" }
q5130
StatBoard.GraphHelper.first_day_of
train
def first_day_of(klass_name) klass = klass_name.to_s.constantize
ruby
{ "resource": "" }
q5131
Magma.Utils.read_file_or_stdin
train
def read_file_or_stdin(filename = nil) filename.nil?
ruby
{ "resource": "" }
q5132
Magma.Utils.run
train
def run(*args, &block) return Open3.popen3(*args,
ruby
{ "resource": "" }
q5133
Magma.Utils.symbolize_keys
train
def symbolize_keys(hash) hash.each_with_object({})
ruby
{ "resource": "" }
q5134
TCFG.Helper.tcfg_get
train
def tcfg_get(key) t_tcfg = tcfg unless t_tcfg.key? key raise NoSuchConfigurationKeyError, "No configuration
ruby
{ "resource": "" }
q5135
Languages.LanguageFactory.get_language
train
def get_language(pType) pType.downcase! return Languages::RubySyntax.new if pType == 'ruby' # if pType == "python" # raise Error::LanguageError # end # if pType == "vhdl" # raise Error::LanguageError # end # if pType == "c"
ruby
{ "resource": "" }
q5136
JsonRecord.EmbeddedDocumentArray.concat
train
def concat (objects) objects = objects.collect do |obj| obj = @klass.new(obj) if obj.is_a?(Hash) raise ArgumentError.new("#{obj.inspect} is not
ruby
{ "resource": "" }
q5137
JsonRecord.EmbeddedDocumentArray.build
train
def build (obj) obj = @klass.new(obj) if obj.is_a?(Hash) raise ArgumentError.new("#{obj.inspect} is not a #{@klass}")
ruby
{ "resource": "" }
q5138
Skydrive.Client.put
train
def put url, body=nil, options={} response = filtered_response(self.class.put(url, { :body => body,
ruby
{ "resource": "" }
q5139
Skydrive.Client.filtered_response
train
def filtered_response response raise Skydrive::Error.new({"code" => "no_response_received", "message" => "Request didn't make through or response not received"}) unless response if response.success? filtered_response = response.parsed_response if response.response.code =~ /(201|200)/ ...
ruby
{ "resource": "" }
q5140
Parser.OutputFactory.get_output
train
def get_output(pType) pType.downcase! return XMLOutputFormat.new if pType == 'xml'
ruby
{ "resource": "" }
q5141
RedisMasterSlave.Client.method_missing
train
def method_missing(name, *args, &block) # :nodoc: if writable_master.respond_to?(name) Client.send(:send_to_master, name)
ruby
{ "resource": "" }
q5142
PaynetEasy::PaynetEasyApi::Callback.CallbackPrototype.process_callback
train
def process_callback(payment_transaction, callback_response) begin validate_callback payment_transaction, callback_response rescue Exception => error payment_transaction.add_error error payment_transaction.status = PaymentTransaction::STATUS_ERROR raise error end
ruby
{ "resource": "" }
q5143
PaynetEasy::PaynetEasyApi::Callback.CallbackPrototype.validate_signature
train
def validate_signature(payment_transaction, callback_response) expected_control_code = Digest::SHA1.hexdigest( callback_response.status + callback_response.payment_paynet_id.to_s + callback_response.payment_client_id.to_s + payment_transaction.query_config.signing_key ) ...
ruby
{ "resource": "" }
q5144
PaynetEasy::PaynetEasyApi::Callback.CallbackPrototype.update_payment_transaction
train
def update_payment_transaction(payment_transaction, callback_response) payment_transaction.status = callback_response.status payment_transaction.payment.paynet_id = callback_response.payment_paynet_id
ruby
{ "resource": "" }
q5145
Massimo.UI.report_errors
train
def report_errors begin yield true rescue Exception => error say 'massimo had a problem', :red indent do say error.message, :magenta say error.backtrace.first, :magenta end
ruby
{ "resource": "" }
q5146
FreshdeskAPI.Client.method_missing
train
def method_missing(method, *args) method = method.to_s method_class = method_as_class(method)
ruby
{ "resource": "" }
q5147
Kuniri.Kuniri.run_analysis
train
def run_analysis @filesPathProject = get_project_file(@configurationInfo[:source]) unless @filesPathProject message = "Problem on source path: #{@configurationInfo[:source]}" Util::LoggerKuniri.error(message)
ruby
{ "resource": "" }
q5148
GithubPivotalFlow.Publish.run!
train
def run! story = @configuration.story fail("Could not find story associated with branch") unless story Git.clean_working_tree? Git.push(story.branch_name, set_upstream: true) unless story.release? print "Creating pull-request on Github... "
ruby
{ "resource": "" }
q5149
PaynetEasy::PaynetEasyApi::Query.CreateCardRefQuery.check_payment_transaction_status
train
def check_payment_transaction_status(payment_transaction) unless payment_transaction.finished? raise ValidationError, 'Only finished payment transaction can be used for create-card-ref-id' end
ruby
{ "resource": "" }
q5150
Roomer.Utils.current_tenant=
train
def current_tenant=(val) key = :"roomer_current_tenant" unless Thread.current[key].try(:url_identifier) == val.try(:url_identifier)
ruby
{ "resource": "" }
q5151
Roomer.Utils.with_tenant
train
def with_tenant(tenant,&blk) orig = self.current_tenant begin self.current_tenant =
ruby
{ "resource": "" }
q5152
JsonRecord.FieldDefinition.convert
train
def convert (val) return nil if val.blank? and val != false if @type == String return val.to_s elsif @type == Integer return Kernel.Integer(val) rescue val elsif @type == Float return Kernel.Float(val) rescue val elsif @type == Boolean v = BOOLEAN_MAPPING[va...
ruby
{ "resource": "" }
q5153
GritterNotices::ActiveRecord.InstanceMethods.method_missing
train
def method_missing(method_name, *args, &block) if level = ValidMethods[method_name.to_s] or level = ValidMethods["gritter_#{method_name}"]
ruby
{ "resource": "" }
q5154
EISCP.Message.get_human_readable_attrs
train
def get_human_readable_attrs @zone = Dictionary.zone_from_command(@command) @command_name = Dictionary.command_to_name(@command) @command_description = Dictionary.description_from_command(@command) @value_name
ruby
{ "resource": "" }
q5155
ConfigCurator.PackageLookup.installed?
train
def installed?(package) fail LookupFailed, 'No supported package tool found.' if tool.nil? cmd = tools[tool] fail LookupFailed,
ruby
{ "resource": "" }
q5156
ConfigCurator.PackageLookup.dpkg
train
def dpkg(package) cmd = command? 'dpkg' Open3.popen3 cmd, '-s', package do |_, _, _, wait_thr|
ruby
{ "resource": "" }
q5157
Mongo.Fixture.check
train
def check return @checked if @checked # If already checked, it's alright raise MissingFixtureError, "No fixture has been loaded, nothing to check" unless @data raise MissingConnectionError, "No connection has been provided, impossible to check" unless @connection @data.each_key do |colle...
ruby
{ "resource": "" }
q5158
Mongo.Fixture.rollback
train
def rollback begin check @data.each_key do |collection| @connection[collection].drop end rescue CollectionsNotEmptyError =>
ruby
{ "resource": "" }
q5159
Altria.Scheduler.scheduled?
train
def scheduled? [:min, :hour, :day, :month, :wday].all? do |key|
ruby
{ "resource": "" }
q5160
AutoExcerpt.Parser.close_tags
train
def close_tags(text) # Don't bother closing tags if html is stripped since there are no tags. if @settings[:strip_html] && @settings[:allowed_tags].empty? tagstoclose = nil else tagstoclose = "" tags = [] opentags = text.scan(OPENING_TAG).transpose[0] || [] open...
ruby
{ "resource": "" }
q5161
AutoExcerpt.Parser.paragraphs
train
def paragraphs return non_excerpted_text if @pghcount < @settings[:paragraphs] text = @body.split("</p>").slice(@settings[:skip_paragraphs],
ruby
{ "resource": "" }
q5162
AutoExcerpt.Parser.strip_html
train
def strip_html(html) return @stripped_html if @stripped_html allowed = @settings[:allowed_tags] reg = if allowed.any? Regexp.new( %(<(?!(\\s|\\/)*(#{ allowed.map {|tag| Regexp.escape( tag )}.join( "|" ) })( |>|\\/|'|"|<|\\s*\\z))[^>]*(>+|\\s*\\z)),
ruby
{ "resource": "" }
q5163
Algebra.SquareMatrix.determinant_by_elimination_old
train
def determinant_by_elimination_old m = dup inv, k = m.left_eliminate!
ruby
{ "resource": "" }
q5164
Algebra.SquareMatrix.determinant_by_elimination
train
def determinant_by_elimination m = dup det = ground.unity each_j do |d| if i = (d...size).find{|i| !m[i, d].zero?} if i != d m.sswap_r!(d, i) det = -det end c = m[d, d] det *= c (d+1...size).each do |i0| r = ...
ruby
{ "resource": "" }
q5165
TextTractor.Project.update_blurb
train
def update_blurb(state, locale, key, value, overwrite = false) id = key key = "projects:#{api_key}:#{state}_blurbs:#{key}" current_value = redis.sismember("projects:#{api_key}:#{state}_blurb_keys", id) ? JSON.parse(redis.get(key)) : {} phrase = Phrase.new(self, current_value)
ruby
{ "resource": "" }
q5166
KonoUtils.BaseSearch.get_query_params
train
def get_query_params out = {} search_attributes.each do |val| out[val.field]=self.send(val.field)
ruby
{ "resource": "" }
q5167
KonoUtils.BaseSearch.update_attributes
train
def update_attributes(datas) search_attributes.each do |val| self.send("#{val.field}=",
ruby
{ "resource": "" }
q5168
Mongoid.Criteria.fuse
train
def fuse(criteria_conditions = {}) criteria_conditions.inject(self) do |criteria, (key, value)|
ruby
{ "resource": "" }
q5169
Mongoid.Criteria.merge
train
def merge(other) @selector.update(other.selector) @options.update(other.options)
ruby
{ "resource": "" }
q5170
Mongoid.Criteria.filter_options
train
def filter_options page_num = @options.delete(:page) per_page_num = @options.delete(:per_page) if (page_num
ruby
{ "resource": "" }
q5171
Mongoid.Criteria.update_selector
train
def update_selector(attributes, operator) attributes.each { |key, value| @selector[key]
ruby
{ "resource": "" }
q5172
AridCache.Framework.active_record?
train
def active_record?(*args) version, comparator = args.pop, (args.pop || :==) result = if version.nil? defined?(::ActiveRecord) elsif defined?(::ActiveRecord) ar_version = ::ActiveRecord::VERSION::STRING.to_f
ruby
{ "resource": "" }
q5173
VulnDBHQ.Client.private_page
train
def private_page(id, options={}) response = get("/api/private_pages/#{id}",
ruby
{ "resource": "" }
q5174
Substation.Environment.inherit
train
def inherit(app_env = self.app_env, actions = Dispatcher.new_registry,
ruby
{ "resource": "" }
q5175
Substation.Environment.register
train
def register(name, other = Chain::EMPTY, exception_chain = Chain::EMPTY, &block) actions[name] =
ruby
{ "resource": "" }
q5176
GroupMe.Messages.create_message
train
def create_message(group_id, text, attachments = []) data = { :message => { :source_guid => SecureRandom.uuid, :text => text } } data[:message][:attachments]
ruby
{ "resource": "" }
q5177
GroupMe.Messages.messages
train
def messages(group_id, options = {}, fetch_all = false) if fetch_all get_all_messages(group_id) else
ruby
{ "resource": "" }
q5178
ConfigCurator.Symlink.install_symlink
train
def install_symlink FileUtils.mkdir_p File.dirname(destination_path)
ruby
{ "resource": "" }
q5179
LatoCore.Interface::Layout.core__get_partials_for_module
train
def core__get_partials_for_module(module_name) module_configs = core__get_module_configs(module_name) return [] unless module_configs # load module items module_partials = []
ruby
{ "resource": "" }
q5180
LatoCore.Interface::Layout.core__generate_partial
train
def core__generate_partial(key, values, module_name) partial = {} partial[:key] = key
ruby
{ "resource": "" }
q5181
LatoCore.Interface::Layout.core__get_widgets_for_module
train
def core__get_widgets_for_module module_name module_configs = core__get_module_configs(module_name) return [] unless module_configs # load module items module_widgets = []
ruby
{ "resource": "" }
q5182
LatoCore.Interface::Layout.core__generate_widget
train
def core__generate_widget key, values, module_name widget = {} widget[:key] = key widget[:icon] = values[:icon] ? values[:icon] : 'check-circle' widget[:path] = values[:path] ? values[:path] : ''
ruby
{ "resource": "" }
q5183
LatoCore.Interface::Layout.core__get_menu_for_module
train
def core__get_menu_for_module module_name module_configs = core__get_module_configs(module_name) return [] unless module_configs # load module items module_menu =
ruby
{ "resource": "" }
q5184
LatoCore.Interface::Layout.core__generate_menu_item
train
def core__generate_menu_item key, values, module_name menu_item = {} menu_item[:key] = key menu_item[:title] = values[:title] ? core__get_menu_title_translation(values[:title], module_name) : 'Undefined' menu_item[:icon] = values[:icon] ? values[:icon] : 'check-circle' menu_item[:url] = va...
ruby
{ "resource": "" }
q5185
LatoCore.Interface::Layout.core__generate_menu_sub_item
train
def core__generate_menu_sub_item key, values, module_name menu_sub_item = {} menu_sub_item[:key] = key menu_sub_item[:title] = values[:title] ? core__get_menu_title_translation(values[:title], module_name) : 'Undefined' menu_sub_item[:url] = values[:url] ? values[:url] : ''
ruby
{ "resource": "" }
q5186
LatoCore.Interface::Layout.core__get_menu_title_translation
train
def core__get_menu_title_translation title, module_name return title if (!title.start_with?('translate')) title_key = core__get_string_inside_strings(title, '[', ']') module_languages = core__get_module_languages(module_name) return
ruby
{ "resource": "" }
q5187
LatoCore.Interface::Layout.core__get_assets_for_module
train
def core__get_assets_for_module module_name module_configs = core__get_module_configs(module_name) return [] unless module_configs # load module assets
ruby
{ "resource": "" }
q5188
AzureMediaService.Service.create_access_policy
train
def create_access_policy(name:'Policy', duration_minutes:300, permission:2) warn("DEPRECATION WARNING: Service#create_access_policy is deprecated. Use AzureMediaService::AccessPolicy.create() instead.") post_body = { "Name" => name, "DurationInMinutes" => duration_minutes,
ruby
{ "resource": "" }
q5189
Chatrix.Room.process_join
train
def process_join(data) @state.update data['state'] if data.key? 'state' @timeline.update
ruby
{ "resource": "" }
q5190
Chatrix.Room.process_leave
train
def process_leave(data) @state.update data['state'] if data.key? 'state' @timeline.update
ruby
{ "resource": "" }
q5191
Chatrix.Room.process_invite_event
train
def process_invite_event(event) return unless event['type'] == 'm.room.member' return unless event['content']['membership'] == 'invite' @users.process_invite self, event sender = @users[event['sender']] invitee
ruby
{ "resource": "" }
q5192
HungryForm.Resolver.get_value
train
def get_value(name, element = nil) return name.call(element) if name.respond_to? :call # We don't want to mess up elements names name = name.to_s.dup # Apply placeholders to the name. # A sample name string can
ruby
{ "resource": "" }
q5193
HungryForm.Resolver.resolve_dependency
train
def resolve_dependency(dependency) dependency.each do |operator, arguments| operator = operator.to_sym case operator when :and, :or return resolve_multi_dependency(operator, arguments) when :not return !resolve_dependency(arguments) end argumen...
ruby
{ "resource": "" }
q5194
HungryForm.Resolver.resolve_multi_dependency
train
def resolve_multi_dependency(type, arguments) if arguments.size == 0 fail HungryFormException, "No arguments for #{type.upcase} comparison: #{arguments}" end result =
ruby
{ "resource": "" }
q5195
Reflexive.Methods.append_ancestor_entry
train
def append_ancestor_entry(ancestors, ancestor, class_methods, instance_methods = nil) if class_methods || instance_methods ancestor_entry = {} ancestor_entry[:class] = class_methods if class_methods
ruby
{ "resource": "" }
q5196
LatoCore.Inputs::Select::Cell.get_option_value_selected
train
def get_option_value_selected(option_value) if @args[:multiple] values = @args[:value].is_a?(Array) ? @args[:value] : @args[:value].split(',')
ruby
{ "resource": "" }
q5197
Biopsy.Target.load_by_name
train
def load_by_name name path = self.locate_definition name raise TargetLoadError.new("Target definition file does not exist for #{name}") if path.nil? config = YAML::load_file(path) raise TargetLoadError.new("Target definition file #{path} is not valid YAML") if
ruby
{ "resource": "" }
q5198
Biopsy.Target.locate_file
train
def locate_file name Settings.instance.target_dir.each do |dir| Dir.chdir File.expand_path(dir) do return File.expand_path(name) if File.exists? name
ruby
{ "resource": "" }
q5199
Biopsy.Target.count_parameter_permutations
train
def count_parameter_permutations @parameters.each_pair.map{
ruby
{ "resource": "" }