query stringlengths 7 9.55k | document stringlengths 10 363k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
def strip_content sanitize(self.content.gsub(/()/i, '\1 '), tags: [], attributes: []).squish if self.content end Format content for search (keep only return to lines tags) force_locale: return content present only in the specified locale | def formatted_content(locale, force_locale: false)
formatted_content = public_content(with_translations: true, locale: locale, force_locale: force_locale)
return formatted_content unless formatted_content
# formatted_content = formatted_content.gsub(/<img (.*?)\/?>/im, '')
return formatted_content.strip_html(replace_with_line: true)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_up_contents()\n # very minimal\n # elements = ['p', 'b', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'], attributes={})\n\n if self.contents?\n html = self.contents\n email_regex = /<p>Email:\\s+((\\w|\\-|\\_|\\.)+\\@((\\w|\\-|\\_)+\\.)+[a-zA-Z]{2,})/i\n\n html.gsub! /\\[endif\\]--/ , ''\n ... | [
"0.68562603",
"0.67935276",
"0.67511415",
"0.6746034",
"0.66721165",
"0.6604419",
"0.65555745",
"0.6511022",
"0.6499526",
"0.6499526",
"0.64936286",
"0.6487311",
"0.6487311",
"0.64599735",
"0.64153767",
"0.6353183",
"0.63192874",
"0.6318653",
"0.62994033",
"0.629001",
"0.6263... | 0.635981 | 15 |
Used by tracker to add a custom value | def custom_popularity(popularity, tracker_count)
popularity *= self.rank if self.rank.present?
return popularity, tracker_count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(value)\n \n end",
"def add_custom_field(name, value)\n add_field name, value\n end",
"def add(value)\n\tend",
"def add(name, value = current_value)\n type.add(name.to_s, Integer(value))\n @current_value = Integer(value) + 1\n end",
... | [
"0.70345473",
"0.6848869",
"0.6759735",
"0.66591007",
"0.6657537",
"0.65924746",
"0.6482569",
"0.63425446",
"0.633697",
"0.6318816",
"0.63098764",
"0.63090515",
"0.62640333",
"0.62548804",
"0.625245",
"0.62212616",
"0.6219438",
"0.6215187",
"0.61853033",
"0.618225",
"0.617288... | 0.0 | -1 |
1.0 and 1.1 support | def file_path path
File.join(output_path, manifest.lookup(path).split('/')[2..-1])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def def_version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def version; end",
"def... | [
"0.6765209",
"0.67217577",
"0.67217577",
"0.67217577",
"0.67217577",
"0.67217577",
"0.67217577",
"0.67217577",
"0.67217577",
"0.67217577",
"0.67217577",
"0.67217577",
"0.67217577",
"0.67217577",
"0.67217577",
"0.67217577",
"0.67217577",
"0.67217577",
"0.67217577",
"0.67217577",... | 0.0 | -1 |
TODO: separate text for singular or plural users | def refused_users_html
emails = email_list(refused_users.map(&:email))
if refused_users.count == 0
nil
else
"#{emails} indicated that they were not present for the meeting.".html_safe
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def full_text\n \"#{role} by #{person.full_name}\"\n end",
"def presented_by text\n \nend",
"def pluralize(text)\n \"#{text.to_s}s\"\n end",
"def text_name\n put_together_name(:full).t.html_to_ascii\n end",
"def list_title_for(text)\n I18n.t(\"backend.general.list\", :mode... | [
"0.6953016",
"0.626552",
"0.615805",
"0.61103475",
"0.60836977",
"0.6052324",
"0.6026688",
"0.60046315",
"0.60013187",
"0.59955233",
"0.5983325",
"0.5977718",
"0.5955342",
"0.59465605",
"0.5935478",
"0.591961",
"0.5914697",
"0.5895591",
"0.5888123",
"0.5880727",
"0.58787954",... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_guide
@guide = Guide.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163927",
"0.6046165",
"0.59465253",
"0.59167755",
"0.58904207",
"0.58346355",
"0.577713",
"0.5703502",
"0.5703502",
"0.56531286",
"0.56215113",
"0.54224145",
"0.5410795",
"0.5410795",
"0.5410795",
"0.53924775",
"0.5379919",
"0.53580743",
"0.53401667",
"0.53397506",
"0.533... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def guide_params
params.require(:guide).permit(:title, :description, :steps, :source)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
now start getting categories | def scrape_altgenres(starting_number)
n = starting_number
loop do
begin
netflix_page = agent.get("http://movies.netflix.com/WiAltGenre?agid=#{n}")
rescue
retry
end
genre = netflix_page.at('#page-title a').content
puts "netflix genre #{n} is #{genre}"
File.open("netflix_genres.txt", 'a+') {|f| f.write( n.to_s + "\t" + genre + "\n") }
n += 1
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_categories\n end",
"def getCat \n\t\tputs ''\n\t\tputs 'Fetching categories . . '\n\t\t@page.css('ul.dropdown li a').each do |cat|\n\t\t\tarr=[]\n\t\t\tarr.push cat.text\n\t\t\tarr.push cat['href']\n\t\t\t@arr_cat.push arr\n\t\t\tprint '. '\n\t\tend\n\t\ti=0\n\t\t@arr_cat.each do |pair|\n\t\t\t@db.... | [
"0.75364083",
"0.74237156",
"0.7383356",
"0.7380479",
"0.7278801",
"0.7250232",
"0.72409475",
"0.7212749",
"0.71934557",
"0.7162126",
"0.71421844",
"0.71377134",
"0.713608",
"0.7124563",
"0.7123774",
"0.7109032",
"0.71061707",
"0.7100659",
"0.7082445",
"0.70720947",
"0.706161... | 0.0 | -1 |
A grid is an array of strings of the same length. | def contains?(primary_grid, match_grid)
match_columns = match_grid.first.length
columns_start = 0
columns_end = columns_start + match_columns - 1
while columns_end < primary_grid.first.length
match_row = 0
primary_grid.each do |primary_row|
primary_slice = primary_row[columns_start..columns_end]
if match_grid[match_row] == primary_slice
match_row += 1
return true if match_row == match_grid.length
end
end
columns_start += 1; columns_end += 1
end
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def represent\n # grid_array will be an array of strings that represent our grid in NxN format\n grid_array=[]\n @h.times{|r| grid_array<<@grid[r*@w,@w].split('')*' '}\n grid_array\n end",
"def generate_grid(board_string) current_grid = Array.new(3, Array.new(3) {\n[\"-\", \"X\"].sample })\n\n pa... | [
"0.75681096",
"0.73180944",
"0.7195355",
"0.7185599",
"0.716091",
"0.70886123",
"0.6943909",
"0.6879295",
"0.68670136",
"0.68433887",
"0.68394244",
"0.6834553",
"0.6834553",
"0.6834553",
"0.6831662",
"0.6782814",
"0.6760092",
"0.6729129",
"0.6725157",
"0.6689592",
"0.6637142"... | 0.0 | -1 |
Ask for console input | def ask_email
ask("email: ") do |q|
q.validate = email_regex
q.responses[:not_valid] = "<%= color('Email is not well formed', :red) %>"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ask(prompt)\n print \"#{prompt}: \"\n $stdin.gets.chomp\n end",
"def ask! message\n print message\n\n STDIN.noecho(&:gets).chomp\n end",
"def ask(question)\n $stdout.puts(question)\n $stdout.print('> ')\n $stdin.gets.chomp\nend",
"def ask message\nprint message\nSTDIN.g... | [
"0.79328054",
"0.7661773",
"0.7639628",
"0.7618524",
"0.7577425",
"0.75392205",
"0.75392205",
"0.75392205",
"0.75325274",
"0.75311637",
"0.75066763",
"0.75020677",
"0.7490132",
"0.7476396",
"0.7474276",
"0.74663484",
"0.7456068",
"0.7415048",
"0.74067724",
"0.7382679",
"0.734... | 0.0 | -1 |
The HEB Monograph handles logic will only be triggered in this nightlyrun job. See HELIO3879. Creation will happen nightly but deletion will be delayed for 30 days (see explanatory text atop, also comment... "Force delete action for all untouched records older than 30 days ago"). But deletion is very rare, and the delay probably won't be noticed anyway (e.g. HELIO4375). | def required_heb_monograph_handles
docs = ActiveFedora::SolrService.query(
"+(has_model_ssim:Monograph AND +press_sim:heb)",
fl: %w[id identifier_tesim],
rows: 100_000
) || []
heb_monograph_handles = {}
docs.each do |doc|
heb_monograph_handles.merge!(HebHandleService.new(doc).handles)
end
heb_monograph_handles
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_job\r\n# disable recycle invites\r\n# min = Time.now.min\r\n# #recycle invites 1 min per hour\r\n# if min == 0\r\n# ret = ActiveRecord::Base.connection.execute(\"delete from invites where invitee_id is null and created_at < subdate(now(), interval 3 day)\")\r\n# puts \"recycle invites: #{... | [
"0.64938843",
"0.595813",
"0.5858434",
"0.58553326",
"0.58520097",
"0.58130926",
"0.5800218",
"0.5800218",
"0.57443243",
"0.5724209",
"0.5719253",
"0.56527376",
"0.5636798",
"0.5629561",
"0.5612371",
"0.5609283",
"0.5564916",
"0.5564367",
"0.55305815",
"0.55104107",
"0.550913... | 0.0 | -1 |
Afficher les questions d'un groupe | def questionsDuGroupe(id_groupe)
# array contient la liste des questions
questions = Array.new
# récupérer la liste des id_question
# et traiter chaque id_question
Groupe.where(etat: false, id_groupe: id_groupe).order('id_question ASC').find_each do |id_question|
questions << QuestionService.instance.afficherQuestionParId(id_question.id_question)
end
questionsDuGroupe = questions
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def questions_for_group group\n questions.select{|question|question.meta_attribute_entity_group==group}\n end",
"def questions\n result = []\n 1.upto(@@max_questions) { |i| result << question(i) }\n result.select { |q| !q.empty? }\n end",
"def questions\n CopQuestion.find(attributes.collec... | [
"0.7275077",
"0.6548555",
"0.6504973",
"0.64411813",
"0.6392301",
"0.63912845",
"0.636715",
"0.62458366",
"0.6151563",
"0.6128301",
"0.60489666",
"0.60378087",
"0.60363066",
"0.6020423",
"0.59985375",
"0.5987396",
"0.5986018",
"0.59605867",
"0.5915664",
"0.59091413",
"0.59073... | 0.65541124 | 1 |
Ajouter une question dans un groupe | def ajouterQuestion(id_groupe, id_question)
ajout = Groupe.new(:id_groupe => id_groupe, :id_question => id_question)
if ajout.save
newAjout = ajout
else
newAjout = nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def creerGroupeQuestion(intitule, estObligatoire, ordre, sondage_id)\n\n question = GroupeQuestion.new(:intitule => intitule,\n :estObligatoire => estObligatoire,\n :ordre => ordre,\n :sondag... | [
"0.7217891",
"0.67281145",
"0.6383716",
"0.63834506",
"0.6374994",
"0.63471013",
"0.6322276",
"0.62217444",
"0.614613",
"0.61414456",
"0.6126904",
"0.6113496",
"0.6102803",
"0.60581994",
"0.6028857",
"0.6021571",
"0.6011687",
"0.60025483",
"0.5998305",
"0.59639186",
"0.593027... | 0.7456876 | 0 |
Supprimer un groupe par ID | def supprimerGroupe(id_groupe)
Groupe.where(id_groupe: id_groupe).update_all(etat: true)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n GroupeService.instance.supprimerGroupe(params[:id_groupe])\n end",
"def remove_group(id)\n delete(\"/groups/#{id}\")\n end",
"def delete_group(id)\n delete(\"groups/#{id}\")\n end",
"def remove_group(group)\n self.groups.destroy group \n end",
"def delete_group(... | [
"0.7499474",
"0.71117306",
"0.69427186",
"0.6899415",
"0.68192655",
"0.68192655",
"0.67832696",
"0.6779284",
"0.6681436",
"0.66350394",
"0.657079",
"0.6512336",
"0.6509844",
"0.6506609",
"0.6445213",
"0.6424352",
"0.6411366",
"0.64034",
"0.63952214",
"0.637327",
"0.6369903",
... | 0.7442571 | 1 |
GET /orders GET /orders.json | def index
#@orders = Order.all
#.order(:day, :shop_id, :product_id)
@orders = Order.find_by_sql ["
SELECT o.id , o.day, o.quantity, o.shop_id, o.locked, o.product_id, o.user_id, p.title as product_title, s.name as shop_name, u.name as user_name
FROM orders AS o
INNER JOIN products AS p ON p.id = o.product_id
INNER JOIN shops AS s ON s.id = o.shop_id
INNER JOIN users AS u ON u.id = o.user_id
ORDER BY o.day, s.name, p.title
"]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getorders(args={})\n {\n :method=> \"GetOrders\"\n }.to_json\n end",
"def orders\n params = { command: 'account_orders' }\n get('/json.php', params)\n end",
"def index\n @orders = Order.all\n render json: @orders\n end",
"def index\n @orders = Order.all\n ... | [
"0.83267236",
"0.815406",
"0.80041754",
"0.7947603",
"0.7846487",
"0.7823147",
"0.78028905",
"0.76992875",
"0.76980406",
"0.7682792",
"0.7682792",
"0.7682792",
"0.7682792",
"0.76827645",
"0.75880665",
"0.7574349",
"0.756171",
"0.7531827",
"0.74860185",
"0.7432208",
"0.7369724... | 0.0 | -1 |
GET /orders/1 GET /orders/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getorders(args={})\n {\n :method=> \"GetOrders\"\n }.to_json\n end",
"def index\n @orders = Order.all\n render json: @orders\n end",
"def index\n @orders = Order.all\n render json: @orders, status: 200\n end",
"def index\n @orders = Order.order(\"id\").all\n\n resp... | [
"0.7554187",
"0.7488565",
"0.7475228",
"0.73777765",
"0.73714006",
"0.7341344",
"0.73384553",
"0.73168725",
"0.73018956",
"0.7291244",
"0.7291244",
"0.7291244",
"0.7291244",
"0.72911215",
"0.7281374",
"0.7266143",
"0.72498786",
"0.7228276",
"0.7213504",
"0.71842283",
"0.71261... | 0.0 | -1 |
POST /orders POST /orders.json | def create
@order = Order.new(order_params)
@order.locked = false
#logger.debug "@order - passed in: " + @order.inspect
# now create the order log record
@log = Orderlog.new
@log.day = @order.day
@log.user_id = @order.user_id
@log.shop_id = @order.shop_id
@log.product_id = @order.product_id
@log.quantity = @order.quantity
@log.oldquantity = 0
#logger.debug "logging record: " + @log.inspect
respond_to do |format|
if @order.save
@log.save
format.html { redirect_to @order, notice: 'Order was successfully created.' }
format.json { render :show, status: :created, location: @order }
else
format.html { render :new }
format.json { render json: @order.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def orders\n authenticated_post(\"orders\").body\n end",
"def orders\n authenticated_post(\"auth/r/orders\").body\n end",
"def create\n order = Order.create(order_params)\n render json: order\nend",
"def submit_order()\n\tputs \"Submitting order\"\n\tdata = create_order()\n\tresponse = ... | [
"0.75886714",
"0.7490972",
"0.7488501",
"0.74664384",
"0.72739846",
"0.7195349",
"0.7063682",
"0.69745994",
"0.6910657",
"0.68880194",
"0.68747663",
"0.685004",
"0.6840204",
"0.6838178",
"0.6838178",
"0.6838178",
"0.6838178",
"0.682244",
"0.6790037",
"0.67793274",
"0.6779247"... | 0.0 | -1 |
PATCH/PUT /orders/1 PATCH/PUT /orders/1.json | def update
#logger.debug "controller orders update called"
#logger.debug "@order-1=" + @order.inspect
# now create the order log record
@log = Orderlog.new
@log.oldquantity = @order.quantity
#@order.quantity = params[:quantity]
#logger.debug "@order-2=" + @order.inspect
respond_to do |format|
if @order.update(order_params)
#logger.debug "@order - after update: " + @order.inspect
@log.day = @order.day
@log.user_id = @order.user_id
@log.shop_id = @order.shop_id
@log.product_id = @order.product_id
@log.quantity = @order.quantity
#logger.debug "logging record: " + @log.inspect
@log.save
#logger.debug "Order controller - successful update"
format.html { redirect_to @order, notice: 'Order was successfully updated.' }
format.js
format.json { render :show, status: :ok, location: @order }
else
#logger.debug "Order controller - failed update"
format.html { render :edit }
format.json { render json: @order.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @order = Order.find(params[:id])\n\n if @order.update(order_params)\n head :no_content\n else\n render json: @order.errors, status: :unprocessable_entity\n end\n end",
"def update\n @order = Order.find(params[:id])\n\n if @order.update(order_params)\n head :no_conte... | [
"0.680141",
"0.680141",
"0.677323",
"0.674207",
"0.67339766",
"0.6725478",
"0.67218167",
"0.6717983",
"0.6703257",
"0.6703184",
"0.6703184",
"0.6703184",
"0.6703184",
"0.6703184",
"0.6703184",
"0.6703184",
"0.6703184",
"0.6703184",
"0.6703184",
"0.6703184",
"0.6703184",
"0.... | 0.0 | -1 |
DELETE /orders/1 DELETE /orders/1.json | def destroy
#logger.debug "@order: " + @order.inspect
# now create the order log record
@log = Orderlog.new
@log.day = @order.day
@log.user_id = @order.user_id
@log.shop_id = @order.shop_id
@log.product_id = @order.product_id
@log.quantity = 0
@log.oldquantity = @order.quantity
#logger.debug "logging record: " + @log.inspect
@order.destroy
@log.save
#logger.debug "logging record after save: " + @log.inspect
respond_to do |format|
format.html { redirect_to orders_url, notice: 'Order was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @v1_order = V1::Order.find(params[:id])\n @v1_order.destroy\n\n head :no_content\n end",
"def destroy\n @order1 = Order1.find(params[:id])\n @order1.destroy\n\n respond_to do |format|\n format.html { redirect_to order1s_url }\n format.json { head :no_content }\n end\... | [
"0.7592003",
"0.7475092",
"0.74298924",
"0.7371978",
"0.7371411",
"0.7371187",
"0.7357556",
"0.7357556",
"0.7357556",
"0.7357556",
"0.7357556",
"0.7347606",
"0.7347606",
"0.7347606",
"0.7347606",
"0.7347606",
"0.7347606",
"0.7347606",
"0.7347606",
"0.7347606",
"0.7347606",
... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_order
@order = Order.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def order_params
#params.require(:id).permit(:product_id, :shop_id, :day, :quantity, :locked, :user_id)
params.require(:order).permit(:product_id, :shop_id, :day, :quantity, :locked, :user_id, :origqty, :cost)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
usign job:nil for stability & latter flexibity Idea being you could also have string:nil then you could initialized with Job objects in the jobs: or you could initialized with String objects in the string: | def initialize(string:nil)
@jobs = string
@jobs_parsed = OTB::Job.parse(@jobs) unless string.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(name, job)\n @name = name\n @job = job\n end",
"def initialize (name, age, job ='unemployed') # takes 3 parameters, job is optional.\n @name = name\n @age = age\n @job =job\n end",
"def initialize(job_name, job_aliases, salary_min, salary_average, salary_high, growing, long_term... | [
"0.68915486",
"0.6791952",
"0.6577363",
"0.64828354",
"0.6461464",
"0.64406323",
"0.6399276",
"0.63581455",
"0.6337852",
"0.6337852",
"0.63084495",
"0.6140607",
"0.6135212",
"0.6097629",
"0.60847473",
"0.60809666",
"0.6064267",
"0.6056221",
"0.6056221",
"0.60490763",
"0.60310... | 0.80043733 | 0 |
Load specific language to cache | def load_cache(language)
# Initialize cache structures
if @o2t.nil?
@o2t = {}
end
if @t2o.nil?
@t2o = {}
end
# Fill cache if empty
if @o2t[language.to_sym].nil? || @t2o[language.to_sym].nil?
@o2t[language.to_sym] = {}
@t2o[language.to_sym] = {}
data = where(slug_language: language.to_s)
data.each do |item|
@o2t[language.to_sym][item.original] = item.translation
@t2o[language.to_sym][item.translation] = item.original
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load(*languages)\n languages.flatten!\n languages.each do |language|\n lang_file_without_ext = \"#{self.lang_file_dir}/#{language}\"\n @@cached_language_data[language.to_sym] = YAML.load_file \"#{lang_file_without_ext}.yml\"\n require lang_file_without_ext if ... | [
"0.7220044",
"0.70409656",
"0.6885864",
"0.68538046",
"0.67555726",
"0.6632781",
"0.64908415",
"0.64817804",
"0.6471598",
"0.63320243",
"0.6282711",
"0.61844844",
"0.61309946",
"0.6130973",
"0.6130973",
"0.61227345",
"0.6120102",
"0.6120102",
"0.61137843",
"0.6087319",
"0.608... | 0.78264606 | 0 |
Get translation according to original | def original_to_translation(language, original)
load_cache(language)
return @o2t[language.to_sym][original.to_s]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def translation\n @translation ||= name.underscore.split('/').last\n end",
"def translation_to_original(language, translation)\n\t\t\t\t\t\tload_cache(language)\n\t\t\t\t\t\treturn @t2o[language.to_sym][translation.to_s]\n\t\t\t\t\tend",
"def get_translation(lang_code)\n # format language co... | [
"0.7621674",
"0.73138934",
"0.7038398",
"0.70007414",
"0.697932",
"0.69433373",
"0.68824655",
"0.68474555",
"0.67479616",
"0.6698093",
"0.6693549",
"0.64930385",
"0.64924127",
"0.64858675",
"0.64834654",
"0.646951",
"0.6463442",
"0.64311826",
"0.6396601",
"0.638552",
"0.63748... | 0.7992376 | 0 |
Get original according to translation | def translation_to_original(language, translation)
load_cache(language)
return @t2o[language.to_sym][translation.to_s]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def original\n @original ||= @container[:translation].original\n end",
"def original_to_translation(language, original)\n\t\t\t\t\t\tload_cache(language)\n\t\t\t\t\t\treturn @o2t[language.to_sym][original.to_s]\n\t\t\t\t\tend",
"def translation\n @translation ||= name.underscore.split('/')... | [
"0.775714",
"0.77550256",
"0.6807759",
"0.6466747",
"0.6373057",
"0.62456024",
"0.62411755",
"0.61990017",
"0.61204076",
"0.60866076",
"0.60141844",
"0.59043497",
"0.5882516",
"0.58818597",
"0.5873915",
"0.5843681",
"0.5801326",
"0.5798161",
"0.5785757",
"0.57718116",
"0.5753... | 0.7630973 | 2 |
Add new slug or edit existing | def add_slug(language, original, translation)
# Do not process blank
return if translation.blank? || original.blank?
# Prepare
language = language.to_s
original = "/" + original.to_s.trim("/")
translation = "/" + translation.to_s.trim("/")
# Root is not slugged
return if original == "/"
# Try to find existing record
slug = where(slug_language: language, original: original).first
if slug.nil?
slug = new
end
# TODO duplicate translations
# Save
slug.slug_language = language
slug.original = original
slug.translation = translation
slug.save
# Clear cache
clear_cache
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def manage_slug\n \tself.slug = self.title.parameterize if self.slug.blank?\n end",
"def update_slug\n get_resource.slug = nil\n get_resource.save!\n end",
"def set_slug\n if self.slug.blank?\n self.slug = self.name.parameterize.downcase unless self.name.nil?\n end\n end",
"d... | [
"0.7258711",
"0.71464527",
"0.70905083",
"0.7040414",
"0.70278144",
"0.698844",
"0.6936673",
"0.6931931",
"0.68893427",
"0.68893427",
"0.68893427",
"0.68893427",
"0.6888744",
"0.6888744",
"0.6888744",
"0.6888744",
"0.68882155",
"0.68882155",
"0.68882155",
"0.68882155",
"0.688... | 0.0 | -1 |
Remove existing slug if exists | def remove_slug(language, original)
# Prepare
language = language.to_s
original = "/" + original.to_s.trim("/")
# Try to find existing record
slug = where(slug_language: language, original: original).first
if !slug.nil?
slug.destroy
end
# Clear cache
clear_cache
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_slug\n get_resource.slug = nil\n get_resource.save!\n end",
"def destroy_slugs\n\t\tif !RicWebsite.slug_model.nil?\n\t\t\turl = URL.gsub(/:id/, self.id.to_s)\n\t\t\ttmp_uri = URI.parse(url)\n\t\t\tI18n.available_locales.each do |locale|\n\t\t\t\tRicWebsite.slug_model.remove_slug(loc... | [
"0.7451814",
"0.73779196",
"0.72018963",
"0.7196395",
"0.70824486",
"0.70262897",
"0.67904955",
"0.67903167",
"0.65563184",
"0.65275866",
"0.6452006",
"0.6446165",
"0.6432961",
"0.6425639",
"0.6369761",
"0.6352674",
"0.6344469",
"0.6342424",
"0.6321874",
"0.63094157",
"0.6296... | 0.7249016 | 2 |
Compose translation from various models | def compose_translation(language, models)
# Convert to array
if !models.is_a? Array
models = [ models ]
end
# Result
result = ""
last_model = nil
last_model_is_category = false
models.each do |section_options|
# Input check
if !section_options.is_a? Hash
raise "Incorrect input, expecting hash with :label and :models or :model items."
end
if section_options[:models].nil? && !section_options[:model].nil?
section_options[:models] = [ section_options[:model] ]
end
if section_options[:models].nil? || section_options[:label].nil?
raise "Incorrect input, expecting hash with :label and :models or :model items."
end
# "Is category" option
last_model_is_category = section_options[:is_category] == true
section_options[:models].each do |model|
# Get part
if model.respond_to?("#{section_options[:label].to_s}_#{language.to_s}".to_sym)
part = model.send("#{section_options[:label].to_s}_#{language.to_s}".to_sym)
elsif model.respond_to?(section_options[:label].to_sym)
part = model.send(section_options[:label].to_sym)
else
part = nil
end
# Add part to result
result += "/" + part.to_url if part
# Save last model
last_model = model
end
end
# Truncate correctly
if !result.blank?
if last_model_is_category || (last_model.hierarchically_ordered? && !last_model.leaf?)
result += "/"
else
#result += ".html"
result += ""
end
end
return result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def models_to_translate\n Utility.models_to_translate\n end",
"def translations; end",
"def text(attr = nil, model = nil)\n keys = i18n_keys(attr, model) << self.underscore.humanize\n ::I18n.translate(keys.shift, default: keys)\n end",
"def translatable\n self._translatable[ba... | [
"0.73439544",
"0.6662369",
"0.64300275",
"0.6395035",
"0.6286546",
"0.6163534",
"0.614237",
"0.6093848",
"0.6082305",
"0.6044923",
"0.60375524",
"0.59774315",
"0.5967678",
"0.59590334",
"0.59590334",
"0.59505606",
"0.59482014",
"0.59399325",
"0.5922556",
"0.5902353",
"0.58890... | 0.69968134 | 1 |
Initialize the Dog attributes. | def initialize(breed, name, age)
@breed = breed
@name = name
@age = age
@hungry = true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(n, h, w, a)\n # defines instance variables upon creation of new object\n # ties specific and individual data to created object (state)\n @name = n\n @height = h\n @weight = w\n\n # increment number of dogs each time new GoodDog object is initialized\n @@number_of_dogs += 1\n ... | [
"0.6734019",
"0.6719518",
"0.6589164",
"0.63769174",
"0.63225883",
"0.62410367",
"0.62269115",
"0.6217642",
"0.615711",
"0.61048836",
"0.61048836",
"0.60885686",
"0.60598767",
"0.6052348",
"0.60516465",
"0.60383266",
"0.60383266",
"0.60383266",
"0.60383266",
"0.60383266",
"0.... | 0.59381133 | 28 |
Method to print string to console. | def bark
p "woof!"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def puts(string)\n self.print(string + \"\\n\")\n end",
"def puts(string)\n self.print(string + \"\\n\")\n end",
"def print(string, options = {})\n return if silent?\n (options[:output] || output).print self.format(string, options)\n end",
"def print(string)\n terminator = @... | [
"0.7844842",
"0.7844842",
"0.7765489",
"0.77622026",
"0.7760136",
"0.77180225",
"0.7435048",
"0.7435048",
"0.7399574",
"0.7349644",
"0.731754",
"0.7302886",
"0.7286801",
"0.7259135",
"0.7225028",
"0.7215083",
"0.720573",
"0.72005224",
"0.71743655",
"0.71658933",
"0.7162368",
... | 0.0 | -1 |
Method to change hungry status to false. | def eat
@hungry = false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_hungry\n if @hungry\n @hungry = false\n else\n @hungry = true\n end\n end",
"def hungry? \n\ttrue\nend",
"def unmarkHelpful\n update_attribute(:isHelpful, false)\n end",
"def hungry? ## a ? means answer is true or false\n @stuff_in_belly <= 2\n end... | [
"0.7496837",
"0.64251345",
"0.6379201",
"0.6310043",
"0.6281188",
"0.6228535",
"0.62161046",
"0.6138384",
"0.6136161",
"0.61314136",
"0.6128757",
"0.6128757",
"0.61231065",
"0.6113654",
"0.6109423",
"0.60734636",
"0.6039763",
"0.60273236",
"0.60208774",
"0.6007131",
"0.599313... | 0.64501697 | 3 |
Puts string interpolation to the console. Change hungry status to true. | def play
puts "#{name} got zoomies playing fetch!"
@hungry = true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_bad( str = '' )\n push_to_output_buffer( bad: str )\n end",
"def say_notice(string)\n HighLine.new.say(\"\\n<%= color('#{string}', :notice ) %>\\n\")\n end",
"def hammer\n\t\tputs \"A nice gentle bangabang\"\n\tend",
"def puts_warning(msg)\n $stdout.puts \"\\e[33m[WARNING] #{msg}... | [
"0.60926944",
"0.5999223",
"0.5989601",
"0.58666414",
"0.5862775",
"0.5852423",
"0.5838926",
"0.582652",
"0.580845",
"0.5796732",
"0.5735637",
"0.5734467",
"0.5673967",
"0.56637955",
"0.5662137",
"0.5660607",
"0.56537414",
"0.564159",
"0.5640629",
"0.56206787",
"0.5613014",
... | 0.0 | -1 |
If a red flagged applicant submits an application send a different email to the admin | def applicant_redflag_notice(applicant, application)
@applicant = applicant
@application = application
@url = url_for(action: 'edit', controller: 'applicants', id: @applicant.id)
mail(:to => 'mcnaughtonbr@tamu.edu', :subject => "Red flagged application notice.")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fingering_submitted_email(fingering, admin)\n @fingering = fingering\n mail(:to => admin.email, :subject => \"Fingering Submitted for Approval\", :from => 'bassoonfingeringfinder@gmail.com') \n end",
"def accepted_application_moderator(vacancy, user)\n @greeting = \"Hi\"\n\n mail to: \"to@examp... | [
"0.7291806",
"0.6993457",
"0.69416875",
"0.69183934",
"0.6864638",
"0.6835611",
"0.6786247",
"0.6748906",
"0.67192394",
"0.6716841",
"0.671663",
"0.6707631",
"0.6679506",
"0.6635636",
"0.66257524",
"0.6612059",
"0.6596363",
"0.6577459",
"0.65582746",
"0.65551895",
"0.65526956... | 0.7340434 | 0 |
returns true if the input user is the logged in user | def current_user?(user)
user == current_user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_login\n p session[:user]\n session[:user] ? true : false\n end",
"def user_is_logged_in()\n user = get_user()\n if user != nil\n true\n else\n false\n end\n end",
"def logged_in?\r\n current_user != :false\r\n end",
"def logged_in?\n current_user != :false \... | [
"0.8225512",
"0.81583476",
"0.81425613",
"0.81336933",
"0.80639493",
"0.80639493",
"0.80620027",
"0.80439603",
"0.80308163",
"0.802216",
"0.8010313",
"0.8004485",
"0.7994573",
"0.79865617",
"0.79781747",
"0.7962208",
"0.7962071",
"0.79531753",
"0.7947438",
"0.79374486",
"0.79... | 0.0 | -1 |
sets the input user to the current user | def current_user=(user)
@current_user = user
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_username \n puts \"What would you like your new username to be?\"\n set_username = gets.strip\n @username = set_username \n end",
"def ask_user\n\tprint \"User: \".blue\n\tgets.chomp\nend",
"def set_User(value)\n set_input(\"User\", value)\n end",
"def set_User(value)\n s... | [
"0.7674143",
"0.74649525",
"0.7405382",
"0.7405382",
"0.7405382",
"0.7405382",
"0.7405382",
"0.7405382",
"0.7405382",
"0.740401",
"0.73569006",
"0.7050058",
"0.6976373",
"0.69560105",
"0.693233",
"0.693233",
"0.6931449",
"0.6931449",
"0.6931449",
"0.6931449",
"0.6931449",
"... | 0.0 | -1 |
returns true if a user is logged in | def signed_in?
!current_user.nil?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_is_logged_in()\n user = get_user()\n if user != nil\n true\n else\n false\n end\n end",
"def logged_in?\n if session[:username]\n if session[:logged_in?]\n return true\n end\n else\n return false\n end\n end",
"def logged_in?()\n ... | [
"0.89205736",
"0.8635109",
"0.863374",
"0.8629122",
"0.857624",
"0.8545388",
"0.85214454",
"0.84986156",
"0.84981257",
"0.8482375",
"0.84794533",
"0.84558797",
"0.84446543",
"0.8431595",
"0.8416256",
"0.8406445",
"0.8387217",
"0.83766806",
"0.83766806",
"0.8374858",
"0.836182... | 0.0 | -1 |
if the current user local var is nil, set it to the user from the cookie | def current_user
@current_user ||= user_from_remember_token
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_current_user\n if params[:user].blank?\n self.my_current_user = nil\n else\n self.my_current_user = User.find params[:user]\n end\n end",
"def set_and_cookie_current_user(user_x)\n user = User === user_x ? user_x : User.find(user_x)\n unless user.nil? || current_user_id == user... | [
"0.7776214",
"0.77337086",
"0.76763004",
"0.76703054",
"0.7629263",
"0.76033396",
"0.7597294",
"0.75755215",
"0.7503996",
"0.74932",
"0.7462392",
"0.7462392",
"0.74542296",
"0.7432432",
"0.74224484",
"0.74111885",
"0.7407179",
"0.73901606",
"0.73706746",
"0.73679954",
"0.7367... | 0.0 | -1 |
ideally aliases would work, but haven't found a nice way to do this | def resolve_source(source)
if source
source = source.dup
source.gsub!(/\$\([^)]+\)/) do |m|
command = m[2..-2]
result = `#{command}`.chomp
unless $?.success?
raise Error, "Command exited with non-zero status:\n#{command}"
end
result
end
end
source
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aliases; end",
"def aliases; end",
"def aliases; end",
"def aliases\n end",
"def aliases\n\n end",
"def alias_names; end",
"def aliased_name; end",
"def alias_of; end",
"def aliases=(_arg0); end",
"def aliases=(_arg0); end",
"def alias_decls; end",
"def aliases\n short ? [nam... | [
"0.8083162",
"0.8083162",
"0.8083162",
"0.7858903",
"0.7748054",
"0.76469606",
"0.7588528",
"0.7415445",
"0.73539555",
"0.73539555",
"0.71337426",
"0.6789279",
"0.6783948",
"0.6780584",
"0.6760527",
"0.6668448",
"0.6656706",
"0.6626133",
"0.6626133",
"0.6529682",
"0.65285367"... | 0.0 | -1 |
The type name for the resource. Default: Model name | def type(type = nil)
@type = type if type
@type || name.split('::').last.gsub(/Resource$/, '').underscore
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def type_name\n @type_name ||= self.name.demodulize.underscore\n end",
"def name\n @type_name\n end",
"def type_name\n @type_name ||= name.underscore\n end",
"def type_as_class(resource_name)\n\t resource_name.singularize.capitalize.constantize\n\tend",
"def t... | [
"0.8165499",
"0.8047494",
"0.8041097",
"0.78091365",
"0.77269363",
"0.7620768",
"0.76043105",
"0.7587855",
"0.7560727",
"0.7550481",
"0.7512654",
"0.7501224",
"0.74956226",
"0.74936485",
"0.74790037",
"0.7447961",
"0.74020857",
"0.7387184",
"0.73809457",
"0.7376896",
"0.73768... | 0.7666632 | 5 |
All the attributes in the resource | def attributes
@attributes ||= []
@attributes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resource_attributes\n resource_class.attribute_names\n end",
"def attributes\n end",
"def attributes\n @attrs\n end",
"def attributes\n @attributes\n end",
"def attributes\n @attributes\n end",
"def attributes\n @attributes\n end",
"def attribu... | [
"0.78184205",
"0.7764755",
"0.7719371",
"0.77141166",
"0.77141166",
"0.77141166",
"0.76789016",
"0.76669914",
"0.7636348",
"0.75956076",
"0.7588377",
"0.7580243",
"0.7563236",
"0.7550473",
"0.75436085",
"0.7540968",
"0.7484748",
"0.7484748",
"0.7484748",
"0.7484748",
"0.74847... | 0.75115114 | 16 |
Get the ID for the resource | def id
model.id.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resource_id\n send self.class.resource_id\n end",
"def resource_id\n return \"%s:%s\" % [self.resource_type, self.id]\n end",
"def resource_id\n return @resource_id\n end",
"def resource_id\n return @resource_id\n end",
"def re... | [
"0.8098129",
"0.80048484",
"0.8002866",
"0.8002866",
"0.8002866",
"0.78488564",
"0.781859",
"0.7757811",
"0.7603257",
"0.7575092",
"0.7405807",
"0.7367097",
"0.7357759",
"0.73455775",
"0.73147136",
"0.72926986",
"0.72566926",
"0.72566926",
"0.7253308",
"0.71887213",
"0.717831... | 0.0 | -1 |
Generate the JSON representation for this resource | def as_json
{}.tap do |root|
root[:id] = id
root[:type] = self.class.type
root[:attributes] = generate_attributes
root[:relationships] = generate_relationships
root[:meta] = generate_metadata
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def jsonize\n {id: self.id, title: self.title, start: self.start_date.strftime('%a %b %d %Y'), end: self.end_date.strftime('%a %b %d %Y'), resource: self.resource_id}\n end",
"def serialize\n JSON.generate(to_h)\n end",
"def to_json\n {\n :json_class => self.class.name,\n :... | [
"0.7651315",
"0.76037616",
"0.7583205",
"0.74851483",
"0.7471651",
"0.7441242",
"0.7379346",
"0.7308986",
"0.72412926",
"0.7200907",
"0.71869206",
"0.712916",
"0.7093659",
"0.70571715",
"0.70108026",
"0.7009569",
"0.7003407",
"0.7002228",
"0.69981456",
"0.69666666",
"0.695858... | 0.71071285 | 12 |
generate expired tokens from user id | def expired_token_generator(user_id)
JsonWebToken.encode({ user_id: user_id }, (Time.now.to_i - 10))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expired_token_generator(user_id)\n\t\tJsonWebToken.encode({ user_id: user_id}, (Time.now.to_i - 10 ))\n\tend",
"def expired_token_generator(user_id)\r\n if user_id != nil\r\n payload = Hash.new\r\n payload[:user_id] = user_id\r\n payload[:exp] = Time.now.to_i - 10\r\n salt_record = Salt.wh... | [
"0.86873484",
"0.84291667",
"0.840066",
"0.7796036",
"0.7522103",
"0.75044173",
"0.72226906",
"0.7109757",
"0.69718075",
"0.68873227",
"0.6862954",
"0.6783817",
"0.6740139",
"0.6729548",
"0.67234117",
"0.6647099",
"0.6618268",
"0.66008544",
"0.65021735",
"0.64937264",
"0.6478... | 0.8703819 | 2 |
Class Methods Instance Methods | def %(arg)
unless arg._isArray
arg = [ arg ]
end
sprintf(self, *arg)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def instance; end",
"def instance; end",
"def instance; end",
"def methods() end",
"def class() end",
"def methods; end",
"def methods; end",
"def methods; end",
"def methods; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def method; end",
"def metho... | [
"0.7326875",
"0.7326875",
"0.7326875",
"0.7237883",
"0.719738",
"0.69158345",
"0.69158345",
"0.69158345",
"0.69158345",
"0.6762435",
"0.6762435",
"0.6762435",
"0.6762435",
"0.6762435",
"0.6762435",
"0.6762435",
"0.6762435",
"0.6762435",
"0.6762435",
"0.6762435",
"0.6762435",
... | 0.0 | -1 |
=== same as == for String | def __prim_equal_failed(other)
# invoked from Smalltalk code in _rubyEqual<env>:
if other.respond_to? :to_str
other == self # per specs
else
false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ==(other)\n str == other\n end",
"def == other\n\t\tstring == other.string\n\tend",
"def == other\n string == other.string\n end",
"def ==(string)\n @data == string\n end",
"def==(other)\n to_s==other.to_s\n end",
"def==(other)\r\n to_s==other.to_s\r\n end",
"def =... | [
"0.8275757",
"0.8155822",
"0.8102017",
"0.7838366",
"0.7732404",
"0.7710618",
"0.76914907",
"0.76787007",
"0.7641789",
"0.7633395",
"0.7495316",
"0.7452731",
"0.74111176",
"0.7404054",
"0.7396703",
"0.7396703",
"0.7396703",
"0.7396703",
"0.7396703",
"0.73863775",
"0.731824",
... | 0.0 | -1 |
str =~ obj => fixnum or nil MatchIf obj is a Regexp, use it as a pattern to match against str,and returns the position the match starts, or nil if there is no match. Otherwise, invokes obj.=~, passing str as an argument. The default =~ in Object returns false. "cat o' 9 tails" =~ /\d/ => 7 "cat o' 9 tails" =~ 9 => false | def =~(*args, &block)
# only one-arg call supported. any other invocation
# will have a bridge method interposed which would
# require different args to __storeRubyVcGlobal
raise ArgumentError, 'expected 1 arg'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def =~(str)\n str = str.to_s if str.is_a?(Symbol)\n # unless str.nil? because it's nil and only nil, not false.\n str = StringValue(str) unless str.nil?\n\n match = match_from(str, 0)\n if match\n Regexp.last_match = match\n return match.begin(0)\n else\n Regexp.last_match = nil\n ... | [
"0.7423942",
"0.6619238",
"0.6391546",
"0.633597",
"0.6231026",
"0.6231026",
"0.6231026",
"0.6231026",
"0.6231026",
"0.6231026",
"0.6231026",
"0.6231026",
"0.6231026",
"0.6231026",
"0.6231026",
"0.6231026",
"0.6231026",
"0.62130713",
"0.6131345",
"0.6101253",
"0.6079557",
"... | 0.0 | -1 |
Smalltalk code handles Regexp and String first args | def __prim_at_put_failed(index, value)
# called from Smalltalk
if value._isFixnum || value._isString
# ok
else
value = Maglev::Type.__coerce_to_String_to_str( value )
val_coerced = true
end
if index._isFixnum
unless val_coerced._equal?(true)
raise IndexError, ('String#[index]=, ' + " index #{index} out of range")
end
self.__at_put(index, value)
elsif index._isRange
arr = index.__beg_len(self.__size)
if arr._equal?(nil)
raise IndexError, ('String#[range]=' + "start out of range for range=#{index}")
else
self.__at_length_put( arr[0] , arr[1], value)
end
else
index = Maglev::Type.coerce_to(index, Fixnum, :to_int)
self.__at_put(index, value)
end
# taint if value.tainted?
value
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def regexp=(_arg0); end",
"def match(regexp); end",
"def regexp; end",
"def regexp; end",
"def submatcher; end",
"def submatcher; end",
"def re; end",
"def monocle(inputString)\n\toptic = Regexp.new(inputString)\n\treturn optic\nend",
"def pre_match() end",
"def match(pattern); end",
"def fnmat... | [
"0.7827348",
"0.7257123",
"0.72378945",
"0.72378945",
"0.6913805",
"0.6913805",
"0.6889863",
"0.6877748",
"0.68216735",
"0.68101835",
"0.65359694",
"0.64933157",
"0.6463031",
"0.6416083",
"0.6404527",
"0.6398813",
"0.63781536",
"0.63781536",
"0.63781536",
"0.63527495",
"0.635... | 0.0 | -1 |
smalltalk code handles Regexp and Fixnum first args | def __prim_at_length_put_failed(index, count, value)
index = Maglev::Type.coerce_to(index, Fixnum, :to_int)
str_value = Maglev::Type.coerce_to(value, String, :to_str)
count = Maglev::Type.coerce_to(count, Fixnum, :to_int)
self.__at_length_put(idx, count, str_value)
# no taint logic
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def regexp=(_arg0); end",
"def regexp; end",
"def regexp; end",
"def re; end",
"def submatcher; end",
"def submatcher; end",
"def match(regexp); end",
"def match(p0) end",
"def match(p0) end",
"def match(pattern); end",
"def regexps; end",
"def pre_match() end",
"def pattern=(_arg0); end",
... | [
"0.7470194",
"0.68646634",
"0.68646634",
"0.6668845",
"0.6616207",
"0.6616207",
"0.6606355",
"0.65522754",
"0.65522754",
"0.6449009",
"0.6370623",
"0.630572",
"0.6305549",
"0.62565506",
"0.6233439",
"0.6233439",
"0.6233439",
"0.62261236",
"0.61985683",
"0.61447895",
"0.610436... | 0.0 | -1 |
str.chomp(separator=$/) => new_str Returns a new String with the given record separator removed from the end of str (if present). If $/ has not been changed from the default Ruby record separator, then chomp also removes carriage return characters (that is it will remove \n, \r, and \r\n). "hello".chomp => "hello" "hello\n".chomp => "hello" "hello\r\n".chomp => "hello" "hello\n\r".chomp => "hello\n" "hello\r".chomp => "hello" "hello \n there".chomp => "hello \n there" "hello".chomp("llo") => "he" | def chomp(separator=$/)
str = self.dup
res = str.chomp!(separator)
if res._equal?(nil)
res = str
end
res
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chomp(sep=$/) end",
"def chomp(sep=$/) end",
"def chomp!(sep=$/) end",
"def chomp!(sep=$/) end",
"def chomp!(sep=$/)\n return nil if sep._equal?(nil)\n my_size = self.__size\n return nil if my_size._equal?(0)\n sep = Maglev::Type.coerce_to(sep, String, :to_str)\n if sep == \"\\n\"\n ... | [
"0.7076488",
"0.7076488",
"0.6998795",
"0.69980496",
"0.69645536",
"0.6461321",
"0.64035237",
"0.63719034",
"0.63140655",
"0.62710416",
"0.60972995",
"0.58730656",
"0.57427853",
"0.56804997",
"0.5610645",
"0.5404497",
"0.52505916",
"0.51835006",
"0.51598483",
"0.51429826",
"0... | 0.8066377 | 0 |
str.chomp!(separator=$/) => str or nil Modifies str in place as described for Stringchomp, returning str, or nil if no modifications were made. | def chomp!(sep=$/)
return nil if sep._equal?(nil)
my_size = self.__size
return nil if my_size._equal?(0)
sep = Maglev::Type.coerce_to(sep, String, :to_str)
if sep == "\n"
last_ch = self.__at(-1)
diminish_by = 0
if last_ch.eql?( ?\n )
diminish_by += 1 if self.__at(-2).eql?( ?\r ) && my_size > 1
elsif last_ch.not_eql?( ?\r )
return nil
end
diminish_by += 1
self.__size=(my_size - diminish_by)
else
separator_sz = sep.__size
if separator_sz._equal?(0)
sz = my_size
while sz > 0 && self.__at(sz-1).eql?( ?\n )
if sz > 1 && self.__at(sz-2).eql?( ?\r )
sz -= 2
else
sz -= 1
end
end
return nil if sz._equal?( my_size )
self.__size=(sz)
else
sep_size = separator_sz
sz = my_size
return nil if sep_size > sz
sep_size = -sep_size
while sep_size < 0
return nil if sep.__at(sep_size) != self.__at(sep_size)
sep_size += 1
end
self.__size=(sz - separator_sz)
end
end
self
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chomp(separator=$/)\n str = self.dup\n res = str.chomp!(separator)\n if res._equal?(nil)\n res = str\n end\n res\n end",
"def chomp!(sep=$/) end",
"def chomp!(sep=$/) end",
"def chomp(sep=$/) end",
"def chomp(sep=$/) end",
"def chomp(string)\n if string[-1] == \"\\n\"\n ... | [
"0.8138797",
"0.72024816",
"0.7201501",
"0.70295084",
"0.70295084",
"0.67060214",
"0.65903753",
"0.6304014",
"0.6302847",
"0.62924564",
"0.62126386",
"0.57850647",
"0.57812315",
"0.57512903",
"0.57169235",
"0.5580742",
"0.5569982",
"0.5568915",
"0.5549758",
"0.55388707",
"0.5... | 0.69573593 | 5 |
callseq: str.chop => new_str Returns a new String with the last character removed. If the string ends with \r\n, both characters are removed. Applying chop to an empty string returns an empty string. Stringchomp is often a safer alternative, as it leaves the string unchanged if it doesn't end in a record separator. "string\r\n".chop => "string" "string\n\r".chop => "string\n" "string\n".chop => "string" "string".chop => "strin" "x".chop.chop => "" | def chop
str = self.class.__withAll(self) # preserve species
str.chop!
str
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chop(word)\n word.chop\nend",
"def remove_char(s)\n s.chop.reverse.chop.reverse\nend",
"def chomp(string)\n if string[-1] == \"\\n\"\n string[-1] = \"\"\n end\n return string\nend",
"def chomp(string)\n i = 0\n if string[-1] == \"\\n\"\n string[-1] = \"\" \n end\n re... | [
"0.63612777",
"0.6348324",
"0.61242133",
"0.6008799",
"0.5965755",
"0.57164985",
"0.5643429",
"0.5611188",
"0.5498565",
"0.54839945",
"0.5445399",
"0.544255",
"0.5425214",
"0.5423867",
"0.54235893",
"0.5417673",
"0.5393549",
"0.5351272",
"0.5305635",
"0.5302661",
"0.5266549",... | 0.56566244 | 6 |
str.chop! => str or nil Processes str as for Stringchop, returning str, or nil if str is the empty string. See also Stringchomp!. | def chop!
my_size = self.__size
if my_size._not_equal?( 0 )
if self.__at(-1).eql?( ?\n )
if my_size > 1 && self.__at(-2).eql?( ?\r )
self.__size=(my_size - 2)
else
self.__size=(my_size - 1)
end
else
self.__size=(my_size - 1)
end
return self
end
return nil # no modification made
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_char(s)\n s.chop.reverse.chop.reverse\nend",
"def chop(word)\n word.chop\nend",
"def remove_punctuation(string)\n punctuation?(string) ? string.chop! : string\nend",
"def remove_char(s)\n s.length <= 1 ? s : s[1...-1]\nend",
"def strip(str,char)\r\n new_str = \"\"\r\n unless str.nil?\... | [
"0.6515163",
"0.65110874",
"0.60333955",
"0.5836406",
"0.58115846",
"0.5806418",
"0.57667917",
"0.5758878",
"0.57524824",
"0.574448",
"0.57319355",
"0.5591283",
"0.5550698",
"0.55285794",
"0.5526971",
"0.55044985",
"0.54954886",
"0.54804224",
"0.545076",
"0.54219955",
"0.5409... | 0.0 | -1 |
specialized version for invocation with block COPY TO ELSE BRANCH OF GENERIC VERSION ABOVE IF CHANGED | def gsub(regex, &block)
return StringGsubEnumerator.new(self, :gsub, regex) unless block
__gsub_perform_block_substitution(regex, &block)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_version!(path, &blk)\n raise NotImplementedError\n end",
"def cop=(_); end",
"def cop=(_); end",
"def cop; end",
"def cop; end",
"def version_helper=(_arg0); end",
"def version_helper=(_arg0); end",
"def version_helper=(_arg0); end",
"def copy\n \n end",
"def version=(_arg0); ... | [
"0.5823628",
"0.5620315",
"0.5620315",
"0.56076074",
"0.56076074",
"0.5584268",
"0.5584268",
"0.5584268",
"0.55237716",
"0.54847056",
"0.54847056",
"0.54847056",
"0.54847056",
"0.54847056",
"0.54686815",
"0.544331",
"0.54390705",
"0.54326004",
"0.54326004",
"0.5304204",
"0.52... | 0.0 | -1 |
Returns an array of [newvalue, modified], where modified is true if a substitution was performed. The old gsub! code tried to compare self == gsub(...) to see is a substitution was performed, but that returned incorrect results for something like "replace the last 's' with an 's'" (which breaks Rails routing...) ++ | def gsub(regex, replacement)
__gsub_perform_substitution(regex, replacement)[0]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gsubs(replacements)\n str = self.dup\n replacements.each do |r|\n str = str.gsub(r[0],r[1])\n end\n str\n end",
"def gsub(*)\n self\n end",
"def gsub!(*args, &block)\n str = self.gsub(*args, &block)\n if str != self\n self.replace(str)\n self\n else\n nil\n... | [
"0.6476149",
"0.63201123",
"0.6279621",
"0.61662436",
"0.6042714",
"0.6013513",
"0.6013513",
"0.6013513",
"0.59276825",
"0.5902055",
"0.5811332",
"0.5796079",
"0.5787157",
"0.5735204",
"0.5735204",
"0.5735204",
"0.5735204",
"0.5730806",
"0.5664857",
"0.5660725",
"0.5660725",
... | 0.5567848 | 22 |
added for 1.8.7 , Stringeach goes away in 1.9 | def ljust(width, padstr = " ") # from Rubinius
justified = dup
justified.justify(width, :left, padstr)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def schubert; end",
"def singular_siegler; end",
"def private; end",
"def anchored; end",
"def sitemaps; end",
"def hipsterfy(string)\r\n\r\nend",
"def probers; end",
"def greibach_normal_form\n raise NotImplementedError\n end",
"def autofinish; end",
"def specie; end",
"def specie; end",
... | [
"0.5971146",
"0.59521145",
"0.59093916",
"0.57362044",
"0.5726161",
"0.55935943",
"0.55676687",
"0.55483055",
"0.55401665",
"0.55140495",
"0.55140495",
"0.55140495",
"0.55140495",
"0.54874706",
"0.5479609",
"0.54355973",
"0.5430385",
"0.5413688",
"0.5389159",
"0.53516763",
"0... | 0.0 | -1 |
MNI: next MNI: next! | def oct
str = self.__zreplace_first_double_underscore.strip # for 1.8.7
arr = str.__extract_base(8)
base = arr.__at(0)
sign_str = arr.__at(1)
body = arr.__at(2)
first_ch = body.__at(0)
if first_ch.eql?( ?+ ) || first_ch.eql?( ?- )
return 0 # redundant sign character is not an octal digit
end
num = Integer.__from_string_radix(body, base)
if sign_str[0].eql?( ?- )
num = num * -1
end
num
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next\n connection.write(\"next\")\n end",
"def next\n connection.write(\"next\")\n end",
"def next\n @server\n end",
"def get_next\n\t\t\n\tend",
"def next_follow\n end",
"def next\n @next\n end",
"def next\n end",
"def next\n end",
"def next\n perf... | [
"0.639694",
"0.639694",
"0.6328317",
"0.61449033",
"0.6126309",
"0.6121066",
"0.6119127",
"0.6119127",
"0.59915715",
"0.5963757",
"0.5963757",
"0.5929512",
"0.5929512",
"0.5923148",
"0.58707815",
"0.5826547",
"0.5810596",
"0.5804796",
"0.5794639",
"0.5794639",
"0.57437193",
... | 0.0 | -1 |
Return the index of the last occurrence of the given substring, character or pattern in self. Returns nil if not found. If the second parameter is present, it specifies the position in the string to end the search characters beyond this point will not be considered. | def rindex(item, offset=MaglevUndefined, &block)
self.__index(item, offset, 0x50) # came here via a bridge from args*
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_last(search_s,target_s)\n last_position = search_s.rindex(target_s)\n if last_position == nil\n puts -1\n else\n return last_position\n end\nend",
"def last_index(str, char)\n return (str.length - 1) - str.reverse.index(char)\nend",
"def last_index(str, char)\n\tlength = str.length - 1\n \... | [
"0.68332297",
"0.6585525",
"0.6304688",
"0.6278386",
"0.6271256",
"0.6023274",
"0.60135293",
"0.59058046",
"0.58907956",
"0.5883715",
"0.5791484",
"0.57797855",
"0.577863",
"0.577863",
"0.5775619",
"0.5770493",
"0.5750116",
"0.5736995",
"0.5687855",
"0.56591004",
"0.56533706"... | 0.0 | -1 |
first arg is onebased offset, no coercion | def __split_string_on(delim, limit, limited, suppress_trailing_empty)
results = []
delim_length = delim.__size
count = start = current = 0
num = limited ? limit - 1 : 0
lim = self.__size
first_char = delim.__at(0)
while current < lim
if self.__at(current).eql?(first_char) and self.__at(current, delim_length).eql?(delim)
results << self.__at(start, (current - start))
count += 1
start = current + delim_length
current = start
break if limited and count == num
else
current += 1
end
end
results << self.__at(start, (lim-start)) unless limited and count > limit
if suppress_trailing_empty
while s = results.last and s.empty?
results.pop
end
end
results
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def offset(arg0)\n end",
"def offset(*) end",
"def call(offset = T.unsafe(nil)); end",
"def first_offset; end",
"def first_offset; end",
"def pos=(_arg0); end",
"def position=(_arg0); end",
"def offset; end",
"def offset; end",
"def offset; end",
"def normalize_offset(offset); end",
"def sta... | [
"0.76642984",
"0.73016787",
"0.7074324",
"0.6986695",
"0.6986695",
"0.67654014",
"0.6763986",
"0.6724811",
"0.6724811",
"0.6724811",
"0.6696912",
"0.6648523",
"0.66066843",
"0.6436581",
"0.6436581",
"0.6436581",
"0.6436581",
"0.63097274",
"0.62870026",
"0.62870026",
"0.628384... | 0.0 | -1 |
Skip contiguous whitespace starting at index and return the index of the first nonwhitespace character. If the end of the string is white space, then the length of the string is returned (i.e., an index past the end). | def __skip_contiguous_whitespace(index)
lim = self.__size
while(index < lim)
char = self.__ordAt(index)
return index unless char <= 32 and __is_whitespace(char) # \t \n etc. are less than space which is 32
index += 1
end
return index
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_whitespace_index(characters)\n n = characters.length\n n.times do |i|\n if characters[i] == \" \"\n return i\n end\n end\n return n\nend",
"def skipSpaces(pos)\n max = @src.length\n while pos < max\n ch = charCodeAt(@src, pos)\n break if !isSpace(ch)\n ... | [
"0.7203192",
"0.6488762",
"0.61840147",
"0.60778475",
"0.59366304",
"0.589215",
"0.581768",
"0.5788139",
"0.5730264",
"0.5714129",
"0.57026696",
"0.56765723",
"0.563769",
"0.56240344",
"0.5618364",
"0.5614227",
"0.5576403",
"0.5523433",
"0.5516835",
"0.54953545",
"0.54886365"... | 0.80357105 | 0 |
Split on each character, honoring the limits. | def __split_chars(limit, limited, suppress_trailing_empty)
result = []
# lim will be the number of single characters in the result. If we are
# limited, then the last element will be the rest of the string:
# 'hi!'.split('', 2) # => ['h', 'i!']
my_siz = self.__size
lim = my_siz
lim = (limit-1) if limited and limit < lim
index = 0
while index < lim
result << self.__at(index, 1)
index += 1
end
result << self.__at(index, (my_siz - index)) if limited
# self[0,0] returns an instance of the recievier: support for sub-classes
result << self.__at(0,0) unless suppress_trailing_empty || limited
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split(pat, limit)\n end",
"def split(pattern=$;, limit=0) end",
"def split(pattern=$;, limit=0) end",
"def splits(text)\n (0..[max_word_length, text.size-1].min).\n map { |i| [text[0..i], text[i+1..text.size]] }\n end",
"def __split_string_on(delim, limit, limited, suppress_trailing_emp... | [
"0.6889639",
"0.6835795",
"0.6835795",
"0.67232144",
"0.6651293",
"0.66154134",
"0.66154134",
"0.66117",
"0.6585861",
"0.65030533",
"0.6440706",
"0.6418728",
"0.61495656",
"0.6126995",
"0.6125779",
"0.6102435",
"0.60889757",
"0.6083061",
"0.6083061",
"0.6081732",
"0.6065003",... | 0.70423555 | 0 |
Returns a copy of +str+ with the first occurrence of +pattern+ replaced with either +replacement+ or the value of the block. See the description of Stringgsub for a description of the parameters. If we were to implement def sub(pattern, replacement=MaglevUndefined, &block) ; end to support fully general send or super() , would still have problems in that we don't know number of frames up stack to find caller's $~ | def sub(pattern, replacement)
replacement = Maglev::Type.coerce_to(replacement, String, :to_str)
regex = self.__get_pattern(pattern, true)
# If pattern is a string, then do NOT interpret regex special characters.
# stores into caller's $~
if (match = regex.__match_vcglobals(self, 0x30))
__replace_match_with(match, replacement)
else
dup
end
# r.taint if replacement.tainted? || self.tainted?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sub!(pattern, replacement = T.unsafe(nil), &block); end",
"def rsub(pattern, replacement)\n if i = rindex(pattern) # rubocop:disable Lint/AssignmentInCondition\n s = @string.dup\n s[i] = replacement\n self.class.new s\n else\n self\n end\n end"... | [
"0.7649497",
"0.7559588",
"0.7555225",
"0.7555225",
"0.7288287",
"0.6991695",
"0.6973144",
"0.6821267",
"0.63311976",
"0.619395",
"0.6132041",
"0.6086373",
"0.607987",
"0.6069114",
"0.6059087",
"0.6000199",
"0.5971525",
"0.5960093",
"0.59575564",
"0.5911794",
"0.5911631",
"... | 0.70992804 | 5 |
If we were to implement def sub!(pattern, replacement=MaglevUndefined, &block) ; end to support fully general send or super() , would still have problems in that we don't know number of frames up stack to find caller's $~ | def sub!(pattern, replacement)
regex = self.__get_pattern(pattern, true)
# stores into caller's $~
if match = regex.__match_vcglobals(self, 0x30)
replace(__replace_match_with(match, replacement))
# self.taint if replacement.tainted?
self
else
nil
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sub!(pattern, replacement = T.unsafe(nil), &block); end",
"def sub!(*args, &block)\n str = self.sub(*args, &block)\n if str != self\n self.replace(str)\n self\n else\n nil\n end\n end",
"def subs!(pattern, replacement)\n sub!(pattern, replacement)\n self\n end",
"... | [
"0.7530599",
"0.6995027",
"0.6520108",
"0.6474814",
"0.6474814",
"0.6368714",
"0.62206507",
"0.62108135",
"0.61881953",
"0.5989962",
"0.59823495",
"0.59749055",
"0.59214175",
"0.5883437",
"0.58583677",
"0.58153987",
"0.58087075",
"0.5803174",
"0.5783555",
"0.57794493",
"0.564... | 0.70176095 | 1 |
Do ruby conversions of a string or regexp to regexp. If pattern is a string, then quote regexp special characters. If pattern is neither a Regexp nor a String, try to coerce to string. | def __get_pattern(pattern, quote = false)
unless pattern._isString || pattern._isRegexp
if pattern.respond_to?(:to_str)
pattern = pattern.to_str
raise TypeError, "can't convert pattern to string" unless pattern._isString
else
raise TypeError, "wrong argument type #{pattern.class} (expected Regexp)"
end
end
pattern = Regexp.quote(pattern) if quote && pattern._isString
pattern = Regexp.new(pattern) unless pattern._isRegexp
pattern
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def coerce(pattern)\n case pattern\n when String, Symbol, Proc\n pattern\n when Regexp\n Regexp.new(pattern.to_s)\n else\n raise ValidationCoercion, \"Wrong type, got #{pattern.class}\"\n end\n end",
"def convert_to_regexp(name,... | [
"0.76102",
"0.68724316",
"0.68148535",
"0.6800159",
"0.6763083",
"0.6477101",
"0.62993443",
"0.62770945",
"0.62600565",
"0.6196674",
"0.61956024",
"0.6163578",
"0.6082221",
"0.600266",
"0.599274",
"0.5965559",
"0.59325397",
"0.5888612",
"0.58381236",
"0.5732604",
"0.5701091",... | 0.7732931 | 0 |
prim detects frozen if would change Returns the successor to self. The successor is calculated by incrementing characters starting from the rightmost alphanumeric (or the rightmost character if there are no alphanumerics) in the string. Incrementing a digit always results in another digit, and incrementing a letter results in another letter of the same case. Incrementing nonalphanumerics uses the underlying character set's collating sequence. If the increment generates a ``carry,'' the character to the left of it is incremented. This process repeats until there is no carry, adding an additional character if necessary. "abcd".succ => "abce" "THX1138".succ => "THX1139" ">".succ => ">" "1999zzz".succ => "2000aaa" "ZZZ9999".succ => "AAAA0000" "".succ => "+" | def succ
d = self.dup
d.succ!
# d.taint if self.tainted?
d
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def increment_string(input)\n nums = \"0123456789\"\n return input + \"1\" if input == \"\" || !nums.include?(input[-1]) \n end_zero = -1 \n end_nine = -1\n \n if input[end_zero] == \"0\"\n num_all_zero = true\n while num_all_zero\n num_all_zero = false\n end_zero -= 1\n if !nums.include... | [
"0.5900517",
"0.58160925",
"0.5780222",
"0.57708085",
"0.57145554",
"0.5713801",
"0.5713801",
"0.5713801",
"0.5663682",
"0.5582337",
"0.55739087",
"0.5561306",
"0.5543316",
"0.55307925",
"0.552591",
"0.5511208",
"0.54634583",
"0.54392576",
"0.54370457",
"0.53966993",
"0.53869... | 0.5730296 | 4 |
prim detects frozen if would change | def swapcase
s = self.dup
s.swapcase!
# s.taint if self.tainted?
s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def frozen?; end",
"def frozen?() end",
"def frozen?() end",
"def frozen?\n true\n end",
"def frozen?\n @frozen\n end",
"def frozen?\n @frozen\n end",
"def frozen?\n !!@frozen\n end",
"def frozen!\n @frozen = true\n end",
"def frozen?\n !%w(started unsubmitted... | [
"0.7310212",
"0.7270165",
"0.7270165",
"0.6840472",
"0.65717185",
"0.64528584",
"0.64280593",
"0.6405194",
"0.6322693",
"0.6300245",
"0.6189455",
"0.6189455",
"0.6148059",
"0.61405355",
"0.6050187",
"0.59053785",
"0.5864001",
"0.585986",
"0.5859398",
"0.58561087",
"0.5819165"... | 0.0 | -1 |
Consider self as an integer and return value given base. From the rubinius API. | def to_inum(base, check=false)
if check && self.__at('__')._not_equal?(nil)
raise ArgumentError, "__ in string, in to_inum"
end
str = self.strip
sign_str = nil
if base._equal?(0)
arr = str.__extract_base(10)
base = arr.__at(0)
sign_str = arr.__at(1)
str = arr.__at(2)
s = str
else
s = str
first_ch = s.__at(0)
if first_ch.eql?( ?+ ) || first_ch.eql?( ?- )
s = s.__at(1, s.__size - 1)
end
end
if check
s = s.downcase.__delete_underscore
bad = false
if base._equal?(10)
bad = s =~ /[^0-9]/
elsif base._equal?(8)
bad = s =~ /[^0-7]/
elsif base._equal?(16)
bad = s =~ /[^0123456789abcdef]/
elsif base._equal?(2)
bad = s =~ /[^01]/
else
raise ArgumentError, "to_inum, unsupported base #{base} "
end
if bad
raise ArgumentError, "to_inum, illegal character for base #{base} in #{self.inspect}"
end
end
num = Integer.__from_string_radix(str, base)
if sign_str._not_equal?(nil) && sign_str[0].eql?( ?- )
num = num * -1
end
num
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_i(base=10) end",
"def base=(value)\n @base = value\n valid_base?\n return @base\n end",
"def value; super.to_i; end",
"def from_base(base=10)\n n = 0\n chars.reverse_each.with_index do |c, power|\n value = BASE_DIGITS[c]\n n += (base**power) * value\n end\n n\n ... | [
"0.727483",
"0.71723056",
"0.6695943",
"0.6673913",
"0.6640583",
"0.65170014",
"0.65085936",
"0.6504333",
"0.64047456",
"0.6287673",
"0.62798434",
"0.6223694",
"0.62112284",
"0.6167232",
"0.6141557",
"0.6112177",
"0.6092969",
"0.60273135",
"0.60265565",
"0.60210675",
"0.60005... | 0.6110029 | 16 |
to_a inherited from Enumerable, uses each | def to_s
if self.class._equal?(String)
self
else
String.new(self)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_a\n each.to_a\n end",
"def to_a\n each.to_a\n end",
"def to_a\n each.force\n end",
"def to_a\n Array(each)\n end",
"def to_a\n result = []\n self.each { |e| result << e } # each will use succ\n result\n end",
"def to_a\n x = []\n self.each do |i... | [
"0.8063359",
"0.8063359",
"0.7980339",
"0.78229284",
"0.7542286",
"0.75261277",
"0.7382504",
"0.7373039",
"0.73563194",
"0.73492074",
"0.73492074",
"0.73492074",
"0.7276453",
"0.72708684",
"0.72696966",
"0.71588254",
"0.71588254",
"0.7158587",
"0.7158587",
"0.7158587",
"0.715... | 0.0 | -1 |
prim detects frozen if would change str.tr!(from_str, to_str) => str or nil Translates str in place, using the same rules as Stringtr. Returns str, or nil if no changes were made. | def tr!(from_str, to_str)
from = Maglev::Type.coerce_to(from_str, String, :to_str)
to = Maglev::Type.coerce_to(to_str, String, :to_str)
# Make the case for single character replacement more efficient.
# Avoids creating a translation table.
if from.__size._equal?(1) && to.__size._equal?(1)
fchar = from[0]
tochar = to[0]
lim = size
i = 0
while (i < lim)
self[i] = tochar if self[i].eql?(fchar)
i += 1
end
self
else
__tr!(from, to)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tr_s!(from_str, to_str)\n return nil if from_str.empty?\n __tr_s!(from_str, to_str)\n end",
"def tr(from_str, to_str)\n s = self.dup\n s.tr!(from_str, to_str)\n # s.taint if tainted?\n s\n end",
"def tr_s(from_str, to_str)\n from = Maglev::Type.coerce_to(from_str, String, :to_str)\n ... | [
"0.7281731",
"0.6947206",
"0.6800944",
"0.60976464",
"0.60547435",
"0.594679",
"0.57078916",
"0.5675394",
"0.5619175",
"0.5611848",
"0.55687076",
"0.55563706",
"0.55422235",
"0.55418503",
"0.554174",
"0.5533457",
"0.5500896",
"0.5481831",
"0.5480991",
"0.54496896",
"0.5423966... | 0.7261433 | 1 |
str.tr(from_str, to_str) => new_str Returns a copy of str with the characters in from_str replaced by the corresponding characters in to_str. If to_str is shorter than from_str, it is padded with its last character. Both strings may use the c1c2 notation to denote ranges of characters, and from_str may start with a ^, which denotes all characters except those listed. "hello".tr('aeiou', '') => "hll" "hello".tr('^aeiou', '') => "eo" "hello".tr('el', 'ip') => "hippo" "hello".tr('ay', 'bz') => "ifmmp" | def tr(from_str, to_str)
s = self.dup
s.tr!(from_str, to_str)
# s.taint if tainted?
s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tr!(from_str, to_str)\n from = Maglev::Type.coerce_to(from_str, String, :to_str)\n to = Maglev::Type.coerce_to(to_str, String, :to_str)\n\n # Make the case for single character replacement more efficient.\n # Avoids creating a translation table.\n if from.__size._equal?(1) && to.__size._equa... | [
"0.81020814",
"0.7545916",
"0.7032155",
"0.70244664",
"0.65740347",
"0.64555675",
"0.6299927",
"0.6297299",
"0.62582594",
"0.61662996",
"0.616411",
"0.60807186",
"0.6022159",
"0.59757435",
"0.5953552",
"0.59192926",
"0.58791435",
"0.5866878",
"0.58649564",
"0.58554643",
"0.58... | 0.7347972 | 2 |
prim detects frozen if would change str.tr_s!(from_str, to_str) => str or nil Performs Stringtr_s processing on str in place, returning str, or nil if no changes were made. | def tr_s!(from_str, to_str)
return nil if from_str.empty?
__tr_s!(from_str, to_str)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tr_s(from_str, to_str)\n from = Maglev::Type.coerce_to(from_str, String, :to_str)\n to = Maglev::Type.coerce_to(to_str, String, :to_str)\n str = self.dup\n # str.taint if self.tainted?\n str.__tr_s!(from, to) || str\n end",
"def tr!(from_str, to_str)\n from = Maglev::Type.coerce_to(fro... | [
"0.74046147",
"0.7067812",
"0.6962818",
"0.62499684",
"0.6046914",
"0.6014902",
"0.59602684",
"0.5859828",
"0.5750732",
"0.57187086",
"0.57187086",
"0.5679397",
"0.5671888",
"0.56325334",
"0.56165034",
"0.5598754",
"0.5582309",
"0.55741155",
"0.555997",
"0.547589",
"0.5474731... | 0.76441705 | 0 |
str.tr_s(from_str, to_str) => new_str Processes a copy of str as described under Stringtr, then removes duplicate characters in regions that were affected by the translation. "hello".tr_s('l', 'r') => "hero" "hello".tr_s('el', '') => "ho" "hello".tr_s('el', 'hx') => "hhxo" | def tr_s(from_str, to_str)
from = Maglev::Type.coerce_to(from_str, String, :to_str)
to = Maglev::Type.coerce_to(to_str, String, :to_str)
str = self.dup
# str.taint if self.tainted?
str.__tr_s!(from, to) || str
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tr_s!(from_str, to_str)\n return nil if from_str.empty?\n __tr_s!(from_str, to_str)\n end",
"def tr!(from_str, to_str)\n from = Maglev::Type.coerce_to(from_str, String, :to_str)\n to = Maglev::Type.coerce_to(to_str, String, :to_str)\n\n # Make the case for single character replacement mor... | [
"0.8015206",
"0.7876714",
"0.7357709",
"0.6591715",
"0.6479559",
"0.63110536",
"0.6267149",
"0.62484914",
"0.62295413",
"0.62209755",
"0.6170301",
"0.6169172",
"0.6138257",
"0.61303836",
"0.6097322",
"0.6071068",
"0.60669553",
"0.60627496",
"0.60627496",
"0.60555613",
"0.6055... | 0.7720199 | 2 |
MNI: upto dup, clone inherited from Object ====== overrides of methods from Comparable: | def >(other)
o = (self <=> other)
if o._equal?(nil)
raise ArgumentError, 'comparision failed'
end
o > 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clone; end",
"def clone; end",
"def clone; end",
"def clone() end",
"def clone(*) end",
"def clone(*) end",
"def clone\n raise NotImplementedError\n end",
"def clone\n super\n end",
"def clone_head; end",
"def clone\n super\n end",
"def clone\n end",
"def cl... | [
"0.68635666",
"0.68635666",
"0.68635666",
"0.6857108",
"0.6795155",
"0.6795155",
"0.6734522",
"0.66928816",
"0.66793674",
"0.66239935",
"0.65321094",
"0.64927125",
"0.64927125",
"0.64927125",
"0.6431601",
"0.63253987",
"0.6115464",
"0.6077728",
"0.60700744",
"0.60628533",
"0.... | 0.0 | -1 |
Let's restrict this to Firefox because it's only a code sample | def setup
if ENV['BROWSER'] == 'firefox'
$driver = Selenium::WebDriver.for :firefox
elsif ENV['BROWSER'] == 'chrome'
$driver = Selenium::WebDriver.for :chrome
else
puts 'The only valid browser options are [firefox | chrome]'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def mozart; end",
"def weber; end",
"def blg; end",
"def extension; end",
"def extension; end",
"def extension; end",
"def extension; end",
"def terpene; end",
"def specia... | [
"0.622989",
"0.5899372",
"0.58343756",
"0.58343756",
"0.58343756",
"0.58343756",
"0.5748019",
"0.5598855",
"0.54966545",
"0.54444927",
"0.54444927",
"0.54444927",
"0.54444927",
"0.5442889",
"0.5440028",
"0.54342175",
"0.54342175",
"0.54189414",
"0.5417221",
"0.5413636",
"0.54... | 0.0 | -1 |
Make sure to exit the browser after each test | def teardown
$driver.quit
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def teardown\n @browser.close\n end",
"def teardown\n @browser.quit\n end",
"def test_03()\n\t\tputs \"Inside test 3\"\n\t\t$browser.stop\n\t\t\n\tend",
"def teardown\r\n\r\n # Close the browser unless there was an error in the setup which caused $browser to not get initialized\r\n unless $brow... | [
"0.80436283",
"0.79749876",
"0.7952069",
"0.7932022",
"0.79218847",
"0.79218847",
"0.7875286",
"0.78536373",
"0.7810883",
"0.7776216",
"0.77145857",
"0.7640378",
"0.75672066",
"0.7512872",
"0.74426985",
"0.7432598",
"0.7371015",
"0.72819877",
"0.72604346",
"0.7258659",
"0.725... | 0.689756 | 41 |
Helper method to load Imgur | def load_imgur
$driver.navigate.to 'https://imgur.com/'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_image(path)\n end",
"def image_from_url\n io = open(URI.parse(image_url))\n def io.original_filename; base_uri.path.split('/').last; end\n self.image = io.original_filename.blank? ? nil : io\n rescue # catch url errors with validations instead of exceptions (Errno::ENOENT, OpenURI::HTTPErr... | [
"0.7004724",
"0.6143793",
"0.6029811",
"0.6006786",
"0.59325415",
"0.58168894",
"0.58075225",
"0.58071554",
"0.5803619",
"0.5786011",
"0.5776185",
"0.57282174",
"0.5725891",
"0.5693071",
"0.56649625",
"0.56602675",
"0.565657",
"0.56371164",
"0.5632141",
"0.5544811",
"0.551315... | 0.58987814 | 5 |
Helper method to return the title of the current page | def get_page_title
$driver.title
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def page_title\n page.title\n end",
"def title\n @title_pages.each { |tp| tp.title and return tp.title }\n nil\n end",
"def pageTitle\n (self || Home.new).title\n end",
"def page_title\n @page_title ||= format_string(page[\"title\"]) || site_title\n end",
"def t... | [
"0.86775464",
"0.84671235",
"0.83855355",
"0.83662176",
"0.83600134",
"0.83166695",
"0.82140297",
"0.81649435",
"0.81617737",
"0.81503314",
"0.8144497",
"0.8143181",
"0.81289834",
"0.81219107",
"0.81061196",
"0.8086648",
"0.80717677",
"0.8015879",
"0.80049956",
"0.8001569",
"... | 0.0 | -1 |
Helper method to get the current URL | def get_page_url
$driver.current_url
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_url\n request.env['REQUEST_URI']\n end",
"def current_url\n evaluate(\"window.top.location.href\")\n end",
"def current_path\n URI.parse(current_url).path\nend",
"def current_url\n page.current_url\n end",
"def current_url\n page.current_url\n end",
"def curre... | [
"0.8749429",
"0.8424985",
"0.8228639",
"0.82107776",
"0.82107776",
"0.8198883",
"0.8096921",
"0.80739874",
"0.80715626",
"0.8047233",
"0.7941029",
"0.78378916",
"0.77279687",
"0.7725404",
"0.76803654",
"0.765305",
"0.7643022",
"0.7617136",
"0.7506906",
"0.7500704",
"0.7418238... | 0.66111594 | 62 |
Pager Setup pager and return helper html for view display | def pager(collection, path, fade_content=true)
if fade_content
%{<div class='pager main'>#{collection.pager.to_html("#{path}", :size => 9)}</div>}.html_safe
else
%{<div class='pager notes-pager'>#{collection.pager.to_html("#{path}", :size => 9)}</div>}.html_safe
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_pager!\n page\n end",
"def pager; end",
"def pager\n Pry::Pager.new(self)\n end",
"def table_pager(type, next_page)\n html = String.new\n html << '<ul class=\"pager\">'\n page = request.id.to_i\n if page > 1\n html << \"<li><a href=\\\"#{url_for(\"#{type}/#{pa... | [
"0.7356786",
"0.69955933",
"0.6610484",
"0.6352794",
"0.63033235",
"0.62778455",
"0.61749667",
"0.6139888",
"0.6117263",
"0.6116982",
"0.6025851",
"0.6021004",
"0.59239125",
"0.59236795",
"0.5910121",
"0.5892466",
"0.58910716",
"0.58670044",
"0.58306867",
"0.5819608",
"0.5808... | 0.686513 | 2 |
Percentage Helper Used for generating customized percentages used in the view and pdf reports. This method will protect impossible percentages. | def percentage_for(count, total, round=2)
begin
percentage = ((count.to_f / total.to_f) * 100).round(round)
return 100.round(round) if percentage.round > 100
percentage
rescue FloatDomainError
0
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def percentage; end",
"def percent()\n ''\n end",
"def percentage\n 0.0\n end",
"def percent\n \"%0.1f%%\" % (to_f * 100)\n end",
"def percentage(percent, total)\n percent.to_f / total * 100\nend",
"def percent_protected\n protected_area / total_area * 100\n end",
"def percentage=(... | [
"0.75013953",
"0.7463437",
"0.7320411",
"0.71036696",
"0.69938666",
"0.6940857",
"0.69022083",
"0.6801996",
"0.6685288",
"0.66848165",
"0.6634778",
"0.66326493",
"0.6628756",
"0.66022813",
"0.6592492",
"0.6557354",
"0.6556233",
"0.6556233",
"0.65410495",
"0.65100676",
"0.6505... | 0.0 | -1 |
Check to determine whether we're on a windows or linux/osx host, later on we use this to launch ansible in the supported way source: | def which(cmd)
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
exts.each { |ext|
exe = File.join(path, "#{cmd}#{ext}")
return exe if File.executable? exe
}
end
return nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def windows?\n\tRbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/\nend",
"def linux?\n unix? and not mac?\n end",
"def linux?\n unix? and not mac?\n end",
"def determine_os\n scp(:source => Provision::Bootstrapper.determine_os_script, :destination => \"/tmp\")\n o = run(\"ch... | [
"0.6782257",
"0.67701983",
"0.67551804",
"0.6734082",
"0.66623306",
"0.6632809",
"0.6631736",
"0.65897906",
"0.6584505",
"0.6554155",
"0.65385735",
"0.6536036",
"0.65259725",
"0.65250605",
"0.65171933",
"0.6509945",
"0.6509522",
"0.64727163",
"0.64492136",
"0.6447653",
"0.644... | 0.0 | -1 |
rules are constant for every rock, paper, scissors game you ever play; doesn't change for each instance of class | def initialize(play_type)
@play_type = play_type
raise PlayTypeError unless VALID_PLAYS.include?(play_type)
#or:
#raise PlayTypeError if !RPSGame.valid_play?(move) or !self.class.valid_play?(move)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rules\n \"Choose rock, paper, scissors, lizard, or spock.\"\n end",
"def initialize\n @valid_moves_list = [\"rock\", \"paper\", \"scissors\"]\n @rules = {\"rock\" => \"scissors\", \"paper\" => \"rock\", \"scissors\" => \"paper\"}\n @winner = \"\"\n end",
"def initialize\n @valid_moves_li... | [
"0.76798797",
"0.7494402",
"0.74593824",
"0.71313244",
"0.6893544",
"0.665888",
"0.6429518",
"0.6427038",
"0.6427038",
"0.6427038",
"0.6427038",
"0.6427038",
"0.6427038",
"0.6427038",
"0.63173246",
"0.62640196",
"0.6156621",
"0.615383",
"0.6153505",
"0.6153505",
"0.6153505",
... | 0.0 | -1 |
GET /lost GET /lost.json | def index
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @lost = Lost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lost }\n end\n end",
"def index\n @losts = Lost.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @losts }\n end\n end"... | [
"0.72046894",
"0.65841144",
"0.65751463",
"0.6271712",
"0.59225416",
"0.59077066",
"0.59057415",
"0.5775273",
"0.5773672",
"0.5724819",
"0.56932175",
"0.56455374",
"0.5635792",
"0.56236905",
"0.5612932",
"0.5573849",
"0.556193",
"0.55432326",
"0.55416983",
"0.5529733",
"0.550... | 0.0 | -1 |
Public: Create a single WebSocket stream :stream The Hash used to define the stream :symbol The String symbol to listen to :type The String type of stream to listen to :level The String level to use for the depth stream (optional) :interval The String interval to use for the kline stream (optional) :methods The Hash which contains the event handler methods to pass to the WebSocket client :open The Proc called when a stream is opened (optional) :message The Proc called when a stream receives a message :error The Proc called when a stream receives an error (optional) :close The Proc called when a stream is closed (optional) | def ws_single(stream:, methods:)
create_stream(
"#{base_url}/ws/#{stream_url(stream)}",
methods: methods,
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_stream\n Stream.new(self)\n end",
"def send_stream_state(state, streaming_user)\n WebSocket::Client::Simple.connect(\n Rails.configuration.x.saber.chat_server,\n headers: { \"streamstate-auth\": Rails.application.credentials.stream_state_auth }\n ) do |ws|\n ws.on :open do\n ... | [
"0.6423991",
"0.633959",
"0.60314256",
"0.59467167",
"0.59407973",
"0.5940067",
"0.5938748",
"0.58743477",
"0.5857777",
"0.5857777",
"0.58286226",
"0.5765706",
"0.5662652",
"0.56597674",
"0.5651085",
"0.5648144",
"0.5645926",
"0.56232166",
"0.55409485",
"0.55317926",
"0.55256... | 0.68188775 | 0 |
Internal: Create a valid URL for a WebSocket to use :symbol The String symbol to listen to :type The String type the stream will listen to :level The String level to use for the depth stream (optional) :interval The String interval to use for the kline stream (optional) | def stream_url(symbol:, type:, level: '', interval: '')
"#{symbol.downcase}@#{type}".tap do |url|
url << level
url << "_#{interval}" unless interval.empty?
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(url, cookies, logs: false, &handler)\n @super_logger = Logger.new(logs ? 'ws_super_logger.log' : '/dev/null')\n\n @uri = URI.parse(url)\n @url = \"ws#{@uri.scheme.split(\"\")[4]}://#{@uri.host}\"\n\n if @uri.scheme.split(\"\")[4] == 's'\n @socket = TCPSocket.new(... | [
"0.6079446",
"0.594802",
"0.5913341",
"0.57932526",
"0.57813823",
"0.57645315",
"0.57645315",
"0.5619003",
"0.54895127",
"0.541252",
"0.53553617",
"0.53068817",
"0.5289082",
"0.5274762",
"0.5193357",
"0.5164566",
"0.5164347",
"0.51188594",
"0.51098335",
"0.50751424",
"0.50734... | 0.7085418 | 0 |
======================================================================= WebSocket APIs ======================================================================= | def partial_book_depth(symbol:, level:, methods:)
ws_single(
stream: {
symbol: symbol,
type: 'depth',
level: level,
},
methods: methods,
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def websocket; end",
"def websocket; end",
"def receive(websocket_message); end",
"def websocket\n @web_socket ||= WebSocket.new\n end",
"def websocket port = nil\n host = @source[\"resource\"].first\n path = @source[\"resource\"][1..-1].join('/')\n if port.nil?\n ... | [
"0.8348351",
"0.8348351",
"0.76598644",
"0.7284588",
"0.720469",
"0.68913865",
"0.6835782",
"0.6701062",
"0.66291314",
"0.6553799",
"0.6551627",
"0.6470419",
"0.64535147",
"0.6377008",
"0.6367395",
"0.6367395",
"0.6367395",
"0.6367395",
"0.6367395",
"0.6366788",
"0.6360741",
... | 0.0 | -1 |
violin is defined as an example in ws.rb | def violin_test(start = 0.0, dur = 1.0)
violin(start, dur, 440, 0.5)
$now = start + dur + 0.2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fm_violin_test(start = 0.0, dur = 1.0)\n fm_violin(start, dur, 440, 0.5)\n $now = start + dur + 0.2\nend",
"def add_isopropanol\n show do\n title \"Add isopropanol\"\n note \"Add isopropanol according to the following table. Pipette up and down to mix.\"\n warning \"Divide the isopropanol... | [
"0.6491876",
"0.5528104",
"0.5185675",
"0.5157963",
"0.5157963",
"0.5157963",
"0.51575875",
"0.5049797",
"0.5017835",
"0.5012094",
"0.5000739",
"0.49804273",
"0.49489856",
"0.4940505",
"0.49217036",
"0.4908415",
"0.48716334",
"0.48693871",
"0.48675412",
"0.48649383",
"0.48580... | 0.644332 | 1 |
fm_violin is defined in v.rb | def fm_violin_test(start = 0.0, dur = 1.0)
fm_violin(start, dur, 440, 0.5)
$now = start + dur + 0.2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iiif_av_viewer\n @iiif_av_viewer ||= :avalon\n end",
"def initialize avi\n @avi = avi\n end",
"def violin_test(start = 0.0, dur = 1.0)\n violin(start, dur, 440, 0.5)\n $now = start + dur + 0.2\nend",
"def vif # variance inflation factor\n @vif ||= 1 / ( 1 - r2 )\n end",
"d... | [
"0.55632526",
"0.5535399",
"0.55296063",
"0.54004997",
"0.5330478",
"0.5242329",
"0.521255",
"0.5164751",
"0.51486474",
"0.513103",
"0.51221627",
"0.5117893",
"0.5104583",
"0.5099209",
"0.5058278",
"0.50187325",
"0.50119436",
"0.5007045",
"0.50048596",
"0.4977945",
"0.4977945... | 0.61483824 | 0 |
MLBVOI translation from MUS10 of Marc LeBrun's waveshaping voice instrument (using FM here) this version translated (and simplified slightly) from CLM's mlbvoi.ins | def vox(start, dur, freq, amp, ampfun, freqfun, freqscl, voxfun, index, vibscl)
f1 = []
f2 = []
f3 = []
(voxfun.length - 1).step(1, -2) do |i|
phon = Formants[voxfun[i]]
x = voxfun[i - 1]
f1.unshift(phon[0])
f1.unshift(x)
f2.unshift(phon[1])
f2.unshift(x)
f3.unshift(phon[2])
f3.unshift(x)
end
car_os = make_oscil(:frequency, 0)
of0 = make_oscil(:frequency, 0)
of1 = make_oscil(:frequency, 0)
of2 = make_oscil(:frequency, 0)
of3 = make_oscil(:frequency, 0)
of4 = make_oscil(:frequency, 0)
of5 = make_oscil(:frequency, 0)
ampf = make_env(:envelope, ampfun, :scaler, amp, :duration, dur)
frmf1 = make_env(:envelope, f1, :duration, dur)
frmf2 = make_env(:envelope, f2, :duration, dur)
frmf3 = make_env(:envelope, f3, :duration, dur)
freqf = make_env(:envelope, freqfun, :duration, dur, :scaler, freqscl * freq, :offset, freq)
per_vib = make_triangle_wave(:frequency, 6, :amplitude, freq * vibscl)
ran_vib = make_rand_interp(:frequency, 20, :amplitude, freq * 0.01)
run_instrument(start, dur) do
frq = env(freqf) + triangle_wave(per_vib) + rand_interp(ran_vib)
car = index * oscil(car_os, hz2radians(frq))
frm = env(frmf1)
frm0 = frm / frq.to_f
frm_int = frm0.floor
if frm_int.even?
frq0 = hz2radians(frm_int * frq)
frq1 = hz2radians((frm_int + 1) * frq)
amp1 = frm0 - frm_int
amp0 = 1.0 - amp1
else
frq1 = hz2radians(frm_int * frq)
frq0 = hz2radians((frm_int + 1) * frq)
amp0 = frm0 - frm_int
amp1 = 1.0 - amp0
end
frm = env(frmf2)
frm0 = frm / frq.to_f
frm_int = frm0.floor
if frm_int.even?
frq2 = hz2radians(frm_int * frq)
frq3 = hz2radians((frm_int + 1) * frq)
amp3 = frm0 - frm_int
amp2 = 1.0 - amp3
else
frq3 = hz2radians(frm_int * frq)
frq2 = hz2radians((frm_int + 1) * frq)
amp2 = frm0 - frm_int
amp3 = 1.0 - amp2
end
frm = env(frmf3)
frm0 = frm / frq.to_f
frm_int = frm0.floor
if frm_int.even?
frq4 = hz2radians(frm_int * frq)
frq5 = hz2radians((frm_int + 1) * frq)
amp5 = frm0 - frm_int
amp4 = 1.0 - amp5
else
frq5 = hz2radians(frm_int * frq)
frq4 = hz2radians((frm_int + 1) * frq)
amp4 = frm0 - frm_int
amp5 = 1.0 - amp4
end
env(ampf) * (0.8 * (amp0 * oscil(of0, frq0 + 0.2 * car) +
amp1 * oscil(of1, frq1 + 0.2 * car)) +
0.15 * (amp2 * oscil(of2, frq2 + 0.5 * car) +
amp3 * oscil(of3, frq3 + 0.5 * car)) +
0.05 * (amp4 * oscil(of4, frq4 + car) +
amp5 * oscil(of5, frq5 + car)))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def instrument(midiIn, duration: 1.0, gmBank: \"000\", gmPatch: \"000\", gmPathDir: \"C:/Users/Michael Sutton/Midiloop/default/\", amp: 1.0, attack: 0.01, decay: 0.3, sustain: 0.5, release: 1.0, lpf: 128, hpf: 1, bpm: 60, pan: 0.0, glIn: \"none\", glFunc: \"none\", midiFlag: \"N\") \r\n\r\n #puts \"xgmPathDir: \... | [
"0.5976963",
"0.59062934",
"0.58414054",
"0.5626566",
"0.55649227",
"0.55070275",
"0.5444877",
"0.54190564",
"0.5412473",
"0.5383772",
"0.53439367",
"0.5328132",
"0.53252447",
"0.5299972",
"0.5233085",
"0.51724565",
"0.5156036",
"0.51535666",
"0.51299936",
"0.5074388",
"0.506... | 0.5639067 | 3 |
FM TRUMPET Dexter Morrill's FMtrumpet: from CMJ feb 77 p51 | def fm_trumpet(start, dur, *args)
frq1, frq2, amp1, amp2, ampatt1, ampdec1, ampatt2, ampdec2 = nil
modfrq1, modind11, modind12, modfrq2, modind21, modind22 = nil
rvibamp, rvibfrq, vibamp, vibfrq, vibatt, vibdec = nil
frqskw, frqatt, ampenv1, ampenv2 = nil
indenv1, indenv2, degree, distance, reverb_amount = nil
optkey(args, binding,
[:frq1, 250.0],
[:frq2, 1500.0],
[:amp1, 0.5],
[:amp2, 0.1],
[:ampatt1, 0.03],
[:ampdec1, 0.35],
[:ampatt2, 0.03],
[:ampdec2, 0.3],
[:modfrq1, 250.0],
[:modind11, 0.0],
[:modind12, 2.66],
[:modfrq2, 250.0],
[:modind21, 0.0],
[:modind22, 1.8],
[:rvibamp, 0.007],
[:rvibfrq, 125.0],
[:vibamp, 0.007],
[:vibfrq, 7.0],
[:vibatt, 0.6],
[:vibdec, 0.2],
[:frqskw, 0.03],
[:frqatt, 0.06],
[:ampenv1, [0, 0, 25, 1, 75, 0.9, 100, 0]],
[:ampenv2, [0, 0, 25, 1, 75, 0.9, 100, 0]],
[:indenv1, [0, 0, 25, 1, 75, 0.9, 100, 0]],
[:indenv2, [0, 0, 25, 1, 75, 0.9, 100, 0]],
[:degree, 0.0],
[:distance, 1.0],
[:reverb_amount, 0.005])
dur = dur.to_f
per_vib_f = make_env(:envelope,
stretch_envelope([0, 1, 25, 0.1, 75, 0, 100, 0],
25,
[100 * (vibatt / dur), 45].min,
75,
[100 * (1.0 - vibdec / dur), 55].max),
:scaler, vibamp, :duration, dur)
ran_vib = make_rand_interp(:frequency, rvibfrq, :amplitude, rvibamp)
per_vib = make_oscil(:frequency, vibfrq)
dec_01 = [75, 100 * (1.0 - 0.01 / dur)].max
frq_f = make_env(:envelope,
stretch_envelope([0, 0, 25, 1, 75, 1, 100, 0],
25,
[25, 100 * (frqatt / dur)].min,
75,
dec_01),
:scaler, frqskw, :duration, dur)
ampattpt1 = [25, 100 * (ampatt1 / dur)].min
ampdecpt1 = [75, 100 * (1.0 - ampdec1 / dur)].max
ampattpt2 = [25, 100 * (ampatt2 / dur)].min
ampdecpt2 = [75, 100 * (1.0 - ampdec2 / dur)].max
mod1_f = make_env(:envelope,
stretch_envelope(indenv1, 25, ampattpt1, 75, dec_01),
:scaler, modfrq1 * (modind12 - modind11), :duration, dur)
mod1 = make_oscil(:frequency, 0.0)
car1 = make_oscil(:frequency, 0.0)
# set frequency to zero here because it is handled multiplicatively below
car1_f = make_env(:envelope,
stretch_envelope(ampenv1, 25, ampattpt1, 75, ampdecpt1),
:scaler, amp1, :duration, dur)
mod2_f = make_env(:envelope,
stretch_envelope(indenv2, 25, ampattpt2, 75, dec_01),
:scaler, modfrq2 * (modind22 - modind21), :duration, dur)
mod2 = make_oscil(:frequency, 0.0)
car2 = make_oscil(:frequency, 0.0)
car2_f = make_env(:envelope,
stretch_envelope(ampenv2, 25, ampattpt2, 75, ampdecpt2),
:scaler, amp2, :duration, dur)
run_instrument(start, dur,
:degree, degree,
:distance, distance,
:reverb_amount, reverb_amount) do
frq_change = hz2radians((1.0 +
rand_interp(ran_vib)) *
(1.0 + env(per_vib_f) *
oscil(per_vib)) *
(1.0 + env(frq_f)))
env(car1_f) *
oscil(car1, frq_change *
(frq1 + env(mod1_f) * oscil(mod1, modfrq1 * frq_change))) +
env(car2_f) *
oscil(car2, frq_change *
(frq2 + env(mod2_f) * oscil(mod2, modfrq2 * frq_change)))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fml (m)\n\tend",
"def drupal(counterquartered, pantryman)\n ulua()\n nonremonstrance_novial_tautoousian(englishly_lamboys)\n dissert_dilleniaceous(contralto_morne, geniohyoglossal, aptotic_inherency)\n end",
"def malts; end",
"def afue_to_thermal_eff(afue)\n \n return afue # Per PNNL ... | [
"0.5932339",
"0.5756003",
"0.55674404",
"0.54843146",
"0.5480797",
"0.54268306",
"0.54127413",
"0.5354887",
"0.5318888",
"0.53012806",
"0.5282418",
"0.52643424",
"0.5227307",
"0.5216018",
"0.5209252",
"0.5186011",
"0.5170607",
"0.5161525",
"0.5145535",
"0.5126037",
"0.5116754... | 0.5842943 | 1 |
FMDRUM Jan Mattox's fm drum: | def fm_drum(start, dur, freq, amp, index, high = false,
degree = 0.0, distance = 1.0, rev_amount = 0.01)
casrat = high ? 8.525 : 3.515
fmrat = high ? 3.414 : 1.414
glsf = make_env(:envelope, [0, 0, 25, 0, 75, 1, 100, 1],
:scaler, high ? hz2radians(66) : 0.0, :duration, dur)
ampfun = [0, 0, 3, 0.05, 5, 0.2, 7, 0.8, 8, 0.95,
10, 1.0, 12, 0.95, 20, 0.3, 30, 0.1, 100, 0]
atdrpt = 100 * (high ? 0.01 : 0.015) / dur
ampf = make_env(:envelope,
stretch_envelope(ampfun, 10, atdrpt, 15,
[atdrpt + 1,
100 - 100 * ((dur - 0.2) / dur)].max),
:scaler, amp, :duration, dur)
indxfun = [0, 0, 5, 0.014, 10, 0.033, 15, 0.061, 20, 0.099,
25, 0.153, 30, 0.228, 35, 0.332, 40, 0.477,
45, 0.681, 50, 0.964, 55, 0.681, 60, 0.478, 65, 0.332,
70, 0.228, 75, 0.153, 80, 0.099, 85, 0.061,
90, 0.033, 95, 0.0141, 100, 0]
indxpt = 100 - 100 * ((dur - 0.1) / dur)
divindxf = stretch_envelope(indxfun, 50, atdrpt, 65, indxpt)
indxf = make_env(:envelope, divindxf, :duration, dur,
:scaler, [hz2radians(index * fmrat * freq), PI].min)
mindxf = make_env(:envelope, divindxf, :duration, dur,
:scaler, [hz2radians(index * casrat * freq), PI].min)
devf = make_env(:envelope,
stretch_envelope(ampfun, 10, atdrpt, 90,
[atdrpt + 1,
100 - 100 * ((dur - 0.05) / dur)].max),
:scaler, [hz2radians(7000), PI].min, :duration, dur)
rn = make_rand(:frequency, 7000, :amplitude, 1)
carrier = make_oscil(:frequency, freq)
fmosc = make_oscil(:frequency, freq * fmrat)
cascade = make_oscil(:frequency, freq * casrat)
run_instrument(start, dur,
:degree, degree,
:distance, distance,
:reverb_amount, rev_amount) do
gls = env(glsf)
env(ampf) *
oscil(carrier,
gls +
env(indxf) *
oscil(fmosc,
gls * fmrat +
env(mindxf) * oscil(cascade,
gls * casrat +
env(devf) * rand(rn))))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fml (m)\n\tend",
"def get_frustum_material\n materials = Sketchup.active_model.materials\n material = materials[\"Camera_FOV\"]\n if( not material )\n material = materials.add \"Camera_FOV\"\n material.color = [211, 211, 211]\n material.alpha = 0.25\n end\n material\nend",... | [
"0.5614201",
"0.5477271",
"0.53448933",
"0.508352",
"0.49811473",
"0.49659455",
"0.496169",
"0.492701",
"0.48755622",
"0.4846614",
"0.48044974",
"0.4798953",
"0.47891793",
"0.47689566",
"0.47683713",
"0.4765626",
"0.47564676",
"0.47530887",
"0.4742268",
"0.47397152",
"0.47323... | 0.55484587 | 1 |
FMGONG Paul Weineke's gong. | def gong(start, dur, freq, amp, *args)
degree, distance, reverb_amount = nil
optkey(args, binding,
[:degree, 0.0],
[:distance, 1.0],
[:reverb_amount, 0.005])
mfq1 = freq * 1.16
mfq2 = freq * 3.14
mfq3 = freq * 1.005
indx01 = hz2radians(0.01 * mfq1)
indx11 = hz2radians(0.30 * mfq1)
indx02 = hz2radians(0.01 * mfq2)
indx12 = hz2radians(0.38 * mfq2)
indx03 = hz2radians(0.01 * mfq3)
indx13 = hz2radians(0.50 * mfq3)
atpt = 5
atdur = 100 * (0.002 / dur)
expf = [0, 0, 3, 1, 15, 0.5, 27, 0.25, 50, 0.1, 100, 0]
rise = [0, 0, 15, 0.3, 30, 1.0, 75, 0.5, 100, 0]
fmup = [0, 0, 75, 1.0, 98, 1.0, 100, 0]
fmdwn = [0, 0, 2, 1.0, 100, 0]
ampfun = make_env(:envelope, stretch_envelope(expf, atpt, atdur),
:scaler, amp, :duration, dur)
indxfun1 = make_env(:envelope, fmup, :scaler, indx11 - indx01,
:duration, dur, :offset, indx01)
indxfun2 = make_env(:envelope, fmdwn, :scaler, indx12 - indx02,
:duration, dur, :offset, indx02)
indxfun3 = make_env(:envelope, rise, :scaler, indx13 - indx03,
:duration, dur, :offset, indx03)
carrier = make_oscil(:frequency, freq)
mod1 = make_oscil(:frequency, mfq1)
mod2 = make_oscil(:frequency, mfq2)
mod3 = make_oscil(:frequency, mfq3)
run_instrument(start, dur,
:degree, degree,
:distance, distance,
:reverb_amount, reverb_amount) do
env(ampfun) *
oscil(carrier,
env(indxfun1) * oscil(mod1) +
env(indxfun2) * oscil(mod2) +
env(indxfun3) * oscil(mod3))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gounod; end",
"def g; end",
"def g; end",
"def blg; end",
"def tongue_twister; end",
"def mitch_hedberg; end",
"def forfeit(guest)\n \"#{guest.name} is washing dishes whilst singing #{guest.fave_song}\"\n end",
"def greet\n\t\treturn \"I'm #{GOODMOOD}. How are you?\"\n\tend",
"def g1\n ... | [
"0.70228946",
"0.66913605",
"0.66913605",
"0.6391894",
"0.63891715",
"0.6209639",
"0.61405426",
"0.59125835",
"0.58996344",
"0.5872046",
"0.5868073",
"0.58389217",
"0.5790409",
"0.5789883",
"0.5789883",
"0.5789539",
"0.5785569",
"0.57751673",
"0.57491314",
"0.57375646",
"0.57... | 0.0 | -1 |
ATTRACT by James McCartney, from CMJ vol 21 no 3 p 6 | def attract(start, dur, amp, c)
a = b = 0.2
dt = 0.04
scale = (0.5 * amp) / c
x = -1.0
y = z = 0.0
run_instrument(start, dur) do
x1 = x - dt * (y + z)
y = y + dt * (x + a * y)
z = z + dt * ((b + x * z) - c * z)
x = x1
scale * x
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def emotional_adjective; end",
"def attr_info; end",
"def silly_adjective; end",
"def attr; end",
"def medical_use; end",
"def attr(name); end",
"def calc_secondary_attributes\n self.san = self.pow * 5\n self.idea = self.int * 5\n self.health = ((self.siz+self.con)/2.0).ceil\n self.... | [
"0.61899394",
"0.6045954",
"0.59487146",
"0.58746034",
"0.5841924",
"0.5813962",
"0.57832724",
"0.5763984",
"0.576302",
"0.5716211",
"0.5713011",
"0.5699247",
"0.56744343",
"0.56744343",
"0.56744343",
"0.56744343",
"0.56744343",
"0.56744343",
"0.56744343",
"0.5651341",
"0.564... | 0.0 | -1 |
PQW phasequadrature waveshaping used to create asymmetric (i.e. single sideband) spectra. The basic idea here is a variant of sin x sin y cos x cos y = cos (x + y) | def pqw(start, dur, spacing_freq, carrier_freq,
amp, ampfun, indexfun, partials, *args)
degree, distance, reverb_amount = nil
optkey(args, binding,
[:degree, 0.0],
[:distance, 1.0],
[:reverb_amount, 0.005])
normalized_partials = normalize_partials(partials)
spacing_cos = make_oscil(:frequency, spacing_freq, :initial_phase, HALF_PI)
spacing_sin = make_oscil(:frequency, spacing_freq)
carrier_cos = make_oscil(:frequency, carrier_freq, :initial_phase, HALF_PI)
carrier_sin = make_oscil(:frequency, carrier_freq)
sin_coeffs = partials2polynomial(normalized_partials, 0)
cos_coeffs = partials2polynomial(normalized_partials, 1)
amp_env = make_env(:envelope, ampfun, :scaler, amp, :duration, dur)
ind_env = make_env(:envelope, indexfun, :duration, dur)
r = carrier_freq / spacing_freq.to_f
tr = make_triangle_wave(:frequency, 5,
:amplitude, hz2radians(0.005 * spacing_freq))
rn = make_rand_interp(:frequency, 12,
:amplitude, hz2radians(0.005 * spacing_freq))
run_instrument(start, dur,
:degree, degree,
:distance, distance,
:reverb_amount, reverb_amount) do
vib = triangle_wave(tr) + rand_interp(rn)
ax = [1.0, env(ind_env)].min * oscil(spacing_cos, vib)
fax = polynomial(cos_coeffs, ax)
yfax = oscil(spacing_sin, vib) * polynomial(sin_coeffs, ax)
env(amp_env) *
(oscil(carrier_sin, vib * r) * yfax -
oscil(carrier_cos, vib * r) * fax)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def f(phase, var)\n A + (B * Math.sin(phase + (D * var)))\nend",
"def wave\n [*0..60].map do |e|\n (4095 * Math.sin(e * Math::PI / 60)).round\n end\nend",
"def setup\n sketch_title 'Additive Wave Exercise'\n @w = width + 16 # Width of entire wave\n @xspacing = 8 # How far apart should each ho... | [
"0.5566415",
"0.5471477",
"0.5466984",
"0.542244",
"0.53757405",
"0.53212965",
"0.5191476",
"0.5108363",
"0.50400126",
"0.5038094",
"0.50282145",
"0.5027834",
"0.49460697",
"0.48928577",
"0.48910952",
"0.48514062",
"0.48291162",
"0.47819367",
"0.47768798",
"0.47328207",
"0.47... | 0.6194286 | 0 |
taken from Perry Cook's stkv1.tar.Z (Synthesis Toolkit), but I was in a bit of a hurry and may not have made slavishly accurate | def tubebell(start, dur, freq, amp, base = 32.0)
osc0 = make_oscil(freq * 0.995)
osc1 = make_oscil(freq * 0.995 * 1.414)
osc2 = make_oscil(freq * 1.005)
osc3 = make_oscil(freq * 1.414)
ampenv1 = make_env(:envelope, [0, 0, 0.005, 1, dur, 0],
:base, base, :duration, dur)
ampenv2 = make_env(:envelope, [0, 0, 0.001, 1, dur, 0],
:base, 2 * base, :duration, dur)
ampmod = make_oscil(:frequency, 2.0)
g0 = 0.5 * amp * 0.707
g1 = 0.203
g2 = 0.5 * amp
g3 = 0.144
run_instrument(start, dur) do
(0.007 *
oscil(ampmod) + 0.993) *
(g0 * env(ampenv1) * oscil(osc0, g1 * oscil(osc1)) +
g2 * env(ampenv2) * oscil(osc2, g3 * oscil(osc3)))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stderrs; end",
"def sld; end",
"def terpene; end",
"def t1pb ast\n lmp(pgm_sl(ast).first)\n #\nend",
"def genome(liszt)\n=begin\n[samopen] SAM header is present: 2 sequences\n7621912 reads; of these:\n 4009241 (52.60%) were paired; of these:\n 1983557 (49.47%) aligned concordantly 0 times\n 18... | [
"0.5805979",
"0.5715318",
"0.5470229",
"0.5466933",
"0.5457507",
"0.54393417",
"0.5416295",
"0.5381064",
"0.53054327",
"0.53007114",
"0.5299368",
"0.521756",
"0.52167565",
"0.52074665",
"0.5203379",
"0.5200048",
"0.5194348",
"0.51868415",
"0.5182899",
"0.5182899",
"0.5175717"... | 0.0 | -1 |
from Perry Cook's Wurley.cpp | def wurley(start, dur, freq, amp)
osc0 = make_oscil(freq)
osc1 = make_oscil(freq * 4.0)
osc2 = make_oscil(510.0)
osc3 = make_oscil(510.0)
ampmod = make_oscil(:frequency, 8.0)
g0 = 0.5 * amp
g1 = 0.307
g2 = 0.5 * amp * 0.307
g3 = 0.117
dur = [dur, 0.3].max
ampenv = make_env(:envelope, [0, 0, 1, 1, 9, 1, 10, 0], :duration, dur)
indenv = make_env(:envelope, [0, 0, 0.001, 1, 0.15, 0, dur, 0],
:duration, dur)
resenv = make_env(:envelope, [0, 0, 0.001, 1, 0.25, 0, dur, 0],
:duration, dur)
run_instrument(start, dur) do
env(ampenv) *
(1.0 + 0.007 * oscil(ampmod)) *
(g0 * oscil(osc0, g1 * oscil(osc1)) +
env(resenv) * g2 * oscil(osc2, g3 * env(indenv) * oscil(osc3)))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def weber; end",
"def king_richard_iii; end",
"def jack_handey; end",
"def leeway; end",
"def leeway; end",
"def witcher; end",
"def wagner; end",
"def private; end",
"def herald; end",
"def who_we_are\r\n end",
"def buzzword; end",
"def buzzword; end",
"def superweening_adorningly(counter... | [
"0.67027414",
"0.6546995",
"0.6459957",
"0.6174895",
"0.6174895",
"0.61523396",
"0.6133107",
"0.60963076",
"0.60229",
"0.6016374",
"0.60158527",
"0.60158527",
"0.60010666",
"0.595303",
"0.5931727",
"0.5931727",
"0.5931727",
"0.58956444",
"0.58706903",
"0.5856056",
"0.5844132"... | 0.0 | -1 |
from Perry Cook's Rhodey.cpp | def rhodey(start, dur, freq, amp, base = 0.5)
osc0 = make_oscil(freq)
osc1 = make_oscil(freq * 0.5)
osc2 = make_oscil(freq)
osc3 = make_oscil(freq * 15.0)
dur = [dur, 0.3].max
ampenv1 = make_env(:envelope, [0, 0, 0.005, 1, dur, 0],
:base, base, :duration, dur)
ampenv2 = make_env(:envelope, [0, 0, 0.001, 1, dur, 0],
:base, base * 1.5, :duration, dur)
ampenv3 = make_env(:envelope, [0, 0, 0.001, 1, 0.25, 0, dur, 0],
:base, base * 4, :duration, dur)
g0 = 0.5 * amp
g1 = 0.535
g2 = 0.5 * amp
g3 = 0.109
run_instrument(start, dur) do
g0 * env(ampenv1) * oscil(osc0, g1 * oscil(osc1)) +
g2 * env(ampenv2) * oscil(osc2, env(ampenv3) * g3 * oscil(osc3))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def r; end",
"def r; end",
"def ravel; end",
"def herald; end",
"def private; end",
"def yyerrok; end",
"def yyerrok; end",
"def king_richard_iii; end",
"def gounod; end",
"def jack_handey; end",
"def weber; end",
"def rossini; end",
"def rassoc(p0) end",
"def surge; end",
"def anchored... | [
"0.71105087",
"0.71105087",
"0.66918635",
"0.6665669",
"0.6460308",
"0.6453937",
"0.6453937",
"0.64533365",
"0.6445935",
"0.64372545",
"0.6422441",
"0.6335355",
"0.63259494",
"0.6302396",
"0.6232468",
"0.6218727",
"0.6202143",
"0.6185835",
"0.61248034",
"0.6100533",
"0.602457... | 0.0 | -1 |
from Perry Cook's BeeThree.cpp | def hammondoid(start, dur, freq, amp)
osc0 = make_oscil(freq * 0.999)
osc1 = make_oscil(freq * 1.997)
osc2 = make_oscil(freq * 3.006)
osc3 = make_oscil(freq * 6.009)
dur = [dur, 0.1].max
ampenv1 = make_env(:envelope, [0, 0, 0.005, 1, dur - 0.008, 1, dur, 0],
:duration, dur)
ampenv2 = make_env(:envelope, [0, 0, 0.005, 1, dur, 0], :duration, dur)
g0 = 0.25 * 0.75 * amp
g1 = 0.25 * 0.75 * amp
g2 = 0.5 * amp
g3 = 0.5 * 0.75 * amp
run_instrument(start, dur) do
env(ampenv1) *
(g0 * oscil(osc0) +
g1 * oscil(osc1) +
g2 * oscil(osc2)) +
env(ampenv2) * g3 * oscil(osc3)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def berlioz; end",
"def bizet; end",
"def bellini; end",
"def probers; end",
"def terpene; end",
"def weber; end",
"def blg; end",
"def buzzword; end",
"def buzzword; end",
"def mitch_hedberg; end",
"def private; end",
"def nebula; end",
"def villian; end",
"def m3\n\t\t\t\t\tsuper * 2\t\... | [
"0.6367179",
"0.6146615",
"0.60969824",
"0.6006979",
"0.59848",
"0.59244907",
"0.5904037",
"0.5878489",
"0.5878489",
"0.5866335",
"0.58624643",
"0.5852011",
"0.5826692",
"0.5771208",
"0.5771208",
"0.5771208",
"0.57697123",
"0.57440376",
"0.5742661",
"0.56671864",
"0.56671864"... | 0.0 | -1 |
from Perry Cook's HeavyMtl.cpp | def metal(start, dur, freq, amp)
osc0 = make_oscil(freq)
osc1 = make_oscil(freq * 4.0 * 0.999)
osc2 = make_oscil(freq * 3.0 * 1.001)
osc3 = make_oscil(freq * 0.5 * 1.002)
dur = [dur, 0.1].max
ampenv0 = make_env(:envelope, [0, 0, 0.001, 1, dur - 0.002, 1, dur, 0],
:duration, dur)
ampenv1 = make_env(:envelope, [0, 0, 0.001, 1, dur - 0.011, 1, dur, 0],
:duration, dur)
ampenv2 = make_env(:envelope, [0, 0, 0.01, 1, dur - 0.015, 1, dur, 0],
:duration, dur)
ampenv3 = make_env(:envelope, [0, 0, 0.03, 1, dur - 0.04, 1, dur, 0],
:duration, dur)
g0 = 0.615 * amp
g1 = 0.202
g2 = 0.574
g3 = 0.116
run_instrument(start, dur) do
g0 *
env(ampenv0) *
oscil(osc0,
g1 * env(ampenv1) * oscil(osc1, g2 * env(ampenv2) * oscil(osc2)) +
g3 * env(ampenv3) * oscil(osc3))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def metal; end",
"def mitch_hedberg; end",
"def trader; end",
"def smoothing; end",
"def malts; end",
"def hamlet; end",
"def warmup(prc = T.unsafe(nil), &block); end",
"def measure; end",
"def blg; end",
"def mega\n big_self * MEGA\n end",
"def mob; end",
"def mozart; end",
"def on... | [
"0.6095991",
"0.57584226",
"0.5624424",
"0.55680835",
"0.5521735",
"0.5518486",
"0.55049753",
"0.54677534",
"0.5449765",
"0.54292256",
"0.53371084",
"0.5264886",
"0.52006525",
"0.5197297",
"0.5186068",
"0.5160597",
"0.5139476",
"0.5139476",
"0.5130518",
"0.51284677",
"0.51284... | 0.5090638 | 23 |
NREV (the most popular Samson box reverb) reverb_factor controls the length of the decay it should not exceed (/ 1.0 .823) lp_coeff controls the strength of the low pass filter inserted in the feedback loop volume can be used to boost the reverb output | def nrev_rb(*args)
reverb_factor, lp_coeff, volume = nil
optkey(args, binding,
[:reverb_factor, 1.09],
[:lp_coeff, 0.7],
[:volume, 1.0])
next_prime = lambda do |val|
if val.prime?
val
else
next_prime.call(val + 2)
end
end
srscale = @srate / 25641
dly_len = [1433, 1601, 1867, 2053, 2251, 2399,
347, 113, 37, 59, 53, 43, 37, 29, 19]
dly_len.map! do |x|
val = (x * srscale).round
val += 1 if val.even?
next_prime.call(val)
end
comb1 = make_comb(0.822 * reverb_factor, dly_len[0])
comb2 = make_comb(0.802 * reverb_factor, dly_len[1])
comb3 = make_comb(0.773 * reverb_factor, dly_len[2])
comb4 = make_comb(0.753 * reverb_factor, dly_len[3])
comb5 = make_comb(0.753 * reverb_factor, dly_len[4])
comb6 = make_comb(0.733 * reverb_factor, dly_len[5])
low = make_one_pole(lp_coeff, lp_coeff - 1.0)
chan2 = (@channels > 1)
chan4 = (@channels == 4)
allpass1 = make_all_pass(-0.7, 0.7, dly_len[6])
allpass2 = make_all_pass(-0.7, 0.7, dly_len[7])
allpass3 = make_all_pass(-0.7, 0.7, dly_len[8])
allpass4 = make_all_pass(-0.7, 0.7, dly_len[9]) # 10 for quad
allpass5 = make_all_pass(-0.7, 0.7, dly_len[11])
allpass6 = (chan2 ? make_all_pass(-0.7, 0.7, dly_len[12]) : nil)
allpass7 = (chan4 ? make_all_pass(-0.7, 0.7, dly_len[13]) : nil)
allpass8 = (chan4 ? make_all_pass(-0.7, 0.7, dly_len[14]) : nil)
reverb_frame = make_frame(@channels)
run_reverb() do |val, i|
rev = volume * val
outrev = all_pass(allpass4,
one_pole(low,
all_pass(allpass3,
all_pass(allpass2,
all_pass(allpass1,
comb(comb1, rev) +
comb(comb2, rev) +
comb(comb3, rev) +
comb(comb4, rev) +
comb(comb5, rev) +
comb(comb6, rev))))))
frame_set!(reverb_frame, 0, all_pass(allpass5, outrev))
frame_set!(reverb_frame, 1, all_pass(allpass6, outrev)) if chan2
frame_set!(reverb_frame, 2, all_pass(allpass7, outrev)) if chan4
frame_set!(reverb_frame, 3, all_pass(allpass8, outrev)) if chan4
reverb_frame
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_reverb(chan, &environ)\n name = get_func_name(3)\n dur = samples2seconds(@ws_reverb.length)\n if @clm then dur += @decay_time end\n with_sound_info(\"reverb \" + name, 0, dur, environ)\n if @verbose\n Snd.message(\"%s on %d in and %d out channels\", name, @reverb_channels, @channels)\n ... | [
"0.4891579",
"0.4746585",
"0.46803853",
"0.4647988",
"0.4605946",
"0.45485547",
"0.4545273",
"0.45179445",
"0.44937345",
"0.44044513",
"0.4356429",
"0.4351967",
"0.43448365",
"0.43068734",
"0.42997524",
"0.42981714",
"0.4288264",
"0.42671216",
"0.42451477",
"0.42300647",
"0.4... | 0.69218296 | 0 |
STK's feedbackfm instrument named CelloN in Samboxland | def cellon(start, dur, pitch0, amp, ampfun, betafun,
beta0, beta1, betaat, betadc, ampat, ampdc, dis, pcrev, deg, pitch1,
glissfun = [0, 0, 100, 0], glissat = 0.0, glissdc = 0.0,
pvibfreq = 0.0, pvibpc = 0.0,
pvibfun = [0, 1, 100, 1], pvibat = 0.0, pvibdc = 0.0,
rvibfreq = 0.0, rvibpc = 0.0, rvibfun = [0, 1, 100, 1])
pit1 = pitch1.zero? ? pitch0 : pitch1
car = make_oscil(:frequency, pitch0)
low = make_one_zero(0.5, -0.5)
fmosc = make_oscil(:frequency, pitch0)
fm = 0.0
dur = dur.to_f
pitch0 = pitch0.to_f
pvib = make_triangle_wave(:frequency, pvibfreq, :amplitude, 1.0)
rvib = make_rand_interp(:frequency, rvibfreq, :amplitude, 1.0)
ampap = (ampat > 0.0 ? (100 * (ampat / dur)) : 25)
ampdp = (ampdc > 0.0 ? (100 * (1.0 - ampdc / dur)) : 75)
glsap = (glissat > 0.0 ? (100 * (glissat / dur)) : 25)
glsdp = (glissdc > 0.0 ? (100 * (1.0 - glissdc / dur)) : 75)
betap = (betaat > 0.0 ? (100 * (betaat / dur)) : 25)
betdp = (betadc > 0.0 ? (100 * (1.0 - betadc / dur)) : 75)
pvbap = (pvibat > 0.0 ? (100 * (pvibat / dur)) : 25)
pvbdp = (pvibdc > 0.0 ? (100 * (1.0 - pvibdc / dur)) : 75)
pvibenv = make_env(:envelope,
stretch_envelope(pvibfun, 25, pvbap, 75, pvbdp),
:scaler, hz2radians(pvibpc * pitch0),
:duration, dur)
rvibenv = make_env(:envelope, stretch_envelope(rvibfun),
:duration, dur,
:scaler, hz2radians(rvibpc * pitch0))
glisenv = make_env(:envelope,
stretch_envelope(glissfun, 25, glsap, 75, glsdp),
:scaler, hz2radians(pit1 - pitch0),
:duration, dur)
amplenv = make_env(:envelope, stretch_envelope(ampfun, 25, ampap, 75, ampdp),
:scaler, amp,
:duration, dur)
betaenv = make_env(:envelope, stretch_envelope(betafun, 25, betap, 75, betdp),
:scaler, beta1 - beta0,
:offset, beta0,
:duration, dur)
run_instrument(start, dur,
:degree, deg,
:distance, dis,
:reverb_amount, pcrev) do
vib = env(pvibenv) * triangle_wave(pvib) +
env(rvibenv) * rand_interp(rvib) +
env(glisenv)
fm = one_zero(low, env(betaenv) * oscil(fmosc, fm + vib))
env(amplenv) * oscil(car, fm + vib)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def throw_fierce_lqqks\n 'Here I am, giving you Soviet-Satellite realness'\n end",
"def go_to_lab\n show do\n warning \"Go to Seelig Lab in order to use the spectrophotometer.\"\n \n end\n end",
"def modeler_description\n return 'This measure receives the AntiSweat... | [
"0.5507099",
"0.54901654",
"0.53727746",
"0.53565323",
"0.5337505",
"0.53331035",
"0.5316959",
"0.5227726",
"0.5188965",
"0.51888937",
"0.5182733",
"0.5171826",
"0.51662916",
"0.51482105",
"0.51416904",
"0.51319784",
"0.51006365",
"0.5092843",
"0.50833756",
"0.5041037",
"0.50... | 0.0 | -1 |
TWOTAB interpolate between two waveforms (this could be extended to implement all the various wavetablebased synthesis techniques). | def two_tab(start, dur, freq, amp,
partial_1 = [1.0, 1.0, 2.0, 0.5],
partial_2 = [1.0, 0.0, 3.0, 1.0],
amp_envelope = [0, 0, 50, 1, 100, 0],
interp_func = [0, 1, 100, 0],
vibrato_amplitude = 0.005,
vibrato_speed = 5.0,
degree = 0.0,
distance = 1.0,
rev_amount = 0.005)
waveform_1 = partials2wave(partial_1)
waveform_2 = partials2wave(partial_2)
frq = hz2radians(freq)
s_1 = make_table_lookup(:frequency, freq, :wave, waveform_1)
s_2 = make_table_lookup(:frequency, freq, :wave, waveform_2)
amp_env = make_env(:envelope, amp_envelope, :scaler, amp, :duration, dur)
interp_env = make_env(:envelope, interp_func, :duration, dur)
per_vib = make_triangle_wave(:frequency, vibrato_speed,
:amplitude, vibrato_amplitude * frq)
ran_vib = make_rand_interp(:frequency, vibrato_speed + 1.0,
:amplitude, vibrato_amplitude * frq)
run_instrument(start, dur,
:degree, degree,
:distance, distance,
:reverb_amount, rev_amount) do
vib = triangle_wave(per_vib) + rand_interp(ran_vib)
intrp = env(interp_env)
env(amp_env) *
(intrp * table_lookup(s_1, vib) +
(1.0 - intrp) * table_lookup(s_2, vib))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def interpolate(a, b)\n a = a.to_f\n b = b.to_f\n b -= a\n\n lambda { |t| a + b * t }\n end",
"def trms_interpolate_to_quarterly\n raise InterpolationException if frequency != 'year'\n new_series_data = {}\n previous_data_val = nil\n previous_year = nil\n last_diff = nil\n data.sor... | [
"0.5915294",
"0.5251918",
"0.52118206",
"0.5191409",
"0.51543355",
"0.5103181",
"0.4964986",
"0.4890669",
"0.48775032",
"0.48724917",
"0.48565173",
"0.48035657",
"0.47636166",
"0.47450668",
"0.4659156",
"0.4647076",
"0.46460885",
"0.46191517",
"0.46185544",
"0.46131974",
"0.4... | 0.6136509 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.