_id
stringlengths 2
6
| title
stringlengths 9
130
| partition
stringclasses 3
values | text
stringlengths 66
10.5k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q4400
|
TelestreamCloud::Tts.TtsApi.corpus
|
train
|
def corpus(project_id, name, opts = {})
data, _status_code, _headers = corpus_with_http_info(project_id, name, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4401
|
TelestreamCloud::Tts.TtsApi.create_corpus
|
train
|
def create_corpus(project_id, name, body, opts = {})
create_corpus_with_http_info(project_id, name, body, opts)
return nil
end
|
ruby
|
{
"resource": ""
}
|
q4402
|
TelestreamCloud::Tts.TtsApi.create_project
|
train
|
def create_project(project, opts = {})
data, _status_code, _headers = create_project_with_http_info(project, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4403
|
TelestreamCloud::Tts.TtsApi.job
|
train
|
def job(project_id, job_id, opts = {})
data, _status_code, _headers = job_with_http_info(project_id, job_id, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4404
|
TelestreamCloud::Tts.TtsApi.job_result
|
train
|
def job_result(project_id, job_id, opts = {})
data, _status_code, _headers = job_result_with_http_info(project_id, job_id, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4405
|
TelestreamCloud::Tts.TtsApi.jobs
|
train
|
def jobs(project_id, opts = {})
data, _status_code, _headers = jobs_with_http_info(project_id, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4406
|
TelestreamCloud::Tts.TtsApi.project
|
train
|
def project(project_id, opts = {})
data, _status_code, _headers = project_with_http_info(project_id, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4407
|
TelestreamCloud::Tts.TtsApi.update_project
|
train
|
def update_project(project, opts = {})
data, _status_code, _headers = update_project_with_http_info(project, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4408
|
TelestreamCloud::Tts.TtsApi.upload_video
|
train
|
def upload_video(project_id, video_upload_body, opts = {})
data, _status_code, _headers = upload_video_with_http_info(project_id, video_upload_body, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4409
|
RailsTables::Searching.ClassMethods.search_on
|
train
|
def search_on(column_source, methods)
Array(methods).each do |method_name|
join column_source
self.searches += [{column_source: column_source.to_s, method_name: method_name.to_s}]
end
end
|
ruby
|
{
"resource": ""
}
|
q4410
|
NIFTI.NRead.read_image
|
train
|
def read_image
raw_image = []
@stream.index = @hdr['vox_offset']
type = NIFTI_DATATYPES[@hdr['datatype']]
format = @stream.format[type]
@image_rubyarray = @stream.decode(@stream.rest_length, type)
end
|
ruby
|
{
"resource": ""
}
|
q4411
|
NIFTI.NRead.get_image_narray
|
train
|
def get_image_narray(image_array, dim)
if Object.const_defined?('NArray')
@image_narray = pixel_data = NArray.to_na(image_array).reshape!(*dim[1..dim[0]])
else
add_msg "Can't find NArray, no image_narray created. Please `gem install narray`"
end
end
|
ruby
|
{
"resource": ""
}
|
q4412
|
NIFTI.NRead.parse_header
|
train
|
def parse_header(options = {})
check_header
@hdr = parse_basic_header
@extended_header = parse_extended_header
# Optional image gathering
read_image if options[:image]
get_image_narray(@image_rubyarray, @hdr['dim']) if options[:narray]
@success = true
end
|
ruby
|
{
"resource": ""
}
|
q4413
|
NIFTI.NRead.parse_basic_header
|
train
|
def parse_basic_header
# The HEADER_SIGNATURE is defined in NIFTI::Constants and used for both reading and writing.
header = {}
HEADER_SIGNATURE.each do |header_item|
name, length, type = *header_item
header[name] = @stream.decode(length, type)
end
# Extract Freq, Phase & Slice Dimensions from diminfo
if header['dim_info']
header['freq_dim'] = dim_info_to_freq_dim(header['dim_info'])
header['phase_dim'] = dim_info_to_phase_dim(header['dim_info'])
header['slice_dim'] = dim_info_to_slice_dim(header['dim_info'])
end
header['sform_code_descr'] = XFORM_CODES[header['sform_code']]
header['qform_code_descr'] = XFORM_CODES[header['qform_code']]
return header
end
|
ruby
|
{
"resource": ""
}
|
q4414
|
NIFTI.NRead.parse_extended_header
|
train
|
def parse_extended_header
extended = []
extension = @stream.decode(4, "BY")
# "After the end of the 348 byte header (e.g., after the magic field),
# the next 4 bytes are an byte array field named extension. By default,
# all 4 bytes of this array should be set to zero. In a .nii file, these 4
# bytes will always be present, since the earliest start point for the
# image data is byte #352. In a separate .hdr file, these bytes may or may
# not be present (i.e., a .hdr file may only be 348 bytes long). If not
# present, then a NIfTI-1.1 compliant program should use the default value
# of extension={0,0,0,0}. The first byte (extension[0]) is the only value
# of this array that is specified at present. The other 3 bytes are
# reserved for future use."
if extension[0] != 0
while @stream.index < @hdr['vox_offset']
esize, ecode = *@stream.decode(8, "UL")
data = @stream.decode(esize - 8, "STR")
extended << {:esize => esize, :ecode => ecode, :data => data}
end
# stream.decode(header['vox_offset'] - stream.index, "STR")
# stream.skip header['vox_offset'] - stream.index
end
return extended
end
|
ruby
|
{
"resource": ""
}
|
q4415
|
NIFTI.NRead.open_file
|
train
|
def open_file(file)
if File.exist?(file)
if File.readable?(file)
if not File.directory?(file)
if File.size(file) > 8
begin
@file = Zlib::GzipReader.new(File.new(file, "rb"))
rescue Zlib::GzipFile::Error
@file = File.new(file, "rb")
end
else
@msg << "Error! File is too small to contain DICOM information (#{file})."
end
else
@msg << "Error! File is a directory (#{file})."
end
else
@msg << "Error! File exists but I don't have permission to read it (#{file})."
end
else
@msg << "Error! The file you have supplied does not exist (#{file})."
end
end
|
ruby
|
{
"resource": ""
}
|
q4416
|
Qe.TextField.validation_class
|
train
|
def validation_class(answer_sheet)
validation = ''
validation += ' required' if self.required?(answer_sheet)
# validate-number, etc.
validate_style = ['number', 'currency-dollar', 'email', 'url', 'phone'].find {|v| v == self.style }
if validate_style
validation += ' validate-' + validate_style
end
validation
end
|
ruby
|
{
"resource": ""
}
|
q4417
|
NIFTI.NWrite.write
|
train
|
def write
# Check if we are able to create given file:
open_file(@file_name)
# Go ahead and write if the file was opened successfully:
if @file
# Initiate necessary variables:
init_variables
@file_endian = false
# Create a Stream instance to handle the encoding of content to a binary string:
@stream = Stream.new(nil, @file_endian)
# Tell the Stream instance which file to write to:
@stream.set_file(@file)
# Write Header and Image
write_basic_header
write_extended_header
write_image
# As file has been written successfully, it can be closed.
@file.close
# Mark this write session as successful:
@success = true
end
end
|
ruby
|
{
"resource": ""
}
|
q4418
|
NIFTI.NWrite.write_basic_header
|
train
|
def write_basic_header
HEADER_SIGNATURE.each do |header_item|
begin
name, length, type = *header_item
str = @stream.encode(@obj.header[name], type)
padded_str = @stream.encode_string_to_length(str, length)
# puts @stream.index, name, str.unpack(@stream.vr_to_str(type))
# pp padded_str.unpack(@stream.vr_to_str(type))
@stream.write padded_str
@stream.skip length
rescue StandardError => e
puts name, length, type, e
raise e
end
end
end
|
ruby
|
{
"resource": ""
}
|
q4419
|
NIFTI.NWrite.write_extended_header
|
train
|
def write_extended_header
unless @obj.extended_header.empty?
@stream.write @stream.encode([1,0,0,0], "BY")
@obj.extended_header.each do |extension|
@stream.write @stream.encode extension[:esize], "UL"
@stream.write @stream.encode extension[:ecode], "UL"
@stream.write @stream.encode_string_to_length(@stream.encode(extension[:data], "STR"), extension[:esize] - 8)
end
else
@stream.write @stream.encode([0,0,0,0], "BY")
end
end
|
ruby
|
{
"resource": ""
}
|
q4420
|
VCloudSdk.Powerable.power_on
|
train
|
def power_on
target = entity_xml
class_name = self.class.name.split("::").last
Config.logger.debug "#{class_name} status: #{target[:status]}"
if is_status?(target, :POWERED_ON)
Config.logger.info "#{class_name} #{target.name} is already powered-on."
return
end
power_on_link = target.power_on_link
unless power_on_link
fail CloudError,
"#{class_name} #{target.name} not in a state able to power on."
end
Config.logger.info "Powering on #{class_name} #{target.name}."
task = connection.post(power_on_link.href, nil)
task = monitor_task task, @session.time_limit[:power_on]
Config.logger.info "#{class_name} #{target.name} is powered on."
self
end
|
ruby
|
{
"resource": ""
}
|
q4421
|
VCloudSdk.Powerable.power_off
|
train
|
def power_off
target = entity_xml
class_name = self.class.name.split("::").last
Config.logger.debug "#{class_name} status: #{target[:status]}"
if is_status?(target, :SUSPENDED)
error_msg = "#{class_name} #{target.name} suspended, discard state before powering off."
fail class_name == "VApp" ? VappSuspendedError : VmSuspendedError,
error_msg
end
if is_status?(target, :POWERED_OFF)
Config.logger.info "#{class_name} #{target.name} is already powered off."
return
end
power_off_link = target.power_off_link
unless power_off_link
fail CloudError, "#{class_name} #{target.name} is not in a state that could be powered off."
end
task = connection.post(power_off_link.href, nil)
monitor_task task, @session.time_limit[:power_off]
Config.logger.info "#{class_name} #{target.name} is powered off."
undeploy(target, class_name)
self
end
|
ruby
|
{
"resource": ""
}
|
q4422
|
TelestreamCloud::Flip.FlipApi.cancel_encoding
|
train
|
def cancel_encoding(id, factory_id, opts = {})
data, _status_code, _headers = cancel_encoding_with_http_info(id, factory_id, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4423
|
TelestreamCloud::Flip.FlipApi.copy_profile
|
train
|
def copy_profile(id, factory_id, copy_profile_body, opts = {})
data, _status_code, _headers = copy_profile_with_http_info(id, factory_id, copy_profile_body, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4424
|
TelestreamCloud::Flip.FlipApi.create_encoding
|
train
|
def create_encoding(factory_id, create_encoding_body, opts = {})
data, _status_code, _headers = create_encoding_with_http_info(factory_id, create_encoding_body, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4425
|
TelestreamCloud::Flip.FlipApi.create_factory
|
train
|
def create_factory(create_factory_body, opts = {})
data, _status_code, _headers = create_factory_with_http_info(create_factory_body, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4426
|
TelestreamCloud::Flip.FlipApi.create_profile
|
train
|
def create_profile(factory_id, create_profile_body, opts = {})
data, _status_code, _headers = create_profile_with_http_info(factory_id, create_profile_body, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4427
|
TelestreamCloud::Flip.FlipApi.create_video
|
train
|
def create_video(factory_id, create_video_body, opts = {})
data, _status_code, _headers = create_video_with_http_info(factory_id, create_video_body, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4428
|
TelestreamCloud::Flip.FlipApi.delete_encoding
|
train
|
def delete_encoding(id, factory_id, opts = {})
data, _status_code, _headers = delete_encoding_with_http_info(id, factory_id, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4429
|
TelestreamCloud::Flip.FlipApi.delete_profile
|
train
|
def delete_profile(id, factory_id, opts = {})
data, _status_code, _headers = delete_profile_with_http_info(id, factory_id, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4430
|
TelestreamCloud::Flip.FlipApi.delete_video
|
train
|
def delete_video(id, factory_id, opts = {})
data, _status_code, _headers = delete_video_with_http_info(id, factory_id, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4431
|
TelestreamCloud::Flip.FlipApi.delete_video_source
|
train
|
def delete_video_source(id, factory_id, opts = {})
data, _status_code, _headers = delete_video_source_with_http_info(id, factory_id, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4432
|
TelestreamCloud::Flip.FlipApi.encoding
|
train
|
def encoding(id, factory_id, opts = {})
data, _status_code, _headers = encoding_with_http_info(id, factory_id, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4433
|
TelestreamCloud::Flip.FlipApi.encodings
|
train
|
def encodings(factory_id, opts = {})
data, _status_code, _headers = encodings_with_http_info(factory_id, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4434
|
TelestreamCloud::Flip.FlipApi.encodings_count
|
train
|
def encodings_count(factory_id, opts = {})
data, _status_code, _headers = encodings_count_with_http_info(factory_id, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4435
|
TelestreamCloud::Flip.FlipApi.factory
|
train
|
def factory(id, opts = {})
data, _status_code, _headers = factory_with_http_info(id, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4436
|
TelestreamCloud::Flip.FlipApi.notifications
|
train
|
def notifications(factory_id, opts = {})
data, _status_code, _headers = notifications_with_http_info(factory_id, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4437
|
TelestreamCloud::Flip.FlipApi.profile
|
train
|
def profile(id_or_name, factory_id, opts = {})
data, _status_code, _headers = profile_with_http_info(id_or_name, factory_id, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4438
|
TelestreamCloud::Flip.FlipApi.profile_encodings
|
train
|
def profile_encodings(id_or_name, factory_id, opts = {})
data, _status_code, _headers = profile_encodings_with_http_info(id_or_name, factory_id, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4439
|
TelestreamCloud::Flip.FlipApi.profiles
|
train
|
def profiles(factory_id, opts = {})
data, _status_code, _headers = profiles_with_http_info(factory_id, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4440
|
TelestreamCloud::Flip.FlipApi.queued_videos
|
train
|
def queued_videos(factory_id, opts = {})
data, _status_code, _headers = queued_videos_with_http_info(factory_id, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4441
|
TelestreamCloud::Flip.FlipApi.retry_encoding
|
train
|
def retry_encoding(id, factory_id, opts = {})
data, _status_code, _headers = retry_encoding_with_http_info(id, factory_id, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4442
|
TelestreamCloud::Flip.FlipApi.signed_encoding_url
|
train
|
def signed_encoding_url(id, factory_id, opts = {})
data, _status_code, _headers = signed_encoding_url_with_http_info(id, factory_id, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4443
|
TelestreamCloud::Flip.FlipApi.signed_encoding_urls
|
train
|
def signed_encoding_urls(id, factory_id, opts = {})
data, _status_code, _headers = signed_encoding_urls_with_http_info(id, factory_id, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4444
|
TelestreamCloud::Flip.FlipApi.signed_video_url
|
train
|
def signed_video_url(id, factory_id, opts = {})
data, _status_code, _headers = signed_video_url_with_http_info(id, factory_id, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4445
|
TelestreamCloud::Flip.FlipApi.toggle_factory_sync
|
train
|
def toggle_factory_sync(id, factory_sync_body, opts = {})
data, _status_code, _headers = toggle_factory_sync_with_http_info(id, factory_sync_body, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4446
|
TelestreamCloud::Flip.FlipApi.update_encoding
|
train
|
def update_encoding(id, factory_id, update_encoding_body, opts = {})
data, _status_code, _headers = update_encoding_with_http_info(id, factory_id, update_encoding_body, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4447
|
TelestreamCloud::Flip.FlipApi.update_factory
|
train
|
def update_factory(id, update_factory_body, opts = {})
data, _status_code, _headers = update_factory_with_http_info(id, update_factory_body, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4448
|
TelestreamCloud::Flip.FlipApi.update_notifications
|
train
|
def update_notifications(factory_id, cloud_notification_settings_body, opts = {})
data, _status_code, _headers = update_notifications_with_http_info(factory_id, cloud_notification_settings_body, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4449
|
TelestreamCloud::Flip.FlipApi.update_profile
|
train
|
def update_profile(id, factory_id, update_profile_body, opts = {})
data, _status_code, _headers = update_profile_with_http_info(id, factory_id, update_profile_body, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4450
|
TelestreamCloud::Flip.FlipApi.upload_video
|
train
|
def upload_video(factory_id, video_upload_body, opts = {})
data, _status_code, _headers = upload_video_with_http_info(factory_id, video_upload_body, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4451
|
TelestreamCloud::Flip.FlipApi.video_encodings
|
train
|
def video_encodings(id, factory_id, opts = {})
data, _status_code, _headers = video_encodings_with_http_info(id, factory_id, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4452
|
TelestreamCloud::Flip.FlipApi.video_metadata
|
train
|
def video_metadata(id, factory_id, opts = {})
data, _status_code, _headers = video_metadata_with_http_info(id, factory_id, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4453
|
TelestreamCloud::Flip.FlipApi.videos
|
train
|
def videos(factory_id, opts = {})
data, _status_code, _headers = videos_with_http_info(factory_id, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4454
|
TelestreamCloud::Flip.FlipApi.workflows
|
train
|
def workflows(factory_id, opts = {})
data, _status_code, _headers = workflows_with_http_info(factory_id, opts)
return data
end
|
ruby
|
{
"resource": ""
}
|
q4455
|
Comable.ApplicationHelper.liquid_assigns
|
train
|
def liquid_assigns
view_context.assigns.merge(
current_store: current_store,
current_comable_user: current_comable_user,
current_order: current_order,
current_trackers: current_trackers,
form_authenticity_token: form_authenticity_token
).stringify_keys
end
|
ruby
|
{
"resource": ""
}
|
q4456
|
Threshold.Thresholds.flush
|
train
|
def flush
begin
valid_existing_file?(@file)
raise ReadOnlyThresholdsFile if @readonly
hash = current_hash
file = File.open(@file, 'w+')
raise ThresholdAtomicLockFailure, 'The @file state/hash changed before we could flush the file' unless stored_hash == hash
file.write self.sort.to_s
file.close
rescue NonExistantThresholdFile
raise ReadOnlyThresholdsFile if @readonly
file = File.open(@file, 'w')
file.write self.sort.to_s
file.close
end
stored_hash=current_hash
return true
end
|
ruby
|
{
"resource": ""
}
|
q4457
|
Threshold.Thresholds.loadfile
|
train
|
def loadfile
valid_existing_file?(@file)
results = Threshold::Parser.new(@file)
@stored_hash= results.filehash
#puts stored_hash
results.caps.each do |result|
builder = Threshold::Builder.new(result)
self << builder.build
end
end
|
ruby
|
{
"resource": ""
}
|
q4458
|
Threshold.Thresholds.valid?
|
train
|
def valid?
begin
self.each do |threshold|
if threshold.respond_to?(:valid?)
return false unless threshold.valid?
else
raise InvalidThresholdsObject, "Container object has unknown objects"
end
end
return true
rescue InvalidThresholdsObject
return false
end
end
|
ruby
|
{
"resource": ""
}
|
q4459
|
Threshold.Thresholds.uniq
|
train
|
def uniq(&blk)
if block_given?
Thresholds.new(@thresholds.uniq(&blk))
else
Thresholds.new(@thresholds.uniq{ |lineitem| lineitem.to_s(true) })
end
end
|
ruby
|
{
"resource": ""
}
|
q4460
|
Threshold.Thresholds.suppressions
|
train
|
def suppressions(&blk)
if block_given?
self.suppressions.select(&blk)
else
Thresholds.new(@thresholds.select{|t| t.class.to_s == "Threshold::Suppression"})
end
end
|
ruby
|
{
"resource": ""
}
|
q4461
|
Threshold.Thresholds.event_filters
|
train
|
def event_filters(&blk)
if block_given?
self.event_filters.select(&blk)
else
Thresholds.new(@thresholds.select{|t| t.class.to_s == "Threshold::EventFilter"})
end
end
|
ruby
|
{
"resource": ""
}
|
q4462
|
Threshold.Thresholds.rate_filters
|
train
|
def rate_filters(&blk)
if block_given?
self.rate_filters.select(&blk)
else
Thresholds.new(@thresholds.select{|t| t.class.to_s == "Threshold::RateFilter"})
end
end
|
ruby
|
{
"resource": ""
}
|
q4463
|
Backlog.API.count_issue
|
train
|
def count_issue(condition)
raise Backlog::API::ArgumentError, "must specify 'projectId'" unless condition.has_key? "projectId"
condition = Backlog::Object::FindCondition.new(condition)
self.call("backlog.countIssue", condition.to_h)
end
|
ruby
|
{
"resource": ""
}
|
q4464
|
NIFTI.NObject.write
|
train
|
def write(file_name, options={})
if file_name.is_a?(String)
w = NWrite.new(self, file_name, options)
w.write
# Write process succesful?
@write_success = w.success
# If any messages has been recorded, send these to the message handling method:
add_msg(w.msg) if w.msg.length > 0
else
raise ArgumentError, "Invalid file_name. Expected String, got #{file_name.class}."
end
end
|
ruby
|
{
"resource": ""
}
|
q4465
|
NIFTI.NObject.read
|
train
|
def read(string, options={})
if string.is_a?(String)
@string = string
r = NRead.new(string, options)
# Store the data to the instance variables if the readout was a success:
if r.success
@read_success = true
# Update instance variables based on the properties of the NRead object:
@header = r.hdr
@extended_header = r.extended_header
if r.image_narray
@image = r.image_narray
elsif r.image_rubyarray
@image = r.image_rubyarray
end
else
@read_success = false
end
# If any messages have been recorded, send these to the message handling method:
add_msg(r.msg) if r.msg.length > 0
else
raise ArgumentError, "Invalid argument. Expected String, got #{string.class}."
end
end
|
ruby
|
{
"resource": ""
}
|
q4466
|
Qe.QuestionSheet.duplicate
|
train
|
def duplicate
new_sheet = QuestionSheet.new(self.attributes)
new_sheet.label = self.label + ' - COPY'
new_sheet.save(:validate => false)
self.pages.each do |page|
page.copy_to(new_sheet)
end
new_sheet
end
|
ruby
|
{
"resource": ""
}
|
q4467
|
Rubylog.Variable.rubylog_unify
|
train
|
def rubylog_unify other
# check if we are bound
if @bound
# if we are bound
# proceed to our dereferenced value
rubylog_dereference.rubylog_unify(other) do yield end
else
# if we are unbound
# dereference the other
other = other.rubylog_dereference
# if the other is a variable
if other.is_a? Rubylog::Variable
# succeed if same object
(yield; return) if self.equal? other
# we union our guards with the other's
other.append_guards guards do
# and bind to the other
bind_to other do
yield
end
end
else
# if the other is a value
# bind to it and
bind_to other do
# check our guards
if guards.all? {|g|g.rubylog_matches_as_guard? other}
yield
end
end
end
end
end
|
ruby
|
{
"resource": ""
}
|
q4468
|
Qe.ReferenceSheet.send_invite
|
train
|
def send_invite
return if self.email.blank?
application = self.applicant_answer_sheet
Notifier.deliver_notification(self.email,
application.email,
"Reference Invite",
{'reference_full_name' => self.name,
'applicant_full_name' => application.name,
'applicant_email' => application.email,
'applicant_home_phone' => application.phone,
'reference_url' => edit_reference_sheet_url(self, :a => self.access_key, :host => ActionMailer::Base.default_url_options[:host])})
# Send notification to applicant
Notifier.deliver_notification(applicant_answer_sheet.email, # RECIPIENTS
Questionnaire.from_email, # FROM
"Reference Notification to Applicant", # LIQUID TEMPLATE NAME
{'applicant_full_name' => applicant_answer_sheet.name,
'reference_full_name' => self.name,
'reference_email' => self.email,
'application_url' => edit_answer_sheet_url(applicant_answer_sheet, :host => ActionMailer::Base.default_url_options[:host])})
self.email_sent_at = Time.now
self.save(:validate => false)
true
end
|
ruby
|
{
"resource": ""
}
|
q4469
|
UUIDTools.UUID.generate_i
|
train
|
def generate_i
return (begin
bytes = (time_low << 96) + (time_mid << 80) +
(time_hi_and_version << 64) + (clock_seq_hi_and_reserved << 56) +
(clock_seq_low << 48)
for i in 0..5
bytes += (nodes[i] << (40 - (i * 8)))
end
bytes
end)
end
|
ruby
|
{
"resource": ""
}
|
q4470
|
Baidu.Client.authorize_url
|
train
|
def authorize_url(opts = {})
opts[:redirect_uri] ||= DEFAULT_REDIRECT_URI
# scope:非必须参数,以空格分隔的权限列表,若不传递此参数,代表请求用户的默认权限。关于权限的具体信息请参考“权限列表”。
opts[:scope] ||= "basic netdisk super_msg"
oauth_client.auth_code.authorize_url(scope: opts[:scope], redirect_uri: opts[:redirect_uri])
end
|
ruby
|
{
"resource": ""
}
|
q4471
|
Baidu.Client.token!
|
train
|
def token!(authorization_code,opts = {})
opts[:redirect_uri] ||= DEFAULT_REDIRECT_URI
self.access_token = oauth_client.auth_code.get_token(authorization_code, redirect_uri: opts[:redirect_uri])
end
|
ruby
|
{
"resource": ""
}
|
q4472
|
Baidu.Client.refresh_token!
|
train
|
def refresh_token!(refresh_token)
old_token = OAuth2::AccessToken.new(oauth_client,'', refresh_token: refresh_token)
self.access_token = old_token.refresh!
end
|
ruby
|
{
"resource": ""
}
|
q4473
|
MiniSpec.InstanceAPI.stub
|
train
|
def stub object, stub, visibility = nil, &proc
[Symbol, String, Hash].include?(stub.class) ||
raise(ArgumentError, 'a Symbol, String or Hash expected')
if stub.is_a?(Hash)
return hash_stub(object, stub, visibility, &proc)
elsif stub =~ /\./
return chained_stub(object, stub, visibility, &proc)
end
visibility ||= MiniSpec::Utils.method_visibility(object, stub) || :public
stubs = (@__ms__stubs[object.__id__] ||= {})
stubs[stub] ||= MiniSpec::Mocks::Stub.new(object, @__ms__messages, @__ms__stubs__originals)
stubs[stub].stubify(stub, visibility, &proc)
stubs[stub]
end
|
ruby
|
{
"resource": ""
}
|
q4474
|
MiniSpec.InstanceAPI.stubs
|
train
|
def stubs object, *stubs, &proc
MiniSpec::Mocks::MultipleStubsProxy.new(stubs.map {|s| stub(object, s, &proc)})
end
|
ruby
|
{
"resource": ""
}
|
q4475
|
GetnetApi.Card.to_request
|
train
|
def to_request
card = {
number_token: self.number_token,
cardholder_name: self.cardholder_name,
security_code: self.security_code,
brand: self.brand,
expiration_month: self.expiration_month,
expiration_year: self.expiration_year
}
return card
end
|
ruby
|
{
"resource": ""
}
|
q4476
|
CamperVan.Server.post_init
|
train
|
def post_init(*args)
logger.info "got connection from #{remote_ip}"
# initialize the line-based protocol: IRC is \r\n
@lt2_delimiter = "\r\n"
# start up the IRCD for this connection
@ircd = IRCD.new(self, options)
if options[:ssl]
logger.info "starting TLS for #{remote_ip}"
start_tls(:cert_chain_file => options[:ssl_cert], :private_key_file => options[:ssl_private_key], :verify_peer => options[:ssl_verify_peer])
end
end
|
ruby
|
{
"resource": ""
}
|
q4477
|
IPAddrExtensions.ClassMethods.generate_ULA
|
train
|
def generate_ULA(mac, subnet_id = 0, locally_assigned=true)
now = Time.now.utc
ntp_time = ((now.to_i + 2208988800) << 32) + now.nsec # Convert time to an NTP timstamp.
system_id = '::/64'.to_ip.eui_64(mac).to_i # Generate an EUI64 from the provided MAC address.
key = [ ntp_time, system_id ].pack('QQ') # Pack the ntp timestamp and the system_id into a binary string
global_id = Digest::SHA1.digest( key ).unpack('QQ').last & 0xffffffffff # Use only the last 40 bytes of the SHA1 digest.
prefix =
(126 << 121) + # 0xfc (bytes 0..6)
((locally_assigned ? 1 : 0) << 120) + # locally assigned? (byte 7)
(global_id << 80) + # 40 bit global idenfitier (bytes 8..48)
((subnet_id & 0xffff) << 64) # 16 bit subnet_id (bytes 48..64)
prefix.to_ip(Socket::AF_INET6).tap { |p| p.length = 64 }
end
|
ruby
|
{
"resource": ""
}
|
q4478
|
Qe.Admin::QuestionPagesController.show_panel
|
train
|
def show_panel
@tab_name = params[:panel_name]
@panel_name = params[:panel_name] == "properties" ? "prop_sheet" : params[:panel_name]
@all_pages = @question_sheet.pages.find(:all) # for pages_list
@page = @question_sheet.pages.find(params[:id])
respond_to do |format|
format.js # load panel
end
end
|
ruby
|
{
"resource": ""
}
|
q4479
|
Svn.Utils.wrap
|
train
|
def wrap( obj )
ptr = FFI::MemoryPointer.new( :uint64 )
ptr.write_uint64( obj.object_id )
ptr
end
|
ruby
|
{
"resource": ""
}
|
q4480
|
MiniSpec.Utils.method_visibility
|
train
|
def method_visibility object, method
{
public: :public_methods,
protected: :protected_methods,
private: :private_methods
}.each_pair do |v,m|
if v == :public
# in case public_methods overridden to include method
# but method in fact does not exists,
# most notable ActiveRecord::Base#find which rely on method_missing
return v if object.respond_to?(method)
else
return v if object.send(m).include?(method)
end
end
nil
end
|
ruby
|
{
"resource": ""
}
|
q4481
|
MiniSpec.Utils.any_match?
|
train
|
def any_match? label, matchers
reject, select = matchers.partition {|m| m.is_a?(Hash)}
rejected = rejected?(label, reject)
if select.any?
return select.find {|x| (x == :*) || match?(label, x)} && !rejected
end
!rejected
end
|
ruby
|
{
"resource": ""
}
|
q4482
|
MiniSpec.Utils.rejected?
|
train
|
def rejected? label, reject
if reject.any? && (x = reject.first[:except])
if x.is_a?(Array)
return true if x.find {|m| match?(label, m)}
else
return true if match?(label, x)
end
end
false
end
|
ruby
|
{
"resource": ""
}
|
q4483
|
MiniSpec.Utils.match?
|
train
|
def match? label, x
x.is_a?(Regexp) ? label.to_s =~ x : label == x
end
|
ruby
|
{
"resource": ""
}
|
q4484
|
UriSigner.Signer.uri_with_signature
|
train
|
def uri_with_signature
separator = if request_parser.query_params? then '&' else '?' end
encoded_signature = signature.extend(UriSigner::Helpers::String).escaped
"%s%s_signature=%s" % [self.uri, separator, encoded_signature]
end
|
ruby
|
{
"resource": ""
}
|
q4485
|
Polish.Proxies.pluralize
|
train
|
def pluralize(n, *variants)
raise ArgumentError, "Must have a Numeric as a first parameter" unless n.is_a?(Numeric)
raise ArgumentError, "Must have 3 variants for pluralization" if variants.size < 3
variants_hash = pluralization_variants_to_hash(*variants)
I18n.backend.send(:pluralize, LOCALE, variants_hash, n)
end
|
ruby
|
{
"resource": ""
}
|
q4486
|
Qe.Question.set_response
|
train
|
def set_response(values, app)
values = Array.wrap(values)
if !object_name.blank? and !attribute_name.blank?
# if eval("app." + object_name).present?
object = object_name == 'application' ? app : eval("app." + object_name)
unless object.present?
if object_name.include?('.')
objects = object_name.split('.')
object = eval("app." + objects[0..-2].join('.') + ".create_" + objects.last)
eval("app." + objects[0..-2].join('.')).reload
end
end
unless responses(app) == values
value = ActiveRecord::Base.connection.quote_string(values.first)
if self.is_a?(DateField) && value.present?
begin
value = Date.strptime(value, (I18n.t 'date.formats.default'))
rescue
raise "invalid date - " + value.inspect
end
end
object.update_attribute(attribute_name, value)
end
# else
# raise object_name.inspect + ' == ' + attribute_name.inspect
# end
else
@answers ||= []
@mark_for_destroy ||= []
# go through existing answers (in reverse order, as we delete)
(@answers.length - 1).downto(0) do |index|
# reject: skip over responses that are unchanged
unless values.reject! {|value| value == @answers[index]}
# remove any answers that don't match the posted values
@mark_for_destroy << @answers[index] # destroy from database later
@answers.delete_at(index)
end
end
# insert any new answers
for value in values
if @mark_for_destroy.empty?
answer = Answer.new(:question_id => self.id)
else
# re-use marked answers (an update vs. a delete+insert)
answer = @mark_for_destroy.pop
end
answer.set(value)
@answers << answer
end
end
end
|
ruby
|
{
"resource": ""
}
|
q4487
|
Qe.Question.save_response
|
train
|
def save_response(answer_sheet)
unless @answers.nil?
for answer in @answers
if answer.is_a?(Answer)
answer.answer_sheet_id = answer_sheet.id
answer.save!
end
end
end
# remove others
unless @mark_for_destroy.nil?
for answer in @mark_for_destroy
answer.destroy
end
@mark_for_destroy.clear
end
rescue TypeError
raise answer.inspect
end
|
ruby
|
{
"resource": ""
}
|
q4488
|
Qe.Question.has_response?
|
train
|
def has_response?(answer_sheet = nil)
if answer_sheet.present?
answers = responses(answer_sheet)
else
answers = Answer.where(:question_id => self.id)
end
return false if answers.length == 0
answers.each do |answer| # loop through Answers
value = answer.is_a?(Answer) ? answer.value : answer
return true if (value.is_a?(FalseClass) && value === false) || value.present?
end
return false
end
|
ruby
|
{
"resource": ""
}
|
q4489
|
Chars.CharSet.<<
|
train
|
def <<(other)
case other
when String
other.each_char do |char|
byte = char_to_byte(char)
@chars[byte] = char
super(byte)
end
return self
when Integer
super(other)
else
raise(TypeError,"can only append Strings and Integers")
end
end
|
ruby
|
{
"resource": ""
}
|
q4490
|
Chars.CharSet.include_char?
|
train
|
def include_char?(char)
unless char.empty?
@chars.has_value?(char) || include_byte?(char_to_byte(char))
else
false
end
end
|
ruby
|
{
"resource": ""
}
|
q4491
|
Chars.CharSet.each_random_char
|
train
|
def each_random_char(n,&block)
return enum_for(:each_random_char,n) unless block_given?
each_random_byte(n) { |byte| yield @chars[byte] }
end
|
ruby
|
{
"resource": ""
}
|
q4492
|
Chars.CharSet.random_bytes
|
train
|
def random_bytes(length)
if (length.kind_of?(Array) || length.kind_of?(Range))
Array.new(length.sort_by { rand }.first) { random_byte }
else
Array.new(length) { random_byte }
end
end
|
ruby
|
{
"resource": ""
}
|
q4493
|
Chars.CharSet.random_distinct_bytes
|
train
|
def random_distinct_bytes(length)
if (length.kind_of?(Array) || length.kind_of?(Range))
self.entries.sort_by { rand }.slice(0...(length.sort_by { rand }.first))
else
self.entries.sort_by { rand }.slice(0...length)
end
end
|
ruby
|
{
"resource": ""
}
|
q4494
|
Chars.CharSet.strings_in
|
train
|
def strings_in(data,options={},&block)
unless block
if options[:offsets]
found = {}
block = lambda { |offset,substring| found[offset] = substring }
else
found = []
block = lambda { |substring| found << substring }
end
strings_in(data,options,&block)
return found
end
min_length = options.fetch(:length,4)
return if data.length < min_length
index = 0
while index <= (data.length - min_length)
if self === data[index,min_length]
sub_index = (index + min_length)
while self.include_char?(data[sub_index,1])
sub_index += 1
end
match = data[index...sub_index]
case block.arity
when 2
yield match, index
else
yield match
end
index = sub_index
else
index += 1
end
end
end
|
ruby
|
{
"resource": ""
}
|
q4495
|
HasOffersModel.ClassMethods.has_offers_model
|
train
|
def has_offers_model(has_offers_class_name)
has_offers_class = "HasOffers::#{has_offers_class_name}".constantize
class_eval do
define_method("has_offers_create") do
if respond_to? :has_offer_id
response = has_offers_class.create(has_offers_params)
if response.success?
if response.data.is_a? Hash
# return_object is true
self.has_offer_id = response.data[has_offers_class_name]["id"].to_i
else
# return_object is false
self.has_offer_id = response.data.to_i
end
end
check_for_errors(response)
end
end
define_method("has_offers_update") do
if respond_to?(:has_offer_id) and has_offer_id
response = has_offers_class.update(has_offer_id, has_offers_params)
check_for_errors(response)
end
end
define_method("check_for_errors") do |response|
unless response.success?
response.error_messages.each do |error_message|
new_error_message = "HasOffers API Error: #{error_message}"
if self.errors.respond_to?(:add_to_base)
self.errors.add_to_base new_error_message
else
self.errors.add :base, new_error_message
end
end
end
response.success?
end
end
end
|
ruby
|
{
"resource": ""
}
|
q4496
|
Diameter.AVP.inner_avps
|
train
|
def inner_avps(name)
code, _type, _vendor = AVPNames.get(name)
grouped_value.select { |a| a.code == code }
end
|
ruby
|
{
"resource": ""
}
|
q4497
|
Diameter.AVP.ip_address=
|
train
|
def ip_address=(value)
bytes = if value.ipv4?
[1].pack('n')
else
[2].pack('n')
end
bytes += value.hton
@content = bytes
end
|
ruby
|
{
"resource": ""
}
|
q4498
|
MiniSpec.InstanceAPI.double
|
train
|
def double *args, &proc
name = args.first.is_a?(Hash) ? nil : args.shift
object = Object.new
object.define_singleton_method(:__ms__double_instance) {true}
object.define_singleton_method(:inspect) {name} if name
hashes, rest = args.partition {|s| s.is_a?(Hash)}
hashes.each {|h| stub(object, h)}
rest.each {|s| stub(object, s, &proc)}
object
end
|
ruby
|
{
"resource": ""
}
|
q4499
|
QontoOfx.Converter.convert
|
train
|
def convert(remove_ns = false)
organization = @gateway.fetch_organization['organization']
builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8')
builder[:ofx].OFX('xmlns:ofx' => 'http://ofx.net/types/2003/04') do |xml|
add_signonmsgsrsv1_block xml
xml.BANKMSGSRSV1 do
xml.parent.namespace = nil
organization['bank_accounts'].each do |bank_account|
xml.STMTTRNRS do
xml.TRNUID 1
add_status_block xml
xml.STMTRS do
xml.CURDEF 'EUR'
add_bankacctfrom_block xml, bank_account
xml.BANKTRANLIST do
process_transactions xml, bank_account
end
xml.LEDGERBAL do
xml.BALAMT bank_account['balance']
xml.DTASOF Time.now.strftime('%Y%m%d%H%M%S')
end
end
end
end
end
end
move_to_first_position(builder, '//DTEND')
move_to_first_position(builder, '//DTSTART')
result = builder.to_xml
raise 'generation failed (invalid OFX)' unless @ofx_validator.valid? result
result = result.gsub(
'ofx:OFX',
'OFX'
).gsub(' xmlns:ofx="http://ofx.net/types/2003/04"', '') if remove_ns
result
end
|
ruby
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.