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 |
|---|---|---|---|---|---|---|
Never trust parameters from the scary internet, only allow the white list through. | def product_params
params[:order].permit(:customer_id, :product_ids, :order_id)
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.6980629",
"0.67819995",
"0.67467666",
"0.67419875",
"0.67347664",
"0.65928614",
"0.6504013",
"0.6498014",
"0.64819515",
"0.64797956",
"0.64562726",
"0.64400834",
"0.6380117",
"0.6377456",
"0.63656694",
"0.6320543",
"0.63002014",
"0.62997127",
"0.629425",
"0.6293866",
"0.62... | 0.0 | -1 |
Store the Request Encoded Token to Redis temp table on user's login def auth_token_store_for_user_device (auth_token, encoded_token, user_id, ip_addr, bw_hash) For UserID, IP, Browser Hash end | def validate_authorize_token (auth_token, allow_visitor_changes = true, *scopes_required)
return {status: :bad_request} if(auth_token.blank? or auth_token[0]['vis'].blank?)
$visitor = DT_Visitor.new(request.remote_ip) if($visitor.nil?)
$visitor.browser = Browser.new(request.env['HTTP_USER_AGENT'])
v... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_token\n self.token ||= Digest::MD5.hexdigest(login + Time.now.to_i.to_s)[0..5]\n $redis.set \"#{KEY}:#{login}:token\", token\n $redis.set \"#{KEY}:#{token}:login\", login\n end",
"def set_auth_token_cache(auth_token, raw_token)\n Authentication::RedisStore.instance.set(auth_toke... | [
"0.6681986",
"0.6596309",
"0.656263",
"0.648226",
"0.6271607",
"0.6217115",
"0.61321217",
"0.61278766",
"0.6113765",
"0.61132103",
"0.6102143",
"0.6084657",
"0.60757256",
"0.60678667",
"0.6063059",
"0.60502243",
"0.6039724",
"0.6012004",
"0.60097367",
"0.6005938",
"0.5983252"... | 0.0 | -1 |
is this true? def value_if_nil(method) if self.method == nil return "" else self.method end end how do i get this in views? | def if_nil(argument)
if argument == nil
""
else
argument
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def displayNull \n \"displayNull\" \n end",
"def nil \n \"nil\" \n end",
"def lookup_method_to_call( default_value=nil )\n @_method ||= nil\n @_method.nil? ? default_value.to_s : @_method\n end",
"def field_value(field)\n @object.respond_to?(field) ? @object.send(f... | [
"0.6578979",
"0.62034017",
"0.61200935",
"0.60872954",
"0.60662454",
"0.5924198",
"0.5896484",
"0.58818626",
"0.58712584",
"0.5857385",
"0.58525896",
"0.5850145",
"0.5784604",
"0.5763236",
"0.5757279",
"0.5689906",
"0.56874686",
"0.568185",
"0.567821",
"0.5656796",
"0.5632797... | 0.56549793 | 20 |
primes(num) returns an array of the first "num" primes. You may wish to use an is_prime? helper method. | def is_prime?(num)
(2..num-1).each do |x|
return false if num % x == 0
end
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def primes(num)\n\twhole_array = (2..num).to_a\n\tprime_array = [whole_array.shift]\n\n\tuntil whole_array == []\n\t\twhole_array.delete_if { |x| x % prime_array.last == 0 }\n\t\tprime_array << whole_array.shift\n\tend\n\tprime_array\nend",
"def primes_less_than(num)\n require 'prime'\n arr = []\n Prime... | [
"0.78565454",
"0.78115475",
"0.773727",
"0.7687439",
"0.76224995",
"0.75731754",
"0.75408304",
"0.7398992",
"0.7373404",
"0.73228616",
"0.7315991",
"0.7302204",
"0.72934705",
"0.7289166",
"0.72817385",
"0.72709435",
"0.7239993",
"0.7198681",
"0.71609604",
"0.71609604",
"0.713... | 0.0 | -1 |
Write a recursive method that returns the first "num" factorial numbers. Note that the 1st factorial number is 0!, which equals 1. The 2nd factorial is 1!, the 3rd factorial is 2!, etc. | def factorials_rec(num)
return [1] if num == 1
prev = factorials_rec(num-1)
prev + [prev.last * (num-1)]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first_factorial(num)\n if num < 2\n return 1\n else\n return num * first_factorial(num - 1)\n end\nend",
"def FirstFactorial(num)\n if num > 1\n return num*(FirstFactorial(num-1)) \n end\n return num \nend",
"def factorialrecursion num\n\tif num < 0\n\t\tnil\n\tend\n\t\n\tif nu... | [
"0.8540021",
"0.8369383",
"0.82035506",
"0.81166357",
"0.7965866",
"0.784428",
"0.78138465",
"0.78060853",
"0.78037107",
"0.7797659",
"0.77891815",
"0.778668",
"0.77804583",
"0.7778425",
"0.7764591",
"0.7754001",
"0.7744245",
"0.77442354",
"0.7743448",
"0.77402467",
"0.774024... | 0.75855356 | 35 |
This method expects an array of certnames to get facts for | def facts_for_node(certnames)
return {} if certnames.empty? || certnames.nil?
certnames.uniq!
name_query = certnames.map { |c| ["=", "certname", c] }
name_query.insert(0, "or")
@logger.debug("Querying certnames")
result = make_query(name_query, 'inventory')
res... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def facts_for_node(certnames)\n return {} if certnames.empty? || certnames.nil?\n\n certnames.uniq!\n name_query = certnames.map { |c| [\"=\", \"certname\", c] }\n name_query.insert(0, \"or\")\n result = make_query(name_query, 'inventory')\n\n result&.each_with_object({}) ... | [
"0.75025713",
"0.6290069",
"0.61423063",
"0.6114281",
"0.5712053",
"0.5709194",
"0.56535554",
"0.5543055",
"0.5502361",
"0.5449369",
"0.5427009",
"0.5333759",
"0.53183925",
"0.53022635",
"0.529403",
"0.52524096",
"0.52503765",
"0.5244014",
"0.5230819",
"0.52054024",
"0.516463... | 0.77868253 | 0 |
Sends a command to PuppetDB using version 1 of the commands API. | def send_command(command, version, payload)
command = command.dup.force_encoding('utf-8')
body = JSON.generate(payload)
# PDB requires the following query parameters to the POST request.
# Error early if there's no certname, as PDB does not return a
# message indicating it's ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def command command_string\n connection.command self.id, nil, command_string\n end",
"def send_command(command)\n @client.write \"#{command}\\r\\n\"\n end",
"def send_command cmd\n raise \"Must be a command object\" unless cmd.is_a? NEAT::Daemon::Command\n @amqp[:exchange].pub... | [
"0.65926534",
"0.6254736",
"0.6169471",
"0.6147442",
"0.60508424",
"0.59976655",
"0.59907955",
"0.5916919",
"0.5906037",
"0.57912946",
"0.5715647",
"0.5710672",
"0.5646185",
"0.5639846",
"0.5616067",
"0.5616067",
"0.5565394",
"0.5550372",
"0.5549143",
"0.55466586",
"0.5527333... | 0.71985114 | 0 |
def choix puts "On refait une partie? Y/N" reponse = gets.chomp if reponse == Y start_game elsif reponse == N exit end end | def run_game
start_game
new_board
while true
print_grid
tour_joueur1
tour_joueur2
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def game\n puts \"Time to play rock, paper, scissors, lizard, spock!\"\n puts \"Choose your move!\"\n get_input\n puts \"play again? (y)es (n)o\"\n choice = gets.chomp.strip.downcase\n exit unless choice.include?(\"y\")\n game\nend",
"def menu(game)\n puts \"Do you want to play tic-tac-toe? 1 for yes 2 f... | [
"0.76431066",
"0.75547856",
"0.7551299",
"0.74730146",
"0.7417366",
"0.74143034",
"0.7353003",
"0.73515654",
"0.7337084",
"0.7334342",
"0.72779363",
"0.72754425",
"0.7273017",
"0.726523",
"0.726167",
"0.7234904",
"0.7233774",
"0.7225321",
"0.7216455",
"0.7202102",
"0.7185859"... | 0.0 | -1 |
TODO: Clean up store instantiation pattern | def get_player
store = YAML::Store.new pathname
store.transaction { store[:player] }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def store; end",
"def store; end",
"def store; end",
"def initialize\n @store = {}\n end",
"def store(*args); end",
"def store?; end",
"def store; shrine_class.new(store_key); end",
"def initialize_store(store_name)\n PStore.new(store_name)\nend",
"def initialize\n @store = []\n end",
"d... | [
"0.75567037",
"0.75567037",
"0.75567037",
"0.74326533",
"0.72809666",
"0.71374184",
"0.7103844",
"0.69606096",
"0.69417",
"0.69415563",
"0.69136626",
"0.6887939",
"0.6886042",
"0.6828794",
"0.6828533",
"0.68071544",
"0.6785086",
"0.6754625",
"0.6754625",
"0.67338645",
"0.6702... | 0.0 | -1 |
Returns collection of all enabled projects available to given user | def all_enabled(options)
all(options).select do |project_info|
project_info.enabled?
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def projects_visible_to_current_user\n ::Project\n .in_namespace(group.self_and_descendants.select(:id))\n .public_or_visible_to_user(current_user)\n end",
"def projects\n if is_deploy_key\n [project]\n else\n user.projects\n end\n end",
"def projects\n proj... | [
"0.7485692",
"0.74032795",
"0.7398234",
"0.7381517",
"0.7381517",
"0.7325911",
"0.7310784",
"0.72453713",
"0.72235394",
"0.72184026",
"0.70855075",
"0.70250344",
"0.7022241",
"0.69961876",
"0.69845533",
"0.69790876",
"0.6944125",
"0.6933042",
"0.69318664",
"0.69116956",
"0.69... | 0.0 | -1 |
Finds project by it's Gitlab ID | def find(id, options)
# Note: We don't want to cache the project query, because
# GitlabConnector might return project info even if it is not managable
# for given user
gitlab = options[:for_user].gitlab
gitlab_project = gitlab.project(id)
return nil unless gitlab_project
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_project\n identifier = params[:project_id]\n scope = Project.active.has_module(:repository)\n project = scope.find_by_identifier(identifier.downcase)\n raise ActiveRecord::RecordNotFound unless project\n return project\n end",
"def project(id)\n self.projects(\"all\").detect { |p| p.i... | [
"0.8072828",
"0.7957781",
"0.78595644",
"0.76261467",
"0.75262505",
"0.7477733",
"0.74323434",
"0.74323434",
"0.7424963",
"0.74170667",
"0.73881376",
"0.73881376",
"0.73837537",
"0.7382701",
"0.7370688",
"0.7339323",
"0.73366576",
"0.7324025",
"0.7316117",
"0.7216132",
"0.716... | 0.75916845 | 4 |
Finds project by it's path (namespace / project) | def find_by_path(namespace_path, project_path, options)
gitlab = options[:for_user].gitlab
matching_projects = gitlab.cached_user_projects.select do |_, project|
if project[:namespace] && project[:namespace][:path] == namespace_path
project[:path] == project_path
else
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_active_project\n if @textmate.documents.first\n active_path = @textmate.documents.first.path\n @projects.find {|p| active_path =~ /^#{p.path}/}\n end\n end",
"def find_project(workspace, name)\r\n project = nil\r\n if ( name != \"Parent\")\r\n project = workspace.projects... | [
"0.7183064",
"0.7097036",
"0.70197225",
"0.7014668",
"0.7014668",
"0.6996846",
"0.69947654",
"0.6902541",
"0.6833138",
"0.6783322",
"0.6673519",
"0.6662364",
"0.6627024",
"0.6606814",
"0.65869266",
"0.65699655",
"0.65347487",
"0.64997774",
"0.6485424",
"0.64745456",
"0.642102... | 0.68250585 | 9 |
should return 0000 0100 0001 0000 | def discover_points # step 1
x = 0
y = 0
@image_arr.each do |row|
x = 0
row.each do |cell|
if cell == 1 # discovered the cell is 1
@ordinal_arr.push([y,x]) # this is where i push the ordinals.
puts "#{y},#{x}"
end
x = x + 1
end
y ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bin(x)\n x.to_s(16).chars.to_a.map{|d| d.to_i(16).to_s(2).rjust(4, '0')}.join(' ')\nend",
"def pattern_bits\n str = bits.to_s(2)\n str = str.rjust(self.step_count, '0')\n str.chars.collect{|x|x=='1'}\n end",
"def binary\n decimal.to_s(2).rjust(8, '0')\n end",
"def replace_binary(str)... | [
"0.660279",
"0.65798354",
"0.63944554",
"0.6379466",
"0.6379466",
"0.6359937",
"0.6349933",
"0.63285965",
"0.63102293",
"0.627532",
"0.62489974",
"0.617238",
"0.6168141",
"0.61340326",
"0.6105748",
"0.60867745",
"0.607527",
"0.605867",
"0.60581535",
"0.6048288",
"0.603121",
... | 0.0 | -1 |
GET /docs GET /docs.json | def index
if params[:view] == "last"
@docs = Doc.find_all_by_created_by(current_user.email)
unless @docs.blank?
@docs = [@docs.sort{|x,y| x.updated_at <=> y.updated_at}.last]
end
elsif params[:view] == "deprecated"
@docs = Doc.find_all_by_deprecated(true)
else
params[:search] ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def documents(params={})\n server.get(\"#{name}/_all_docs\", params)\n end",
"def docs\n @docs ||= raw_response['response']['docs']\n end",
"def docs api\n\t\tget_html \"#{@options[:docs]}/#{@apis[api][:url]}.htm\"\n\tend",
"def index\n @documents = Document.all\n\n respond_to do |f... | [
"0.7754817",
"0.73168564",
"0.72231567",
"0.72078264",
"0.7152903",
"0.7129849",
"0.711735",
"0.7095418",
"0.7080763",
"0.6848705",
"0.68337184",
"0.6829536",
"0.681571",
"0.6811151",
"0.68056756",
"0.6799729",
"0.6770199",
"0.6768741",
"0.67258096",
"0.6724253",
"0.671709",
... | 0.69525224 | 9 |
GET /docs/1 GET /docs/1.json | def show
@doc = Doc.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @doc }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def documents(params={})\n server.get(\"#{name}/_all_docs\", params)\n end",
"def get_document index, id\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_doc/#{id}\")\n req = Net::HTTP::Get.new(uri)\n run(uri, req)\n end",
"def index\n @documents = Document.all\n\n respond_to do |form... | [
"0.70895255",
"0.7012796",
"0.68799365",
"0.685092",
"0.68200016",
"0.6787213",
"0.6655958",
"0.665376",
"0.66343766",
"0.66319126",
"0.66288614",
"0.6607591",
"0.6607101",
"0.66051066",
"0.6562644",
"0.65557605",
"0.6550644",
"0.65431905",
"0.65348536",
"0.6532803",
"0.65286... | 0.71081495 | 0 |
GET /docs/new GET /docs/new.json | def new
if params[:id]
@old_doc = Doc.find(params[:id])
@doc = Doc.new({:component => @old_doc.component, :maj_version => (params[:version] == "major" ? @old_doc.maj_version + 1 : @old_doc.maj_version ), :min_version => (params[:version] == "minor" ? @old_doc.min_version + 1 : @old_doc.min_version), :dev_sta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n \n @document = Document.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document }\n end\n \n end",
"def new\n @special_document = ModifiedDocument.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json {... | [
"0.75819236",
"0.7419194",
"0.7382026",
"0.7373448",
"0.7373448",
"0.7373448",
"0.7373448",
"0.7373448",
"0.7373448",
"0.7373448",
"0.7373448",
"0.7373448",
"0.72789603",
"0.7020201",
"0.69840705",
"0.6958336",
"0.6915672",
"0.69136286",
"0.6911274",
"0.6878745",
"0.6831669",... | 0.7041195 | 13 |
POST /docs POST /docs.json | def create
@doc = Doc.new(params[:doc])
respond_to do |format|
if @doc.save
format.html { redirect_to @doc, notice: "\"#{@doc.component}\" was successfully created." }
format.json { render json: @doc, status: :created, location: @doc }
else
format.html { render action: "new"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @documentation = current_user.documentations.build(documentation_params)\n\n respond_to do |format|\n if @documentation.save\n format.html { redirect_to @documentation, notice: 'Documentation was successfully created.' }\n format.json { render :show, status: :created, location... | [
"0.65525573",
"0.64653116",
"0.6416161",
"0.6412102",
"0.64093024",
"0.6374213",
"0.6360607",
"0.63537806",
"0.6316606",
"0.626678",
"0.62502766",
"0.6242765",
"0.6235035",
"0.6223301",
"0.6211914",
"0.6208781",
"0.6208781",
"0.61932325",
"0.6160277",
"0.615898",
"0.6157754",... | 0.6413679 | 3 |
PUT /docs/1 PUT /docs/1.json | def update
@doc = Doc.find(params[:id])
# do a check to make sure the editor hasn't incremented the version without making a new doc first - if true then create new doc instead
@version = params[:doc][:dev_stage] + " " + params[:doc][:maj_version] + "." + params[:doc][:min_version]
unless @doc.get_version... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put_document index, id, document\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_doc/#{id}\")\n req = Net::HTTP::Put.new(uri)\n req.body = document.to_json\n run(uri, req)\n end",
"def update!(**args)\n @docs = args[:docs] if args.key?(:docs)\n end",
"def put( doc, opts = {}... | [
"0.69887424",
"0.68877685",
"0.68548435",
"0.6849533",
"0.67706853",
"0.6632565",
"0.65742505",
"0.6528036",
"0.647579",
"0.6431722",
"0.64214534",
"0.63548714",
"0.63513464",
"0.63313663",
"0.6323787",
"0.62923336",
"0.62324226",
"0.6194112",
"0.6189256",
"0.618634",
"0.6179... | 0.577267 | 92 |
DELETE /docs/1 DELETE /docs/1.json | def destroy
@doc = Doc.find(params[:id])
@doc.destroy
respond_to do |format|
format.html { redirect_to docs_url }
format.json { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n @client.delete_document(@path)\n end",
"def destroy\n @doc.destroy\n respond_to do |format|\n format.html { redirect_to docs_url, notice: 'Документ был удалён' }\n format.json { head :no_content }\n end\n end",
"def delete_document index, id\n uri = URI(\"htt... | [
"0.75944895",
"0.75073785",
"0.74701095",
"0.7256425",
"0.723555",
"0.723555",
"0.72186625",
"0.7185573",
"0.7178284",
"0.7062502",
"0.705485",
"0.70414793",
"0.70191264",
"0.7007405",
"0.70025456",
"0.6986645",
"0.6983179",
"0.6983179",
"0.6983179",
"0.6983179",
"0.6983179",... | 0.76623607 | 0 |
THIS IS WHAT YOUR ATTR ACCESSORS ARE WRITING FOR YOU: reader, getter def owner_name | def print_balance
# $50.00
# "$" + balance.to_s + ".00"
"$#{balance}.00"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name\n @owner\n end",
"def owner\n attribute_prop(6)\n end",
"def name_reader\n @name\n end",
"def get_name # AK as mentioned in `item.rb`, getters and setters are generated by `attr_accessor`. Kind of like in C# with properties.\r\n \"#{self.name}\"\r\n end",
"def owner; end",
... | [
"0.7591164",
"0.7527294",
"0.7045502",
"0.7044509",
"0.69646996",
"0.69646996",
"0.69642895",
"0.6908323",
"0.69001955",
"0.6895809",
"0.6891044",
"0.6850132",
"0.6734654",
"0.67327636",
"0.6731355",
"0.66905063",
"0.66905063",
"0.66905063",
"0.66905063",
"0.66905063",
"0.669... | 0.0 | -1 |
The balance writer method is private it can only be called by other instance methods | def balance=(balance)
@balance = balance
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def balance\n super\n end",
"def balance\n super\n end",
"def balance #same as attr_reader :balance\n @balance\n end",
"def springboard_adjust_balance!\n springboard_export_class.adjust_balance(self)\n end",
"def balance=(value)\n @balance = value\n end",
"def balance\n ... | [
"0.6756261",
"0.6756261",
"0.6490155",
"0.63468426",
"0.6174957",
"0.61598265",
"0.61190987",
"0.60880077",
"0.6086511",
"0.6062125",
"0.6052033",
"0.60375065",
"0.6020168",
"0.6013832",
"0.59969586",
"0.5988138",
"0.5970784",
"0.59587455",
"0.59293336",
"0.5925784",
"0.59080... | 0.6177398 | 4 |
Function automatically checks if URI has protocol specified, if not it adds the http. | def uri_normalize(uri)
return 'http://' + uri unless uri =~ /http:\/\//
uri
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_url_protocol\n unless url[/\\Ahttp:\\/\\//] || url[/\\Ahttps:\\/\\//]\n self.url = \"http://#{self.url}\"\n end\n end",
"def smart_add_url_protocol\n return if self.original.blank?\n unless self.original[/\\Ahttp:\\/\\//] || self.original[/\\Ahttps:\\/\\//]\n self.original = \"http... | [
"0.8039781",
"0.7968304",
"0.78166825",
"0.77317053",
"0.77317053",
"0.7615313",
"0.7564061",
"0.7397988",
"0.717515",
"0.7113219",
"0.7111266",
"0.710505",
"0.70534384",
"0.69170445",
"0.6895583",
"0.6887996",
"0.688446",
"0.6865225",
"0.68546885",
"0.67916536",
"0.6785705",... | 0.66126454 | 26 |
Not needed since Rails 2.2, the followings are automatically provided. =begin def setup | def test_dvd_routings
assert_routing '/dvds', :controller => 'dvds', :action => 'index'
assert_routing '/dvds/index/1', :controller => 'dvds', :action => 'index', :id => '1'
assert true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def before_setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setu... | [
"0.80879396",
"0.775352",
"0.775352",
"0.775352",
"0.775352",
"0.775352",
"0.775352",
"0.775352",
"0.775352",
"0.775352",
"0.775352",
"0.775352",
"0.775352",
"0.775352",
"0.775352",
"0.775352",
"0.775352",
"0.775352",
"0.775352",
"0.775352",
"0.7704747",
"0.76450616",
"0.... | 0.0 | -1 |
No way to change password for 'CAS' account | def lost_password_with_cas
if request.post?
user = User.find_by_mail(params[:mail])
flash.now[:error] = l(:notice_can_t_change_password) and return if (user and !user.change_password_allowed?)
lost_password_without_cas
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_password!(password)\n json = JSON.generate(:changePassword => { :adminPass => password })\n @compute.connection.req('POST', \"/servers/#{@id}/action\", :data => json)\n @adminPass = password\n end",
"def password=(new_password); end",
"def change_password!(opts = {})\n passwor... | [
"0.74551946",
"0.7143379",
"0.70965105",
"0.70362765",
"0.6977774",
"0.69075316",
"0.6894504",
"0.6850493",
"0.68022543",
"0.67888623",
"0.67692524",
"0.67607176",
"0.6754935",
"0.67481637",
"0.6718015",
"0.6700283",
"0.6663237",
"0.6643354",
"0.6616087",
"0.66035026",
"0.657... | 0.0 | -1 |
Called during save, after all validations have passed | def create_fedora_object
Concept.new(pid: next_pid)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_validate\n end",
"def save_with_validation!()\n if valid?\n save_without_validation!()\n else\n raise RecordInvalid.new(self)\n end\n end",
"def save!\n valid?\n end",
"def save!\n unless self.class.validators.empty?\n errors.clear\n ... | [
"0.7523",
"0.6989928",
"0.69116414",
"0.6847265",
"0.6841014",
"0.6824149",
"0.6770115",
"0.67432845",
"0.6739385",
"0.6737039",
"0.67241156",
"0.6719951",
"0.6716811",
"0.6681919",
"0.66747475",
"0.6662704",
"0.66440934",
"0.66312957",
"0.6627666",
"0.66034424",
"0.6559566",... | 0.0 | -1 |
Overriding base behavior to also include publish_target_data | def data_for_hyacinth_ds
data = super
data[DIGITAL_OBJECT_DATA_KEY] = Marshal.load(Marshal.dump(@publish_target_data))
data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def publisher; end",
"def publisher; end",
"def publish!\n raise 'Not implemented!'\n end",
"def publisher\n end",
"def publish(data = {})\n assign_properties(data)\n\n self\n end",
"def publish\n end",
"def publish\n end",
"def publish\n end",
"def publish(type, data... | [
"0.6203195",
"0.6203195",
"0.6105072",
"0.60778487",
"0.605585",
"0.59601164",
"0.59601164",
"0.59601164",
"0.58785844",
"0.57438725",
"0.5708722",
"0.5666639",
"0.56363684",
"0.5634931",
"0.5605465",
"0.5561241",
"0.55359155",
"0.55359155",
"0.5528453",
"0.54972124",
"0.5481... | 0.5285753 | 41 |
provides access to tokens, through token identifier | def token(tokenname)
@tokens[tokenname.to_sym]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def token\n end",
"def token; end",
"def token; end",
"def token; end",
"def token; end",
"def token; end",
"def token; end",
"def token\n @token\n end",
"def getToken\n @tokens\n end",
"def token\n @token\n end",
"def token_key\n @token_key\n end",
"def id\n tok... | [
"0.73532635",
"0.7225251",
"0.7225251",
"0.7225251",
"0.7225251",
"0.7225251",
"0.7225251",
"0.72087044",
"0.7192733",
"0.7176242",
"0.70365834",
"0.7020811",
"0.6940149",
"0.6940149",
"0.6940149",
"0.6940149",
"0.6940149",
"0.6940149",
"0.6940149",
"0.6940149",
"0.6804187",
... | 0.7387965 | 0 |
tries to find matching tokenklass for token i.e. Token::Token::ParamToken for :param then calls matching tokenhandler (if exists) with data in `this`context | def process_token(tokenline)
begin
camelcased = tokenline.token.to_s.capitalize.gsub(/_\w/){|w| w[1].capitalize}
tokenklass = Token.const_get "#{camelcased}Token"
instance_exec(tokenklass, tokenline.content, &(tokenklass.handler))
rescue Exception => error
raise NoTokenHa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_class(token)\n if @subroutine.key?(token.val)\n @subroutine[token.val].get_class\n else\n @class[token.val].get_class\n end\n end",
"def process_token(token)\n # Create a ProcessedToken to make sure we don't process the same thing twice\n processed_token = ProcessedToken.new... | [
"0.62583226",
"0.6158763",
"0.59636706",
"0.59003943",
"0.58792734",
"0.58061004",
"0.5773732",
"0.5741211",
"0.5741211",
"0.57286245",
"0.5598494",
"0.55483174",
"0.5547604",
"0.55424875",
"0.5528406",
"0.5516578",
"0.5514505",
"0.5494825",
"0.5465305",
"0.5465305",
"0.53885... | 0.6718424 | 0 |
ls(disk, '/vtrgb') ls(disk, '/') | def get_zones_from_block(disk, block)
disk.seek(block)
bytes_read = 0
zones = []
loop do
zone = disk.read(2).unpack('S')[0]
break if bytes_read >= 1024 or zone == 0
zones << zone
bytes_read += 2
end
return zones
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lsblk_path(p)\n return unless !p['path'] && p['name']\n\n if File.exist?(\"/dev/#{p['name']}\")\n p['path'] = \"/dev/#{p['name']}\"\n elsif File.exist?(\"/dev/mapper/#{p['name']}\")\n p['path'] = \"/dev/mapper/#{p['name']}\"\n end\n end",
"def list_partiti... | [
"0.6298422",
"0.62468547",
"0.62023866",
"0.6157513",
"0.6152726",
"0.6092483",
"0.6066112",
"0.6039278",
"0.6000993",
"0.5996516",
"0.5976484",
"0.59719723",
"0.5954666",
"0.58630496",
"0.5854355",
"0.58509195",
"0.5850522",
"0.5847133",
"0.58279747",
"0.57707095",
"0.576605... | 0.0 | -1 |
disk.seek(find_inode_offset(1126)) inode = MinixInode.read(disk) pp(get_zones(disk, inode.i_zone)) disk.seek(35668 1024) data = disk.read(1024) pp data | def cat(disk, path)
inode_num = find_inode_num(disk, path)
disk.seek(find_inode_offset(inode_num))
inode = MinixInode.read(disk)
data = ""
size = inode.i_size
zones = get_zones(disk, inode.i_zone)
for zone in zones do
disk.seek(zone * 1024)
if size <= 1024 then
da... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_zones_from_block(disk, block)\n disk.seek(block)\n bytes_read = 0\n zones = []\n loop do\n zone = disk.read(2).unpack('S')[0]\n break if bytes_read >= 1024 or zone == 0\n zones << zone\n bytes_read += 2\n end\n return zones\nend",
"def disk_at(minpos, maxpos)... | [
"0.6883398",
"0.5610405",
"0.52652127",
"0.526167",
"0.5203848",
"0.5202133",
"0.5185481",
"0.5162975",
"0.5162975",
"0.5118699",
"0.51094645",
"0.5094096",
"0.5093738",
"0.5090003",
"0.5088743",
"0.50694686",
"0.506575",
"0.50257856",
"0.49983948",
"0.4979395",
"0.49761522",... | 0.68636507 | 1 |
You have an array of integers, and for each index you want to find the product of every integer except the integer at that index. Write a function get_products_of_all_ints_except_at_index() that takes an array of integers and returns an array of the products. Solution 1: Brute Force O(n^2) | def get_products_of_all_ints_except_at_index_brute(arr)
result = []
arr.each_with_index do |el, i|
arr.delete_at(i)
product = arr.inject(1) {|product, int| product*int}
arr.insert(i, el)
result << product
end
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_products_of_all_ints_except_at_index(array)\n\t# Make sure there are atleast two integers in the array\n\tif array.length < 2\n\t\traise IndexError, \"Two or more integers are required\"\n\tend\n\n\tproducts_of_all_ints_except_at_index = []\n\n\t# For each integer we find the product of all the integers be... | [
"0.9152622",
"0.91404355",
"0.9113969",
"0.9066938",
"0.8889153",
"0.87513614",
"0.8505914",
"0.84432036",
"0.8390014",
"0.8258849",
"0.8224876",
"0.8178421",
"0.8013773",
"0.79863703",
"0.78687865",
"0.7846555",
"0.7832634",
"0.7796632",
"0.773626",
"0.7588241",
"0.7533138",... | 0.9147141 | 1 |
Solution 2: Greedy approach O(n) time and O(n)O(n) space. We make two passes through our input array, and the array we build always has the same length as the input array. A greedy algorithm iterates through the problem space taking the optimal solution "so far," until it reaches the end. The greedy approach is only op... | def get_products_of_all_ints_except_at_index(arr)
result = Array.new(arr.length, 1)
product_so_far_before_index = 1
arr.each_with_index do |int, i|
result[i] = product_so_far_before_index
product_so_far_before_index *= int
end
product_so_far_after_index = 1
i = arr.length-1
while i >= 0
resu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_products_but_self(arr)\n # raise 'need more than itself to get all other products' if arr.length < 2\n # result = [] \n # #first just try to come up with a way that works even if it's slow \n # arr.each_with_index do |el,idx|\n # arr[idx] = 1 \n # result << arr.reduce(:*) O(n) in... | [
"0.801452",
"0.73461634",
"0.7312627",
"0.7208949",
"0.71124834",
"0.7032457",
"0.69729227",
"0.69581276",
"0.6899148",
"0.68180615",
"0.67924696",
"0.67704153",
"0.676354",
"0.6696181",
"0.6695226",
"0.6688082",
"0.6663701",
"0.6647655",
"0.66473854",
"0.66164744",
"0.657082... | 0.66933686 | 15 |
Solution 3 with division | def get_products_of_all_ints_except_at_index_with_div(arr)
result = Array.new(arr.length, 0)
if arr.include? 0
index_of_0 = arr.find_index(0)
else
product = arr.inject(1) {|product, int| product*int}
arr.each_with_index do |int, i|
result[i] = product / int
end
end
p result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solve\n return ((1..40).inject(:*) / ((1..20).inject(:*) ** 2))\nend",
"def solution(number)\n mul3 = (number - 1) / 3\n mul5 = (number - 1) / 5\n mul15 = (number - 1) / 15\n\n (3 * mul3 * (mul3 + 1) + 5 * mul5 * (mul5 + 1) - 15 * mul15 * (mul15 + 1)) / 2\nend",
"def solution\n (1..40).inject(:*)... | [
"0.7344609",
"0.70928216",
"0.6990728",
"0.6805046",
"0.66101736",
"0.6581642",
"0.65585047",
"0.6544029",
"0.6528922",
"0.64872855",
"0.6446503",
"0.6444827",
"0.6427044",
"0.6353904",
"0.6291457",
"0.62723446",
"0.6240156",
"0.62245005",
"0.6204515",
"0.62008554",
"0.619017... | 0.0 | -1 |
GET /dotsmembers/1 GET /dotsmembers/1.json | def show
@dotsmember = Dotsmember.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @dotsmember }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_members\n HTTP.headers(:accept => @@accept, \"content-type\" => @@content_type).basic_auth(:user => ENV[\"API_USERNAME\"], :pass => ENV[\"API_PASSWORD\"])\n .get(\"#{@@base_url}/users/#{self.guid}/members\").parse[\"members\"]\n end",
"def members\n raw_response = get_request('user... | [
"0.6752961",
"0.67524856",
"0.66838694",
"0.6553561",
"0.65479493",
"0.65183735",
"0.6475098",
"0.6413915",
"0.6395219",
"0.6331851",
"0.63109726",
"0.6297596",
"0.6297596",
"0.6297596",
"0.62703377",
"0.625537",
"0.6246245",
"0.6221197",
"0.6221197",
"0.62208235",
"0.6205862... | 0.72846 | 0 |
GET /dotsmembers/new GET /dotsmembers/new.json | def new
@dotsmember = Dotsmember.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @dotsmember }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @member = Member.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @member }\n end\n end",
"def new\n new_url = \"#{ENV['KPASS_ENDPOINT']}/members/new?app_id=#{ENV['KPASS_APP_ID']}\"\n redirect_to new_url\n end",
"def new\n ... | [
"0.69776654",
"0.69719934",
"0.69666284",
"0.69666284",
"0.69666284",
"0.69666284",
"0.69666284",
"0.69666284",
"0.69666284",
"0.69396555",
"0.6786453",
"0.67726684",
"0.6740101",
"0.67363083",
"0.6704276",
"0.6687198",
"0.6630977",
"0.66187334",
"0.6592398",
"0.6563694",
"0.... | 0.7912109 | 0 |
POST /dotsmembers POST /dotsmembers.json | def create
@dotsmember = Dotsmember.new(params[:dotsmember])
respond_to do |format|
if @dotsmember.save
format.html { redirect_to @dotsmember, notice: 'Dotsmember was successfully created.' }
format.json { render json: @dotsmember, status: :created, location: @dotsmember }
else
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @dotsmember = Dotsmember.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dotsmember }\n end\n end",
"def add_member_to_list(user, list, member_id, options={})\n post(\"/#{user}/#{list}/members.json\", options.merge(:id => member_id))\n ... | [
"0.6181585",
"0.5789378",
"0.5646284",
"0.55543065",
"0.553352",
"0.55139905",
"0.5497863",
"0.5422286",
"0.537379",
"0.53324544",
"0.5319486",
"0.52958965",
"0.5287732",
"0.5284367",
"0.52689284",
"0.5254804",
"0.5226609",
"0.5222158",
"0.5198918",
"0.5187555",
"0.5183591",
... | 0.692266 | 0 |
PUT /dotsmembers/1 PUT /dotsmembers/1.json | def update
@dotsmember = Dotsmember.find(params[:id])
respond_to do |format|
if @dotsmember.update_attributes(params[:dotsmember])
format.html { redirect_to @dotsmember, notice: 'Dotsmember was successfully updated.' }
format.json { head :no_content }
else
format.html { rend... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update_current_logged_in_user(args = {}) \n put(\"/users.json/current\", args)\nend",
"def update_members\n unless self.list_members.blank?\n #create new members\n self.list_members.each do |ap... | [
"0.62721723",
"0.59164494",
"0.58592075",
"0.5746674",
"0.5704834",
"0.5646536",
"0.5642699",
"0.563529",
"0.5605303",
"0.55768526",
"0.5548447",
"0.5510007",
"0.54990554",
"0.54915726",
"0.54870236",
"0.54712415",
"0.5467983",
"0.5463808",
"0.543614",
"0.5435807",
"0.5424807... | 0.6832127 | 0 |
DELETE /dotsmembers/1 DELETE /dotsmembers/1.json | def destroy
@dotsmember = Dotsmember.find(params[:id])
@dotsmember.destroy
respond_to do |format|
format.html { redirect_to dotsmembers_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def delete_member path\n rewrite_members member_paths.delete(path)\n end",
"def destroy\n @member = Member.find(params[:id])\n @member.destroy\n\n \n respond_to do |format|\n for... | [
"0.69152945",
"0.67468077",
"0.6603239",
"0.65447503",
"0.65447503",
"0.6521533",
"0.6521533",
"0.6518718",
"0.64413434",
"0.64413434",
"0.6433634",
"0.6433634",
"0.6433634",
"0.6433634",
"0.6433634",
"0.6433634",
"0.6433634",
"0.6413163",
"0.64048415",
"0.63537735",
"0.63304... | 0.7594474 | 0 |
First time doing exercise | def any?(array)
return false if array.empty?
result = nil
array.each do |element|
result = yield(element)
return result if result == true
end
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exercise_119 (number)\n end",
"def solution4(input)\n end",
"def suivre; end",
"def alg; end",
"def p15\n\t\nend",
"def passes; end",
"def passes; end",
"def challenge; end",
"def exercise_1113 (matrix)\n end",
"def anchored; end",
"def king_richard_iii; end",
"def slop!; end",... | [
"0.6343587",
"0.6235195",
"0.5914975",
"0.58330274",
"0.58194894",
"0.5797823",
"0.5797823",
"0.5797147",
"0.57450384",
"0.5737075",
"0.57134795",
"0.5667611",
"0.5667611",
"0.5659621",
"0.5630683",
"0.5616609",
"0.5578058",
"0.5556174",
"0.55525106",
"0.55517954",
"0.5539372... | 0.0 | -1 |
Second pass through exercise | def any?(collection)
collection.each do |element|
return true if yield(element)
end
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def part2(program)\n special = 19690720\n (0..99).to_a.repeated_permutation(2).each do |noun, verb|\n input = program.dup\n input[1] = noun\n input[2] = verb\n\n output = run(input)\n puts \"noun = #{noun}, verb = #{verb}, output = #{output[0]}\"\n if output[0] == special\n return [noun, v... | [
"0.65472114",
"0.6088604",
"0.6088604",
"0.5891307",
"0.5728156",
"0.5725427",
"0.57047945",
"0.5704577",
"0.5685854",
"0.5680344",
"0.5664739",
"0.5612547",
"0.55993724",
"0.55773836",
"0.55651915",
"0.5563116",
"0.55341965",
"0.5533744",
"0.5507989",
"0.54751986",
"0.547092... | 0.0 | -1 |
Create a new Esgob Client instance. | def initialize(*args)
if args.empty?
# Load configuration from file if no arguments were given
@config = Esgob::Config.load
elsif args.first.is_a?(Esgob::Config)
@config = args.first
elsif args.first.is_a?(Hash)
@config = Esgob::Config.new(args.first)
elsif args.length == 2
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @client = Client.new\n end",
"def new\n @client = Client.new\n end",
"def new\n @client = Client.new\n end",
"def new(out, encoder, options = {})\n Client.new(out, encoder, options)\n end",
"def new\n\t\t@client = Client.new\n\tend",
"def new_client(id, env, private_... | [
"0.67705965",
"0.67705965",
"0.67705965",
"0.6524672",
"0.6506419",
"0.6213401",
"0.613451",
"0.6109429",
"0.60754144",
"0.6059206",
"0.6035877",
"0.60308534",
"0.5962856",
"0.5912058",
"0.59050924",
"0.5898446",
"0.5884536",
"0.58424467",
"0.582896",
"0.58075005",
"0.5796571... | 0.65300184 | 3 |
Call a named Esgob API function. | def call(function_name, args = {})
uri = URI(config.endpoint + function_name)
uri.query = build_query(default_arguments.merge(args))
res = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
req = Net::HTTP::Get.new(uri.request_uri)
req['Accept'] = 'application/json... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def use_function(name)\n call \"_#{name}\"\n end",
"def run_function(name, params)\n payload = Payload.new\n payload.function_name = name\n payload.params = params\n call_route(:function, name, payload)\n end",
"def request(function_name, *para)\n id_count = id\n ... | [
"0.62297946",
"0.60736847",
"0.60118705",
"0.58598506",
"0.58429015",
"0.5780719",
"0.57379097",
"0.56978565",
"0.56971204",
"0.56971204",
"0.5680367",
"0.5673404",
"0.5619976",
"0.56033236",
"0.5546935",
"0.5536562",
"0.55042565",
"0.55033547",
"0.55033547",
"0.54784584",
"0... | 0.65742636 | 0 |
Return account status; credit balance, etc. | def accounts_get
account = call('accounts.get')
account[:added] = Time.at(account[:added]) if account[:added].is_a?(Fixnum)
account
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def account_status\n Account::Status.for(self)\n end",
"def get_account_status\n send_post(\"/accountStatus\", {})\n end",
"def get_account_status\n send_post(\"/accountStatus\", {})\n end",
"def account_status\n overview_table.rows_text[1][3]\n end",
"def account_balance\n ... | [
"0.7462626",
"0.7440599",
"0.7440599",
"0.73661315",
"0.7248581",
"0.7086959",
"0.70514864",
"0.70182073",
"0.70182073",
"0.68520176",
"0.68153006",
"0.6753415",
"0.67503625",
"0.674052",
"0.67271364",
"0.6685715",
"0.66722363",
"0.66127527",
"0.66084987",
"0.66036975",
"0.65... | 0.0 | -1 |
Returns all hosted domains | def domains_list
call('domains.list')[:domains]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def domains\n @_domains ||= mxers.map { |m| Host.new(m.first).domain_name }.sort.uniq\n end",
"def domains\n request('domain-list_domains').inject([]) { |domains, domain|\n domains << Domain.new(domain)\n }\n end",
"def domains\n connection.list_domains[:domains]\n end",... | [
"0.77566826",
"0.7721695",
"0.77200574",
"0.77119434",
"0.76761454",
"0.7577101",
"0.73340493",
"0.7254375",
"0.7150555",
"0.71377075",
"0.70207953",
"0.70204496",
"0.70161253",
"0.6994115",
"0.6994115",
"0.68347555",
"0.68244445",
"0.68226165",
"0.679849",
"0.6756938",
"0.67... | 0.78661996 | 0 |
Returns all hosted slave domains as a hash | def domains_slaves_list
Hash[
call('domains.slaves.list')[:domains].map do |item|
[item[:domain], item[:masterip]]
end
]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def domains_slave_names\n domains_names = []\n self.domains.slave.each do |domain|\n domains_names.push domain.name\n end\n domains_names\n end",
"def domains\n @_domains ||= mxers.map { |m| Host.new(m.first).domain_name }.sort.uniq\n end",
"def all_server_hosts\n [server_host]\n... | [
"0.7436661",
"0.680669",
"0.6635894",
"0.6545969",
"0.64325374",
"0.6410877",
"0.64073133",
"0.64042366",
"0.6372465",
"0.62801844",
"0.62184954",
"0.6216724",
"0.6097903",
"0.6062102",
"0.6045534",
"0.60445607",
"0.6043916",
"0.6038668",
"0.6024427",
"0.6009382",
"0.5962335"... | 0.79475296 | 0 |
Adds a new slave domain. | def domains_slaves_add(domain, masterip)
result = call('domains.slaves.add', :domain => domain, :masterip => masterip)
result[:domain] ||= domain
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def domains_slaves_axfrout_add(domain, axfrip)\n result = call('domains.slaves.axfrout.add', :domain => domain, :axfrip => axfrip)\n result[:domain] ||= domain\n result\n end",
"def add_slave(*cmdline, name: nil, **spawn_options)\n slave = Slave.new(*cmdline, name: name, seed: seed, **spawn_... | [
"0.68576074",
"0.6386203",
"0.6380966",
"0.62343484",
"0.59439516",
"0.59054005",
"0.5879076",
"0.58556813",
"0.58013046",
"0.56952536",
"0.56496596",
"0.5605037",
"0.5581396",
"0.54838383",
"0.54820836",
"0.5478487",
"0.5467872",
"0.5444201",
"0.5444201",
"0.5437726",
"0.542... | 0.813463 | 0 |
Deletes a slave domain. | def domains_slaves_delete(domain)
result = call('domains.slaves.delete', :domain => domain)
result[:domain] ||= domain
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def domains_slaves_axfrout_delete(domain, axfrip)\n result = call('domains.slaves.axfrout.delete', :domain => domain, :axfrip => axfrip)\n result[:domain] ||= domain\n result\n end",
"def delete_slave(options)\n date = instance_date(options)\n puts \"Deleting slave instance of TokyoTyrant... | [
"0.6925048",
"0.6842588",
"0.66154635",
"0.63643885",
"0.6308097",
"0.6218632",
"0.61968696",
"0.6175473",
"0.6119054",
"0.607158",
"0.60484976",
"0.59943885",
"0.59347075",
"0.5932611",
"0.5932121",
"0.5906336",
"0.5849888",
"0.5844739",
"0.58446574",
"0.58444184",
"0.581205... | 0.8092177 | 0 |
Force AXFR / transfer from master of a slave domain | def domains_slaves_forcetransfer(domain)
result = call('domains.slaves.forcetransfer', :domain => domain)
result[:domain] ||= domain
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def use_master \n send_cmd(\"use_master\")\n end",
"def phy_master_slave_mode\n super\n end",
"def update_slave\n return false unless master?\n Rollbar.warning \"Sidekiq not ready\" unless Report.sidekiq_ready?\n MultitenantProxyWorker.perform_async(Customer.tenant_name, self.id)\n end",
... | [
"0.58735377",
"0.58057106",
"0.5750429",
"0.5684277",
"0.55750364",
"0.55674046",
"0.553641",
"0.5463019",
"0.5334336",
"0.5332624",
"0.52666116",
"0.52666116",
"0.52474004",
"0.5223147",
"0.51436037",
"0.51209116",
"0.5068471",
"0.50658065",
"0.50171334",
"0.50035673",
"0.49... | 0.6965203 | 0 |
Updates the master IP of a slave domain | def domains_slaves_updatemasterip(domain, masterip)
result = call('domains.slaves.updatemasterip', :domain => domain, :masterip => masterip)
result[:domain] ||= domain
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_change_master(master, slave, coordinates, opts = {})\n master_server = server_for_instance(master)\n raise \"master_server is nil\" unless master_server\n \n begin\n slave_connection = Client.open(slave)\n if slave_connection\n \n # Replication on the ... | [
"0.66461825",
"0.6559381",
"0.63678485",
"0.6265431",
"0.6203855",
"0.6164362",
"0.61031425",
"0.5919384",
"0.58642024",
"0.5810922",
"0.5751935",
"0.56745225",
"0.56302977",
"0.5613702",
"0.5609559",
"0.5609486",
"0.5588183",
"0.55692106",
"0.55692106",
"0.55684173",
"0.5553... | 0.82528603 | 0 |
Add a host allowed to AXFR out | def domains_slaves_axfrout_add(domain, axfrip)
result = call('domains.slaves.axfrout.add', :domain => domain, :axfrip => axfrip)
result[:domain] ||= domain
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowHost\n end",
"def visit_host?(host)\n @host_rules.accept?(host)\n end",
"def host_allowed?(arg)\n true\n end",
"def add_host(host)\r\n if host.class == String\r\n host = Regexp.new(host)\r\n end\r\n unless @hosts.include?(host)\r\n @hosts << host\r\n end\r\n ... | [
"0.66147894",
"0.5913481",
"0.5839345",
"0.5826693",
"0.5812019",
"0.58047354",
"0.5626895",
"0.55924636",
"0.5441211",
"0.54212946",
"0.5376282",
"0.53575265",
"0.53431964",
"0.5337632",
"0.53342456",
"0.52936566",
"0.52643025",
"0.5223214",
"0.5209665",
"0.51622444",
"0.515... | 0.4757385 | 82 |
AccountDelete a host allowed to AXFR out | def domains_slaves_axfrout_delete(domain, axfrip)
result = call('domains.slaves.axfrout.delete', :domain => domain, :axfrip => axfrip)
result[:domain] ||= domain
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_account\n @connection.request({\n :method => 'DELETE'\n }) \n end",
"def delete_host(host)\n validate_list([[\"Host\", host, :presence]])\n options = {\"Host\" => host}\n\n connection = Connection.new\n connection.post(\"Domain/Host/Dele... | [
"0.7424638",
"0.7405136",
"0.73655736",
"0.7302452",
"0.69294685",
"0.68402946",
"0.6839751",
"0.68162525",
"0.65845615",
"0.65539587",
"0.6544468",
"0.65218246",
"0.64975905",
"0.64474076",
"0.6367302",
"0.6307612",
"0.62904227",
"0.62904227",
"0.628029",
"0.62360287",
"0.62... | 0.61553466 | 24 |
Retrieve the domain SOA serial number from the master and each anycast node | def domains_tools_soacheck(domain)
call('domains.tools.soacheck', :domain => domain)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serial_number; Common.serial_number(@handle); end",
"def serial_number\n return @serial_number\n end",
"def serial_number\n raw_response[4..-1].pack('c*').unpack('H*').first.upcase\n end",
"def _get_serial_number\n require 'fileutils'\n appname = @appname\n file... | [
"0.6462325",
"0.61236566",
"0.6001853",
"0.5883708",
"0.58740634",
"0.58569854",
"0.5813705",
"0.57940567",
"0.5756884",
"0.57337934",
"0.56868166",
"0.5669882",
"0.5654061",
"0.56330675",
"0.5612699",
"0.5594897",
"0.54932153",
"0.5460739",
"0.5460739",
"0.5436927",
"0.54326... | 0.0 | -1 |
Given a list of domains and a master IP, add and delete domains so that the Esgob account matches the local list | def domains_slaves_sync(domains, masterip)
existing_domains = domains_slaves_list
# Add any missing domains
responses = []
domains.each do |domain|
unless existing_domains.include?(domain)
response = domains_slaves_add(domain, masterip)
response[:domain] ||= domain
respons... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_domain_list(name)\n configure \"ip domain-list #{name}\"\n end",
"def domains_slaves_add(domain, masterip)\n result = call('domains.slaves.add', :domain => domain, :masterip => masterip)\n result[:domain] ||= domain\n result\n end",
"def remove_domain_list(name)\n configure... | [
"0.6296671",
"0.62729126",
"0.6243263",
"0.61337453",
"0.6103156",
"0.60488516",
"0.5888003",
"0.5887302",
"0.58676934",
"0.5745424",
"0.5683125",
"0.56268954",
"0.5617757",
"0.5591242",
"0.5590282",
"0.5588443",
"0.5566213",
"0.55476993",
"0.55414176",
"0.5502547",
"0.548734... | 0.751575 | 0 |
Clear all expectations with the given request | def clear(request)
request = camelized_hash(HTTP_REQUEST => Request.new(symbolize_keys(request)))
logger.debug("Clearing expectation with request: #{request}")
logger.debug("URL: #{CLEAR_ENDPOINT}. Payload: #{request.to_hash}")
response = @base[CLEAR_ENDPOINT].put(request.to_json, content_type... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear\n self.request = nil\n end",
"def clear_request\n @url = nil\n @options = nil\n end",
"def clear_all\n clear\n clear_stored_requests\n end",
"def reset_request\n @params = @headers = @body = nil\n end",
"def clear!\n @handlers = {}\n @environ... | [
"0.7094157",
"0.6874908",
"0.6868575",
"0.6785373",
"0.66927177",
"0.64222115",
"0.6194972",
"0.619024",
"0.61843455",
"0.61654323",
"0.59812385",
"0.5957318",
"0.5957291",
"0.5941239",
"0.57574415",
"0.5733035",
"0.5689481",
"0.56751513",
"0.566083",
"0.5657553",
"0.5619295"... | 0.7895446 | 0 |
Reset the mock server clearing all expectations previously registered | def reset
request = {}
logger.debug('Resetting mockserver')
logger.debug("URL: #{RESET_ENDPOINT}. Payload: #{request.to_hash}")
response = @base[RESET_ENDPOINT].put(request.to_json)
logger.debug("Got reset response: #{response.code}")
parse_string_to_json(response)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __mock_reset; end",
"def reset\n @config = nil\n @client = nil\n end",
"def reset\n @client = nil\n end",
"def reset\n @discovered_clients = nil\n end",
"def reset\n @protocols = {}\n @servers = {}\n @routes = {}\n @subscribers = {}\n ... | [
"0.7237009",
"0.7137659",
"0.6947353",
"0.6878064",
"0.67830646",
"0.67668647",
"0.67420334",
"0.6732375",
"0.67203116",
"0.66624",
"0.6611876",
"0.6555601",
"0.6515313",
"0.65124637",
"0.6505688",
"0.6494793",
"0.6494755",
"0.6493268",
"0.6467271",
"0.6460795",
"0.64535356",... | 0.73789597 | 0 |
Retrieve the list of requests that have been processed by the server | def retrieve(request = nil)
request = request ? camelized_hash(HTTP_REQUEST => Request.new(symbolize_keys(request))) : {}
logger.debug('Retrieving request list from mockserver')
logger.debug("URL: #{RETRIEVE_ENDPOINT}. Payload: #{request.to_hash}")
response = @base[RETRIEVE_ENDPOINT].put(reque... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def requests\n @requests_obj.list\n end",
"def requests\n @requests_lock.synchronize { Array.new(@requests) }\n end",
"def requests\n REQUESTS\n end",
"def pending_requests\n requests.keys\n end",
"def get_requests\n @requests\n end",
"def requests\n\t\tRequest.find(:all)\... | [
"0.7622532",
"0.7478797",
"0.74071306",
"0.7389639",
"0.7384039",
"0.7027782",
"0.69946736",
"0.675907",
"0.66957897",
"0.65785784",
"0.6572227",
"0.65626043",
"0.65265894",
"0.65108585",
"0.6455434",
"0.64524657",
"0.63842654",
"0.63758284",
"0.63690084",
"0.6335745",
"0.631... | 0.5462002 | 91 |
Request to dump logs to file | def dump_log(request = nil, java = false)
type_params = java ? '?type=java' : ''
url = "#{DUMP_LOG_ENDPOINT}#{type_params}"
request = request ? Request.new(symbolize_keys(request)) : {}
logger.debug('Sending dump log request to mockserver')
logger.debug("URL: #{url}. Payload: ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_file\n end",
"def log_file; end",
"def start_log(log)\n File.open(log, 'w')\nend",
"def logs\n @file = \"crowbar-logs-#{ctime}.tar.bz2\"\n system(\"sudo -i /opt/dell/bin/gather_logs.sh #{@file}\")\n redirect_to \"/export/#{@file}\"\n end",
"def logs\n @file = \"crowbar-logs-#{ctime... | [
"0.68769",
"0.6648306",
"0.65710324",
"0.65299076",
"0.65299076",
"0.64307976",
"0.6410623",
"0.63263816",
"0.6318248",
"0.62785274",
"0.62785274",
"0.62712955",
"0.6262375",
"0.6236544",
"0.61662835",
"0.6148497",
"0.6148497",
"0.61288524",
"0.61096376",
"0.61084646",
"0.610... | 0.5736486 | 52 |
Verify that the given request is called the number of times expected | def verify(request, times = exactly(1))
logger.debug('Sending query for verify to mockserver')
results = retrieve(request)
# Reusing the times model here so interpreting values here
times = Times.new(symbolize_keys(times))
num_times = times.remaining_times
is_exact = !times.u... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count\n case @call.method_name\n when :expects, :once\n 1\n when :returns\n the_call_to_stubs_or_expects.method_name == :expects ? 1 : nil\n when :twice\n 2\n end\n end",
"def call(request)\n test request\n end",
"def not_be_cal... | [
"0.6639494",
"0.63494647",
"0.6308838",
"0.61968917",
"0.61205655",
"0.609658",
"0.6057529",
"0.6029231",
"0.60165614",
"0.59221673",
"0.5918224",
"0.5874209",
"0.5873362",
"0.5783983",
"0.5763461",
"0.5759851",
"0.5712646",
"0.56645167",
"0.5659554",
"0.564483",
"0.56445134"... | 0.6466708 | 1 |
Don't need to check diagonal result when in the bottom three rows | def should_check_diagonal?
return false unless @two_dimensional_arrays[2].any? { |column| column != "." }
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_diagonal2\n cell = @last_cell_played\n count = 1\n while cell.rd && cell.rd.color == cell.color\n cell = cell.rd\n end\n while cell.lu && cell.lu.color == cell.color\n cell = cell.lu\n count += 1\n end\n return true if count >= 4\n false\n end",
"def check_diagon... | [
"0.75952226",
"0.7470045",
"0.7119921",
"0.70355296",
"0.68538934",
"0.6848333",
"0.67709374",
"0.6768445",
"0.6751007",
"0.6735217",
"0.67153054",
"0.6712372",
"0.6684139",
"0.66741437",
"0.66505295",
"0.6637235",
"0.66256106",
"0.66181815",
"0.66159964",
"0.66067475",
"0.65... | 0.6607149 | 19 |
allows [:iteration_number, :start_on] Accessing Helpers You can access any helper via a proxy Normal Usage: helpers.number_to_currency(2) Abbreviated : h.number_to_currency(2) Or, optionally enable "lazy helpers" by calling this method: lazy_helpers Then use the helpers with no proxy: number_to_currency(2) Defining an ... | def remaining_hours_by_day
values_by_day(0, true) { |x| model.remaining_hours_for_day_number(x) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def helper_method(*methods); end",
"def helpers; end",
"def helpers; end",
"def helpers; end",
"def define_helpers; end",
"def helpers &blk\n @helpers = blk\n end",
"def helper(*helpers)\r\n helper_object.extend *helpers\r\n end",
"def helper\n @helper\n end",
"def helpe... | [
"0.62402046",
"0.61647373",
"0.61647373",
"0.61647373",
"0.56985164",
"0.56967443",
"0.561521",
"0.555359",
"0.555359",
"0.5538757",
"0.550505",
"0.5483792",
"0.53861123",
"0.5385376",
"0.53666157",
"0.5346502",
"0.53454816",
"0.53382033",
"0.52793455",
"0.52673066",
"0.52639... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_transaction_account
@transaction_account = TransactionAccount.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.6163754",
"0.6045816",
"0.5944853",
"0.59169096",
"0.58892167",
"0.58342934",
"0.5776148",
"0.57057375",
"0.57057375",
"0.56534296",
"0.56209534",
"0.54244673",
"0.54101455",
"0.54101455",
"0.54101455",
"0.53951085",
"0.5378493",
"0.53563684",
"0.53399915",
"0.5338049",
"0... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def transaction_account_params
params.require(:transaction_account).permit(:name, :description, :color, :namespace)
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.71213365",
"0.70527846",
"0.6947171",
"0.6901663",
"0.67342883",
"0.6717481",
"0.668679",
"0.667654",
"0.6660948",
"0.655484",
"0.6525947",
"0.64567953",
"0.64502525",
"0.6450165",
"0.6446098",
"0.6433068",
"0.64118934",
"0.64118934",
"0.63903046",
"0.6379847",
"0.6379847"... | 0.0 | -1 |
Create an each node method for the block. | def each_node(&block)
block.call(@value)
@left.each_node(&block) if @left
@right.each_node(&block) if @right
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each(node, &block); end",
"def each_node(&block)\n\t\t\tnodes.each(&block)\n\t\tend",
"def each_node(&block)\n nodes.each(&block)\n end",
"def each_node(&block)\n @nodes.each &block\n end",
"def each_node(&block)\n @nodes.each &block\n end",
"def each_node(&block)\n nodes.each_... | [
"0.80439925",
"0.8040539",
"0.78754354",
"0.7853061",
"0.7853061",
"0.78183055",
"0.78183055",
"0.7677066",
"0.7661642",
"0.75473124",
"0.7435654",
"0.7381808",
"0.72844243",
"0.72264665",
"0.72199005",
"0.70862156",
"0.70768225",
"0.70768225",
"0.7034369",
"0.7009722",
"0.70... | 0.0 | -1 |
GET /student_interests GET /student_interests.json | def index
@matches = Match.all
@student_interests = StudentInterest.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @interests = Interest.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @interests }\n end\n end",
"def show\n @interest = Interest.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @interest }\n end\n ... | [
"0.72150147",
"0.71996343",
"0.7167937",
"0.70317906",
"0.70141566",
"0.69825447",
"0.6941719",
"0.6941719",
"0.68059677",
"0.67648464",
"0.67209613",
"0.6658619",
"0.6583133",
"0.6579353",
"0.6527925",
"0.65254533",
"0.65191525",
"0.649514",
"0.6484149",
"0.64396816",
"0.642... | 0.60424376 | 52 |
GET /student_interests/1 GET /student_interests/1.json | def show
@mous = Mou.where(category_id: @student_interest.category_id)
@match = Match.new
@user = User.find(current_user)
@matches = Match.where(student_interest_id: @student_interest.id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @interest = Interest.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @interest }\n end\n end",
"def show\n @interest = Interest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @interest }\n... | [
"0.7530484",
"0.73532873",
"0.7331843",
"0.7306648",
"0.72772115",
"0.72327685",
"0.6926178",
"0.6916976",
"0.6904862",
"0.6843045",
"0.6843045",
"0.6820633",
"0.6782205",
"0.667498",
"0.6637932",
"0.66270703",
"0.6621599",
"0.66203856",
"0.6618005",
"0.6611544",
"0.659493",
... | 0.0 | -1 |
POST /student_interests POST /student_interests.json | def create
@student_interest = StudentInterest.new(student_interest_params)
respond_to do |format|
if @student_interest.save
format.html { redirect_to @student_interest, notice: 'Student interest was successfully created.' }
format.json { render action: 'show', status: :created, location:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @interest = Interest.new(params[:interest])\n \n respond_to do |format|\n if @interest.save\n format.json { render :json => @interest,\n :status => :created, :location => @interest }\n else\n format.json { render :json => @interest.errors,\n :status => :u... | [
"0.7109849",
"0.6962512",
"0.6942208",
"0.6795574",
"0.6726444",
"0.66939163",
"0.665764",
"0.6628438",
"0.66095483",
"0.64935315",
"0.6492566",
"0.6466013",
"0.6415883",
"0.6345911",
"0.6332703",
"0.62690324",
"0.62596774",
"0.6232489",
"0.6227099",
"0.6172621",
"0.6165072",... | 0.7472101 | 0 |
PATCH/PUT /student_interests/1 PATCH/PUT /student_interests/1.json | def update
respond_to do |format|
if @student_interest.update(student_interest_params)
format.html { redirect_to @student_interest, notice: 'Student interest was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.js... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @interest = Interest.find(params[:id])\n \n respond_to do |format|\n if @interest.update_attributes(params[:interest])\n format.json { head :ok }\n else\n format.json { render :json => @interest.errors,\n :status => :unprocessable_entity }\n end\n end\n ... | [
"0.7517283",
"0.7130575",
"0.71265006",
"0.7001823",
"0.6988745",
"0.68743837",
"0.6873935",
"0.68278533",
"0.68138385",
"0.67495245",
"0.6728354",
"0.6711569",
"0.6638011",
"0.6635851",
"0.6613742",
"0.6604792",
"0.6598528",
"0.65981305",
"0.6551644",
"0.6551644",
"0.6548457... | 0.75698715 | 0 |
DELETE /student_interests/1 DELETE /student_interests/1.json | def destroy
@student_interest.destroy
respond_to do |format|
format.html { redirect_to student_interests_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @interest = Interest.find(params[:id])\n @interest.destroy\n\n respond_to do |format|\n format.json { head :ok }\n end \n end",
"def destroy\n @interest.destroy\n\n respond_to do |format|\n format.html { redirect_to interests_url }\n format.json { head :no_content }... | [
"0.7624007",
"0.75027305",
"0.7471847",
"0.74715835",
"0.73367757",
"0.7319722",
"0.72867465",
"0.72867465",
"0.72544724",
"0.72544724",
"0.72360265",
"0.722845",
"0.7213927",
"0.7202574",
"0.7202574",
"0.7202574",
"0.7202574",
"0.7202574",
"0.7202574",
"0.7202574",
"0.720257... | 0.7975358 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_student_interest
@student_interest = StudentInterest.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.6163754",
"0.6045816",
"0.5944853",
"0.59169096",
"0.58892167",
"0.58342934",
"0.5776148",
"0.57057375",
"0.57057375",
"0.56534296",
"0.56209534",
"0.54244673",
"0.54101455",
"0.54101455",
"0.54101455",
"0.53951085",
"0.5378493",
"0.53563684",
"0.53399915",
"0.5338049",
"0... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def student_interest_params
params.require(:student_interest).permit(:firstName, :lastName, :school_id, :category_id, :notes)
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.6979893",
"0.6781746",
"0.6746611",
"0.6742344",
"0.6735229",
"0.6592651",
"0.65027124",
"0.6498011",
"0.648163",
"0.647716",
"0.64556813",
"0.64386255",
"0.63784456",
"0.63756156",
"0.636574",
"0.6319542",
"0.63004524",
"0.6299559",
"0.62925464",
"0.62923217",
"0.6289894"... | 0.0 | -1 |
check for wining combination | def won?
WIN_COMBINATIONS.find do |combo|
combo.all? {|i| board.cells[i] == "X"} || combo.all? {|i| board.cells[i] == "O"}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def won?\n the_win_combination = false\n WIN_COMBINATIONS.each do |win_combination|\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n\n position_1 = @board[win_index_1]\n position_2 = @board[win_index_2]\n position... | [
"0.82330513",
"0.81354505",
"0.81179553",
"0.8091403",
"0.80392694",
"0.8027235",
"0.8015365",
"0.8009697",
"0.80043066",
"0.7999118",
"0.7998606",
"0.7996266",
"0.7996093",
"0.799462",
"0.79897743",
"0.7989171",
"0.79705757",
"0.79557925",
"0.79541504",
"0.79226303",
"0.7919... | 0.77329314 | 64 |
I believe this is what they're looking for with the inc function | def inc(cb)
c = 0
additive = 0
left_32 = cb.slice(12..15)
while c<=4
additive += left_32(c)
c+=1
end
additive %= 4
cb = cb.setbyte(15,additive)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def incr\n add(1)\n end",
"def incr(x) x + 1 end",
"def inc\n $i + 1\n end",
"def inc(key)\n \n end",
"def increment \n\t\t@counter = @counter + 1\n\tend",
"def inc_l\n end",
"def increment_order!\n @current += 1\n end",
"def __to_inc__\n self\n ... | [
"0.78842807",
"0.7743985",
"0.7606785",
"0.752646",
"0.7378083",
"0.7320266",
"0.72798544",
"0.72621673",
"0.7252814",
"0.71732193",
"0.7165326",
"0.7165326",
"0.7144286",
"0.7125997",
"0.7125997",
"0.7114994",
"0.7076135",
"0.7044032",
"0.7021225",
"0.6951409",
"0.6944431",
... | 0.64512193 | 47 |
Get a word from remote "random word" service | def initialize(word)
@word = word
@guesses = ''
@wrong_guesses = ''
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_word\n uri = URI('https://random-word-api.herokuapp.com/word?number=5')\n words = Net::HTTP.get(uri) \n words = words.delete(\"[\").delete(\"]\").delete(\"\\\"\")\n words = words.split(\",\")\n index = rand(words.count - 1)\n return words[index]\n end",
"d... | [
"0.7923229",
"0.72521865",
"0.7027946",
"0.6697948",
"0.6693158",
"0.6584901",
"0.65799564",
"0.65278965",
"0.64663476",
"0.6423196",
"0.6406597",
"0.6373306",
"0.63587654",
"0.62857455",
"0.62704974",
"0.6270179",
"0.6240232",
"0.6239242",
"0.6222812",
"0.6216876",
"0.619933... | 0.0 | -1 |
you run a site that offers a matching service between vendors selling laptops and customers ..looking to purchase; you charge a fee to be listed as a vendor your site's users must sign in and if they are an admin they are able to make changes to the site write a function "user_permission" that accepts four parameters: ... | def user_permission
#ask the user if they pay their bills (yes/no)
puts("Are your bills paid?")
#store their answer in a variable
user_bills_status = gets.strip
#ask the user if they have canceled a deal (yes/no)
puts("Have you canceled a deal?")
#store their answer in a variable
user_deal_status = gets.strip
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_permission(signed_in, admin, paid, cancelled)\n\tif paid == \"no\" or cancelled == \"yes\"\n\t\tputs (\"Go away!\")\n\n\telsif signed_in == \"yes\" and admin == \"yes\"\n\t\tputs (\"You can see and change all the pages\")\n\n\telsif signed_in == \"yes\" and admin == \"no\"\n\t\tputs (\"You can see all the... | [
"0.8214287",
"0.8202267",
"0.8164122",
"0.71345705",
"0.6417489",
"0.6409143",
"0.63993686",
"0.63993275",
"0.63778096",
"0.6248584",
"0.6214124",
"0.619288",
"0.6191394",
"0.6190204",
"0.61672056",
"0.61604226",
"0.6131969",
"0.6130062",
"0.6120472",
"0.61062634",
"0.6090420... | 0.6997186 | 4 |
Get the method from the options First, we check to see if any options are being sent to the method of the form: name "Fred" If there are args sent to it, check to see if it is an array If it is, we want to send it an array only if the array is contains more than one element. This becomes important when we are building ... | def get_from_options(m, *args, &block)
if args.empty?
if options.has_key?(m)
options[m]
else
(parent.nil? || parent.class == self.class || !parent.respond_to?(:options) || parent.options.has_key?(m) || !parent.respond_to?(m)) ? nil : parent.send(m, *args, &block)
end ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def method\n options.fetch(:method, nil)\n end",
"def method_missing(method, *args, &block)\n if method =~ /(.+)\\?$/\n options[$1.to_sym].present?\n else\n options[method]\n end\n end",
"def method\n @method ||= options[:method]\n end",
"def method... | [
"0.63766134",
"0.63533616",
"0.63319534",
"0.61419356",
"0.5681382",
"0.5585664",
"0.5585664",
"0.55647844",
"0.55098104",
"0.5484046",
"0.547705",
"0.5476845",
"0.5430225",
"0.53788257",
"0.5371233",
"0.5274907",
"0.52637774",
"0.52570826",
"0.5249521",
"0.5228614",
"0.51968... | 0.5253852 | 18 |
can be multiplied to get the maximum number in the array. If the number is used once it can't be used again. If there articletwo same numbers then that number can be used 2 times. in: array of integers out: boolean representing if any three of the integers can be multiplied to == the largest integer AL: set the largest... | def mult_of_three_nums(arr)
return nil if arr.size < 3
0.upto(arr.size - 3) do |first_idx|
binding.pry
(first_idx + 1).upto(arr.size - 2) do |second_idx|
(second_idx + 1).upto(arr.size - 1) do |third_idx|
return true if arr[first_idx] * arr[second_idx] * arr[third_idx] == arr.max
end
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def highest_product_of_three(array)\n negative_count = array.select { |value| value < 0 }\n array.map! { |value| value.abs }.sort! if negative_count.length.even?\n solution = 1\n array.max(3).each { |max| solution *= max }\n p solution\nend",
"def find_max(array)\n max = 0\n array.each do |subarray|\n... | [
"0.74612075",
"0.7460603",
"0.74417305",
"0.73386216",
"0.72193956",
"0.721899",
"0.721195",
"0.71839225",
"0.7179527",
"0.71492535",
"0.7145096",
"0.7140453",
"0.71359867",
"0.7115765",
"0.7061776",
"0.7061776",
"0.70303416",
"0.70088136",
"0.6958627",
"0.6948809",
"0.693650... | 0.7079723 | 14 |
GET /review_images/1 GET /review_images/1.json | def show
@review_image = ReviewImage.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @review_image }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @review_image = ReviewImage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @review_image }\n end\n end",
"def show\n @review = Review.includes(:reviewable).find_by_id(params[:id])\n if @review.nil?\n flash[:notice] = t(:review_not... | [
"0.6961911",
"0.6905347",
"0.68873703",
"0.6651436",
"0.6651436",
"0.66170055",
"0.65815467",
"0.65576476",
"0.6556238",
"0.65215236",
"0.6489029",
"0.6484236",
"0.6472715",
"0.6472195",
"0.6466764",
"0.6466764",
"0.6466764",
"0.6466764",
"0.64493537",
"0.64475214",
"0.644381... | 0.775149 | 0 |
GET /review_images/new GET /review_images/new.json | def new
@review_image = ReviewImage.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @review_image }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @review = current_user.reviews.new\n 1.times { @review.review_photos.build }\n @place = Place.first\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @review }\n end\n end",
"def new\n @new_review = NewReview.new\n\n respond_to do |form... | [
"0.7543141",
"0.7345983",
"0.73052794",
"0.73052794",
"0.73052794",
"0.73052794",
"0.73052794",
"0.73052794",
"0.72541696",
"0.72436976",
"0.7220128",
"0.7210835",
"0.7182113",
"0.7055756",
"0.7055756",
"0.7055756",
"0.7055756",
"0.7055756",
"0.7055756",
"0.6938616",
"0.69363... | 0.81456333 | 0 |
POST /review_images POST /review_images.json | def create
@review_image = ReviewImage.new(params[:review_image])
respond_to do |format|
if @review_image.save
format.html { redirect_to @review_image, notice: 'Review image was successfully created.' }
format.json { render json: @review_image, status: :created, location: @review_image }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @add_image_to_review = AddImageToReview.new(add_image_to_review_params)\n\n respond_to do |format|\n if @add_image_to_review.save\n format.html { redirect_to @add_image_to_review, notice: 'Add image to review was successfully created.' }\n format.json { render :show, status: :... | [
"0.7416678",
"0.67278147",
"0.66339874",
"0.66252154",
"0.6480933",
"0.6475001",
"0.64179295",
"0.641517",
"0.6384802",
"0.6280595",
"0.6251346",
"0.6232781",
"0.62007135",
"0.61791915",
"0.61791915",
"0.61791915",
"0.61770415",
"0.61415094",
"0.6114518",
"0.6106098",
"0.6091... | 0.73195535 | 1 |
PUT /review_images/1 PUT /review_images/1.json | def update
@review_image = ReviewImage.find(params[:id])
respond_to do |format|
if @review_image.update_attributes(params[:review_image])
format.html { redirect_to @review_image, notice: 'Review image was successfully updated.' }
format.json { head :no_content }
else
format.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @add_image_to_review.update(add_image_to_review_params)\n format.html { redirect_to @add_image_to_review, notice: 'Add image to review was successfully updated.' }\n format.json { render :show, status: :ok, location: @add_image_to_review }\n else\... | [
"0.7319094",
"0.67284393",
"0.67076075",
"0.67025024",
"0.6651533",
"0.6626284",
"0.6593261",
"0.6573377",
"0.65027964",
"0.6454498",
"0.6424937",
"0.63562196",
"0.6326572",
"0.6326572",
"0.6326572",
"0.6326572",
"0.6318783",
"0.6315948",
"0.6302158",
"0.62602985",
"0.6242516... | 0.7352386 | 0 |
DELETE /review_images/1 DELETE /review_images/1.json | def destroy
@review_image = ReviewImage.find(params[:id])
@review_image.destroy
respond_to do |format|
format.html { redirect_to review_images_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @add_image_to_review.destroy\n respond_to do |format|\n format.html { redirect_to add_image_to_reviews_url, notice: 'Add image to review was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @image.destroy\n\n respond_to do |format|... | [
"0.759791",
"0.7256027",
"0.7218105",
"0.71706086",
"0.7165867",
"0.7163038",
"0.7163038",
"0.7163038",
"0.7163038",
"0.7163038",
"0.7163038",
"0.71339524",
"0.7108557",
"0.7108557",
"0.7108557",
"0.7108557",
"0.7108557",
"0.7108557",
"0.7108557",
"0.70688903",
"0.70197225",
... | 0.7940017 | 0 |
Helper function to extract the line of the config that specified the operation. Useful in printing helpful error messages | def get_config_line(call_history)
call_history.first.split(':in').first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getconf(target)\n\t\t@log.info \"--util.rb : util.getconf(\" + target + \") \"\n\t\tFile.foreach(@config_file) do |line|\n\t\t#File.foreach(\"../../config.txt\") do |line|\n\t\t\tconf = line.chomp\n\t\t\tif(conf.index(target)) then\n\t\t\t\t@log.debug \"return \" + conf.split[1]\n\t\t\t\treturn conf.split[1]\n... | [
"0.579401",
"0.56690806",
"0.5485858",
"0.54753125",
"0.54753125",
"0.5366778",
"0.53582495",
"0.53575754",
"0.5342422",
"0.5295371",
"0.52665144",
"0.52587605",
"0.52430856",
"0.52227175",
"0.5216839",
"0.5215784",
"0.5190882",
"0.5149763",
"0.5143916",
"0.51400626",
"0.5136... | 0.6845958 | 0 |
DSL method to specify a name/value pair. RFlow core uses the 'rflow.' prefix on all of its settings. Custom settings should use a custom (unique) prefix | def setting(setting_name, setting_value)
setting_specs << {:name => setting_name.to_s, :value => setting_value.to_s, :config_line => get_config_line(caller)}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name=(value); configuration.name = value; end",
"def name=(val)\n self[:name] = val\n self[:key] = val.parameterize\n end",
"def name=(value); end",
"def setting(name)\n @settings[normalize_key(name)]\n end",
"def method_missing(name, *args, &block)\n if name.to_s[-1] == '='\... | [
"0.6468202",
"0.6274145",
"0.62158114",
"0.6064672",
"0.60501707",
"0.598447",
"0.59563893",
"0.59129655",
"0.5884391",
"0.5859717",
"0.56729996",
"0.5653121",
"0.5649054",
"0.56396043",
"0.5634665",
"0.56250054",
"0.56172436",
"0.56063735",
"0.55866617",
"0.55791026",
"0.556... | 0.59407735 | 7 |
DSL method to specify a shard block for either a process or thread | def shard(shard_name, shard_options={})
raise ArgumentError, "Cannot use DEFAULT as a shard name" if shard_name == 'DEFAULT'
shard_type = if shard_options[:thread] || shard_options[:type] == :thread
:thread
else
:process
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shard_block(threshold, &block)\n yield block if block_given? && in_shard?(threshold)\n end",
"def using_shard(shard, &_block)\n older_shard = current_shard\n older_slave_group = current_slave_group\n older_load_balance_options = current_load_balance_options\n\n begin\n unle... | [
"0.72781163",
"0.67156225",
"0.66094136",
"0.6262624",
"0.6195493",
"0.59822416",
"0.5932805",
"0.5615291",
"0.5582518",
"0.55476743",
"0.5540853",
"0.5404479",
"0.5386255",
"0.53654593",
"0.5240619",
"0.5193551",
"0.51610714",
"0.5135879",
"0.5127946",
"0.5127946",
"0.510224... | 0.6389706 | 3 |
DSL method to specify a component. Expects a name, specification, and set of component specific options, that must be marshallable into the database (i.e. should all be strings) | def component(component_name, component_specification, component_options={})
@current_shard[:components] << {
:name => component_name,
:specification => component_specification.to_s, :options => component_options,
:config_line => get_config_line(caller)
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def component_params\n params.require(:component).permit(:name)\n end",
"def component_params\n params.permit(:component_name)\n end",
"def component_params\n params.require(:component).permit(:kind, :list_id, :part_id)\n end",
"def component name, version='', options={}\n at... | [
"0.6069979",
"0.58815026",
"0.5447405",
"0.54323953",
"0.5367516",
"0.5229327",
"0.51932406",
"0.51932406",
"0.51932406",
"0.5190882",
"0.5182504",
"0.513929",
"0.5138824",
"0.51227695",
"0.5115121",
"0.5107033",
"0.5100223",
"0.50893503",
"0.508178",
"0.5075921",
"0.5050358"... | 0.6442252 | 0 |
DSL method to specify a connection between a component/output_port and another component/input_port. The component/port specification is a string where the names of the two elements are separated by '', and the "connection" is specified by a Ruby Hash, i.e.: connect 'componentAoutput' => 'componentBinput' Array ports a... | def connect(connection_hash)
config_file_line = get_config_line(caller)
connection_hash.each do |output_string, input_string|
output_component_name, output_port_name, output_port_key = parse_connection_string(output_string)
input_component_name, input_port_name, input_port_key = pars... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_connection_spec(connection_spec)\n RFlow.logger.debug \"Found connection from '#{connection_spec[:output_string]}' to '#{connection_spec[:input_string]}', creating\"\n\n # an input port can be associated with multiple outputs, but\n # an output port can only be associated with one ... | [
"0.63657874",
"0.5900484",
"0.5478581",
"0.54452467",
"0.5443474",
"0.5312679",
"0.5300928",
"0.5300928",
"0.5211433",
"0.5206168",
"0.52044886",
"0.517721",
"0.5167707",
"0.51463354",
"0.5058462",
"0.503577",
"0.50258934",
"0.50161684",
"0.50095063",
"0.49856374",
"0.4944165... | 0.5982529 | 1 |
Method to process the 'DSL' objects into the config database via ActiveRecord | def process
process_setting_specs
process_shard_specs
process_connection_specs
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def orm; end",
"def database_configuration; end",
"def database_configuration; end",
"def setup!\n ActiveRecord::Base.configurations[configuration_name] = db_config\n ActiveRecord::Base.establish_connection(configuration_name).connection\n self\n end",
"def compile_dsl\n @registr... | [
"0.5739402",
"0.5708739",
"0.5708739",
"0.56793815",
"0.55074865",
"0.5506605",
"0.54811907",
"0.5473359",
"0.5416474",
"0.5377309",
"0.53535455",
"0.531254",
"0.5281804",
"0.52745456",
"0.5261517",
"0.52521074",
"0.524759",
"0.52461183",
"0.5225246",
"0.52120394",
"0.5201649... | 0.0 | -1 |
Iterates through each setting specified in the DSL and creates rows in the database corresponding to the setting | def process_setting_specs
setting_specs.each do |setting_spec|
RFlow.logger.debug "Found config file setting '#{setting_spec[:name]}' = (#{Dir.getwd}) '#{setting_spec[:value]}'"
RFlow::Configuration::Setting.create! :name => setting_spec[:name], :value => setting_spec[:value]
end
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cmd_db_set_auto\n\t\t\t#TODO: Find a way to persist sets by serializing? them to .msf4 etc\n\t\t\t#TODO: Let the user add or subtract from this\n\t\t\tself.create_set(\"windows\", \"hosts where os_name~windows\")\n\t\t\tself.create_set(\"linux\", \"hosts where os_name~linux\")\n\t\t\tself.create_set(\"all_ho... | [
"0.5911362",
"0.57097965",
"0.5678244",
"0.5554013",
"0.5536988",
"0.5519714",
"0.54968196",
"0.5433802",
"0.54251134",
"0.5404177",
"0.53498995",
"0.53035873",
"0.53019416",
"0.5249714",
"0.5242588",
"0.5196959",
"0.51957613",
"0.5183493",
"0.51803416",
"0.5177401",
"0.51574... | 0.54231966 | 9 |
Iterates through each shard specified in the DSL and creates rows in the database corresponding to the shard and included components | def process_shard_specs
@shard_specs.each do |shard_spec|
RFlow.logger.debug "Found #{shard_spec[:type]} shard '#{shard_spec[:name]}', creating"
shard_class = case shard_spec[:type]
when :process
RFlow::Configuration::ProcessShard
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shards\n perform_request(api_url('shards')).map do |shard_data|\n DynamicModel.new shard_data\n end\n end",
"def add_shards( shard_definitions )\n added_shards = []\n\n shard_definitions.each do |definition|\n begin\n added_shards << add_shard( definition )\n ... | [
"0.60261005",
"0.559722",
"0.55909103",
"0.5577623",
"0.555476",
"0.5504436",
"0.548919",
"0.54743993",
"0.5473276",
"0.5335928",
"0.53024125",
"0.5252368",
"0.5214681",
"0.52135843",
"0.5175927",
"0.5127004",
"0.50486153",
"0.5048598",
"0.5024527",
"0.50196904",
"0.50081396"... | 0.70915014 | 0 |
Iterates through each component specified in the DSL and uses 'process_connection' to insert all the parts of the connection into the database | def process_connection_specs
connection_specs.each do |connection_spec|
process_connection_spec(connection_spec)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process\n process_setting_specs\n process_shard_specs\n process_connection_specs\n end",
"def setup_connection(conn)\n conn = super(conn)\n statement(conn) do |stmt|\n connection_configuration_sqls.each{|sql| log_yield(sql){stmt.execute(sql)}}\n ... | [
"0.54758024",
"0.5411961",
"0.52258277",
"0.51283014",
"0.5104479",
"0.50595945",
"0.50439316",
"0.5034035",
"0.5007937",
"0.49739873",
"0.48978043",
"0.4866999",
"0.48518887",
"0.48336667",
"0.48245883",
"0.4816337",
"0.48110417",
"0.48081762",
"0.4785146",
"0.47786057",
"0.... | 0.6304424 | 0 |
For the given connection, break up each input/output component/port specification, ensure that the component already exists in the database (by name). Also, only supports ZeroMQ ipc sockets | def process_connection_spec(connection_spec)
RFlow.logger.debug "Found connection from '#{connection_spec[:output_string]}' to '#{connection_spec[:input_string]}', creating"
# an input port can be associated with multiple outputs, but
# an output port can only be associated with one input
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_or_create_input_port_if_necessary(port)\n find_or_create_port_if_necessary(:input, port)\n end",
"def input_port?(name)\n input_ports[name]\n end",
"def conn_graph_create(filename) \n ### Making the filename \n newfilename=make_filename(filename)\n\n tmpInpHash=Hash.new\n ... | [
"0.5293039",
"0.5147359",
"0.5037872",
"0.49599576",
"0.4880463",
"0.4860499",
"0.4852178",
"0.47258633",
"0.4724795",
"0.47239155",
"0.47203508",
"0.47057354",
"0.4694751",
"0.46626455",
"0.46461833",
"0.46461833",
"0.46461833",
"0.46001753",
"0.45725095",
"0.45617405",
"0.4... | 0.65662366 | 0 |
GET /forums GET /forums.json | def index
res = can?(:create, Forum) ? Forum : Forum.where(hidden: false)
@forums = res.order(updated_at: :desc)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n\t\t@forums = Forum.all\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.json { render json: @forums }\n\t\tend\n\tend",
"def forum_get(args)\n JSON.parse(HelpSpot.api_request('forums.get', 'GET', :xForumId => args[:forum_id])) rescue []\n end",
"def GetForum i... | [
"0.77672285",
"0.75885355",
"0.75181055",
"0.74770254",
"0.71537775",
"0.7028155",
"0.7028155",
"0.7028155",
"0.7028155",
"0.69905275",
"0.69206876",
"0.68273073",
"0.6738129",
"0.6722654",
"0.6604148",
"0.6594946",
"0.6526631",
"0.65162504",
"0.6500902",
"0.6473248",
"0.6471... | 0.650107 | 18 |
POST /forums POST /forums.json | def create
@forum = Forum.new(forum_params)
respond_to do |format|
if @forum.save
format.html { redirect_to @forum, notice: t('.success') }
format.json { render :show, status: :created, location: @forum }
else
format.html { render :new }
format.json { render json: @fo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CreateForum params = {}\n \n APICall(path: 'forums.json',method: 'POST',payload: params.to_json)\n \n end",
"def create_forum payload\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.post FORUMS, payload )\n\t\t\t\tend",
"def create\n @forum = current_user.forums.... | [
"0.7769648",
"0.7113142",
"0.7035345",
"0.6650583",
"0.658821",
"0.6508893",
"0.64052427",
"0.6389956",
"0.63823986",
"0.63561374",
"0.6338724",
"0.63356394",
"0.63356394",
"0.63356394",
"0.63356394",
"0.6334558",
"0.62868303",
"0.6261359",
"0.62036777",
"0.6188403",
"0.61851... | 0.64418274 | 6 |
PUT /forums/1 PUT /forums/1.json | def update
respond_to do |format|
if @forum.update(forum_params)
format.html { redirect_to forums_path, notice: t('.success') }
format.json { render :show, status: :ok, location: @forum }
else
format.html { render :edit }
format.json { render json: @forum.errors, status: ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def UpdateForum id,params = {}\n \n APICall(path: \"forums/#{id}.json\",method: 'PUT',payload: params.to_json)\n \n end",
"def update\n respond_to do |format|\n if @forum.update(forum_params)\n format.html { redirect_to @forum, notice: 'Forum was successfully updated.' }\... | [
"0.7757689",
"0.65316284",
"0.65316284",
"0.6500892",
"0.64966315",
"0.64580137",
"0.6449359",
"0.6449359",
"0.6449359",
"0.64453286",
"0.6435314",
"0.6427191",
"0.6363869",
"0.6291023",
"0.6280954",
"0.6279108",
"0.6275414",
"0.62207955",
"0.619089",
"0.6174129",
"0.61739314... | 0.6605961 | 1 |
DELETE /forums/1 DELETE /forums/1.json | def destroy
@forum.destroy
respond_to do |format|
format.html { redirect_to forums_url, notice: t('.success') }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeleteForum id\n \n APICall(path: \"forums/#{id}.json\",method: 'DELETE')\n \n end",
"def destroy\n @forum.destroy\n respond_to do |format|\n format.html { redirect_to forums_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @forum.destro... | [
"0.82132876",
"0.7545011",
"0.7545011",
"0.7545011",
"0.7545011",
"0.7545011",
"0.7491223",
"0.74232876",
"0.74172777",
"0.7356391",
"0.7347319",
"0.73433286",
"0.7335318",
"0.73206747",
"0.73199016",
"0.73189086",
"0.72923857",
"0.7283329",
"0.72607195",
"0.72569203",
"0.724... | 0.7474816 | 7 |
Use callbacks to share common setup or constraints between actions. | def set_forum
@forum = Forum.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.6165152",
"0.60463154",
"0.59467196",
"0.5917112",
"0.5890387",
"0.58345735",
"0.57773316",
"0.56991524",
"0.56991524",
"0.565454",
"0.5622282",
"0.54232633",
"0.54119074",
"0.54119074",
"0.54119074",
"0.53937256",
"0.53801376",
"0.5358599",
"0.53412294",
"0.5340814",
"0.5... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def forum_params
params.require(:forum).permit(:name, :description, :hidden)
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.6980629",
"0.67819995",
"0.67467666",
"0.67419875",
"0.67347664",
"0.65928614",
"0.6504013",
"0.6498014",
"0.64819515",
"0.64797956",
"0.64562726",
"0.64400834",
"0.6380117",
"0.6377456",
"0.63656694",
"0.6320543",
"0.63002014",
"0.62997127",
"0.629425",
"0.6293866",
"0.62... | 0.0 | -1 |
initializes new player with name and lives=3 | def initialize (name)
@name = name
@lives = MAX_LIVES
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(player_name)\n @name = player_name\n @life_points = 10\n end",
"def initialize(name_player)\n @life_points = 10\n @name = name_player\n end",
"def initialize(name) # j'initialise les données qui doivent être ajoutées en même temps que la création du player\n @name = na... | [
"0.8223046",
"0.8163283",
"0.8132587",
"0.81323874",
"0.76718336",
"0.7621789",
"0.7584125",
"0.748515",
"0.74787253",
"0.72903466",
"0.7275475",
"0.7152916",
"0.7152916",
"0.7152916",
"0.7152916",
"0.7134801",
"0.70715714",
"0.7048398",
"0.6912314",
"0.690337",
"0.69010854",... | 0.69839156 | 18 |
method called to decrease life (called when player answers question incorrectly) | def lose_life
@lives -= 1
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lose_life()\r\n @life -= 1\r\n end",
"def lose_life\n @life -= 1\n end",
"def lose_life\n puts \"Sorry, that is the wrong answer!\"\n @current_player.life -= 1\n if @current_player.life == 0\n puts \"#{current_player.name} loses! Game Over!\"\n end\n end",
"def lives_decriment\... | [
"0.72749484",
"0.7177837",
"0.70764697",
"0.69467384",
"0.68732464",
"0.6753699",
"0.67305934",
"0.67063445",
"0.6692728",
"0.6667164",
"0.6524953",
"0.6498453",
"0.6458548",
"0.64103466",
"0.64075124",
"0.63548404",
"0.63408035",
"0.6306107",
"0.62970716",
"0.62874156",
"0.6... | 0.6890608 | 7 |
method called to check if player is done (ie have they reached 0 lives) | def done
@lives <= 0
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def finished?\n @players.any? do |player|\n @position[player] == @length\n end\n end",
"def lives_checker\n if (player_1.lives == 0 || player_2.lives == 0)\n self.game_over\n else\n puts \"------NEW ROUND------\"\n self.start_game\n end\n end",
"def finished?\n\n @player... | [
"0.75152737",
"0.7484276",
"0.7455448",
"0.73341",
"0.7331149",
"0.7253914",
"0.7230381",
"0.71623826",
"0.7155209",
"0.7125951",
"0.7085316",
"0.70551693",
"0.7037816",
"0.6995174",
"0.69940704",
"0.69833106",
"0.6972215",
"0.69471914",
"0.6946767",
"0.6934396",
"0.6927014",... | 0.7557252 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.