_id
stringlengths
2
6
title
stringlengths
9
130
partition
stringclasses
3 values
text
stringlengths
30
4.3k
language
stringclasses
1 value
meta_information
dict
q18600
Origin.Selectable.not
train
def not(*criterion) if criterion.empty? tap { |query| query.negating = true } else
ruby
{ "resource": "" }
q18601
Origin.Selectable.text_search
train
def text_search(terms, opts = nil) clone.tap do |query| if terms criterion = { :$text => { :$search => terms } }
ruby
{ "resource": "" }
q18602
Origin.Selectable.typed_override
train
def typed_override(criterion, operator) if criterion criterion.update_values do |value| yield(value)
ruby
{ "resource": "" }
q18603
Origin.Selectable.selection
train
def selection(criterion = nil) clone.tap do |query| if criterion criterion.each_pair do |field, value| yield(query.selector, field.is_a?(Key) ? field :
ruby
{ "resource": "" }
q18604
Origin.Queryable.initialize_copy
train
def initialize_copy(other) @options = other.options.__deep_copy__ @selector = other.selector.__deep_copy__
ruby
{ "resource": "" }
q18605
Origin.Pipeline.evolve
train
def evolve(entry) aggregate = Selector.new(aliases) entry.each_pair do |field, value|
ruby
{ "resource": "" }
q18606
Origin.Forwardable.select_with
train
def select_with(receiver) (Selectable.forwardables + Optional.forwardables).each do |name|
ruby
{ "resource": "" }
q18607
Origin.Aggregable.aggregation
train
def aggregation(operation) return self unless operation clone.tap do |query| unless aggregating? query.pipeline.concat(query.selector.to_pipeline)
ruby
{ "resource": "" }
q18608
Origin.Smash.storage_pair
train
def storage_pair(key) field = key.to_s name = aliases[field] || field
ruby
{ "resource": "" }
q18609
Origin.Mergeable.with_strategy
train
def with_strategy(strategy, criterion, operator) selection(criterion) do |selector, field, value| selector.store(
ruby
{ "resource": "" }
q18610
Origin.Mergeable.prepare
train
def prepare(field, operator, value) unless operator =~ /exists|type|size/ value = value.__expand_complex__ serializer = serializers[field] value = serializer ? serializer.evolve(value) : value
ruby
{ "resource": "" }
q18611
Origin.Selector.merge!
train
def merge!(other) other.each_pair do |key, value| if value.is_a?(Hash) && self[key.to_s].is_a?(Hash) value = self[key.to_s].merge(value) do |_key, old_val, new_val| if in?(_key) new_val & old_val elsif nin?(_key) (old_val + new_val).uniq ...
ruby
{ "resource": "" }
q18612
Origin.Selector.store
train
def store(key, value) name, serializer = storage_pair(key) if multi_selection?(name) super(name, evolve_multi(value)) else
ruby
{ "resource": "" }
q18613
Origin.Selector.evolve
train
def evolve(serializer, value) case value when Hash evolve_hash(serializer, value) when Array evolve_array(serializer,
ruby
{ "resource": "" }
q18614
Origin.Options.to_pipeline
train
def to_pipeline pipeline = [] pipeline.push({ "$skip" => skip }) if skip pipeline.push({ "$limit" => limit }) if limit
ruby
{ "resource": "" }
q18615
Origin.Macroable.key
train
def key(name, strategy, operator, additional = nil, &block)
ruby
{ "resource": "" }
q18616
Origin.Optional.order_by
train
def order_by(*spec) option(spec) do |options, query| spec.compact.each do |criterion| criterion.__sort_option__.each_pair do |field, direction| add_sort_option(options, field, direction)
ruby
{ "resource": "" }
q18617
Origin.Optional.skip
train
def skip(value = nil) option(value) do |options, query| val = value.to_i options.store(:skip, val)
ruby
{ "resource": "" }
q18618
Origin.Optional.slice
train
def slice(criterion = nil) option(criterion) do |options| options.__union__( fields: criterion.inject({}) do |option, (field, val)| option.tap
ruby
{ "resource": "" }
q18619
Origin.Optional.without
train
def without(*args) args = args.flatten option(*args) do |options| options.store(
ruby
{ "resource": "" }
q18620
Origin.Optional.add_sort_option
train
def add_sort_option(options, field, direction) if driver == :mongo1x sorting = (options[:sort] || []).dup sorting.push([ field, direction ]) options.store(:sort, sorting)
ruby
{ "resource": "" }
q18621
Origin.Optional.option
train
def option(*args) clone.tap do |query| unless args.compact.empty?
ruby
{ "resource": "" }
q18622
Origin.Optional.sort_with_list
train
def sort_with_list(*fields, direction) option(fields) do |options, query| fields.flatten.compact.each do |field| add_sort_option(options, field, direction)
ruby
{ "resource": "" }
q18623
Guillotine.Adapter.parse_url
train
def parse_url(url, options) url.gsub!(/\s/, '') url.gsub!(/\?.*/, '') if options.strip_query? url.gsub!(/\#.*/,
ruby
{ "resource": "" }
q18624
Guillotine.RiakAdapter.add
train
def add(url, code = nil, options = nil) sha = url_key url url_obj = @url_bucket.get_or_new sha, :r => 1 if url_obj.raw_data fix_url_object(url_obj) code = url_obj.data end code = get_code(url, code, options) code_obj = @code_bucket.get_or_new code code_obj....
ruby
{ "resource": "" }
q18625
Guillotine.RiakAdapter.url_object
train
def url_object(code) @code_bucket.get(code, :r => 1) rescue Riak::FailedRequest => err
ruby
{ "resource": "" }
q18626
Guillotine.RiakAdapter.code_object
train
def code_object(url) sha = url_key url if o = @url_bucket.get(sha, :r => 1) fix_url_object(o) end
ruby
{ "resource": "" }
q18627
Xcode.ConfigurationList.create_config
train
def create_config(name) name = ConfigurationList.symbol_config_name_to_config_name[name] if ConfigurationList.symbol_config_name_to_config_name[name] # @todo a configuration has additional fields that are ususally set with # some target information
ruby
{ "resource": "" }
q18628
Xcode.Resource.define_property
train
def define_property name, value # Save the properties within the resource within a custom hash. This # provides access to them without the indirection that we are about to # set up. @properties[name] = value # Generate a getter method for this property based on the gi...
ruby
{ "resource": "" }
q18629
Xcode.Project.file
train
def file(name_with_path) path, name = File.split(name_with_path)
ruby
{ "resource": "" }
q18630
Xcode.Project.products_group
train
def products_group current_group = groups.group('Products').first
ruby
{ "resource": "" }
q18631
Xcode.Project.frameworks_group
train
def frameworks_group current_group = groups.group('Frameworks').first
ruby
{ "resource": "" }
q18632
Xcode.Project.save
train
def save(path) Dir.mkdir(path) unless File.exists?(path) project_filepath = "#{path}/project.pbxproj" # @toodo Save the workspace
ruby
{ "resource": "" }
q18633
Xcode.Project.scheme
train
def scheme(name) scheme = schemes.select {|t| t.name == name.to_s}.first raise "No such
ruby
{ "resource": "" }
q18634
Xcode.Project.target
train
def target(name) target = targets.select {|t| t.name == name.to_s}.first raise "No such
ruby
{ "resource": "" }
q18635
Xcode.Project.create_target
train
def create_target(name,type=:native) target = @registry.add_object Target.send(type) @project.properties['targets'] << target.identifier target.name = name
ruby
{ "resource": "" }
q18636
Xcode.Project.remove_target
train
def remove_target(name) found_target = targets.find {|target| target.name == name } if found_target @project.properties['targets'].delete found_target.identifier
ruby
{ "resource": "" }
q18637
Xcode.Project.describe
train
def describe puts "Project #{name} contains" targets.each do |t| puts " + target:#{t.name}" t.configs.each do |c| puts " + config:#{c.name}" end end schemes.each do |s|
ruby
{ "resource": "" }
q18638
Xcode.Project.parse_pbxproj
train
def parse_pbxproj registry = Xcode::PLUTILProjectParser.parse "#{@path}/project.pbxproj" class << registry
ruby
{ "resource": "" }
q18639
Xcode.PLUTILProjectParser.parse
train
def parse(path) registry = Plist.parse_xml open_project_file(path)
ruby
{ "resource": "" }
q18640
Xcode.TerminalOutput.print_input
train
def print_input message, level=:debug return if LEVELS.index(level) > LEVELS.index(@@log_level) puts
ruby
{ "resource": "" }
q18641
Xcode.TerminalOutput.print_output
train
def print_output message, level=:debug return if LEVELS.index(level) > LEVELS.index(@@log_level) puts
ruby
{ "resource": "" }
q18642
Xcode.Target.create_build_phases
train
def create_build_phases *base_phase_names base_phase_names.compact.flatten.map do |phase_name| build_phase =
ruby
{ "resource": "" }
q18643
Xcode.Target.create_product_reference
train
def create_product_reference(name) product = project.products_group.create_product_reference(name)
ruby
{ "resource": "" }
q18644
Xcode.Keychain.in_search_path
train
def in_search_path(&block) keychains = Keychains.search_path begin Keychains.search_path = [self] + keychains yield
ruby
{ "resource": "" }
q18645
Xcode.Keychain.import
train
def import(cert, password) cmd = Xcode::Shell::Command.new "security" cmd << "import '#{cert}'" cmd << "-k \"#{@path}\"" cmd
ruby
{ "resource": "" }
q18646
Xcode.Keychain.identities
train
def identities names = [] cmd = Xcode::Shell::Command.new "security" cmd << "find-certificate" cmd << "-a" cmd << "\"#{@path}\"" cmd.show_output
ruby
{ "resource": "" }
q18647
Xcode.Keychain.lock
train
def lock cmd = Xcode::Shell::Command.new "security"
ruby
{ "resource": "" }
q18648
Xcode.Keychain.unlock
train
def unlock(password) cmd = Xcode::Shell::Command.new "security" cmd << "unlock-keychain"
ruby
{ "resource": "" }
q18649
Xcode.ConfigurationOwner.config
train
def config(name) config = configs.select {|config| config.name == name.to_s }.first raise "No
ruby
{ "resource": "" }
q18650
Xcode.ConfigurationOwner.create_configuration
train
def create_configuration(name) # To create a configuration, we need to create or retrieve the configuration list
ruby
{ "resource": "" }
q18651
Xcode.ConfigurationOwner.create_configurations
train
def create_configurations(*configuration_names) configuration_names.compact.flatten.map do |config_name| created_config = create_configuration config_name do |config|
ruby
{ "resource": "" }
q18652
Xcode.BuildPhase.file
train
def file(name) files.find {|file| file.file_ref.name
ruby
{ "resource": "" }
q18653
Xcode.BuildPhase.build_file
train
def build_file(name) build_files.find {|file| file.name == name
ruby
{ "resource": "" }
q18654
Xcode.BuildPhase.add_build_file
train
def add_build_file(file,settings = {}) find_file_by = file.path || file.name unless build_file(find_file_by) new_build_file
ruby
{ "resource": "" }
q18655
Xcode.Registry.add_object
train
def add_object(object_properties) new_identifier = SimpleIdentifierGenerator.generate :existing_keys =>
ruby
{ "resource": "" }
q18656
Xcode.Workspace.project
train
def project(name) project = @projects.select {|c| c.name == name.to_s}.first raise "No such project
ruby
{ "resource": "" }
q18657
Xcode.TargetDependency.create_dependency_on
train
def create_dependency_on(target) @properties['target'] = target.identifier container_item_proxy = ContainerItemProxy.default target.project.project.identifier, target.identifier, target.name container_item_proxy
ruby
{ "resource": "" }
q18658
Xcode.Configuration.info_plist
train
def info_plist info = Xcode::InfoPlist.new(self, info_plist_location) yield
ruby
{ "resource": "" }
q18659
Xcode.Configuration.get
train
def get(name) if respond_to?(name) send(name) elsif Configuration.setting_name_to_property(name) send
ruby
{ "resource": "" }
q18660
Xcode.Configuration.set
train
def set(name, value) if respond_to?(name) send("#{name}=",value) elsif Configuration.setting_name_to_property(name)
ruby
{ "resource": "" }
q18661
Xcode.Configuration.append
train
def append(name, value) if respond_to?(name) send("append_to_#{name}",value) elsif Configuration.setting_name_to_property(name) send("append_to_#{Configuration.setting_name_to_property(name)}",value) else # @note this will likely raise some errors if trying to append a ...
ruby
{ "resource": "" }
q18662
Xcode.Group.group
train
def group(name) groups.find_all {|group|
ruby
{ "resource": "" }
q18663
Xcode.Group.file
train
def file(name) files.find_all {|file| file.name == name or
ruby
{ "resource": "" }
q18664
Xcode.Group.exists?
train
def exists?(name) children.find_all do |child|
ruby
{ "resource": "" }
q18665
Xcode.Group.create_group
train
def create_group(name) new_group = create_child_object
ruby
{ "resource": "" }
q18666
Xcode.Group.create_file
train
def create_file(file_properties) # This allows both support for the string value or the hash as the parameter file_properties = { 'path' => file_properties } if file_properties.is_a? String # IF the file already exists then we will not create the file with the # parameters that are being ...
ruby
{ "resource": "" }
q18667
Xcode.Group.remove!
train
def remove!(&block) # @note #groups and #files is used because it adds the very precious # supergroup to each of the child items. groups.each {|group| group.remove!(&block) }
ruby
{ "resource": "" }
q18668
Xcode.Group.find_or_create_child_object
train
def find_or_create_child_object(child_properties) found_child = children.find {|child| child.name == child_properties['name'] or child.path == child_properties['path'] }
ruby
{ "resource": "" }
q18669
Xcode.Group.remove_child_object
train
def remove_child_object(identifier) found_child = children.find {|child| child.identifier == identifier }
ruby
{ "resource": "" }
q18670
Xcode.RakeTask.define_per_project_scheme_builder_tasks
train
def define_per_project_scheme_builder_tasks projects.each do |project| project.schemes.each do |scheme| builder_actions.each do |action| description = "#{action.capitalize} #{project.name} #{scheme.name}" task_name = friendlyname("#{name}:#{project.nam...
ruby
{ "resource": "" }
q18671
Xcode.RakeTask.define_per_project_config_builder_tasks
train
def define_per_project_config_builder_tasks projects.each do |project| project.targets.each do |target| target.configs.each do |config| builder_actions.each do |action| description = "#{action.capitalize} #{project.name} #{target.name}...
ruby
{ "resource": "" }
q18672
Xcode.ProjectReference.group
train
def group(name,options = {},&block) # By default create missing groups along the way options = { :create => true }.merge(options) current_group = main_group # @todo consider this traversing and find/create as a normal procedure when # traversing the project. na...
ruby
{ "resource": "" }
q18673
CIDE.Runner.run!
train
def run!(interactive: false) start_links! run_options = ['--detach'] @env.each_pair do |key, value| run_options.push '--env', [key, value].join('=') end @links.each do |link| run_options.push '--link', [link.id, link.name].join(':') end run_options.push '--n...
ruby
{ "resource": "" }
q18674
H3.Regions.max_polyfill_size
train
def max_polyfill_size(geo_polygon, resolution) geo_polygon = geo_json_to_coordinates(geo_polygon)
ruby
{ "resource": "" }
q18675
H3.Regions.polyfill
train
def polyfill(geo_polygon, resolution) geo_polygon = geo_json_to_coordinates(geo_polygon) if geo_polygon.is_a?(String) max_size
ruby
{ "resource": "" }
q18676
H3.Regions.h3_set_to_linked_geo
train
def h3_set_to_linked_geo(h3_indexes) h3_set = H3Indexes.with_contents(h3_indexes) linked_geo_polygon = LinkedGeoPolygon.new Bindings::Private.h3_set_to_linked_geo(h3_set, h3_indexes.size, linked_geo_polygon)
ruby
{ "resource": "" }
q18677
H3.Indexing.geo_to_h3
train
def geo_to_h3(coords, resolution) raise ArgumentError unless coords.is_a?(Array) && coords.count == 2 lat, lon = coords if lat > 90 || lat < -90 || lon > 180 || lon < -180 raise(ArgumentError, "Invalid coordinates") end coords = GeoCoord.new
ruby
{ "resource": "" }
q18678
H3.Indexing.h3_to_geo
train
def h3_to_geo(h3_index) coords = GeoCoord.new Bindings::Private.h3_to_geo(h3_index,
ruby
{ "resource": "" }
q18679
H3.Indexing.h3_to_geo_boundary
train
def h3_to_geo_boundary(h3_index) geo_boundary = GeoBoundary.new Bindings::Private.h3_to_geo_boundary(h3_index,
ruby
{ "resource": "" }
q18680
H3.UnidirectionalEdges.h3_indexes_from_unidirectional_edge
train
def h3_indexes_from_unidirectional_edge(edge) max_hexagons = 2 out = H3Indexes.of_size(max_hexagons)
ruby
{ "resource": "" }
q18681
H3.UnidirectionalEdges.h3_unidirectional_edges_from_hexagon
train
def h3_unidirectional_edges_from_hexagon(origin) max_edges = 6 out = H3Indexes.of_size(max_edges)
ruby
{ "resource": "" }
q18682
H3.UnidirectionalEdges.h3_unidirectional_edge_boundary
train
def h3_unidirectional_edge_boundary(edge) geo_boundary = GeoBoundary.new Bindings::Private.h3_unidirectional_edge_boundary(edge,
ruby
{ "resource": "" }
q18683
H3.Traversal.hex_ring
train
def hex_ring(origin, k) max_hexagons = max_hex_ring_size(k) out = H3Indexes.of_size(max_hexagons) pentagonal_distortion = Bindings::Private.hex_ring(origin, k, out)
ruby
{ "resource": "" }
q18684
H3.Traversal.hex_ranges
train
def hex_ranges(h3_set, k, grouped: true) h3_range_indexes = hex_ranges_ungrouped(h3_set, k) return h3_range_indexes unless grouped
ruby
{ "resource": "" }
q18685
H3.Traversal.k_ring_distances
train
def k_ring_distances(origin, k) max_out_size = max_kring_size(k) out = H3Indexes.of_size(max_out_size) distances = FFI::MemoryPointer.new(:int, max_out_size) Bindings::Private.k_ring_distances(origin, k, out, distances) hexagons = out.read
ruby
{ "resource": "" }
q18686
H3.Inspection.h3_to_string
train
def h3_to_string(h3_index) h3_str = FFI::MemoryPointer.new(:char, H3_TO_STR_BUF_SIZE)
ruby
{ "resource": "" }
q18687
H3.GeoJSON.geo_json_to_coordinates
train
def geo_json_to_coordinates(input) geom = RGeo::GeoJSON.decode(input) coordinates = fetch_coordinates(geom) swap_lat_lon(coordinates)
ruby
{ "resource": "" }
q18688
H3.GeoJSON.coordinates_to_geo_json
train
def coordinates_to_geo_json(coordinates) coordinates = swap_lat_lon(coordinates) outer_coords, *inner_coords = coordinates factory = RGeo::Cartesian.simple_factory exterior = factory.linear_ring(outer_coords.map { |lon, lat| factory.point(lon, lat) }) interior_rings = inner_coords.map do |...
ruby
{ "resource": "" }
q18689
H3.Hierarchy.h3_to_children
train
def h3_to_children(h3_index, child_resolution) max_children = max_h3_to_children_size(h3_index, child_resolution)
ruby
{ "resource": "" }
q18690
H3.Hierarchy.max_uncompact_size
train
def max_uncompact_size(compacted_set, resolution) h3_set = H3Indexes.with_contents(compacted_set) size = Bindings::Private.max_uncompact_size(h3_set,
ruby
{ "resource": "" }
q18691
H3.Hierarchy.compact
train
def compact(h3_set) h3_set = H3Indexes.with_contents(h3_set) out = H3Indexes.of_size(h3_set.size) failure = Bindings::Private.compact(h3_set,
ruby
{ "resource": "" }
q18692
H3.Hierarchy.uncompact
train
def uncompact(compacted_set, resolution) max_size = max_uncompact_size(compacted_set, resolution) out = H3Indexes.of_size(max_size) h3_set = H3Indexes.with_contents(compacted_set) failure
ruby
{ "resource": "" }
q18693
Necromancer.ConversionTarget.to
train
def to(target, options = {}) conversion = conversions[source || detect(object, false), detect(target)]
ruby
{ "resource": "" }
q18694
Necromancer.ConversionTarget.detect
train
def detect(object, symbol_as_object = true) case object when TrueClass, FalseClass then :boolean when Integer then :integer when Class then object.name.downcase
ruby
{ "resource": "" }
q18695
Necromancer.Conversions.load
train
def load ArrayConverters.load(self) BooleanConverters.load(self) DateTimeConverters.load(self)
ruby
{ "resource": "" }
q18696
Necromancer.Conversions.register
train
def register(converter = nil, &block) converter ||= Converter.create(&block) key = generate_key(converter) converter = add_config(converter, @configuration) return false
ruby
{ "resource": "" }
q18697
Necromancer.Conversions.add_config
train
def add_config(converter, config) converter.instance_exec(:"@config") do |var|
ruby
{ "resource": "" }
q18698
TLAW.DataTable.[]
train
def [](index_or_column) case index_or_column when Integer super when String, Symbol map { |h| h[index_or_column.to_s] }
ruby
{ "resource": "" }
q18699
TLAW.DataTable.columns
train
def columns(*names) names.map!(&:to_s) DataTable.new(map
ruby
{ "resource": "" }