anchor stringlengths 10 14.3k | positive stringlengths 10 14.9k |
|---|---|
The identifier of the CA certificate for this DB instance | def ca_certificate_identifier
@dbi.ca_certificate_identifier
end |
List of tests 1. Empty Eobqa create 2. Create with invalid data Check with nil total_fields Check with nil total_incorrect_fields Check with nil account_number Check Uniqueness of name 3. Check Eobqa count when we created and distroy Blank EOBQA | def test_blank_eobqa
eobqa = EobQa.new(:total_fields => 10, :total_incorrect_fields => 2)
assert_equal(false, eobqa.save)
end |
Lists all tapes. API Key Scope: tapes / index | def index_tapes_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: TapesApi.index_tapes ...'
end
# resource path
local_var_path = '/tapes'
# query parameters
query_params = opts[:query_params] || {}
query_params[:'li... |
remove a stock from database | def remove_stock(db,stock_ticker)
db.execute(<<-SQL
DELETE FROM stocks2
Where stock_ticker="#{stock_ticker}";
SQL
)
puts "==================================================="
puts "#{stock_ticker} has been removed from the database."
puts "=================================================... |
Sum of two points | def bbpAdd(first_point, second_point)
cxp(first_point.x + second_point.x, first_point.y + second_point.y)
end |
Change the useragent sent to the Prowl server. | def user_agent(user_agent)
@user_agent = user_agent
end |
Return a hash suitable for passing to Whitestone.run | def _whitestone_options()
{ :filter => @options.filter, :full_backtrace => @options.full_backtrace }
end |
Never trust parameters from the scary internet, only allow the white list through. | def background_params
params.require(:background).permit(:name)
end |
POST /tipocuenta POST /tipocuenta.json | def create
@tipocuentum = Tipocuentum.new(tipocuentum_params)
respond_to do |format|
if @tipocuentum.save
format.html { redirect_to @tipocuentum, notice: 'Tipocuentum was successfully created.' }
format.json { render :show, status: :created, location: @tipocuentum }
else
for... |
reduce 553 omitted reduce 554 omitted reduce 555 omitted reduce 556 omitted reduce 557 omitted reduce 558 omitted reduce 559 omitted reduce 560 omitted reduce 561 omitted reduce 562 omitted reduce 563 omitted reduce 564 omitted reduce 565 omitted reduce 566 omitted reduce 567 omitted reduce 568 omitted reduce 569 omitt... | def _reduce_574(val, _values, result)
yyerrok
result
end |
testing protected methods and everything in this module is protected | def authenticated?; super; end |
List institution by id | def show
institution = Institution.find(params[:id])
render json: { status: '200', message: "Loaded Institution with id #{params[:id]}", data: institution }, status: :ok
rescue ActiveRecord::RecordNotFound
render json: { status: '404', error: "No Institution with id #{params[:id]}", data: ... |
Update properties of this object | def update!(**args)
@next_page_token = args[:next_page_token] unless args[:next_page_token].nil?
@result_size_estimate = args[:result_size_estimate] unless args[:result_size_estimate].nil?
@threads = args[:threads] unless args[:threads].nil?
end |
Return the width and height of the named style, as a 2element array. | def dimensions(style_name=nil)
style_name ||= reflection.default_style
if style_name.equal?(:original)
original_width = from_examination(:@original_width)
original_height = from_examination(:@original_height)
[original_width, original_height]
else
resize_d... |
Method to print a list and make it look pretty input: list of hash we want to print steps: print keys as strings with corresponding value output: keys as strings and their quantity | def print_list(list)
list.each do |item, quantity| puts "#{item}: #{quantity}"
end
end |
If authorized, return the loggedin user information based on different conditionals: user has profile image and previous geolocation coordinates. | def auth
@user = current_user
render json: @user
end |
=begin To get hash value of job | def get_hash()
return @@hash;
end |
DELETE /parking_spots/1 DELETE /parking_spots/1.json | def destroy
@parking_spot = ParkingSpot.find(params[:id])
@parking_spot.destroy
respond_to do |format|
format.html { redirect_to parking_spots_url }
format.json { head :no_content }
end
end |
traverse the BBT in depth and returns the data in post order in an array | def post_order_traversal(current_node = @root)
@accumulator = []
post_order_traversal_aux(current_node)
@accumulator
end |
in a nonbooting version this should map to _add_singleton_method | def add_function function
raise "not a function #{function}" unless function.is_a? Function
raise "syserr " unless function.name.is_a? Symbol
@functions << function
end |
Append a node to the end of the list. | def append(node)
if node.head
raise ArgumentError, "Node is already in a list!"
end
node.tail = self
@head.tail = node
node.head = @head
@head = node
return added(node)
end |
Locally schedule within each basic block. | def locally_schedule_block(first_node)
# Find all the nodes in this basic block.
in_block = Set.new(nodes_in_block(first_node))
# Back up a second... our first node could be a fixed node, which
# actually has input values. Such as a branch with a condition.
# The nodes involved in that c... |
GET /customers/1 GET /customers/1.json | def show
end |
PATCH/PUT /friends/1 or /friends/1.json | def update
respond_to do |format|
if @friend.update(friend_params)
format.html { redirect_to @friend, notice: "Friend was successfully updated." }
format.json { render :show, status: :ok, location: @friend }
else
format.html { render :edit, status: :unprocessable_entity }
... |
Asserts that I see a particular tag (see HTMLAnalysis.tag) | def i_see_tag(name, opts = nil)
assert has_tag?(name, opts), __last_because + " (don't see tag <#{name} #{opts.inspect})"
end |
returns value and addr | def value_with_addr(block_num = nil)
block_num ||= @auth_block
raise Mifare::Error, "Not authenticated" unless block_num
value_ptr = FFI::MemoryPointer.new(:int32, 1)
addr_ptr = FFI::MemoryPointer.new(:uchar, 1)
res = Mifare.mifare_classic_read_value(@pointer, block_num, value_ptr, addr_ptr)
... |
End of DTM_233 Segment Details Client Specific Helper Methods End of Client Specific Helper Methods Conditions to print a Segment : Overwritten Methods | def verify_ts3_condition
Unified835Output::BenignNull.new
end |
Extract omniauth credentials from the request environment | def omniauth_credentials
if omniauth_hash = request.env['omniauth.auth']
{
provider: omniauth_hash['provider'],
uid: omniauth_hash['uid'],
email: omniauth_hash['info']['email'],
name: omniauth_hash['info']['name'],
}
else
nil
end
end |
Generated method to gather all the accepted keypresses. | def accepts
self.current_state.pressings || {}
end |
// For example, S = "abba", T = "^abba$". // ^ and $ signs are sentinels appended to each end to avoid bounds checking | def preProcess(s)
n = s.length().to_i
if n==0
return "^$"
end
ret = "^"
(0..n-1).each do |re|
ret += ('#' + s[re].to_s)
end
ret += '#$'
return ret
end |
Runs a string given in input as Ruby code or buffers it if the command is incomplete Test against level or input to check if the command has been executed | def run str
@input ||= ''
@level += str.scan(LEVEL_UP).length
@level -= str.scan(/(^|\s)end($|\s)/).length # Will probably fail with a character chain
@input += str + "\n"
if @level <= 0
tmp = input
reset
eval tmp, context
end
end |
wraper for the brand method ActiveMerchant returns master or american_express Banwire requires mastercard and amex | def get_brand(brand)
case brand
when "master"
return "mastercard"
when "american_express"
return "amex"
else
return brand
end
end |
DELETE /recipies/1 DELETE /recipies/1.json | def destroy
@recipy = Recipy.find(params[:id])
@recipy.destroy
respond_to do |format|
format.html { redirect_to recipies_url }
format.json { head :no_content }
end
end |
List Tier 1 Service Interfaces Paginated list of all Tier 1 Service Interfaces | def list_tier1_service_interfaces_0(tier_1_id, locale_service_id, opts = {})
data, _status_code, _headers = list_tier1_service_interfaces_0_with_http_info(tier_1_id, locale_service_id, opts)
data
end |
GET /passwordrecovery/remindersent The success page after the user enters email for password recovery | def reminder_sent
end |
DELETE /solos/1 DELETE /solos/1.json | def destroy
@solo.destroy
respond_to do |format|
format.html { redirect_to solos_url, notice: 'Solo was successfully destroyed.' }
format.json { head :no_content }
end
authorize @solo
end |
Constructs a dependency with +name+ and +requirements+. The last argument can optionally be the dependency type, which defaults to :runtime. | def initialize(name, *requirements)
case name
when String then # ok
when Regexp then
msg = ["NOTE: Dependency.new w/ a regexp is deprecated.",
"Dependency.new called from #{Gem.location_of_caller.join(":")}"]
warn msg.join("\n") unless Gem::Deprecate.skip
else
raise Argume... |
Initializes a LoginRadius Account object with an apikey and secret Takes in a hash containing site_name(required), api_key(required), api_secret(required) | def initialize
@site_name = ENV['SITE_NAME']
@api_key = ENV['API_KEY']
@api_secret = ENV['API_SECRET']
raise LoginRadius::Error.new, "'site_name' is a required option for Account class initialization." \
unless @site_name != '' && @site_name != nil
raise LoginRadius::Error.new, "'a... |
Create a way for the username to become encrypted | def encrypt(val)
#Usage self.encrypt(val)
return Digest::SHA1.hexdigest(val.to_s)
end |
GET /prod_cotis GET /prod_cotis.json | def index
@prod_cotis = ProdCoti.all
end |
rand generates pseudo random from 01 rand(10) generates pseudo random from 010 we use it to get something like 4.41445946155691 | def random_float
rand * rand(10)
end |
Takes a hash as its argument. The key is a symbol or an array of symbols. These symbols correspond to method names, instance variable names, or constant names (see def_delegator). The value is the accessor to which the methods will be delegated. :callseq: delegate method => accessor delegate [method, method, ...] => ac... | def instance_delegate(hash)
hash.each do |methods, accessor|
unless defined?(methods.each)
def_instance_delegator(accessor, methods)
else
methods.each {|method| def_instance_delegator(accessor, method)}
end
end
end |
Perform replacement on specific (un)hyphenated config directives. | def unhyphenate(string)
string.to_s.gsub(/(pre|post)xfer/, '\1-xfer')
end |
The client code works with complex subsystems through a simple interface provided by the Facade. When a facade manages the lifecycle of the subsystem, the client might not even know about the existence of the subsystem. This approach lets you keep the complexity under control. | def client_code(facade)
puts facade.operation
end |
Retrieve all the attribute names (keys) from the session. like Hashkeys | def keys
getAttributeNames.to_a
end |
Raise an error if the payment failed or if the signature is invalid | def validate!
Cybersource::Security.validate_signature!(@fields['signature'], signed_data)
raise PaymentFailed unless payment_success?
self
end |
Never trust parameters from the scary internet, only allow the white list through. | def article_params
params.require(:category).permit(:title, :description, :weight)
end |
remove files / dirs from collection, which are located below a collected dir | def remove_collection_redundancy
redundant_file_count = 0
redundant_dir_count = 0
redundant_files = []
redundant_dirs = []
session[@pallet.collection][:directories].each do |dir|
session[@pallet.collection][:files].each do |file|
if file.starts_with?(dir + '/')
logger.debug ... |
Unfollow a user by id | def unfollow(other_user_id)
user_to_unfollow = User.find_by(id: other_user_id)
active_relationships.find_by(followed_id: user_to_unfollow.id).destroy
end |
imperials is the imperials value | def metrics
standard.unit.convert_to_metric imperials
end |
Get Estimated Wait Time | def get_routing_queue_estimatedwaittime(queue_id, opts = {})
data, _status_code, _headers = get_routing_queue_estimatedwaittime_with_http_info(queue_id, opts)
return data
end |
function for creating new features to the EnsEMBL Sequence object | def create_features_ensembl_seq_obj(bioseq,targets)
targets.each do |key,value|
f1 = Bio::Feature.new("target_CTTCTT","#{key[0]}..#{key[1]}")
#im no sure if it is a interior coding exon
f1.append(Bio::Feature::Qualifier.new('interior coding exon', "#{value[0]}"))
f1.append(Bio:... |
Returns the unique classes and modules discovered by RDoc. ::complete must have been called prior to using this method. | def unique_classes_and_modules
@unique_classes + @unique_modules
end |
Some posts have an unwatermarked version of the image. Usually it's lower resolution and lower JPEG quality than the watermarked image. Multiimage posts will have only one unwatermarked URL. | def unwatermarked_url
return nil if api_response["article_image_url"].nil?
Source::URL.parse(api_response["article_image_url"])
end |
GET /prospectives/new GET /prospectives/new.json | def new
@prospective = Prospective.new
respond_to do |format|
format.html # new.html.erb
format.json { render :json => @prospective }
end
end |
The node is a unique state within the system e.g. x,y coordinate | def node
[@x, @y]
end |
wookay.noh at gmail.com L lowercase letters. D words in this language. A pattern consists of exactly L tokens Each token is either a single lowercase letter (the scientists are very sure that this is the letter) or a group of unique lowercase letters surrounded by parenthesis ( and ). The first line of input contains 3... | def make_pattern pattern
state = :close
rule = ''
last_ch = ''
pattern.split('').each do |ch|
case ch
when '('
state = :open
rule << '('
when ')'
state = :close
rule << ')'
else
case state
when :open
case last_ch
when '('
else
... |
This method finds all the files with the mentioned groups and services | def grep_files_by_properties
# I - filter on @properties[:grouping] keywords.
property_filter = "@properties[:grouping]"
# @services_to_run ||= []
@groups_to_run ||= []
# groups to run may contain something like ["g1,g2,g3","g4,g5,g6"]
groups_to_run_filter = @groups_to_run.map {|g| ... |
GET /thing_lists/1 GET /thing_lists/1.xml | def show
@thing_list = ThingList.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @thing_list }
end
end |
Joins the raw paragraph text and converts inline HardBreaks to the +hard_break+ text followed by the indent. | def text hard_break = nil
@parts.map do |part|
if RDoc::Markup::HardBreak === part then
'%1$s%3$*2$s' % [hard_break, @indent, ' '] if hard_break
else
part
end
end.join
end |
Show the studios that have not produced films with director "Walter Hill". | SELECT Studio FROM film EXCEPT SELECT Studio FROM film WHERE Director = "Walter Hill" |
Show the student id of the oldest student. | SELECT StuID FROM Student WHERE age = (SELECT max(age) FROM Student) |
What is the total revenue of companies with revenue greater than the lowest revenue of any manufacturer in Austin? | SELECT sum(revenue) FROM manufacturers WHERE revenue > (SELECT min(revenue) FROM manufacturers WHERE headquarter = 'Austin') |
In which country does Roberto Almeida? | SELECT country FROM customers WHERE first_name = "Roberto" AND last_name = "Almeida"; |
how many degrees were conferred between 1998 and 2002? | SELECT T1.campus , sum(T2.degrees) FROM campuses AS T1 JOIN degrees AS T2 ON T1.id = T2.campus WHERE T2.year >= 1998 AND T2.year <= 2002 GROUP BY T1.campus |
Sort the names of all counties in ascending order of population. | SELECT County_name FROM county ORDER BY Population ASC |
How many projects are there? | SELECT count(*) FROM Projects |
List the locations of schools that do not have any player. | SELECT LOCATION FROM school WHERE School_ID NOT IN (SELECT School_ID FROM Player) |
What are the different names and ages of every friend of either Dan or alice? | SELECT DISTINCT T1.name , T1.age FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend = 'Dan' OR T2.friend = 'Alice' |
What is the name of the activity that has the most faculty members involved in? | SELECT T1.activity_name FROM Activity AS T1 JOIN Faculty_participates_in AS T2 ON T1.actID = T2.actID GROUP BY T1.actID ORDER BY count(*) DESC LIMIT 1 |
Find the number of different airports which are the destinations of the American Airlines. | SELECT count(DISTINCT dst_apid) FROM airlines AS T1 JOIN routes AS T2 ON T1.alid = T2.alid WHERE T1.name = 'American Airlines' |
What are all the distinct participant ids who attended any events? | SELECT count(DISTINCT participant_id) FROM participants_in_Events |
Compute the number of products with a price larger than or equal to $180. | SELECT count(*) FROM products WHERE price >= 180 |
Show details of all visitors. | SELECT Tourist_Details FROM VISITORS |
Find the first and last name of the author(s) who wrote the paper "Nameless, Painless". | SELECT t1.fname , t1.lname FROM authors AS t1 JOIN authorship AS t2 ON t1.authid = t2.authid JOIN papers AS t3 ON t2.paperid = t3.paperid WHERE t3.title = "Nameless , Painless" |
Show the delegates and the names of county they belong to. | SELECT T2.Delegate , T1.County_name FROM county AS T1 JOIN election AS T2 ON T1.County_id = T2.District |
Which papers have the substring "Database" in their titles? Show the titles of the papers. | SELECT title FROM papers WHERE title LIKE "%Database%" |
what are the details of the cmi masters that have the cross reference code 'Tax'? | SELECT T1.cmi_details FROM Customer_Master_Index AS T1 JOIN CMI_Cross_References AS T2 ON T1.master_customer_id = T2.master_customer_id WHERE T2.source_system_code = 'Tax' |
What document type codes do we have? | SELECT document_type_code FROM Ref_Document_Types; |
find the event names that have more than 2 records. | SELECT event_name FROM party_events GROUP BY event_name HAVING count(*) > 2 |
Which county do the delegates on "Appropriations" committee belong to? Give me the county names. | SELECT T1.County_name FROM county AS T1 JOIN election AS T2 ON T1.County_id = T2.District WHERE T2.Committee = "Appropriations" |
Return the address of store 1. | SELECT T2.address FROM store AS T1 JOIN address AS T2 ON T1.address_id = T2.address_id WHERE store_id = 1 |
Show all countries and the number of people from each country. | SELECT country , count(*) FROM people GROUP BY country |
What are the details of the project with no outcomes? | SELECT project_details FROM Projects WHERE project_id NOT IN ( SELECT project_id FROM Project_outcomes ) |
List all employees in the circulation history of the document with id 1. List the employee's name. | SELECT Employees.employee_name FROM Employees JOIN Circulation_History ON Circulation_History.employee_id = Employees.employee_id WHERE Circulation_History.document_id = 1; |
What are all the location codes and location names? | SELECT location_code , location_name FROM Ref_locations |
Find the grade taught in classroom 103. | SELECT DISTINCT grade FROM list WHERE classroom = 103 |
In 2014, what are the id and rank of the team that has the largest average number of attendance? | SELECT T2.team_id , T2.rank FROM home_game AS T1 JOIN team AS T2 ON T1.team_id = T2.team_id WHERE T1.year = 2014 GROUP BY T1.team_id ORDER BY avg(T1.attendance) DESC LIMIT 1; |
What are the total purchases for members rated at level 6? | SELECT count(*) FROM purchase AS T1 JOIN member AS T2 ON T1.member_id = T2.member_id WHERE T2.level = 6 |
display the department id and the total salary for those departments which contains at least two employees. | SELECT department_id , SUM(salary) FROM employees GROUP BY department_id HAVING count(*) >= 2 |
Which country does customer with first name as Carole and last name as Bernhard lived in? | SELECT T2.country FROM Customers AS T1 JOIN Addresses AS T2 ON T1.customer_address_id = T2.address_id WHERE T1.first_name = "Carole" AND T1.last_name = "Bernhard" |
Count the number of products with the 'hot' charactersitic. | SELECT count(*) FROM products AS t1 JOIN product_characteristics AS t2 ON t1.product_id = t2.product_id JOIN CHARACTERISTICS AS t3 ON t2.characteristic_id = t3.characteristic_id WHERE t3.characteristic_name = "hot" |
Count the number of cinemas. | SELECT count(*) FROM cinema |
Who is the director of movie Avatar? | SELECT director FROM Movie WHERE title = 'Avatar' |
How many cities have a stadium that was opened before the year of 2006? | SELECT count(DISTINCT city) FROM stadium WHERE opening_year < 2006 |
What are the names of students who have more than one advisor? | SELECT T1.name FROM student AS T1 JOIN advisor AS T2 ON T1.id = T2.s_id GROUP BY T2.s_id HAVING count(*) > 1 |
What is the average number of customers across banks in the state of Utah? | SELECT avg(no_of_customers) FROM bank WHERE state = 'Utah' |
Find the name of the person who has friends with age above 40 and under age 30? | SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age > 40) INTERSECT SELECT T1.name FROM Person AS T1 JOIN PersonFriend AS T2 ON T1.name = T2.name WHERE T2.friend IN (SELECT name FROM Person WHERE age < 30) |
Show all headquarters without a company in banking industry. | SELECT headquarters FROM company EXCEPT SELECT headquarters FROM company WHERE main_industry = 'Banking' |
Find the dates on which more than one revisions were made. | SELECT date_of_latest_revision FROM Catalogs GROUP BY date_of_latest_revision HAVING count(*) > 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.