query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
Gets user_id from email table | def get_id(email)
db_params = {
host: ENV['host'],
port: ENV['port'],
dbname: ENV['dbname'],
user: ENV['user'],
password: ENV['password']
}
db = PG::Connection.new(db_params)
user_id = db.exec("SELECT user_id FROM email WHERE email = '#{email}'").values
... | [
"def get_user_id(email)\n endpoint = return_pagerduty_url(:users)\n out_array = get_object(endpoint)['users'].select { |i| i['email'].eql?(email) }\n return Hash[*out_array]['id']\n end",
"def invite_user_id\n User.find_by_email(self.email).try(:id)\n end",
"def get_user(email)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
func that sends email for user that has no pto days | def email_for_no_pto(full_name, pto, pto_type)
Mail.defaults do
delivery_method :smtp,
address: "email-smtp.us-east-1.amazonaws.com",
port: 587,
:user_name => ENV['a3smtpuser'],
:password => ENV['a3smtppass'],
:enable_ssl => true
end
email_body = "#{... | [
"def project_not_funded_email(user, project, days)\n @user = user\n @project = project\n @days = days\n mail(to: @user.email, subject: 'Aw, Shucks!')\n end",
"def email_if_needed\n if !email_sent\n if users_followers >= 15000 || retweet_count >= 5 || favorite_count >= 15\n UserMailer.i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
comment_filter removes all sets of comments that contain blanks | def comment_filter(comments)
# p comments
comments.each do |info|
# p info
# p info[1].values
info[1].values.each do |item|
if item.gsub(/\s+/, "") == ""
comments.delete(info[0])
end
end
end
if comments.empty?
"empty"
else
c... | [
"def without_comments(data)\n data.select do |el|\n !XML_COMMENT_ATTRIBUTES.include? el.name\n end\n end",
"def remove_comments\n\n #Split all lines and put them in an array\n line_array=@text_to_process.split(\"\\n\")\n\n #We assume the line is not part of multi line comm... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
makes comments into nested hash of client_name=>date=>[comment] | def comment_reformat(comments)
# p comments
info = {}
comments.each_pair do |key,value|
# p "#{key},#{value}"
if info[value['client']] == nil
info[value['client']] = {value['date']=>[value['comment']]}
elsif info[value['client']].keys.include?(value['date'])
info[val... | [
"def build_comments_from_hash(comments_hash)\n comments_hash.map do |locale, comment|\n build_comment(locale, comment: comment)\n end\n end",
"def new_comments comments_data, context\n top_level_comments = comments_data.select { |comment_data| comment_data[:parent_id] == \"0\" }\n comment_replie... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
To add a blank array to show clients, even if you've worked, but no commits for them | def adding_blank_clients(clients, cli_to_rep)
clients.each do |client|
if cli_to_rep.has_key?(client) == false
cli_to_rep["#{client}"] = []
end
end
cli_to_rep
end | [
"def remove_all_clients\n @clients = Array.new\n end",
"def initialize\n @clients = []\n end",
"def get_clients\n if @client_arr == []\n client_info = \"No clients in system.\\n\"\n else\n client_info = @client_arr.inject(\"\") do |client_info_str, client|\n client_info_str <<... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
To check for if the date is a monday(start of the business week) | def monday_check?(start_date)
new_week = Date.parse(start_date)
if new_week.strftime('%A') == "Monday"
true
else
false
end
end | [
"def monday?\n wday == 1\n end",
"def next_monday_if_sunday(date, day)\n case date.wday\n when 1 # Monday\n date.day.between?(day, day + 1)\n when 0, 6 # Weekends\n false\n else # Tuesday - Friday\n date.day == day\n end\n end",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the total amount of vibration | def total_vibration; @right_force + @left_force + @neutral_force; end | [
"def get_vibration\n $game_system.vibration_rate\n end",
"def calc_vibration_power(pad_index = 0) \n 65535 * vibration_rate / 100\n\tend",
"def vat_rate\n end",
"def total_volume\n volume = 0\n logistics_order_items.each do |i|\n volume += i.total_volume\n end\n end",
"def total_v... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Apply vibration on critical damage | def apply_vibration
str = actor? ? VibrationConfig::CRITICAL_ALLY : VibrationConfig::CRITICAL_ENEMY
Input.vibrate(str[0], str[1], str[2])
end | [
"def update_vibration(value)\n $game_system.set_vibration_rate(value)\n Input.vibrate(100, 100, 20) if SceneManager.scene_is?(Scene_Options)\n end",
"def perform_damage_effect\n end",
"def detect_vibration\n # read acceleration value\n accel = @vib.read_acceleration(true)\n\n # check accelerato... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /pianos GET /pianos.json | def index
@pianos = Piano.all
end | [
"def index\n @pessoas = Pessoa.all\n render json: @pessoas\n end",
"def index\n @pilotos = Piloto.all\n end",
"def show\n render json: @pessoa\n end",
"def index\n @pomodoros = Pomodoro.all\n\n render json: @pomodoros\n end",
"def index\n @processos = Processo.all\n\n render json... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /pianos/1 PATCH/PUT /pianos/1.json | def update
respond_to do |format|
if @piano.update(piano_params)
format.html { redirect_to @piano, notice: 'Piano was successfully updated.' }
format.json { render :show, status: :ok, location: @piano }
else
format.html { render :edit }
format.json { render json: @piano.e... | [
"def update\n respond_to do |format|\n if @piloto.update(piloto_params)\n format.html { redirect_to @piloto, notice: 'Piloto was successfully updated.' }\n format.json { render :show, status: :ok, location: @piloto }\n else\n format.html { render :edit }\n format.json { rend... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
as a single candidate name. The candidate with the highest number of votes wins the election. In case of a tie, when multiple candidates have the same number of votes, they should be sorted alphabetically in descending order where last name wins. If Albert and Zach both get 5 votes then the winner is Zach. Eg. if votes... | def election_winner(votes)
candidate_votes = Hash.new(0)
votes.each { |vote| candidate_votes[vote] += 1 }
max_votes = candidate_votes.values.max
candidate_votes.select { |_, v| v == max_votes }.sort.reverse[0][0]
end | [
"def decide_winner\n descending_sort = ->(a, b) { b.hand.total_score <=> a.hand.total_score }\n @players.sort!(& descending_sort)\n\n first_score = @players[0].hand.total_score\n ties = []\n @players.each do |player|\n ties << player if player.hand.total_score == first_score\n end\n\n winn... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Constructor SiteSummary(id, site_name, description, riskfactor = 1) | def initialize(id, site_name, description, riskfactor = 1)
@id = id
@site_name = site_name
@description = description
@riskfactor = riskfactor
end | [
"def setSiteSummary(site_name, description, riskfactor = 1)\n\t\t@site_summary = SiteSummary.new(-1,site_name,description,riskfactor)\n\n\tend",
"def initialize(id, site_name, description, riskfactor = 1.0)\n @id = id\n @site_name = site_name\n @description = description\n @riskfactor = riskfa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds a new host to the hosts array | def addHost(host)
@hosts.push(host)
end | [
"def add_host(new_host)\n @hosts.push(new_host)\n end",
"def addHost(host)\n @hosts.push(host)\n end",
"def add_hosts(hosts:)\n @hosts += Array hosts\n\n self\n end",
"def add_hosts(hosts:)\n @hosts = @hosts.+ Array hosts\n\n self\n end",
"def ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds a new alert to the alerts array | def addAlert(alert)
@alerts.push(alert)
end | [
"def addAlert(alert)\n @alerts.push(alert)\n end",
"def add_alert(text)\n @alerts << Alert.new(text, @db)\n end",
"def processNewAlerts\n @session.alerts.each{ |alert|\n if alert.is_a? Libtorrent::TorrentAlert\n if alert.handle.valid? && alert.handle.has_metadata\n addToHashL... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds a new set of credentials to the credentials array | def addCredentials(credential)
@credentials.push(credential)
end | [
"def addCredentials(credential)\n @credentials.push(credential)\n end",
"def add_credentials!\n @accessor.auth_manager.add_credentials(self)\n end",
"def credentials=(value)\n @credentials = value\n end",
"def credentials=(value)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates a new site summary | def setSiteSummary(site_name, description, riskfactor = 1)
@site_summary = SiteSummary.new(-1,site_name,description,riskfactor)
end | [
"def setSiteSummary(site_name, description, riskfactor = 1.0)\n @site_summary = SiteSummary.new(-1, site_name, description, riskfactor)\n\n end",
"def create_summary\r\n puts \"Creating a summary...\"\r\n #@lists.disp_summary\r\n create_html_summary\r\n file = File.open('test.html','w')\r\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Initiates a scan of this site. If successful returns scan_id and engine_id in an associative array. Returns false if scan is unsuccessful. | def scanSite()
r = @connection.execute('<SiteScanRequest session-id="' + "#{@connection.session_id}" + '" site-id="' + "#{@site_id}" + '"/>')
if(r.success)
res = {}
r.res.elements.each('//Scan/') do |s|
res[:scan_id] = s.attributes['scan-id']
res[:engine_id] = s.attributes['engine-id']
end
ret... | [
"def scanSite()\n r = @connection.execute('<SiteScanRequest session-id=\"' + \"#{@connection.session_id}\" + '\" site-id=\"' + \"#{@site_id}\" + '\"/>')\n if (r.success)\n res = {}\n r.res.elements.each('//Scan/') do |s|\n res[:scan_id] = s.attributes['scan-id']\n res[:engi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Saves this site in the NSC | def saveSite()
r = @connection.execute('<SiteSaveRequest session-id="' + @connection.session_id + '">' + getSiteXML() + ' </SiteSaveRequest>')
if (r.success)
@site_id = r.attributes['site-id']
@site_config._set_site_id(@site_id)
@site_config.scanConfig._set_configID(@site_id)
@site_config.scanConfig._s... | [
"def save\n frm.button(:value, \"Save\").click\n Sites.new(@browser)\n end",
"def save\n frm.button(:value=>\"Save\").click\n Sites.new(@browser)\n end",
"def new_site_save\n active_submit.click\n end",
"def save_as\n frm.link(:text, \"Save As\").click\n SiteSaveAs.new(@browser)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds a new Recipient to the recipients array | def addRecipient(recipient)
@recipients.push(recipient)
end | [
"def add_recipient(recipient)\n @recipients << recipient\n end",
"def add_new_recipients(recipients)\n recipients.each do |recipient|\n self.users << recipient\n end\n end",
"def add(*recipients)\n return if recipients.size == 0\n recipients.each do |r|\n if r.is_a?(Ar... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the Vulnerability Filter for this alert. | def setVulnFilter(vulnFilter)
@vulnFilter = vulnFilter
end | [
"def setVulnFilter(vulnFilter)\n @vulnFilter = vulnFilter\n end",
"def filter=(value)\n @filter = value\n end",
"def filter=(value)\n @filter = value\n end",
"def filter=(value)\n @filter = value\n end",
"def set_Filter(valu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the Vulnerability Filter for this alert. | def setVulnFilter(vulnFilter)
@vulnFilter = vulnFilter
end | [
"def setVulnFilter(vulnFilter)\n @vulnFilter = vulnFilter\n end",
"def filter=(value)\n @filter = value\n end",
"def filter=(value)\n @filter = value\n end",
"def filter=(value)\n @filter = value\n end",
"def set_Filter(valu... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds a new Schedule for this ScanConfig | def addSchedule(schedule)
@schedules.push(schedule)
end | [
"def addSchedule(schedule)\n @schedules.push(schedule)\n end",
"def deployment_schedule(schedule)\n @deployment_schedules << {\n schedule: schedule,\n nodes_selectors_stack: current_nodes_selectors_stack\n }\n end",
"def schedule=(value)\n @schedule = value\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds a new ScanTrigger to the scanTriggers array | def addScanTrigger(scanTrigger)
@scanTriggers.push(scanTrigger)
end | [
"def addScanTrigger(scanTrigger)\n @scanTriggers.push(scanTrigger)\n end",
"def add_trigger(trigger)\n @triggers << trigger\n end",
"def add_trigger(index, trigger)\n raise Error, _('No current task scheduler. ITaskScheduler is NULL.') if @pits.nil?\n raise Error, _('No currently active task. ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Constructor ScanSummary(can_id, $engine_id, $name, tartTime, $endTime, tatus) | def initialize(scan_id, engine_id, name, startTime, endTime, status)
@scan_id = scan_id
@engine_id = engine_id
@name = name
@startTime = startTime
@endTime = endTime
@status = status
end | [
"def initialize(scan_id, engine_id, name, startTime, endTime, status)\n\n @scan_id = scan_id\n @engine_id = engine_id\n @name = name\n @startTime = startTime\n @endTime = endTime\n @status = status\n\n end",
"def create_summaries(obj, base_time)\n base_start = base_time\n ba... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Constructor EngineSummary(id, name, address, port, status) | def initialize(id, name, address, port, status)
@id = id
@name = name
@address = address
@port = port
@status = status
end | [
"def initialize(scan_id, engine_id, name, startTime, endTime, status)\n\n @scan_id = scan_id\n @engine_id = engine_id\n @name = name\n @startTime = startTime\n @endTime = endTime\n @status = status\n\n end",
"def initialize(id, name, address, port, status)\n\t\t\t@id = id\n\t\t\t@... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Constructor VulnerabilitySummary(id, title, severity) | def initialize(id, title, severity)
@id = id
@title = title
@severity = severity
end | [
"def initialize(id, site_name, description, riskfactor = 1.0)\n @id = id\n @site_name = site_name\n @description = description\n @riskfactor = riskfactor\n end",
"def initialize(id, site_name, description, riskfactor = 1)\n\t\t@id = id\n\t\t@site_name = site_name\n\t\t@description = descrip... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Constructor ReportConfigSummary(id, name, format, last_generated_on, last_generated_uri) | def initialize(id, name, format, last_generated_on, last_generated_uri)
@id = id
@name = name
@format = format
@last_generated_on = last_generated_on
@last_generated_uri = last_generated_uri
end | [
"def report_listing\n r = execute(make_xml('ReportListingRequest', {}))\n reports = []\n if (r.success)\n r.res.elements.each('//ReportConfigSummary') do |report|\n reports << {\n :template_id => report.attributes['template-id'],\n :cfg_id => report.attributes['c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=== Description Save the report definition to the NSC. Returns the configid. | def saveReport()
r = @connection.execute('<ReportSaveRequest session-id="' + @connection.session_id.to_s + '">' + getXML().to_s + ' </ReportSaveRequest>')
if(r.success)
@config_id = r.attributes['reportcfg-id']
return true
end
return false
end | [
"def saveReport()\n r = @connection.execute('<ReportSaveRequest session-id=\"' + @connection.session_id.to_s + '\">' + getXML().to_s + ' </ReportSaveRequest>')\n if (r.success)\n @config_id = r.attributes['reportcfg-id']\n return true\n end\n return false\n end",
"def save\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=== Description Adds a new email recipient | def addEmailRecipient(recipient)
@email_recipients.push(recipient)
end | [
"def add_recipient(p0) end",
"def addrecipient(msgid, recipient)\n req(\"addrecipient\", recipient, \"\", msgid, \"\")\n end",
"def addEmailRecipient(recipient)\n @email_recipients.push(recipient)\n end",
"def add_recipient(recipient)\n @recipients << recipient\n end"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Compute details hash and key according to user options (e.g. passed from render). default "details": default_formats: ::ActionView::Base.default_formats || [:html, :text, :js, :css, :xml, :json] default_variants: [] default_handlers: ::ActionView::Template::Handlers.extensions deault_locale: [:en] (after calculation ;)... | def detail_args_for(options)
# for most plain case, you may not provide any of [:locale, :formats, :variants, :handlers]
# it will return here
return @details, details_key if options.empty?
# merge details with "details" provided by "user"
user_details = @details.merge(option... | [
"def product_details\n if macys?\n color_size = product_color_size.match(/Color: (.*), Size: (.*)/)\n raise \"Unable to parse color and size from '#{product_color_size}'.\" if color_size.nil?\n product_info = {\n 'title' => product_title,\n 'color' => color_size[1],\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /loan_munitions/1 PATCH/PUT /loan_munitions/1.json | def update
respond_to do |format|
if @loan_munition.update(loan_munition_params)
format.html { redirect_to reserf_soldier_loan_path(@reserve,@soldier,@loan), notice: 'Loan munition was successfully updated.' }
format.json { render :show, status: :ok, location: reserf_soldier_loan_path(@reserve... | [
"def update\n @on_loan = OnLoan.find(params[:id])\n\n respond_to do |format|\n if @on_loan.update_attributes(params[:on_loan])\n format.html { redirect_to @on_loan, notice: 'On loan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render act... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /loan_munitions/1 DELETE /loan_munitions/1.json | def destroy
@munition = Munition.find(@loan_munition.munition)
@munition.amount += @loan_munition.amount
@munition.save
@loan_munition.destroy
respond_to do |format|
format.html { redirect_to reserf_soldier_loan_path(@reserve,@soldier,@loan), notice: 'Loan munition was successfully destroyed.'... | [
"def destroy\n @on_loan = OnLoan.find(params[:id])\n @on_loan.destroy\n\n respond_to do |format|\n format.html { redirect_to on_loans_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @moresmalltrialstatus = Moresmalltrialstatus.find(params[:id])\n @moresmalltrials... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
:doggo_id cant equal :friend_id | def void_self_friendship
if doggo_id == friend_id
errors.add(:doggo_id, 'cannot friend self you lonely doggo')
end
end | [
"def person_is_friend?\n if self.person_id == self.friend_id \n self.errors.add :base, \"Person can't be a friend\"\n return false\n end\n\n return true\n end",
"def no_same_donor_and_donee\n donor_conns = donor_connections.to_a\n donee_conns = donee_connections.to_a\n\n # first check... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Also fetch if followers, followings, or repos are empty | def fetch
super
if [:followers, :followings, :repos].any? {|assoc| self.send(assoc).empty?}
api_obj.fetch(:followers, :followings, :repos)
@followers = @followings = @projects = nil
end
self
end | [
"def fetch\n super\n if [:followers, :followings, :repos].any? {|assoc| self.send(assoc).empty?}\n api_obj.fetch(:followers, :followings, :repos)\n @repos = nil\n end\n self\n end",
"def should_fetch_by_page?\n Follower.count == 0 || remote_followers_count - Follower.coun... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Override each to descend into project. Can't do that through normal summary information, as it leads to recursion loops | def each(summary = nil, &block)
super
projects.each {|p| p.each(&block)} unless summary
end | [
"def each_project\n # For convenience, return the projects in lexicographical order.\n names = @projects.keys.sort!\n names.each do |n|\n yield @projects[n] unless @projects[n].drupal?\n end\n end",
"def each_project(&block)\n depth_first = lambda do |p|\n p.projects.each... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Starts a new UDP server that listens on the given port. The state is updated atomically and yielded to an optional block everytime a change is made. By returning `false` the block can cancel the state update. This call is blocking. | def run(host: nil, port: DEFAULT_PORT, &block)
logger.info "Listening on port #{port}"
Socket.udp_server_loop host, port do |msg, sender|
logger.debug { "#{sender.remote_address.inspect} -> '#{msg.inspect}'" }
handler = @handlers.find { |h| h.handles? msg } || next
@state_lock.synch... | [
"def run( port=nil )\n return if @thread && @thread.alive?\n @server.listen( @options[:BindAddress], port ) if port\n @thread = Thread.new( &self.method(:run_server) )\n return @thread\n end",
"def start(start_port)\n return port if running?\n @handle = self.class.start_se... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Updates the state atomicly. The current state will be yielded to the given block and the return value used as the next state. | def update
@state_lock.synchronize do
@state = yield @state
end
end | [
"def update\n\t\t\t# Ideally #update would be a dynamically defined singleton\n\t\t\t# In that singleton method, the appropriate blocks would be\n\t\t\t# called if they had been defined on initialization\n\t\t\tstate = next_state\n\t\t\ttransition_to state\n\t\t\t@active = state\n\t\tend",
"def update(&block)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the 1931 CIE x, y chromaticities of r, g, b display primaries and the white point as an arrray: [white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y] | def get_data
white_x = Shared::interpret_bytes_4(@data[0..3].unpack("C*"))/100000.0
white_y = Shared::interpret_bytes_4(@data[4..7].unpack("C*"))/100000.0
red_x = Shared::interpret_bytes_4(@data[8..11].unpack("C*"))/100000.0
red_y = Shared::interpret_bytes_4(@data[12..15].unpack("C*"... | [
"def create_pixel_array\n\t\t@pixel_array = []\n\t\t@master.each_pixel do |pixel, c, r| \n\t\t @pixel_array << {:red => pixel.red, :green => pixel.green, :blue => pixel.blue} \n\t\tend\n\tend",
"def get_pixels\r\n\t\tpixels_on = []\r\n\t\t@image.each.with_index do |row, row_index|\r\n\t\t\trow.each.with_index ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a hash containing fields that are stored in arrays associated with a tag. Normally, the array should only have a single member, but in case of tag collisions the fields are stored in this way. To get the data of a field in a parsed format, call +get_data+ Example: exif_hash = img.ancillary_chunks[:eXIf][0].get_... | def get_data
#First time, create hash contaning exif fields, freeze the hash, then
#return it. For future calls, simply return the frozen hash.
@pack_str ||= get_pack_str
if @pack_str == ""
warn "Unknown Exif format!"
return self.data
end
if @exif_h... | [
"def get_fields\n return @fields if @fields\n return @fields = CICPHash.new unless has_tag\n ape_items = CICPHash.new\n offset = 0\n last_possible_item_start = tag_data.length - ApeItem::MIN_SIZE\n tag_item_count.times do\n raise ApeTagError, \"End of tag reached but more items ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns an array [+num_frames+, +num_plays+] | def get_data
dat = @data.unpack("C*")
num_frames = Shared::interpret_bytes_4(dat[0..3])
num_plays = Shared::interpret_bytes_4(dat[4..7])
return [num_frames, num_plays]
end | [
"def frames\n total=0\n toneparts.each {|tp| total+=tp.tone.frames}\n total\n end",
"def frame_count\n frames.length\n end",
"def total_sample_frames\n @sample_frames_existing + @sample_frames_written\n end",
"def get_total_games_played\n\t\treturn games.size\n\tend",
"def frames(i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a Headers::PngHeader based on the chunk data | def to_png_header(header)
h = header
Imgrb::Headers::PngHeader.new(@width, @height, h.bit_depth, 0,
h.image_type, 0, 0)
end | [
"def ihdr_chunk\n width = @bitmap.width\n height = @bitmap.height\n # 8 bits per color, use true color (rather than indexed)\n bit_depth = 8\n color_type = 2\n compression_method = 0\n # 0 is the only method available.\n filter_method = 0\n # No interalcing\n interlace_method = 0\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gives the name of the dispose operation: +:none+ +:background+ or +:previous+ | def dispose_operation
case @dispose_op
when 0
:none
when 1
:background
when 2
:previous
end
end | [
"def dispose_title_command\n @new_command.dispose;\n end",
"def disposeTitle\n @screen.dispose\n end",
"def name\n @operation.name\n end",
"def name\n self.class.operation_name\n end",
"def dispose\n $game_system.name_timer = @timer\n super\n end",
"def disposed?\n end",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gives the name of the blend operation: +:source+ or +:over+ | def blend_operation
case @blend_op
when 0
:source
when 1
:over
end
end | [
"def source_operand_name\n return @source_operand_name\n end",
"def name\n @operation.name\n end",
"def contextual_name\n dep_source.cloneable? ? \"#{dep_source.name}:#{name}\" : name\n end",
"def symbol_to_blending_mode(mode)\n \"Magick::#{mode.to_s.camelize}Composi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /promotersbinds/1 GET /promotersbinds/1.json | def show
@promotersbind = Promotersbind.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render :json => @promotersbind }
end
end | [
"def new\n @promotersbind = Promotersbind.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @promotersbind }\n end\n end",
"def create\n @promotersbind = Promotersbind.new(params[:promotersbind])\n\n respond_to do |format|\n if @promotersbin... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /promotersbinds/new GET /promotersbinds/new.json | def new
@promotersbind = Promotersbind.new
respond_to do |format|
format.html # new.html.erb
format.json { render :json => @promotersbind }
end
end | [
"def create\n @promotersbind = Promotersbind.new(params[:promotersbind])\n\n respond_to do |format|\n if @promotersbind.save\n format.html { redirect_to @promotersbind, :notice => 'Promotersbind was successfully created.' }\n format.json { render :json => @promotersbind, :status => :created... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /promotersbinds POST /promotersbinds.json | def create
@promotersbind = Promotersbind.new(params[:promotersbind])
respond_to do |format|
if @promotersbind.save
format.html { redirect_to @promotersbind, :notice => 'Promotersbind was successfully created.' }
format.json { render :json => @promotersbind, :status => :created, :location... | [
"def new\n @promotersbind = Promotersbind.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @promotersbind }\n end\n end",
"def destroy\n @promotersbind = Promotersbind.find(params[:id])\n @promotersbind.destroy\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /promotersbinds/1 PUT /promotersbinds/1.json | def update
@promotersbind = Promotersbind.find(params[:id])
respond_to do |format|
if @promotersbind.update_attributes(params[:promotersbind])
format.html { redirect_to @promotersbind, :notice => 'Promotersbind was successfully updated.' }
format.json { head :ok }
else
forma... | [
"def create\n @promotersbind = Promotersbind.new(params[:promotersbind])\n\n respond_to do |format|\n if @promotersbind.save\n format.html { redirect_to @promotersbind, :notice => 'Promotersbind was successfully created.' }\n format.json { render :json => @promotersbind, :status => :created... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /promotersbinds/1 DELETE /promotersbinds/1.json | def destroy
@promotersbind = Promotersbind.find(params[:id])
@promotersbind.destroy
respond_to do |format|
format.html { redirect_to promotersbinds_url }
format.json { head :ok }
end
end | [
"def destroy\n @productsbind = Productsbind.find(params[:id])\n @productsbind.destroy\n\n respond_to do |format|\n format.html { redirect_to productsbinds_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @bind = Bind.find(params[:id])\n @bind.destroy\n\n respond_to do ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /empathy_map_records GET /empathy_map_records.json | def index
@empathy_map_records = EmpathyMapRecord.all
end | [
"def index\n @empathy_maps = EmpathyMap.all\n end",
"def index\n @maps = Map.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @maps }\n end\n end",
"def index\n\n @maps = Map.all\n\n respond_to do |format|\n format.html # index.html.er... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /empathy_map_records POST /empathy_map_records.json | def create
@empathy_map = EmpathyMap.find_or_create_by(id: empathy_map_record_params[:empathy_map_id])
@empathy_map_record = EmpathyMapRecord.new(empathy_map_record_params.merge(empathy_map_id: @empathy_map.id))
respond_to do |format|
if @empathy_map_record.save
format.html { redirect_to @emp... | [
"def create\n @empathy_map = EmpathyMap.new(empathy_map_params)\n\n respond_to do |format|\n if @empathy_map.save\n format.html { redirect_to @empathy_map, notice: 'Empathy map was successfully created.' }\n format.json { render :show, status: :created, location: @empathy_map }\n else\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /empathy_map_records/1 PATCH/PUT /empathy_map_records/1.json | def update
respond_to do |format|
if @empathy_map_record.update(empathy_map_record_params)
format.html { redirect_to @empathy_map_record, notice: 'Empathy map record was successfully updated.' }
format.json { render :show, status: :ok, location: @empathy_map_record }
else
format.... | [
"def update\n respond_to do |format|\n if @empathy_map.update(empathy_map_params)\n format.html { redirect_to @empathy_map, notice: 'Empathy map was successfully updated.' }\n format.json { render :show, status: :ok, location: @empathy_map }\n else\n format.html { render :edit }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /empathy_map_records/1 DELETE /empathy_map_records/1.json | def destroy
@empathy_map_record.destroy
respond_to do |format|
format.html { redirect_to empathy_map_records_url, notice: 'Empathy map record was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @empathy_map.destroy\n respond_to do |format|\n format.html { redirect_to empathy_maps_url, notice: 'Empathy map was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @extmap.destroy\n respond_to do |format|\n format.html { red... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set the pairwise server auth, host, and protocol values. ==== Parameters options:host:: the pairwise server. options:user:: the pairwise user. options:password:: the pairwise password for user. options:protocol:: the internet protocol to use, probably HTTP or HTTPS. | def server(options)
@auth = Base64.b64encode("#{options[:user]}:#{options[:pass]}")
@host = options[:host]
@protocol = options[:protocol]
end | [
"def set_server_option(opt)\n check_connection\n @protocol.set_option_command opt\n self\n end",
"def initialize(options = {})\n requires!(options, :host, :username)\n requires!(options, :password) unless options[:remote_key]\n \n @host = options[:host]\n @username = opt... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a question. ==== Return Array of question external ids. ==== Parameters data:: a single question string or an array of question strings. | def question(data)
xml = xml_root("questions")
arrayed(data).each do |name|
xml.root << (XML::Node.new("question") << name)
end
send_and_process('questions/add', 'questions/question', xml)
end | [
"def item(data, question_ids)\n xml = xml_root(\"items\")\n\n questions = question_ids.inject(XML::Node.new(\"questions\")) do |doc, id|\n question = XML::Node.new(\"question\")\n question[\"id\"] = id.to_s\n doc << question\n end\n\n arrayed(data).each do |name|\n xm... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create an item for questions. ==== Return On success returns an array of item external ids. Failure on passing nonexistent question id. ==== Parameters data:: a single item data string or an array of item data strings. question_ids:: an array of integers representing the external ids of the questions the item is to be ... | def item(data, question_ids)
xml = xml_root("items")
questions = question_ids.inject(XML::Node.new("questions")) do |doc, id|
question = XML::Node.new("question")
question["id"] = id.to_s
doc << question
end
arrayed(data).each do |name|
xml.root << (XML::Node.ne... | [
"def question(data)\n xml = xml_root(\"questions\")\n\n arrayed(data).each do |name|\n xml.root << (XML::Node.new(\"question\") << name)\n end\n\n send_and_process('questions/add', 'questions/question', xml)\n end",
"def create_item\n props = {\n bibIds: [create_bib],\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Update an item's state. ==== Return On response returns true. Failure on incorrect item id. ==== Parameters item_id:: the external id of the items whose state to set. state:: state will be set to 'activated' if state is true. Otherwise state will be set to 'suspended'. | def update_item_state(item_id, state)
!send_pairwise_request("items/#{item_id}/#{state ? 'activate' : 'suspend'}", nil, 'Get').nil?
end | [
"def update_item_state(item_id, state)\n state = ( state ? 'complete' : 'incomplete' ) unless state.is_a?(String)\n client.put(\n \"/cards/#{card_id}/checkItem/#{item_id}\",\n state: state\n )\n end",
"def checkin(item, state=States::SUCCESS)\n if item.kind_of?(Hash) && ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create voters with given features. Each can pass a single hash of features to create a single voter or an array of hashes to create multiple voters. ==== Return On sucess returns the voter external ids. ==== Parameters features:: a hash of name to value pairs for the voter's features. | def voter(features)
xml = arrayed(features).inject(xml_root("voters").root) do |voters, hash|
voter = XML::Node.new("voter")
features = XML::Node.new("features")
hash.each do |name, value|
feature = XML::Node.new("feature") << value
feature["name"] = name.to_s
... | [
"def register_features(with_features)\n Thread.new do\n features = []\n features = with_features.each do | feature |\n features.push(key: feature[:key],\n variants: feature[:variants],\n failoverVariant: feature[:failover_variant])\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Update the state of voter feature name to value. ==== Retturn On success returns voter external id. ==== Parameters voter_id:: the external voter id. name:: the feature to set. value:: the value to set the feature to. ==== Failure on incorrect voter id. | def update_voter_state(voter_id, name, value)
send_and_process("voters/set/#{voter_id}?#{name}=#{value}", 'voter')
end | [
"def update_value(name, value)\n feature = features.find_or_create_by!(name: name)\n\n feature.update_attributes(value: value, enabled: true)\n end",
"def value=(new_value)\n @feature.value = new_value\n end",
"def feature(name)\n @feature_name = name\n end",
"def set_value(feature_id, ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create n prompts for question and voter. Can restrict to items and specify number of items expected in returned prompt. ==== Return Array with each member a prompt external id followed by an array of item external ids for that prompt. ==== Parameters question_id:: the question to create the prompt for. voter_id:: the v... | def prompt(question_id, voter_id, n = 1, prime = false, num_items = 2)
res = "prompts/create/#{question_id}/#{voter_id || 0}/#{n}"
res += "/1" if prime
res = send_pairwise_request(res, nil, 'Get')
# process response
if res
prompt_ids = fetch_xml_attr('prompts/prompt', res)
... | [
"def prompts(question_id, voter_id, count)\n all_items = items_for_request(question_id)\n items = []\n prompt_item_ids = {}\n # leaks with create/find in req loop\n Prompt.transaction do\n count.times do |i|\n items = all_items.dup if items.length < 2 # ensure we still have ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tell pairwise this prompt has been viewed so stats can be updated ==== Parameters id:: the prompt external id. | def view(id)
send_pairwise_request("prompts/view/#{id}")
end | [
"def notify(id)\n logger.info(\"Notifying snitch #{id}\")\n result = http.get('/' + id)\n logger.debug(\"Snitch notification result: #{result}\")\n result.is_a? Net::HTTPSuccess\n end",
"def info(id)\n @query = {id: id}\n post_call('/info')\n end",
"def display_target(id)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a vote on a prompt for an item or a skip if nil. Can be cast for a voter or the anonymous voter and a response time can be sent. ==== Return Array of vote external ids. ==== Parameters prompt_id:: the prompt external id to record a vote for. item_id:: the item_id to record the vote for. If item_id is nil or fals... | def vote(prompt_id, item_id = nil, voter_id = 0, response_time = 0)
send_and_process("votes/add/#{prompt_id}/#{voter_id || 0}/#{response_time}#{"/#{item_id}" if item_id}", 'vote')
end | [
"def prompt(question_id, voter_id, n = 1, prime = false, num_items = 2)\n res = \"prompts/create/#{question_id}/#{voter_id || 0}/#{n}\"\n res += \"/1\" if prime\n res = send_pairwise_request(res, nil, 'Get')\n\n # process response\n if res\n prompt_ids = fetch_xml_attr('prompts/promp... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Call list method. Can pass a question and rank algorithm id. List method :item is supported. ==== Return Array each element being an item external id followed by a rank value. ==== Parameters method:: a symbol representing the type of list request to send. question_id:: the question external id of the question's items ... | def list(method, question_id = nil, rank_algorithm_id = nil)
case method
when :item
res = send_pairwise_request("items/list/#{question_id.to_i}/#{rank_algorithm_id.to_i}")
fetch_xml_attr('items/item', res).zip(fetch_xml_attr('items/item', res, 'rank')) if res
end
end | [
"def cmdRankGetList\n params = {\n \"rank_get_list\" => 1,\n \"app_version\" => @config[\"version\"],\n }\n response = @client.request(params, @sid, true, false)\n serializer = Serializer.new(response)\n return serializer.parseRankList\n end",
"def list(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
==== Return Response from the pairwise path parsed with the res_path. ==== Parameters path:: where to send the pairwise request to. res_path:: the parse path for the xml. xml:: the data to send to pairwise, default nil. | def send_and_process(path, res_path, xml = nil) # :doc:
# send XML
res = send_pairwise_request(path, xml)
# process response
fetch_xml_attr(res_path, res) if res
end | [
"def send_pairwise_request(path, xml = nil, method = nil) # :doc:\n url = URI.parse(\"#{protocol}://#{host}/#{path}\")\n headers = {\n 'Content-Type' => 'text/xml',\n 'Authorization' => \"Basic #{auth}\"\n }\n res = Net::HTTP.new(url.host, url.port)\n res.use_ssl = true if url... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
==== Parameters path:: where to send the pairwise request to. xml:: the post body to send. If xml is nil and method is nil (see below) a get request is sent. Default nil. method:: type of request to send. If method is nil request type is determined by the value of value of xml. | def send_pairwise_request(path, xml = nil, method = nil) # :doc:
url = URI.parse("#{protocol}://#{host}/#{path}")
headers = {
'Content-Type' => 'text/xml',
'Authorization' => "Basic #{auth}"
}
res = Net::HTTP.new(url.host, url.port)
res.use_ssl = true if url.port == Net::HT... | [
"def send_and_process(path, res_path, xml = nil) # :doc:\n # send XML\n res = send_pairwise_request(path, xml)\n # process response\n fetch_xml_attr(res_path, res) if res\n end",
"def send_request( xml )\n write( xml )\n read\n end",
"def post(method, params = {})\n url = ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
==== Parameters xml:: an HTTP response. path:: the path to search in xml. attribute:: the attribute to return for each element in the search path. | def fetch_xml_attr(path, xml, attribute = "id") # :doc:
XML::Parser.parse(xml.body, "/pairwise/#{path}", attribute)
end | [
"def get_value(attribute,xml)\n xml.xpath(\".//#{attribute}\").first.content\n end",
"def _getAttribElem(data, attribute, value)\n data.each do |g|\n attrib = Rack::Utils.parse_query URI(g).query\n if(attrib[attribute] == value) \n return g\n end\n end\n end",
"def read_attr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
creates an XML document and sets the root value to string. ==== Parameters string:: the root value of a new XML document. | def xml_root(string) # :doc:
xml = XML::Document.new
xml.root = XML::Node.new(string)
xml
end | [
"def xml_str(root, str)\n\t\t\treturn \"<#{root}>#{str}</#{root}>\"\n\t\tend",
"def parse(xml_string)\n Document.new(xml_string)\n end",
"def initialize(xml_str)\n @doc = REXML::Document.new(xml_str)\n @root = @doc.root\n end",
"def text(string)\n insert(@doc.create_text_node... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
A simplified loop: loops until +condition+ is met execution +ruby_block+. The loop is synchronized on +clk_e+ and initialized by +init+. If +condition+ is nil, then +init+ is used as +condition+. | def while_loop(clk_e, init, condition = nil, &ruby_block)
# Create the loop task.
tsk = while_task(clk_e,init,condition,ruby_block).(HDLRuby.uniq_name)
# Create the inner access port.
prt = tsk.inner HDLRuby.uniq_name
# Return the access port.
return prt
end | [
"def until_instruct(condition, body, opts={})\n opts = {value: true}.merge(opts)\n body_block, after_block, precond_block = create_blocks 3\n\n with_jump_targets(break: after_block, redo: body_block, next: precond_block) do\n uncond_instruct precond_block\n start_blo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Loop +num+ times executing +ruby_block+. The loop is synchronized on +clk_e+. | def times_loop(clk_e, num, &ruby_block)
# Compute the width of the counter.
width = num.respond_to?(:width) ? num.width : num.type.width
# Declares the counter.
cnt = [width].inner(HDLRuby.uniq_name)
# Create the loop.
return while_loop(clk_e, proc{cnt<=0}, cnt<num) do
cnt <= cnt + 1
... | [
"def execute(exec_num, &block)\n exec_num.times do timed(&block)\n end\n end",
"def repeater(num = 1, &block)\n\tnum.times { block.call }\nend",
"def benchmark ( num )\n\n\t# create a start time\n\tstart_time = Time.now\n\t# start the loop n.times\n\t\t# and run the block\n\tnum.times { yield if block_gi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Popplerglib needs a newer cairo than provided by OS X 10.6.x and pdf2svg needs it to be on PKG_CONFIG_PATH during the build | def install
unless have_poppler_glib?
onoe <<-EOS.undent
pkg-config could not find poppler-glib! Please try re-installing
Poppler with support for the Glib backend:
brew uninstall poppler
brew install --with-glib poppler
EOS
exit 1
end
ENV.x11
... | [
"def post_install\n ENV[\"GDK_PIXBUF_MODULEDIR\"] = \"#{HOMEBREW_PREFIX}/#{module_subdir}\"\n system \"#{Formula[\"gdk-pixbuf\"].opt_bin}/gdk-pixbuf-query-loaders\", \"--update-cache\"\n end",
"def gdk_so_ver\n Formula[\"gdk-pixbuf\"].gdk_so_ver\n end",
"def main\n url = 'http://downloads.ghost... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /cohort_students GET /cohort_students.json | def index
@cohort_students = CohortStudent.all
end | [
"def index\n @cohorts_students = CohortsStudent.all\n end",
"def show\n @cohort = current_user.accessible_cohorts.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cohort }\n end\n end",
"def index\n @cohorts = current_user.access... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /cohort_students POST /cohort_students.json | def create
@cohort_student = CohortStudent.new(cohort_student_params)
respond_to do |format|
if @cohort_student.save
format.html { redirect_to students_path, notice: 'Student was successfully added.' }
format.json { render :show, status: :created, location: @cohort_student }
else
... | [
"def create\n @student_cohorts = StudentCohort.new(student_cohort_params)\n @students = Student.all\n @cohorts = Cohort.all\n \n respond_to do |format|\n if @student_cohort.save\n format.html { redirect_to @student_cohort, notice: 'Student cohort was successfully created.' }\n form... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /cohort_students/1 PATCH/PUT /cohort_students/1.json | def update
respond_to do |format|
if @cohort_student.update(cohort_student_params)
format.html { redirect_to cohorts_path, notice: 'Cohort student was successfully updated.' }
format.json { render :show, status: :ok, location: @cohort_student }
else
format.html { render :edit }
... | [
"def update\n respond_to do |format|\n if @cohort_student.update(cohort_student_params)\n format.html { redirect_to @cohort_student, notice: 'Cohort student was successfully updated.' }\n format.json { render :show, status: :ok, location: @cohort_student }\n else\n format.html { re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /cohort_students/1 DELETE /cohort_students/1.json | def destroy
@cohort_student.destroy
respond_to do |format|
format.html { redirect_to cohorts_path, notice: 'Student was successfully removed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @student_cohort.destroy\n respond_to do |format|\n format.html { redirect_to student_cohorts_url, notice: 'Student cohort was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cohort_student.destroy\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
clones an individual course with no deep cloning | def clone_course(course)
cloned_course = course.dup
cloned_course.update_attribute("name", course.name + "-CLONE")
cloned_course.save
cloned_course
end | [
"def clone\n #begin\n # clone course\n cloned_course = @course.dup()\n cloned_course.title = @course.title + \" cloned\"\n cloned_course.token = '' # course cannot have duplicated tokens\n cloned_course.save\n\n question_id_dict = {} # hash that maps the original_question_id => clon... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /task_metrics/1 GET /task_metrics/1.json | def show
@task_metric = TaskMetric.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render :json => @task_metric }
end
end | [
"def get_metrics\n {\n method: \"Performance.getMetrics\"\n }\n end",
"def get\n\t\tunless params[:metric] then\n\t\t\trender json: {error: \"must provide a metric\"}\n\t\t\treturn\n\t\tend\n\t\tm = params[:metric]\n\n\t\tnow = Time.now().to_i\n\t\tstart = (params[:start] || now - STA... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /task_metrics/new GET /task_metrics/new.json | def new
@task_metric = TaskMetric.new
respond_to do |format|
format.html # new.html.erb
format.json { render :json => @task_metric }
end
end | [
"def create\n @task_metric = TaskMetric.new(params[:task_metric])\n\n respond_to do |format|\n if @task_metric.save\n format.html { redirect_to @task_metric, :notice => 'Task metric was successfully created.' }\n format.json { render :json => @task_metric, :status => :created, :location => ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /task_metrics POST /task_metrics.json | def create
@task_metric = TaskMetric.new(params[:task_metric])
respond_to do |format|
if @task_metric.save
format.html { redirect_to @task_metric, :notice => 'Task metric was successfully created.' }
format.json { render :json => @task_metric, :status => :created, :location => @task_metri... | [
"def report_metrics\n metadata = {\n 'sourcetype' => 'json',\n 'source' => 'chef-handler',\n 'host' => node.hostname,\n 'index' => @index,\n 'check-index' => false\n }\n\n # We're creating a new Hash b/c 'node' and 'all_resources' in run_status\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /task_metrics/1 PUT /task_metrics/1.json | def update
@task_metric = TaskMetric.find(params[:id])
respond_to do |format|
if @task_metric.update_attributes(params[:task_metric])
format.html { redirect_to @task_metric, :notice => 'Task metric was successfully updated.' }
format.json { head :no_content }
else
format.htm... | [
"def create\n @task_metric = TaskMetric.new(params[:task_metric])\n\n respond_to do |format|\n if @task_metric.save\n format.html { redirect_to @task_metric, :notice => 'Task metric was successfully created.' }\n format.json { render :json => @task_metric, :status => :created, :location => ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /task_metrics/1 DELETE /task_metrics/1.json | def destroy
@task_metric = TaskMetric.find(params[:id])
@task_metric.destroy
respond_to do |format|
format.html { redirect_to task_metrics_url }
format.json { head :no_content }
end
end | [
"def test_delete_not_exist_metric\n not_exist_id = '10000'\n output = `curl -X DELETE http://localhost:8080/metrics/metrics/#{not_exist_id}`\n assert_match \"<html>\", output, \"TEST 5: delete not existing metric - FAILED\"\n end",
"def destroy\n authorize! :manage, @metric\n\n @metric.destroy\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Mark the object as read for notifiable. Object can be: A Receipt A Message An Array of these Optionally pass in details of the read receipt as String | def mark_as_read(obj, details = nil)
case obj
when Alerter::Receipt
obj.mark_as_read if obj.receiver == self
when Alerter::Message
obj.mark_as_read(self, details)
when Array
obj.map{ |sub_obj| mark_as_read(sub_obj, details) }
end
e... | [
"def mark_as_read(obj, details = nil)\n case obj\n when Alerter::Receipt\n obj.mark_as_read if obj.receiver == self\n when Alerter::Message\n obj.mark_as_read(self)\n when Array\n obj.map{ |sub_obj| mark_as_read(sub_obj) }\n end\n\n end"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Mark the object as unread for notifiable. Object can be: A Receipt A Message An Array of these Optionally pass in details of the unread receipt as String | def mark_as_unread(obj, details = nil)
case obj
when Alerter::Receipt
obj.mark_as_unread if obj.receiver == self
when Alerter::Message
obj.mark_as_unread(self, details)
when Array
obj.map{ |sub_obj| mark_as_unread(sub_obj, details) }
end
... | [
"def mark_as_unread(obj, details = nil)\n case obj\n when Alerter::Receipt\n obj.mark_as_unread if obj.receiver == self\n when Alerter::Message\n obj.mark_as_unread(self)\n when Array\n obj.map{ |sub_obj| mark_as_unread(sub_obj) }\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Mark the object as deleted for notifiable. Object can be: A Receipt A Message An Array of these Optionally pass in details of the deletion as String | def mark_as_deleted(obj, details = nil)
case obj
when Receipt
return obj.mark_as_deleted if obj.receiver == self
when Message
obj.mark_as_deleted(self, details)
when Array
obj.map{ |sub_obj| mark_as_deleted(sub_obj, details) }
else
... | [
"def mark_as_deleted(obj, details = nil)\n case obj\n when Receipt\n return obj.mark_as_deleted if obj.receiver == self\n when Message\n obj.mark_as_deleted(self)\n when Array\n obj.map{ |sub_obj| mark_as_deleted(sub_obj) }\n else\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Could use this if wanted to change the magic number. | def set_magic(file, bytes)
raise unless bytes.size == 4
unless nowrite()
File.open(file, File::RDWR) do |io|
io.write(bytes)
end
end
end | [
"def fat_magic?(num); end",
"def is_magic_number?(n)\nend",
"def fat_magic32?(num); end",
"def compressed_magic?(num); end",
"def filemagic\n @filemagic ||= FileMagic.new(FileMagic::MAGIC_MIME_TYPE)\n end",
"def increment_manuscript_rev_num\n if self.version && self.article\n num = self.ma... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Compiles the specified file to .pyc. A Python source file called ``py_file`` must exist. The created .pyc file will be given the name ``pyc_file``, or if not specified, the name ``py_file``. | def compile(source_name, py_file, pyc_file = nil)
pyc_file ||= py_file
source_name =~ /\.py$/ or raise
base = $`
pyofile = base + '.pyo'
cp(py_file, source_name)
command = format('python2.2 -OO -c \'%s\'',
format('import py_compile; py_compile.compile("%s")', source_name))
... | [
"def compile(py_file)\n py_file =~ /\\.py$/ or raise\n base = $`\n pyo_file = base + '.pyo'\n pyc_file = base + '.pyc'\n\n # To build python2.2 from source\n # ./configure --prefix=$HOME/local --program-suffix=2.2\n # make\n # make install\n # rm $HOME/local/bin/python\n command = format('python2.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /operation_hours/1 GET /operation_hours/1.js | def show
@operation_hour = OperationHour.find(params[:id])
end | [
"def show\n @operationhour = Operationhour.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @operationhour }\n end\n end",
"def index\n userId = params[:id].to_i\n time_unit_id = params[:time_unit_id].to_i\n\n user = @userReposito... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /operation_hours POST /operation_hours.js | def create
@operation_hours = OperationHour.paginate(:page => params[:page], :per_page => 30).order('updated_at DESC')
@operation_hour = OperationHour.create(params[:operation_hour])
end | [
"def create\n @operationhour = Operationhour.new(params[:operationhour])\n\n respond_to do |format|\n if @operationhour.save\n format.html { redirect_to @operationhour, notice: 'Operationhour was successfully created.' }\n format.json { render json: @operationhour, status: :created, locatio... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /operation_hours/1 PATCH/PUT /operation_hours/1.json | def update
@operation_hour = OperationHour.find(params[:id])
@operation_hour.update_attributes(params[:operation_hour])
@operation_hours = OperationHour.paginate(:page => params[:page], :per_page => 30).order('updated_at DESC')
end | [
"def update\n @operationhour = Operationhour.find(params[:id])\n\n respond_to do |format|\n if @operationhour.update_attributes(params[:operationhour])\n format.html { redirect_to @operationhour, notice: 'Operationhour was successfully updated.' }\n format.json { head :no_content }\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /operation_hour/1/delete GET /operation_hour/1/delete.js | def delete
@operation_hour = OperationHour.find(params[:operation_hour_id])
end | [
"def destroy\n @operationhour = Operationhour.find(params[:id])\n @operationhour.destroy\n\n respond_to do |format|\n format.html { redirect_to operationhours_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @operation_hours = OperationHour.paginate(:page => params[:... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /operation_hours/1 DELETE /operation_hours/1.json | def destroy
@operation_hours = OperationHour.paginate(:page => params[:page], :per_page => 30).order('updated_at DESC')
@operation_hour = OperationHour.find(params[:id])
@error = nil
begin
@operation_hour.destroy
rescue ActiveRecord::DeleteRestrictionError => e
@error = e.message
en... | [
"def destroy\n @operationhour = Operationhour.find(params[:id])\n @operationhour.destroy\n\n respond_to do |format|\n format.html { redirect_to operationhours_url }\n format.json { head :no_content }\n end\n end",
"def delete\n @operation_hour = OperationHour.find(params[:operation_hour_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a new Entity for the specified +world+, and use the specified +id+ if given. If no +id+ is given, one will be automatically generated. | def initialize( world, id=nil )
@world = world
@id = id || self.class.make_new_id
end | [
"def newWorld(db, name)\n\tif db.hexists('sgt-worlds', name)\n\t\treturn World.new(db, db.hget('sgt-worlds', name))\n\tend\n\tnewId = newUUID(db)\n\t\n\t# Associate this name to the world id\n\tdb.hset('sgt-worlds', name, newId)\n\t\t\n\t# The 'name' property of the object\n\tdb.hset('sgt-world:'+newId, 'name', nam... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the components that the entity's World has registered for it as a Hash keyed by the Component class. | def components
return self.world.components_for( self )
end | [
"def available_components\n components = []\n @components.each_key do |k|\n components << k if @components[k].registered?\n end\n components\n end",
"def get_components(entity)\n @components.each_with_object([]) do |pair, acc|\n _, entities = *pair\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Fetch the component of the specified +component_class+ that corresponds with the receiving entity. Returns +nil+ if so much component exists. | def get_component( component_class )
return self.world.get_component_for( self, component_class )
end | [
"def get_component_for( entity, component_class )\n\t\tentity = entity.id if entity.respond_to?( :id )\n\t\treturn self.components_by_entity[ entity ][ component_class ]\n\tend",
"def get_components(entity, component_class)\n self[entity][component_class]\n end",
"def get_component!(entity, type)\n Mor... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Remove the component of the specified +component_class+ that corresponds with the receiving entity. Returns the component instance if it was removed, or +nil+ if no Component of the specified type was registered to the entity. | def remove_component( component_class )
return self.world.remove_component_from( self, component_class )
end | [
"def remove_component_from( entity, component )\n\t\tentity = entity.id if entity.respond_to?( :id )\n\t\tif component.is_a?( Class )\n\t\t\tself.entities_by_component[ component ].delete( entity )\n\t\t\tcomponent_hash = self.components_by_entity[ entity ]\n\t\t\tcomponent_hash.delete( component )\n\t\t\tself.upda... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns +true+ if this entity has a component of the specified +component_class+. | def has_component?( component_class )
return self.world.has_component_for?( self, component_class )
end | [
"def is?(component_class)\n !!component_class.one(self)\n end",
"def has_component_for?( entity, component )\n\t\tentity = entity.id if entity.respond_to?( :id )\n\t\tif component.is_a?( Class )\n\t\t\treturn self.components_by_entity[ entity ].key?( component )\n\t\telse\n\t\t\treturn self.components_by_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The python prefix (special cased for a brewed python to point into the opt_prefix) | def prefix
if brewed?
# Homebrew since a long while only supports frameworked python
HOMEBREW_PREFIX/"opt/#{name}/Frameworks/Python.framework/Versions/#{version.major}.#{version.minor}"
elsif from_osx?
# Python on OS X has been stripped off its includes (unless you install the CLT), therefore ... | [
"def exec_prefix() return @prefix end",
"def prefix\n Babushka::BrewHelper.prefix\n end",
"def current_prefix; end",
"def name_prefix=(_arg0); end",
"def prefixed_label(package)\n label = ( package =~ /^#{$prefix}(.*)$/ ) && $1 || package\n label = '.' if label.empty?\n label\nend",
"def cli_pr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
python.xy => "python2.7" is often used (and many formulae had this as `which_python`). | def xy
"python#{version.major}.#{version.minor}"
end | [
"def python_binary\n @python_binary ||= begin\n `which python2`\n $?.success? ? \"python2\" : \"python\"\n end\n end",
"def default_python_binary\n if parent_python\n parent_python.python_binary\n else\n which('python')\n end\n end",
"def de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Homebrew's global sitepackages. The local ones (just `site_packages`) are populated by the python_helperg method when the `prefix` of a formula is known. | def global_site_packages
HOMEBREW_PREFIX/"lib/#{xy}/site-packages"
end | [
"def prefix_site_packages\n HOMEBREW_PREFIX+\"lib/python2.7/site-packages\"\n end",
"def prefix_site_packages\n HOMEBREW_PREFIX/\"lib/pypy/site-packages\"\n end",
"def prefix_site_packages\n HOMEBREW_PREFIX+\"lib/python3.2/site-packages\"\n end",
"def python_packages\n PRE_INSTALLED_PYTHON_PACK... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Dir containing Python.h and others. | def incdir
if (from_osx? || brewed?) && framework?
prefix/"Headers"
else
# For all other we use Python's own standard method (works with a non-framework version, too)
Pathname.new(`#{binary} -c 'from distutils import sysconfig; print(sysconfig.get_python_inc())'`.strip)
end
end | [
"def module_directory\n install_root + FileSep + self['ModuleDirectory']\n end",
"def modules_home\n FilePath.new(@build_dir, \"modules\").ensure_directory\n end",
"def prefix_site_packages\n HOMEBREW_PREFIX/\"lib/pypy/site-packages\"\n end",
"def prefix_site_packages\n HOMEBREW_PREFIX+\"lib/py... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Dir containing e.g. libpython2.7.dylib | def libdir
if brewed? || from_osx?
if @min_version.major == 3
prefix/"lib/#{xy}/config-#{version.major}.#{version.minor}m"
else
prefix/"lib/#{xy}/config"
end
else
Pathname.new(`#{binary} -c "from distutils import sysconfig; print(sysconfig.get_config_var('LIBPL'))"`.strip... | [
"def prefix_site_packages\n HOMEBREW_PREFIX+\"lib/python2.7/site-packages\"\n end",
"def libdir()\n LIBDIR\n end",
"def ndk_libdir\n ndk_sysroot + '/usr/lib/'\n end",
"def applicationFilesDirectory\n file_manager = NSFileManager.defaultManager\n library_url = file_manager.URLsFo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Pkgconfig (pc) files of python | def pkg_config_path
if from_osx?
# No matter if CLT-only or Xcode-only, the pc file is always here on OS X:
path = Pathname.new("/System/Library/Frameworks/Python.framework/Versions/#{version.major}.#{version.minor}/lib/pkgconfig")
path if path.exist?
else
prefix/"lib/pkgconfig"
end
... | [
"def try_package_configuration(pc)\n unless ENV.key?(\"NOKOGIRI_TEST_PKG_CONFIG_GEM\")\n # try MakeMakefile#pkg_config, which uses the system utility `pkg-config`.\n return if checking_for(\"#{pc} using `pkg_config`\", LOCAL_PACKAGE_RESPONSE) do\n pkg_config(pc)\n end\n end\n\n # `pkg-config` proba... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.