_id stringlengths 2 6 | title stringlengths 9 130 | partition stringclasses 3
values | text stringlengths 66 10.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q3300 | ActsAsStaticRecord.SingletonMethods.find_with_static_record | train | def find_with_static_record(*args)#:nodoc:
if scope(:find).nil? && args
if args.first.is_a?(Fixnum) &&
((args.length == 1 ||
(args[1].is_a?(Hash) && args[1].values.delete(nil).nil?)))
return static_record_cache[:primary_key][args.first]
elsif args.first == :all &&... | ruby | {
"resource": ""
} |
q3301 | ActsAsStaticRecord.SingletonMethods.calculate_with_static_record | train | def calculate_with_static_record(operation, column_name, options={})#:nodoc:
if scope(:find).nil? && !options.any?{ |k,v| k.to_s.downcase != 'distinct' }
key = "#{operation}_#{column_name}_#{options.none?{|k,v| v.blank? }}"
static_record_cache[:calc][key]||=
case operation.to_s
... | ruby | {
"resource": ""
} |
q3302 | ActsAsStaticRecord.SingletonMethods.static_records_for_calculation | train | def static_records_for_calculation(column_name, options={}, &block)#:nodoc:
if columns_hash.has_key?(column_name.to_s)
records = static_record_cache[:primary_key].values.collect(&(column_name.to_sym)).compact
results = (options[:distinct]||options['distinct']) ? records.uniq : records
bloc... | ruby | {
"resource": ""
} |
q3303 | ActsAsStaticRecord.SingletonMethods.initialize_static_record_cache | train | def initialize_static_record_cache#:nodoc:
return unless @static_record_cache.nil?
records = self.find_without_static_record(:all, acts_as_static_record_options[:find]||{})
@static_record_cache = records.inject({:primary_key => {}, :key => {}, :calc => {}}) do |cache, record|
cache[:primary_ke... | ruby | {
"resource": ""
} |
q3304 | ActsAsStaticRecord.DefineFinderMethods.static_record_finder_method_name | train | def static_record_finder_method_name(finder, attributes)#:nodoc:
method_to_call = "find_in_static_record_cache(#{finder.inspect}, #{attributes.inspect})"
if attributes.length == 1
key_value = case attributes.keys.first.to_s
when self.primary_key then [:primary_key, attributes.values.first.... | ruby | {
"resource": ""
} |
q3305 | ActsAsStaticRecord.DefineFinderMethods.define_static_record_finder_method | train | def define_static_record_finder_method(method_id, finder, bang, attributes)#:nodoc:
method_to_call = static_record_finder_method_name(finder, attributes)
method_with_static_record = "#{method_id}_with_static_rc"
#override the method to search memory if there are no args
class_eval %{
de... | ruby | {
"resource": ""
} |
q3306 | ActsAsStaticRecord.DefineFinderMethods.method_missing | train | def method_missing(method_id, *arguments, &block)#:nodoc:
# If the missing method is XXX_without_static_rc, define XXX
# using the superclass ActiveRecord::Base method_missing then
# Finally, alias chain it to XXX_with_static_rc
if ((match = method_id.to_s.match(/(.*)_without_static_rc$/)) &&
... | ruby | {
"resource": ""
} |
q3307 | Bollettino.Generator.generate! | train | def generate!(slip, path)
image = MiniMagick::Image.open(File.expand_path('../../../assets/slip.png', __FILE__))
Bollettino::Renderer::Slip.render(image, slip)
image.write path
end | ruby | {
"resource": ""
} |
q3308 | Hyperb.Compose.compose_down | train | def compose_down(params = {})
raise ArgumentError, 'Invalid arguments.' unless check_arguments(params, 'project')
path = '/compose/down'
query = {}
query[:project] = params[:project] if params.key?(:project)
query[:vol] = params[:vol] if params.key?(:vol)
query[:rmi] = params[:rmi] i... | ruby | {
"resource": ""
} |
q3309 | Hyperb.Compose.compose_create | train | def compose_create(params = {})
raise ArgumentError, 'Invalid arguments.' unless check_arguments(params, 'project')
path = '/compose/create'
query = {}
body = {}
query[:project] = params[:project] if params.key?(:project)
body[:serviceconfigs] = { 'M': {} } # inherited from libcompo... | ruby | {
"resource": ""
} |
q3310 | JProtobuf.Message.write_to_string_io | train | def write_to_string_io(string_io)
java_proto.write_to(org.jruby.util.IOOutputStream.new(string_io))
nil
end | ruby | {
"resource": ""
} |
q3311 | JProtobuf.Message.write_to_string | train | def write_to_string
string_io = StringIO.new.set_encoding(Encoding::BINARY)
write_to_string_io(string_io)
string_io.string
end | ruby | {
"resource": ""
} |
q3312 | Zyps.FaceAction.do | train | def do(actor, targets)
return if targets.empty?
actor.vector.pitch = Utility.find_angle(actor.location, random_target(targets).location)
end | ruby | {
"resource": ""
} |
q3313 | Zyps.ApproachAction.do | train | def do(actor, targets)
return if targets.empty?
#Apply thrust to the creature's movement vector, adjusted by elapsed time.
actor.vector += Vector.new(
delta,
Utility.find_angle(actor.location, random_target(targets).location)
)
end | ruby | {
"resource": ""
} |
q3314 | Zyps.DestroyAction.do | train | def do(actor, targets)
targets.each do |target|
target.environment.remove_object(target.identifier)
end
end | ruby | {
"resource": ""
} |
q3315 | Zyps.TagAction.do | train | def do(actor, targets)
targets.each do |target|
target.tags << tag unless target.tags.include?(tag)
end
end | ruby | {
"resource": ""
} |
q3316 | Zyps.BlendAction.do | train | def do(actor, targets)
actor.color.red += (@color.red - actor.color.red) * delta
actor.color.green += (@color.green - actor.color.green) * delta
actor.color.blue += (@color.blue - actor.color.blue) * delta
end | ruby | {
"resource": ""
} |
q3317 | Zyps.PushAction.do | train | def do(actor, targets)
#Acceleration will be limited by elapsed time.
push_force = delta
targets.each do |target|
#Angle to target is also angle of push force.
push_angle = Utility.find_angle(actor.location, target.location)
#Apply the force to the creature's movement vector.
target.... | ruby | {
"resource": ""
} |
q3318 | Zyps.PullAction.do | train | def do(actor, targets)
#Acceleration will be limited by elapsed time.
pull_force = delta
targets.each do |target|
#Angle from target to actor is also angle of pull force (opposite of that for push).
pull_angle = Utility.find_angle(target.location, actor.location)
#Apply the force to the cr... | ruby | {
"resource": ""
} |
q3319 | Zyps.SpawnAction.do | train | def do(actor, targets)
prototypes.each do |prototype|
actor.environment.add_object(generate_child(actor, prototype))
end
end | ruby | {
"resource": ""
} |
q3320 | Zyps.SpawnAction.generate_child | train | def generate_child(actor, prototype)
#Copy prototype so it can be spawned repeatedly if need be.
child = prototype.copy
child.location = actor.location.copy
child
end | ruby | {
"resource": ""
} |
q3321 | Zyps.ExplodeAction.generate_child | train | def generate_child(actor, prototype)
child = super
child.vector += actor.vector
child.size = actor.size / prototypes.length
child
end | ruby | {
"resource": ""
} |
q3322 | Zyps.ShootAction.do | train | def do(actor, targets)
return if targets.empty?
#If next item is a collection of prototypes, copy them all in at once.
if prototypes[@prototype_index].respond_to?(:each)
prototypes[@prototype_index].each do |prototype|
actor.environment.add_object(generate_child(actor, prototype, targets[@targ... | ruby | {
"resource": ""
} |
q3323 | Zyps.ShootAction.generate_child | train | def generate_child(actor, prototype, target)
child = super(actor, prototype)
child.vector.pitch = Utility.find_angle(actor.location, target.location) + child.vector.pitch
child
end | ruby | {
"resource": ""
} |
q3324 | Percolate.Percolator.find | train | def find(context, facet_name, *args)
facet = find_facet(context, facet_name)
if !facet
return nil
end
case result = facet.find(*args)
when Array
result.map { |item| @entities[item] }
when String
@entities[result]
when NilClass
nil
else
... | ruby | {
"resource": ""
} |
q3325 | Percolate.Percolator.find_facet | train | def find_facet(context, facet_name)
cache_key = [context, facet_name]
if @facet_cache.include?(cache_key)
facet = @facet_cache[cache_key]
else
begin
require "percolate/facet/#{facet_name}_facet"
rescue LoadError
# Do nothing. Give the benefit of the doubt i... | ruby | {
"resource": ""
} |
q3326 | Gitter.Utils.url_for | train | def url_for params
p = params.dup
query = p.map{|key, value| value.to_query(key) } * '&'
"#{h.url_for({})}?#{query}"
end | ruby | {
"resource": ""
} |
q3327 | Hyperb.Services.create_service | train | def create_service(params = {})
valid = check_arguments(params, 'name', 'image', 'replicas', 'serviceport', 'labels')
raise ArgumentError, 'Invalid arguments.' unless valid
path = '/services/create'
body = {}
body.merge!(params)
downcase_symbolize(JSON.parse(Hyperb::Request.new(self,... | ruby | {
"resource": ""
} |
q3328 | HashKit.Helper.symbolize | train | def symbolize(hash)
{}.tap do |h|
hash.each { |key, value| h[key.to_sym] = map_value_symbol(value) }
end
end | ruby | {
"resource": ""
} |
q3329 | HashKit.Helper.stringify | train | def stringify(hash)
{}.tap do |h|
hash.each { |key, value| h[key.to_s] = map_value_string(value) }
end
end | ruby | {
"resource": ""
} |
q3330 | HashKit.Helper.to_hash | train | def to_hash(obj)
return nil unless obj
return obj if obj.is_a?(Hash)
hash = {}
obj.instance_variables.each do |key|
hash[key[1..-1].to_sym] = deeply_to_hash(obj.instance_variable_get(key))
end
hash
end | ruby | {
"resource": ""
} |
q3331 | Amico.Relationships.follow | train | def follow(from_id, to_id, scope = Amico.default_scope_key)
return if from_id == to_id
return if blocked?(to_id, from_id, scope)
return if Amico.pending_follow && pending?(from_id, to_id, scope)
if Amico.pending_follow
Amico.redis.multi do |transaction|
transaction.zadd("#{Ami... | ruby | {
"resource": ""
} |
q3332 | Amico.Relationships.unfollow | train | def unfollow(from_id, to_id, scope = Amico.default_scope_key)
return if from_id == to_id
Amico.redis.multi do
Amico.redis.zrem("#{Amico.namespace}:#{Amico.following_key}:#{scope}:#{from_id}", to_id)
Amico.redis.zrem("#{Amico.namespace}:#{Amico.followers_key}:#{scope}:#{to_id}", from_id)
... | ruby | {
"resource": ""
} |
q3333 | Amico.Relationships.block | train | def block(from_id, to_id, scope = Amico.default_scope_key)
return if from_id == to_id
Amico.redis.multi do
Amico.redis.zrem("#{Amico.namespace}:#{Amico.following_key}:#{scope}:#{from_id}", to_id)
Amico.redis.zrem("#{Amico.namespace}:#{Amico.following_key}:#{scope}:#{to_id}", from_id)
... | ruby | {
"resource": ""
} |
q3334 | Amico.Relationships.accept | train | def accept(from_id, to_id, scope = Amico.default_scope_key)
return if from_id == to_id
add_following_followers_reciprocated(from_id, to_id, scope)
end | ruby | {
"resource": ""
} |
q3335 | Amico.Relationships.deny | train | def deny(from_id, to_id, scope = Amico.default_scope_key)
return if from_id == to_id
Amico.redis.multi do
Amico.redis.zrem("#{Amico.namespace}:#{Amico.pending_key}:#{scope}:#{to_id}", from_id)
Amico.redis.zrem("#{Amico.namespace}:#{Amico.pending_with_key}:#{scope}:#{from_id}", to_id)
... | ruby | {
"resource": ""
} |
q3336 | Amico.Relationships.following? | train | def following?(id, following_id, scope = Amico.default_scope_key)
!Amico.redis.zscore("#{Amico.namespace}:#{Amico.following_key}:#{scope}:#{id}", following_id).nil?
end | ruby | {
"resource": ""
} |
q3337 | Amico.Relationships.follower? | train | def follower?(id, follower_id, scope = Amico.default_scope_key)
!Amico.redis.zscore("#{Amico.namespace}:#{Amico.followers_key}:#{scope}:#{id}", follower_id).nil?
end | ruby | {
"resource": ""
} |
q3338 | Amico.Relationships.blocked? | train | def blocked?(id, blocked_id, scope = Amico.default_scope_key)
!Amico.redis.zscore("#{Amico.namespace}:#{Amico.blocked_key}:#{scope}:#{id}", blocked_id).nil?
end | ruby | {
"resource": ""
} |
q3339 | Amico.Relationships.blocked_by? | train | def blocked_by?(id, blocked_by_id, scope = Amico.default_scope_key)
!Amico.redis.zscore("#{Amico.namespace}:#{Amico.blocked_by_key}:#{scope}:#{id}", blocked_by_id).nil?
end | ruby | {
"resource": ""
} |
q3340 | Amico.Relationships.reciprocated? | train | def reciprocated?(from_id, to_id, scope = Amico.default_scope_key)
following?(from_id, to_id, scope) && following?(to_id, from_id, scope)
end | ruby | {
"resource": ""
} |
q3341 | Amico.Relationships.pending_with? | train | def pending_with?(from_id, to_id, scope = Amico.default_scope_key)
!Amico.redis.zscore("#{Amico.namespace}:#{Amico.pending_with_key}:#{scope}:#{to_id}", from_id).nil?
end | ruby | {
"resource": ""
} |
q3342 | Amico.Relationships.following_page_count | train | def following_page_count(id, page_size = Amico.page_size, scope = Amico.default_scope_key)
total_pages("#{Amico.namespace}:#{Amico.following_key}:#{scope}:#{id}", page_size)
end | ruby | {
"resource": ""
} |
q3343 | Amico.Relationships.followers_page_count | train | def followers_page_count(id, page_size = Amico.page_size, scope = Amico.default_scope_key)
total_pages("#{Amico.namespace}:#{Amico.followers_key}:#{scope}:#{id}", page_size)
end | ruby | {
"resource": ""
} |
q3344 | Amico.Relationships.blocked_page_count | train | def blocked_page_count(id, page_size = Amico.page_size, scope = Amico.default_scope_key)
total_pages("#{Amico.namespace}:#{Amico.blocked_key}:#{scope}:#{id}", page_size)
end | ruby | {
"resource": ""
} |
q3345 | Amico.Relationships.blocked_by_page_count | train | def blocked_by_page_count(id, page_size = Amico.page_size, scope = Amico.default_scope_key)
total_pages("#{Amico.namespace}:#{Amico.blocked_by_key}:#{scope}:#{id}", page_size)
end | ruby | {
"resource": ""
} |
q3346 | Amico.Relationships.reciprocated_page_count | train | def reciprocated_page_count(id, page_size = Amico.page_size, scope = Amico.default_scope_key)
total_pages("#{Amico.namespace}:#{Amico.reciprocated_key}:#{scope}:#{id}", page_size)
end | ruby | {
"resource": ""
} |
q3347 | Amico.Relationships.pending_page_count | train | def pending_page_count(id, page_size = Amico.page_size, scope = Amico.default_scope_key)
total_pages("#{Amico.namespace}:#{Amico.pending_key}:#{scope}:#{id}", page_size)
end | ruby | {
"resource": ""
} |
q3348 | Amico.Relationships.pending_with_page_count | train | def pending_with_page_count(id, page_size = Amico.page_size, scope = Amico.default_scope_key)
total_pages("#{Amico.namespace}:#{Amico.pending_with_key}:#{scope}:#{id}", page_size)
end | ruby | {
"resource": ""
} |
q3349 | Amico.Relationships.count | train | def count(id, type, scope = Amico.default_scope_key)
validate_relationship_type(type)
self.send("#{type.to_s}_count".to_sym, id, scope)
end | ruby | {
"resource": ""
} |
q3350 | Amico.Relationships.page_count | train | def page_count(id, type, page_size = Amico.page_size, scope = Amico.default_scope_key)
validate_relationship_type(type)
self.send("#{type.to_s}_page_count".to_sym, id, page_size, scope)
end | ruby | {
"resource": ""
} |
q3351 | Amico.Relationships.add_following_followers_reciprocated | train | def add_following_followers_reciprocated(from_id, to_id, scope)
Amico.redis.multi do
Amico.redis.zadd("#{Amico.namespace}:#{Amico.following_key}:#{scope}:#{from_id}", Time.now.to_i, to_id)
Amico.redis.zadd("#{Amico.namespace}:#{Amico.followers_key}:#{scope}:#{to_id}", Time.now.to_i, from_id)
... | ruby | {
"resource": ""
} |
q3352 | Amico.Relationships.total_pages | train | def total_pages(key, page_size)
(Amico.redis.zcard(key) / page_size.to_f).ceil
end | ruby | {
"resource": ""
} |
q3353 | Amico.Relationships.members | train | def members(key, options = default_paging_options)
options = default_paging_options.dup.merge!(options)
if options[:page] < 1
options[:page] = 1
end
if options[:page] > total_pages(key, options[:page_size])
options[:page] = total_pages(key, options[:page_size])
end
... | ruby | {
"resource": ""
} |
q3354 | GAAPI.Response.csv | train | def csv
@csv ||= CSV.generate do |csv|
reports.each(&:report).each do |report|
# If there are no dimensions, but totals, we need to put an extra
# column at the start for the word "Total".
# I don't see how totals will be different than the metrics if you
# don't sp... | ruby | {
"resource": ""
} |
q3355 | Hyperb.Containers.containers | train | def containers(params = {})
path = '/containers/json'
query = {}
query.merge!(params)
response = JSON.parse(Hyperb::Request.new(self, path, query, 'get').perform)
response.map { |container| Hyperb::Container.new(container) }
end | ruby | {
"resource": ""
} |
q3356 | Hyperb.Containers.remove_container | train | def remove_container(params = {})
raise ArgumentError, 'Invalid arguments.' unless check_arguments(params, 'id')
path = '/containers/' + params[:id]
query = {}
query[:v] = params[:v] if params.key?(:v)
query[:force] = params[:force] if params.key?(:force)
response = JSON.parse(Hyperb... | ruby | {
"resource": ""
} |
q3357 | Hyperb.Containers.create_container | train | def create_container(params = {})
raise ArgumentError, 'Invalid arguments.' unless check_arguments(params, 'image')
path = '/containers/create'
query = {}
# set default size, otherwise container can't be started
body = { labels: { sh_hyper_instancetype: 's1' } }
# parse host_config ... | ruby | {
"resource": ""
} |
q3358 | Hyperb.Containers.rename_container | train | def rename_container(params = {})
raise ArgumentError, 'Invalid arguments.' unless check_arguments(params, 'name', 'id')
path = '/containers/' + params[:id] + '/rename'
query = {}
query[:name] = params[:name] if params.key?(:name)
Hyperb::Request.new(self, path, query, 'post').perform
... | ruby | {
"resource": ""
} |
q3359 | Logmsg.LogMsg.load | train | def load
close if @loaded
@path.each do |file|
next unless File.exist?(file)
@settings = Psych.load_file(file)
next unless @settings.include?(@namespace)
parse(@settings[@namespace])
@loaded = true
break
end
fail unless @loaded
end | ruby | {
"resource": ""
} |
q3360 | Logmsg.LogMsg.parse | train | def parse(settings, logfile = nil)
settings.each do |key, value|
if value.is_a?(Hash)
logfile = Logmsg::LogFile.new(key)
logfiles[key.to_sym] = logfile
parse(value, logfile)
logfile.register
else
logfile.public_send("#{key}=", value)
end
... | ruby | {
"resource": ""
} |
q3361 | Rdio.Api.addFriend | train | def addFriend(user)
method = 'addFriend'
type = true
args = {:user=>user}
return_object type,method,args,true
end | ruby | {
"resource": ""
} |
q3362 | Rdio.Api.addToCollection | train | def addToCollection(objs)
method = 'addToCollection'
type = true
args = {:keys=>Rdio::keys(objs)}
return_object type,method,args,true
end | ruby | {
"resource": ""
} |
q3363 | Rdio.Api.addToPlaylist | train | def addToPlaylist(playlist,tracks)
method = 'addToPlaylist'
type = true
args = {:playlist=>playlist, :tracks=>Rdio::keys(tracks)}
return_object type,method,args,true
end | ruby | {
"resource": ""
} |
q3364 | Rdio.Api.createPlaylist | train | def createPlaylist(name,description,tracks,extras=nil)
method = 'createPlaylist'
type = Playlist
args = {:name=>name,:description=>description,
:tracks=>Rdio::keys(tracks)}
args[:extras] = extras if extras
return_object type,method,args,true
end | ruby | {
"resource": ""
} |
q3365 | Rdio.Api.currentUser | train | def currentUser(extras=nil)
method = 'currentUser'
type = User
args = {}
args[:extras] = extras if extras
return_object type,method,args,true
end | ruby | {
"resource": ""
} |
q3366 | Rdio.Api.deletePlaylist | train | def deletePlaylist(playlist)
method = 'deletePlaylist'
type = Boolean
args = {:playlist=>playlist}
return_object type,method,args,true
end | ruby | {
"resource": ""
} |
q3367 | Rdio.Api.getActivityStream | train | def getActivityStream(user,scope,last_id=nil)
method = 'getActivityStream'
type = ActivityStream
args = {:user=>user,:scope=>scope}
args[:last_id] = last_id if last_id
auth = user
return_object type,method,args,auth
end | ruby | {
"resource": ""
} |
q3368 | Rdio.Api.getAlbumsForArtistInCollection | train | def getAlbumsForArtistInCollection(artist,user=nil,extras=nil)
method = 'getAlbumsForArtistInCollection'
type = Album
args = {:artist=>artist}
args[:user] = user if user
args[:extras] = extras if extras
auth = !!user
return_object type,method,args,auth
end | ruby | {
"resource": ""
} |
q3369 | Rdio.Api.getHeavyRotation | train | def getHeavyRotation(user=nil,type=nil,friends=nil,limit=nil,extras=nil)
method = 'getHeavyRotation'
cls = TODO
if type == 'artist'
cls = Artist
elsif type == 'album'
cls = Album
end
args = {}
args[:user] = user if user
args[:type] = type if type
arg... | ruby | {
"resource": ""
} |
q3370 | Rdio.Api.getNewReleases | train | def getNewReleases(time=nil,start=nil,count=nil,extras=nil)
method = 'getNewReleases'
type = Album
args = {}
args[:time] = time if time
args[:start] = start if start
args[:count] = count if count
args[:extras] = extras if extras
return_object type,method,args
end | ruby | {
"resource": ""
} |
q3371 | Rdio.Api.getObjectFromShortCode | train | def getObjectFromShortCode(short_code,type=nil)
method = 'getObjectFromShortCode'
type = BaseObj if not type
args = {:short_code=>short_code}
return_object type,method,args,true
end | ruby | {
"resource": ""
} |
q3372 | Rdio.Api.getObjectFromUrl | train | def getObjectFromUrl(url,type=nil)
method = 'getObjectFromUrl'
type = BaseObj if not type
args = {:url=>url}
return_object type,method,args,true
end | ruby | {
"resource": ""
} |
q3373 | Rdio.Api.getPlaybackToken | train | def getPlaybackToken(domain=nil)
method = 'getPlaybackToken'
type = String
args = {}
args[:domain] = domain if domain
return_object type,method,args,true
end | ruby | {
"resource": ""
} |
q3374 | Rdio.Api.getPlaylists | train | def getPlaylists(extras=nil)
method = 'getPlaylists'
type = Playlist
args = {}
args[:extras] = extras if extras
return_object type,method,args,true
end | ruby | {
"resource": ""
} |
q3375 | Rdio.Api.getTopCharts | train | def getTopCharts(type,start=nil,count=nil,extras=nil)
method = 'getTopCharts'
cls = TODO
case type
when 'Artist'
cls = Artist
when 'Album'
cls = Album
when 'Track'
cls = Track
when 'Playlist'
cls = Playlist
end
args = {:type=>type}
... | ruby | {
"resource": ""
} |
q3376 | Rdio.Api.getTracksForAlbumInCollection | train | def getTracksForAlbumInCollection(album,user=nil,extras=nil)
method = 'getTracksForAlbumInCollection'
type = Track
args = {:album=>album}
args[:user] = user if user
args[:extras] = extras if extras
return_object type,method,args
end | ruby | {
"resource": ""
} |
q3377 | Rdio.Api.getTracksForArtistInCollection | train | def getTracksForArtistInCollection(artist,user=nil,extras=nil)
method = 'getTracksForArtistInCollection'
type = Track
args = {:artist=>artist}
args[:user] = user if user
args[:extras] = extras if extras
return_object type,method,args
end | ruby | {
"resource": ""
} |
q3378 | Rdio.Api.removeFriend | train | def removeFriend(user)
method = 'removeFriend'
type = Boolean
args = {:user=>user}
return_object type,method,args,true
end | ruby | {
"resource": ""
} |
q3379 | Rdio.Api.removeFromCollection | train | def removeFromCollection(objs)
method = 'removeFromCollection'
type = Boolean
args = {:keys=>Rdio::keys(objs)}
return_object type,method,args
end | ruby | {
"resource": ""
} |
q3380 | Rdio.Api.removeFromPlaylist | train | def removeFromPlaylist(playlist,index,count,tracks)
method = 'removeFromPlaylist'
type = TODO
args = {:playlist=>playlist,:index=>index,
:count=>count,:tracks=>Rdio::keys(tracks)}
return_object type,method,args,true
end | ruby | {
"resource": ""
} |
q3381 | Rdio.Api.setPlaylistFields | train | def setPlaylistFields(playlist,name,description)
method = 'setPlaylistFields'
type = Boolean
args = {:playlist=>playlist,:name=>name,:description=>description}
return_object type,method,args,true
end | ruby | {
"resource": ""
} |
q3382 | Rdio.Api.searchSuggestions | train | def searchSuggestions(query,extras)
method = 'searchSuggestions'
type = TODO
args = {:query=>query}
args[:extras] = extras if extras
return_object type,method,args
end | ruby | {
"resource": ""
} |
q3383 | Linkshare.Strategy.get_token | train | def get_token(username, password, sid, params = {}, opts = {})
request_body = opts.delete('auth_scheme') == 'request_body'
params = {'grant_type' => 'password',
'username' => username,
'password' => password,
'scope' => sid
}.merge(client_par... | ruby | {
"resource": ""
} |
q3384 | Socialcast.Gitx.run_cmd | train | def run_cmd(cmd)
raise "Unstubbed git command #{cmd}" if ENV['SCGITX_TEST'] == 'true'
say "\n$ "
say cmd.gsub("'", ''), :red
raise "#{cmd} failed" unless system cmd
end | ruby | {
"resource": ""
} |
q3385 | GoogleAuthentication.ActsAsGoogleUser.acts_as_google_user | train | def acts_as_google_user *modules
# assign devise modules to module variable
if modules.empty?
self.devise_modules_to_include = [:omniauthable]
else
# restrict modules given to devise
self.devise_modules_to_include = (modules + [:omniauthable] - FORBIDDEN_MODULES) & ALLOWED_MODU... | ruby | {
"resource": ""
} |
q3386 | Hoiio.Client.set_up_resources | train | def set_up_resources
@user = Hoiio::User.new self
@sms = Hoiio::SMS.new self
@voice = Hoiio::Voice.new self
@fax = Hoiio::Fax.new self
@number = Hoiio::Number.new self
@ivr = Hoiio::IVR.new self
end | ruby | {
"resource": ""
} |
q3387 | OmekaClient.Client.put_item | train | def put_item(omeka_item)
self.put("items", omeka_item.data.id, omeka_item.data.to_h.to_json)
end | ruby | {
"resource": ""
} |
q3388 | OmekaClient.Client.build_request | train | def build_request(method, resource = nil, id = nil, body =nil, query = {})
url = self.endpoint
url += "/" + resource unless resource.nil?
url += "/" + id.to_s unless id.nil?
query[:key] = self.api_key unless self.api_key.nil?
case method
when "get"
self.connection.get(url... | ruby | {
"resource": ""
} |
q3389 | Markascend.LineUnit.parse_inline_code | train | def parse_inline_code
if s = @src.scan(/
(`{1,})(\ ?)
.*?
\2\1
/x)
s =~ /^
(`{1,})(\ ?)
(.*?)
\2\1
$/x
@out << (::Markascend.hilite $3, env.hi, true)
true
end
end | ruby | {
"resource": ""
} |
q3390 | Phonology.Sound.<< | train | def <<(*args)
args.to_a.flatten.each do |feature|
features.subtract Features.set(feature).to_a
add! feature
end
self
end | ruby | {
"resource": ""
} |
q3391 | Phonology.Sound.>> | train | def >>(*args)
args.to_a.flatten.each do |feature|
features.delete feature.to_sym
end
self
end | ruby | {
"resource": ""
} |
q3392 | Unified.Chunk.each_line | train | def each_line
original_line_number = @original_line_number
modified_line_number = @modified_line_number
@lines.each do |line|
if line.addition?
yield line, nil, modified_line_number
modified_line_number += 1
elsif line.deletion?
yield line, original_line_... | ruby | {
"resource": ""
} |
q3393 | Sys::Proc::Concern::StaticInstance.ClassMethods.method_missing | train | def method_missing(method, *args, &block)
if respond_to_missing?(method)
new.public_send(method, *args, &block)
else
super
end
end | ruby | {
"resource": ""
} |
q3394 | Manageable.ApplicationHelper.manageable_content_box | train | def manageable_content_box(options = {}, &block)
box_buffer = Helpers::BoxBuilder.new(self)
box_content = capture(box_buffer, &block)
options = {
:id => nil,
:class => []
}.merge(options)
block_class = ([ "block" ] + [ options[:class] ].flatten).join(" ")
content_t... | ruby | {
"resource": ""
} |
q3395 | Manageable.ApplicationHelper.manageable_icon | train | def manageable_icon(name, size = :small, options = {})
return "" if name.nil?
dimension = ( (size == :small) ? "16" : "32" ).html_safe
options[:alt] ||= name.capitalize.gsub("_", " ")
image_tag(asset_path("manageable/icons/#{dimension}x#{dimension}/#{name}.png"), {
:alt => options[:alt... | ruby | {
"resource": ""
} |
q3396 | Manageable.ApplicationHelper.manageable_controls | train | def manageable_controls(options = {})
options[:class] ||= ""
options[:class] << " control"
options[:class].strip!
items = Helpers::NavigationBuilder.new
yield items if block_given?
content_tag("div", options) do
items.collect { |item|
manageable_button(item[:label... | ruby | {
"resource": ""
} |
q3397 | Manageable.ApplicationHelper.manageable_breadcrumbs | train | def manageable_breadcrumbs(options = {})
items = Helpers::NavigationBuilder.new
yield items if block_given?
options[:class] ||= ""
options[:class] << " breadcrumb"
options[:class].strip!
content_tag("div", options) do
content_tag("ul") do
items.collect { |item|
... | ruby | {
"resource": ""
} |
q3398 | Manageable.ApplicationHelper.manageable_button | train | def manageable_button(body, url, html_options = {})
html_options[:class] = [html_options[:class], "button"].compact.join(" ")
icon = manageable_icon(html_options.delete(:icon), :small, :alt => body) if html_options[:icon]
link_to url, html_options do
[icon, body].compact.join(" ").html_s... | ruby | {
"resource": ""
} |
q3399 | Manageable.ApplicationHelper.manageable_attributes | train | def manageable_attributes(record, options = {}, &block)
options[:html] ||= {}
html_class = [ "attrtastic", record.class.to_s.underscore, options[:html][:class] ].compact.join(" ")
output = tag(:div, { :class => html_class}, true)
if block_given?
output << capture(Helpers::AttributesBui... | ruby | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.