_id
stringlengths 2
6
| title
stringlengths 9
130
| partition
stringclasses 3
values | text
stringlengths 30
4.3k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q25400
|
RediSearchRails.ClassMethods.redi_search_schema
|
validation
|
def redi_search_schema(schema)
@schema = schema.to_a.flatten
@fields = schema.keys
@model
|
ruby
|
{
"resource": ""
}
|
q25401
|
RediSearchRails.ClassMethods.ft_search_count
|
validation
|
def ft_search_count(args)
ft_search(args).first
rescue Exception => e
|
ruby
|
{
"resource": ""
}
|
q25402
|
RediSearchRails.ClassMethods.ft_add_all
|
validation
|
def ft_add_all
@model.all.each {|record| ft_add(record: record) }
|
ruby
|
{
"resource": ""
}
|
q25403
|
RediSearchRails.ClassMethods.ft_add
|
validation
|
def ft_add record:
fields = []
@fields.each { |field| fields.push(field, record.send(field)) }
REDI_SEARCH.call('FT.ADD', @index_name, record.to_global_id.to_s, @score,
|
ruby
|
{
"resource": ""
}
|
q25404
|
RediSearchRails.ClassMethods.ft_addhash
|
validation
|
def ft_addhash redis_key:
REDI_SEARCH.call('FT.ADDHASH', @index_name, redis_key, @score,
|
ruby
|
{
"resource": ""
}
|
q25405
|
RediSearchRails.ClassMethods.ft_del_all
|
validation
|
def ft_del_all
@model.all.each {|record| ft_del(record: record) }
|
ruby
|
{
"resource": ""
}
|
q25406
|
RediSearchRails.ClassMethods.ft_del
|
validation
|
def ft_del record:
doc_id = record.to_global_id
REDI_SEARCH.call('FT.DEL', @index_name,
|
ruby
|
{
"resource": ""
}
|
q25407
|
RediSearchRails.ClassMethods.ft_info
|
validation
|
def ft_info
REDI_SEARCH.call('FT.INFO', @index_name)
rescue Exception => e
|
ruby
|
{
"resource": ""
}
|
q25408
|
RediSearchRails.ClassMethods.ft_sugadd_all
|
validation
|
def ft_sugadd_all (attribute:)
@model.all.each {|record| ft_sugadd(record: record, attribute:
|
ruby
|
{
"resource": ""
}
|
q25409
|
RediSearchRails.ClassMethods.ft_sugadd
|
validation
|
def ft_sugadd (record:, attribute:, score: 1)
# => combine model with attribute to create unique key like user_name
key = "#{@model.to_s}:#{attribute}"
string = record.send(attribute)
REDI_SEARCH.call('FT.SUGADD', key, string,
|
ruby
|
{
"resource": ""
}
|
q25410
|
RediSearchRails.ClassMethods.ft_sugget
|
validation
|
def ft_sugget (attribute:, prefix:)
key = "#{@model}:#{attribute}"
REDI_SEARCH.call('FT.SUGGET', key,
|
ruby
|
{
"resource": ""
}
|
q25411
|
RediSearchRails.ClassMethods.ft_sugdel_all
|
validation
|
def ft_sugdel_all (attribute:)
@model.all.each {|record| ft_sugdel(record: record, attribute:
|
ruby
|
{
"resource": ""
}
|
q25412
|
RediSearchRails.ClassMethods.ft_suglen
|
validation
|
def ft_suglen (attribute:)
key = "#{@model}:#{attribute}"
REDI_SEARCH.call('FT.SUGLEN', key)
|
ruby
|
{
"resource": ""
}
|
q25413
|
Reality.Zapwhite.run
|
validation
|
def run
normalize_count = 0
if generate_gitattributes?
output_options = {:prefix => '# DO NOT EDIT: File is auto-generated', :normalize => true}
new_gitattributes = generate_gitattributes!
new_content = new_gitattributes.as_file_contents(output_options)
old_content = File.exist?(@attributes.attributes_file) ? IO.read(@attributes.attributes_file) : nil
if new_content != old_content
@attributes = new_gitattributes
if check_only?
puts 'Non-normalized .gitattributes file'
else
puts 'Fixing: .gitattributes'
@attributes.write(output_options)
end
normalize_count += 1
end
end
files = {}
collect_file_attributes(files)
files.each_pair do |filename, config|
full_filename = "#{@base_directory}/#{filename}"
original_bin_content = File.binread(full_filename)
encoding = config[:encoding].nil? ? 'utf-8' : config[:encoding].gsub(/^UTF/,'utf-')
content = File.read(full_filename, :encoding => "bom|#{encoding}")
|
ruby
|
{
"resource": ""
}
|
q25414
|
Reality.Zapwhite.in_dir
|
validation
|
def in_dir(dir, &block)
original_dir = Dir.pwd
begin
Dir.chdir(dir)
block.call
|
ruby
|
{
"resource": ""
}
|
q25415
|
Fridge.RailsHelpers.validate_token
|
validation
|
def validate_token(access_token)
validator = Fridge.configuration.validator
|
ruby
|
{
"resource": ""
}
|
q25416
|
Fridge.RailsHelpers.validate_token!
|
validation
|
def validate_token!(access_token)
validator = Fridge.configuration.validator
if validator.call(access_token)
access_token
else
|
ruby
|
{
"resource": ""
}
|
q25417
|
CreateSend.Subscriber.update
|
validation
|
def update(new_email_address, name, custom_fields, resubscribe,
consent_to_track, restart_subscription_based_autoresponders=false)
options = {
:query => { :email => @email_address },
:body => {
:EmailAddress => new_email_address,
:Name => name,
:CustomFields => custom_fields,
:Resubscribe => resubscribe,
|
ruby
|
{
"resource": ""
}
|
q25418
|
CreateSend.Subscriber.history
|
validation
|
def history
options = { :query => { :email => @email_address } }
response
|
ruby
|
{
"resource": ""
}
|
q25419
|
CreateSend.Segment.subscribers
|
validation
|
def subscribers(date="", page=1, page_size=1000, order_field="email",
order_direction="asc", include_tracking_preference=false)
options = { :query => {
:date => date,
:page => page,
:pagesize => page_size,
:orderfield => order_field,
|
ruby
|
{
"resource": ""
}
|
q25420
|
CreateSend.Template.update
|
validation
|
def update(name, html_url, zip_url)
options = { :body => {
:Name => name,
:HtmlPageURL => html_url,
:ZipFileURL
|
ruby
|
{
"resource": ""
}
|
q25421
|
CreateSend.CreateSend.clients
|
validation
|
def clients
response = get('/clients.json')
|
ruby
|
{
"resource": ""
}
|
q25422
|
CreateSend.CreateSend.administrators
|
validation
|
def administrators
response = get('/admins.json')
|
ruby
|
{
"resource": ""
}
|
q25423
|
CreateSend.CreateSend.set_primary_contact
|
validation
|
def set_primary_contact(email)
options = { :query => { :email => email } }
|
ruby
|
{
"resource": ""
}
|
q25424
|
CreateSend.List.create_custom_field
|
validation
|
def create_custom_field(field_name, data_type, options=[],
visible_in_preference_center=true)
options = { :body => {
:FieldName => field_name,
|
ruby
|
{
"resource": ""
}
|
q25425
|
CreateSend.List.update_custom_field
|
validation
|
def update_custom_field(custom_field_key, field_name,
visible_in_preference_center)
custom_field_key = CGI.escape(custom_field_key)
options = { :body => {
:FieldName => field_name,
|
ruby
|
{
"resource": ""
}
|
q25426
|
CreateSend.List.update_custom_field_options
|
validation
|
def update_custom_field_options(custom_field_key, new_options,
keep_existing_options)
custom_field_key = CGI.escape(custom_field_key)
|
ruby
|
{
"resource": ""
}
|
q25427
|
CreateSend.List.custom_fields
|
validation
|
def custom_fields
response = get "customfields"
|
ruby
|
{
"resource": ""
}
|
q25428
|
CreateSend.List.segments
|
validation
|
def segments
response = get "segments"
|
ruby
|
{
"resource": ""
}
|
q25429
|
CreateSend.List.active
|
validation
|
def active(date="", page=1, page_size=1000, order_field="email",
order_direction="asc", include_tracking_preference=false)
paged_result_by_date("active", date, page,
|
ruby
|
{
"resource": ""
}
|
q25430
|
CreateSend.List.webhooks
|
validation
|
def webhooks
response = get "webhooks"
|
ruby
|
{
"resource": ""
}
|
q25431
|
CreateSend.Person.update
|
validation
|
def update(new_email_address, name, access_level, password)
options = {
:query => { :email => @email_address },
:body => {
:EmailAddress => new_email_address,
:Name => name,
:AccessLevel => access_level,
|
ruby
|
{
"resource": ""
}
|
q25432
|
CreateSend.Client.campaigns
|
validation
|
def campaigns
response = get 'campaigns'
|
ruby
|
{
"resource": ""
}
|
q25433
|
CreateSend.Client.scheduled
|
validation
|
def scheduled
response = get 'scheduled'
|
ruby
|
{
"resource": ""
}
|
q25434
|
CreateSend.Client.drafts
|
validation
|
def drafts
response = get 'drafts'
|
ruby
|
{
"resource": ""
}
|
q25435
|
CreateSend.Client.lists
|
validation
|
def lists
response = get 'lists'
|
ruby
|
{
"resource": ""
}
|
q25436
|
CreateSend.Client.lists_for_email
|
validation
|
def lists_for_email(email_address)
options = { :query => { :email => email_address } }
response
|
ruby
|
{
"resource": ""
}
|
q25437
|
CreateSend.Client.people
|
validation
|
def people
response = get "people"
|
ruby
|
{
"resource": ""
}
|
q25438
|
CreateSend.Client.suppressionlist
|
validation
|
def suppressionlist(page=1, page_size=1000, order_field="email",
order_direction="asc")
options = { :query => {
:page => page,
|
ruby
|
{
"resource": ""
}
|
q25439
|
CreateSend.Client.suppress
|
validation
|
def suppress(emails)
options = { :body => {
:EmailAddresses =>
|
ruby
|
{
"resource": ""
}
|
q25440
|
CreateSend.Client.templates
|
validation
|
def templates
response = get 'templates'
|
ruby
|
{
"resource": ""
}
|
q25441
|
CreateSend.Client.set_basics
|
validation
|
def set_basics(company, timezone, country)
options = { :body => {
:CompanyName => company,
:TimeZone => timezone,
|
ruby
|
{
"resource": ""
}
|
q25442
|
CreateSend.Client.set_payg_billing
|
validation
|
def set_payg_billing(currency, can_purchase_credits, client_pays,
markup_percentage, markup_on_delivery=0, markup_per_recipient=0,
markup_on_design_spam_test=0)
options = { :body => {
:Currency => currency,
:CanPurchaseCredits => can_purchase_credits,
:ClientPays => client_pays,
:MarkupPercentage => markup_percentage,
|
ruby
|
{
"resource": ""
}
|
q25443
|
CreateSend.Client.set_monthly_billing
|
validation
|
def set_monthly_billing(currency, client_pays, markup_percentage,
monthly_scheme = nil)
options = { :body => {
:Currency => currency,
:ClientPays => client_pays,
|
ruby
|
{
"resource": ""
}
|
q25444
|
CreateSend.Client.transfer_credits
|
validation
|
def transfer_credits(credits, can_use_my_credits_when_they_run_out)
options = { :body => {
:Credits => credits,
|
ruby
|
{
"resource": ""
}
|
q25445
|
CreateSend.Campaign.send_preview
|
validation
|
def send_preview(recipients, personalize="fallback")
options = { :body => {
:PreviewRecipients => recipients.kind_of?(String) ?
[ recipients ] : recipients,
|
ruby
|
{
"resource": ""
}
|
q25446
|
CreateSend.Campaign.email_client_usage
|
validation
|
def email_client_usage
response = get "emailclientusage",
|
ruby
|
{
"resource": ""
}
|
q25447
|
CreateSend.Campaign.opens
|
validation
|
def opens(date="", page=1, page_size=1000, order_field="date",
order_direction="asc")
|
ruby
|
{
"resource": ""
}
|
q25448
|
CreateSend.Campaign.clicks
|
validation
|
def clicks(date="", page=1, page_size=1000, order_field="date",
order_direction="asc")
|
ruby
|
{
"resource": ""
}
|
q25449
|
CreateSend.Campaign.unsubscribes
|
validation
|
def unsubscribes(date="", page=1, page_size=1000, order_field="date",
order_direction="asc")
|
ruby
|
{
"resource": ""
}
|
q25450
|
CreateSend.Campaign.spam
|
validation
|
def spam(date="", page=1, page_size=1000, order_field="date",
order_direction="asc")
|
ruby
|
{
"resource": ""
}
|
q25451
|
CreateSend.Campaign.bounces
|
validation
|
def bounces(date="", page=1, page_size=1000, order_field="date",
order_direction="asc")
|
ruby
|
{
"resource": ""
}
|
q25452
|
CreateSend.Administrator.update
|
validation
|
def update(new_email_address, name)
options = {
:query => { :email => @email_address },
:body => {
:EmailAddress => new_email_address,
:Name => name
}.to_json }
put '/admins.json', options
|
ruby
|
{
"resource": ""
}
|
q25453
|
SnowplowTracker.AsyncEmitter.flush
|
validation
|
def flush(async=true)
loop do
@lock.synchronize do
@queue.synchronize do
@results_unprocessed += 1
end
@queue << @buffer
@buffer = []
end
if not async
LOGGER.info('Starting synchronous flush')
@queue.synchronize do
|
ruby
|
{
"resource": ""
}
|
q25454
|
RocketChat.Util.stringify_hash_keys
|
validation
|
def stringify_hash_keys(hash)
new_hash = {}
hash.each do |key, value|
new_hash[key.to_s] =
if value.is_a? Hash
|
ruby
|
{
"resource": ""
}
|
q25455
|
RocketChat.Util.slice_hash
|
validation
|
def slice_hash(hash, *keys)
return {} if keys.length.zero?
new_hash = {}
hash.each do |key, value|
|
ruby
|
{
"resource": ""
}
|
q25456
|
RocketChat.Server.login
|
validation
|
def login(username, password)
response = request_json(
'/api/v1/login',
method: :post,
|
ruby
|
{
"resource": ""
}
|
q25457
|
MandrillDm.Message.attachments
|
validation
|
def attachments
regular_attachments = mail.attachments.reject(&:inline?)
regular_attachments.collect do |attachment|
|
ruby
|
{
"resource": ""
}
|
q25458
|
MandrillDm.Message.images
|
validation
|
def images
inline_attachments = mail.attachments.select(&:inline?)
inline_attachments.collect do |attachment|
|
ruby
|
{
"resource": ""
}
|
q25459
|
BeanstalkdView.BeanstalkdUtils.get_chart_data_hash
|
validation
|
def get_chart_data_hash(tubes)
chart_data = {}
chart_data["total_jobs_data"] = Hash.new
chart_data["buried_jobs_data"] = Hash.new
chart_data["total_jobs_data"]["items"] = Array.new
chart_data["buried_jobs_data"]["items"] = Array.new
|
ruby
|
{
"resource": ""
}
|
q25460
|
BeanstalkdView.BeanstalkdUtils.guess_min_peek_range
|
validation
|
def guess_min_peek_range(tubes)
min = 0
tubes.each do |tube|
response = tube.peek('ready')
if response
if min == 0
min = response.id.to_i
|
ruby
|
{
"resource": ""
}
|
q25461
|
Foursquare2.Pages.page_venues
|
validation
|
def page_venues(page_id, options={})
response = connection.get do |req|
req.url "pages/#{page_id}/venues", options
end
venues = return_error_or_body(response, response.body.response.venues)
|
ruby
|
{
"resource": ""
}
|
q25462
|
Foursquare2.Pages.managed_pages
|
validation
|
def managed_pages(options={})
response = connection.get do |req|
req.url "pages/managing",
|
ruby
|
{
"resource": ""
}
|
q25463
|
Foursquare2.Users.search_users_by_tip
|
validation
|
def search_users_by_tip(options={})
name = options.delete(:name)
options[:limit] = 500
tips = search_tips(options)
user = []
tips.each
|
ruby
|
{
"resource": ""
}
|
q25464
|
Foursquare2.Users.user_requests
|
validation
|
def user_requests(options={})
response = connection.get do |req|
req.url "users/requests",
|
ruby
|
{
"resource": ""
}
|
q25465
|
Foursquare2.Users.user_checkins
|
validation
|
def user_checkins(options={})
response = connection.get do |req|
req.url "users/self/checkins",
|
ruby
|
{
"resource": ""
}
|
q25466
|
Foursquare2.Users.user_friends
|
validation
|
def user_friends(user_id, options={})
response = connection.get do |req|
req.url
|
ruby
|
{
"resource": ""
}
|
q25467
|
Foursquare2.Users.user_tips
|
validation
|
def user_tips(user_id, options={})
response = connection.get do |req|
req.url "users/#{user_id}/tips", options
end
tips = return_error_or_body(response, response.body.response.tips)
|
ruby
|
{
"resource": ""
}
|
q25468
|
Foursquare2.Users.user_todos
|
validation
|
def user_todos(user_id, options={})
response = connection.get do |req|
req.url
|
ruby
|
{
"resource": ""
}
|
q25469
|
Foursquare2.Users.user_photos
|
validation
|
def user_photos(options={})
response = connection.get do |req|
req.url "users/self/photos",
|
ruby
|
{
"resource": ""
}
|
q25470
|
Foursquare2.Users.user_venue_history
|
validation
|
def user_venue_history(options={})
response = connection.get do |req|
req.url "users/self/venuehistory",
|
ruby
|
{
"resource": ""
}
|
q25471
|
Foursquare2.Users.user_mayorships
|
validation
|
def user_mayorships(user_id, options={})
response = connection.get do |req|
req.url "users/#{user_id}/mayorships",
|
ruby
|
{
"resource": ""
}
|
q25472
|
Foursquare2.Users.user_lists
|
validation
|
def user_lists(user_id, options={})
response = connection.get do |req|
req.url
|
ruby
|
{
"resource": ""
}
|
q25473
|
Foursquare2.Users.user_friend_request
|
validation
|
def user_friend_request(user_id, options={})
response = connection.post do |req|
req.url "users/#{user_id}/request", options
end
|
ruby
|
{
"resource": ""
}
|
q25474
|
Foursquare2.Users.user_set_friend_pings
|
validation
|
def user_set_friend_pings(user_id, value)
response = connection.post do |req|
req.url "users/#{user_id}/setpings", value
end
|
ruby
|
{
"resource": ""
}
|
q25475
|
Foursquare2.Tips.tip
|
validation
|
def tip(tip_id, options={})
response = connection.get do |req|
req.url "tips/#{tip_id}",
|
ruby
|
{
"resource": ""
}
|
q25476
|
Foursquare2.Tips.search_tips
|
validation
|
def search_tips(options={})
response = connection.get do |req|
req.url
|
ruby
|
{
"resource": ""
}
|
q25477
|
Foursquare2.Tips.venue_tips
|
validation
|
def venue_tips(venue_id, options={})
query = options.delete(:query)
response = connection.get do |req|
req.url "venues/#{venue_id}/tips", options
end
tips = return_error_or_body(response,
|
ruby
|
{
"resource": ""
}
|
q25478
|
Foursquare2.Tips.add_tip
|
validation
|
def add_tip(options={})
response = connection.post do |req|
req.url
|
ruby
|
{
"resource": ""
}
|
q25479
|
Foursquare2.Tips.mark_tip_todo
|
validation
|
def mark_tip_todo(tip_id, options={})
response = connection.post do |req|
req.url "tips/#{tip_id}/marktodo", options
end
|
ruby
|
{
"resource": ""
}
|
q25480
|
Foursquare2.Events.event
|
validation
|
def event(event_id, options={})
response = connection.get do |req|
req.url "events/#{event_id}",
|
ruby
|
{
"resource": ""
}
|
q25481
|
Foursquare2.Campaigns.campaign
|
validation
|
def campaign(campaign_id, options={})
response = connection.get do |req|
req.url "campaigns/#{campaign_id}",
|
ruby
|
{
"resource": ""
}
|
q25482
|
Foursquare2.Client.connection
|
validation
|
def connection
params = {}
params[:client_id] = @client_id if @client_id
params[:client_secret] = @client_secret if @client_secret
params[:oauth_token] = @oauth_token if @oauth_token
params[:v] = @api_version if @api_version
|
ruby
|
{
"resource": ""
}
|
q25483
|
Foursquare2.Client.return_error_or_body
|
validation
|
def return_error_or_body(response, response_body)
if response.body['meta'].code == 200
response_body
else
|
ruby
|
{
"resource": ""
}
|
q25484
|
Foursquare2.Checkins.checkin
|
validation
|
def checkin(checkin_id, options={})
response = connection.get do |req|
req.url "checkins/#{checkin_id}",
|
ruby
|
{
"resource": ""
}
|
q25485
|
Foursquare2.Checkins.recent_checkins
|
validation
|
def recent_checkins(options={})
response = connection.get do |req|
req.url
|
ruby
|
{
"resource": ""
}
|
q25486
|
Foursquare2.Checkins.add_checkin
|
validation
|
def add_checkin(options={})
response = connection.post do |req|
req.url "checkins/add",
|
ruby
|
{
"resource": ""
}
|
q25487
|
Foursquare2.Checkins.add_checkin_comment
|
validation
|
def add_checkin_comment(checkin_id, options={})
response = connection.post do |req|
|
ruby
|
{
"resource": ""
}
|
q25488
|
Foursquare2.Checkins.add_checkin_reply
|
validation
|
def add_checkin_reply(checkin_id, options={})
response = connection.post do |req|
req.url "checkins/#{checkin_id}/reply", options
end
|
ruby
|
{
"resource": ""
}
|
q25489
|
Foursquare2.Venuegroups.venuegroup
|
validation
|
def venuegroup(group_id, options={})
response = connection.get do |req|
req.url "venuegroups/#{group_id}",
|
ruby
|
{
"resource": ""
}
|
q25490
|
Foursquare2.Venuegroups.add_venuegroup
|
validation
|
def add_venuegroup(options={})
response = connection.post do |req|
req.url "venuegroups/add",
|
ruby
|
{
"resource": ""
}
|
q25491
|
Foursquare2.Venuegroups.venuegroup_update
|
validation
|
def venuegroup_update(group_id, options={})
response = connection.post do |req|
req.url
|
ruby
|
{
"resource": ""
}
|
q25492
|
Foursquare2.Venuegroups.list_venuegroup
|
validation
|
def list_venuegroup(options={})
response = connection.get do |req|
req.url "venuegroups/list",
|
ruby
|
{
"resource": ""
}
|
q25493
|
Foursquare2.Specials.special
|
validation
|
def special(special_id, options={})
response = connection.get do |req|
req.url "specials/#{special_id}",
|
ruby
|
{
"resource": ""
}
|
q25494
|
Foursquare2.Specials.search_specials
|
validation
|
def search_specials(options={})
response = connection.get do |req|
req.url "specials/search",
|
ruby
|
{
"resource": ""
}
|
q25495
|
Foursquare2.Lists.list
|
validation
|
def list(list_id, options={})
response = connection.get do |req|
req.url "lists/#{list_id}",
|
ruby
|
{
"resource": ""
}
|
q25496
|
Foursquare2.Venues.trending_venues
|
validation
|
def trending_venues(ll, options={})
options[:ll] = ll
response = connection.get do |req|
req.url "venues/trending", options
|
ruby
|
{
"resource": ""
}
|
q25497
|
Foursquare2.Venues.search_venues_by_tip
|
validation
|
def search_venues_by_tip(options={})
tips = search_tips(options)
venues = []
tips.each do |tip|
|
ruby
|
{
"resource": ""
}
|
q25498
|
Foursquare2.Venues.venue_categories
|
validation
|
def venue_categories(options={})
response = connection.get do |req|
req.url "venues/categories",
|
ruby
|
{
"resource": ""
}
|
q25499
|
Foursquare2.Venues.venue_links
|
validation
|
def venue_links(venue_id, options={})
response = connection.get do |req|
req.url
|
ruby
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.