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 |
|---|---|---|---|---|---|---|
Borrow the default connection of BigRecord | def connection
BigRecord::Base.connection
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_connection=(_arg0); end",
"def default_connection=(_arg0); end",
"def default_connection=(_arg0); end",
"def default_connection\n\t @default_config ||= ActiveRecord::Base.connection.instance_variable_get(\"@config\").dup\n\tend",
"def new_connection; end",
"def default_connection\n @def... | [
"0.7462079",
"0.7462079",
"0.7462079",
"0.71424204",
"0.7112515",
"0.7041343",
"0.7029988",
"0.69570535",
"0.6802838",
"0.67726105",
"0.67726105",
"0.67726105",
"0.67726105",
"0.67726105",
"0.67726105",
"0.67726105",
"0.67726105",
"0.6761941",
"0.6761941",
"0.6681553",
"0.665... | 0.7598714 | 1 |
Class attribute that holds the name of the embedded type for dispaly | def pretty_name
@pretty_name || self.to_s
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def type_name\n self['type_name']\n end",
"def name\n @type_name\n end",
"def type_name; end",
"def type_name; end",
"def type_name; end",
"def type_name; end",
"def type_name; end",
"def type_name; end",
"def type_name; end",
"def type_name; end",
"def type_name; end",
"def ty... | [
"0.74811673",
"0.73814577",
"0.73481554",
"0.73481554",
"0.73481554",
"0.73481554",
"0.73481554",
"0.73481554",
"0.73481554",
"0.73481554",
"0.73481554",
"0.73481554",
"0.73481554",
"0.73481554",
"0.73481554",
"0.73481554",
"0.73481554",
"0.71049726",
"0.6997456",
"0.69879144",... | 0.0 | -1 |
Returns the text of the button. For input elements, returns the "value" attribute. For button elements, returns the inner text. | def text
assert_exists
case @element.tag_name
when 'input'
@element.attribute(:value)
when 'button'
@element.text
else
raise Exception::Error, "unknown tag name for button: #{@element.tag_name}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def text\n assert_exists\n case @element.tag_name\n when 'input'\n value\n when 'button'\n text\n else\n raise Exception::Error, \"unknown tag name for button: #{@element.tag_name}\"\n end\n end",
"def getvalue\n @button_group.value\n end",
"def but... | [
"0.807315",
"0.64913195",
"0.638224",
"0.6362075",
"0.6339576",
"0.633353",
"0.6316995",
"0.62961185",
"0.628258",
"0.6249267",
"0.6227569",
"0.6219535",
"0.62051713",
"0.62046355",
"0.61577463",
"0.6113873",
"0.6037578",
"0.60095274",
"0.5940218",
"0.5890131",
"0.5888374",
... | 0.8207249 | 0 |
Returns true if this element is enabled | def enabled?
!disabled?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enabled?\n @enabled\n end",
"def enabled?\n @enabled\n end",
"def enabled?\n @enabled\n end",
"def enabled?\n @enabled\n end",
"def enabled?\n inclusively { @enabled }\n end",
"def enabled?\n @enabled != false\n end",
"def enabled?\n @enabled |... | [
"0.8150319",
"0.8150319",
"0.8150319",
"0.8150319",
"0.8094539",
"0.808526",
"0.8059756",
"0.7980042",
"0.7980042",
"0.7950614",
"0.7944656",
"0.7940912",
"0.79234844",
"0.79137874",
"0.7882772",
"0.7882772",
"0.78800803",
"0.78800803",
"0.7829766",
"0.78116983",
"0.781133",
... | 0.8154332 | 1 |
GET /document_term_matrices/1 GET /document_term_matrices/1.json | def show
@document_term_matrix = DocumentTermMatrix.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @document_term_matrix }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @document_term_matrix = DocumentTermMatrix.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document_term_matrix }\n end\n end",
"def create\n @document_term_matrix = DocumentTermMatrix.new(params[:document_term_matrix])\n\n respond_to ... | [
"0.7568399",
"0.70465153",
"0.67378366",
"0.65203214",
"0.6349073",
"0.56841254",
"0.55963814",
"0.5534587",
"0.549189",
"0.5478525",
"0.5465672",
"0.54352665",
"0.54197645",
"0.54197645",
"0.54006374",
"0.5381253",
"0.5286972",
"0.52579015",
"0.52579015",
"0.5257582",
"0.524... | 0.7774318 | 0 |
GET /document_term_matrices/new GET /document_term_matrices/new.json | def new
@document_term_matrix = DocumentTermMatrix.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @document_term_matrix }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @document_term_matrix = DocumentTermMatrix.new(params[:document_term_matrix])\n\n respond_to do |format|\n if @document_term_matrix.save\n format.html { redirect_to @document_term_matrix, notice: 'Document term matrix was successfully created.' }\n format.json { render json: @... | [
"0.7783357",
"0.6569989",
"0.65169895",
"0.6487241",
"0.64357984",
"0.6408224",
"0.6277045",
"0.6277045",
"0.6277045",
"0.62231016",
"0.61486447",
"0.6107392",
"0.6068887",
"0.60678554",
"0.6064881",
"0.6052546",
"0.60340625",
"0.5988523",
"0.5973682",
"0.59722376",
"0.596451... | 0.82597566 | 0 |
POST /document_term_matrices POST /document_term_matrices.json | def create
@document_term_matrix = DocumentTermMatrix.new(params[:document_term_matrix])
respond_to do |format|
if @document_term_matrix.save
format.html { redirect_to @document_term_matrix, notice: 'Document term matrix was successfully created.' }
format.json { render json: @document_term_matrix, status: :created, location: @document_term_matrix }
else
format.html { render action: "new" }
format.json { render json: @document_term_matrix.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @document_term_matrix = DocumentTermMatrix.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document_term_matrix }\n end\n end",
"def destroy\n @document_term_matrix = DocumentTermMatrix.find(params[:id])\n @document_term_matrix.destroy... | [
"0.7174603",
"0.65269285",
"0.63291854",
"0.62898916",
"0.55954134",
"0.54989237",
"0.5377338",
"0.53378695",
"0.52932465",
"0.52554303",
"0.52554303",
"0.52355033",
"0.52241975",
"0.5216781",
"0.52099663",
"0.51924205",
"0.51767796",
"0.5171591",
"0.51691496",
"0.5142224",
"... | 0.7871769 | 0 |
PUT /document_term_matrices/1 PUT /document_term_matrices/1.json | def update
@document_term_matrix = DocumentTermMatrix.find(params[:id])
respond_to do |format|
if @document_term_matrix.update_attributes(params[:document_term_matrix])
format.html { redirect_to @document_term_matrix, notice: 'Document term matrix was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @document_term_matrix.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @document_term_matrix = DocumentTermMatrix.new(params[:document_term_matrix])\n\n respond_to do |format|\n if @document_term_matrix.save\n format.html { redirect_to @document_term_matrix, notice: 'Document term matrix was successfully created.' }\n format.json { render json: @... | [
"0.7288433",
"0.67670894",
"0.67435247",
"0.6397036",
"0.5807477",
"0.5546189",
"0.54296756",
"0.54169875",
"0.53470635",
"0.5343404",
"0.5331176",
"0.5211777",
"0.52027327",
"0.51796395",
"0.51746",
"0.5161028",
"0.5138983",
"0.5138983",
"0.5117527",
"0.5104033",
"0.5075823"... | 0.76547205 | 0 |
DELETE /document_term_matrices/1 DELETE /document_term_matrices/1.json | def destroy
@document_term_matrix = DocumentTermMatrix.find(params[:id])
@document_term_matrix.destroy
respond_to do |format|
format.html { redirect_to document_term_matrices_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\r\n @matrix.destroy\r\n respond_to do |format|\r\n format.html { redirect_to matrices_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @jc_term = JcTerm.find(params[:id])\n @jc_term.destroy\n\n respond_to do |format|\n format.html { redirec... | [
"0.6731105",
"0.6507621",
"0.6499557",
"0.6456442",
"0.64558196",
"0.6418062",
"0.640837",
"0.63975513",
"0.635056",
"0.6288535",
"0.62800777",
"0.6263782",
"0.62303066",
"0.62049586",
"0.6202211",
"0.61958814",
"0.61767924",
"0.61742496",
"0.6166021",
"0.61625594",
"0.615899... | 0.8265631 | 0 |
edit a certificate pack | def update(id:, hosts:)
id_check(:id, id)
non_empty_array_check(:hosts, hosts) unless hosts.nil?
data = {hosts: hosts}
cf_patch(path: "/zones/#{zone_id}/ssl/certificate_packs/#{id}", data: data)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update!(**args)\n @certificate = args[:certificate] if args.key?(:certificate)\n @package_name = args[:package_name] if args.key?(:package_name)\n end",
"def update!(**args)\n @public_key_certificate = args[:public_key_certificate] if args.key?(:public_key_certificate)\n ... | [
"0.6587856",
"0.65486073",
"0.65486073",
"0.6505984",
"0.6479744",
"0.6479744",
"0.63356274",
"0.6147052",
"0.6144104",
"0.60991603",
"0.6073693",
"0.60151553",
"0.595631",
"0.59423834",
"0.5939211",
"0.5857681",
"0.5811217",
"0.58047616",
"0.5789907",
"0.5733074",
"0.5710301... | 0.5746922 | 19 |
Create a new MutateJobService client object. Examples To create a new MutateJobService client with the default configuration: client = ::Google::Ads::GoogleAds::V3::Services::MutateJobService::Client.new To create a new MutateJobService client with a custom configuration: client = ::Google::Ads::GoogleAds::V3::Services::MutateJobService::Client.new do |config| config.timeout = 10.0 end | def initialize
# These require statements are intentionally placed here to initialize
# the gRPC module only when it's required.
# See https://github.com/googleapis/toolkit/issues/446
require "gapic/grpc"
require "google/ads/google_ads/v3/services/mutate_job_service_services_pb"
# Create the configuration object
@config = Configuration.new Client.configure
# Yield the configuration if needed
yield @config if block_given?
# Create credentials
credentials = @config.credentials
credentials ||= Credentials.default scope: @config.scope
if credentials.is_a?(String) || credentials.is_a?(Hash)
credentials = Credentials.new credentials, scope: @config.scope
end
@quota_project_id = @config.quota_project
@quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
@operations_client = Operations.new do |config|
config.credentials = credentials
config.endpoint = @config.endpoint
end
@mutate_job_service_stub = ::Gapic::ServiceStub.new(
::Google::Ads::GoogleAds::V3::Services::MutateJobService::Stub,
credentials: credentials,
endpoint: @config.endpoint,
channel_args: @config.channel_args,
interceptors: @config.interceptors
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize credentials, retries: nil, timeout: nil, host: nil, quota_project: nil\n @credentials = credentials\n @service = API::CloudResourceManagerService.new\n @service.client_options.application_name = \\\n \"gcloud-ruby\"\n @service.client_options.application... | [
"0.54714346",
"0.5433116",
"0.54268825",
"0.5375957",
"0.52193373",
"0.5192219",
"0.5161485",
"0.5070396",
"0.50610965",
"0.50588053",
"0.5017945",
"0.5009968",
"0.49534342",
"0.4931043",
"0.4925494",
"0.4914508",
"0.4900465",
"0.4888902",
"0.48700115",
"0.48635805",
"0.48573... | 0.586287 | 0 |
Configurations for individual RPCs | def rpcs
@rpcs ||= begin
parent_rpcs = nil
parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
Rpcs.new parent_rpcs
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rpc_configs\n @rpc_enabled = true\n @rpc_configs = OpenStruct.new(\n :address => rpc_default_path,\n :verbose => false,\n :server => OpenStruct.new(\n :preload => nil,\n :num_workers => 5\n ... | [
"0.7670324",
"0.65388",
"0.6519626",
"0.6519626",
"0.6519626",
"0.6519626",
"0.6519626",
"0.6519626",
"0.6519626",
"0.6519626",
"0.6519626",
"0.6519626",
"0.6519626",
"0.6519626",
"0.6519626",
"0.6519626",
"0.6519626",
"0.6519626",
"0.6475326",
"0.6475326",
"0.6475326",
"0.... | 0.6496722 | 18 |
Currently, this method is expected to be run from a Pry session only. | def debug it
PryByebug::BreakCommand.new.send :add_breakpoint, "Testo::Test#run", nil
# How to "next next step" automatically when the breakpoint is hit?
begin
run it
raise "Cannot reproduce. It might be a heisebug."
rescue
$!
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def pausable; end",
"def probers; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def refutal()\n end",
"def ready; end",
"def ready; end",
"def pending?; end"... | [
"0.6462834",
"0.6396954",
"0.6140178",
"0.5869853",
"0.5869853",
"0.5869853",
"0.5869853",
"0.5869853",
"0.5869853",
"0.5869853",
"0.5869853",
"0.5869853",
"0.57719433",
"0.56677026",
"0.56677026",
"0.5640816",
"0.56390435",
"0.56390435",
"0.5598957",
"0.5594855",
"0.5594855"... | 0.0 | -1 |
The timeout has to be enforced from the parent, because some code may cause MRI to become unresponsive indefinetely. | def in_isolation &block
reader, writer = IO.pipe
pid = fork do
reader.close
writer.write Marshal.dump block.call
writer.close
end
writer.close
begin
Timeout.timeout TIMEOUT do
Marshal.load reader.read
end
rescue Timeout::Error
Process.kill :KILL, pid
{ pid: pid, error: $! }
end.tap { reader.close; Process.wait pid }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timeout\n super\n end",
"def timeout\n super\n end",
"def failsafe_timeout\n super\n end",
"def timeout; end",
"def timeout; end",
"def timeout; end",
"def timeout\n options[:timeout] || super\n end",
"def timeout!; end",
"def timeout_at; end",
"def error_timeout; ... | [
"0.8008821",
"0.8008821",
"0.7604144",
"0.74249125",
"0.74249125",
"0.74249125",
"0.7251384",
"0.7110391",
"0.71036875",
"0.69741833",
"0.69579405",
"0.69374686",
"0.69207746",
"0.6900951",
"0.68833184",
"0.68833184",
"0.68833184",
"0.6850113",
"0.68456423",
"0.67686427",
"0.... | 0.0 | -1 |
Writes a Puppetfile that includes specifications for each of the modules. | def write(path, moduledir = nil)
File.open(path, 'w') do |file|
if moduledir
file.puts "# This Puppetfile is managed by Bolt. Do not edit."
file.puts "# For more information, see https://pup.pt/bolt-modules"
file.puts
file.puts "# The following directive installs modules to the managed moduledir."
file.puts "moduledir '#{moduledir.basename}'"
file.puts
end
@modules.each { |mod| file.puts mod.to_spec }
end
rescue SystemCallError => e
raise Bolt::FileError.new(
"#{e.message}: unable to write Puppetfile.",
path
)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write(path, moduledir = nil)\n File.open(path, 'w') do |file|\n file.puts '# This Puppetfile is managed by Bolt. Do not edit.'\n file.puts \"moduledir '#{moduledir.basename}'\" if moduledir\n modules.each { |mod| file.puts mod.to_spec }\n end\n rescue SystemCallError => e\n ... | [
"0.6417638",
"0.6164088",
"0.59643126",
"0.5950596",
"0.5945176",
"0.5863578",
"0.5839929",
"0.5721064",
"0.571137",
"0.5703105",
"0.5672448",
"0.565665",
"0.56328905",
"0.560509",
"0.556379",
"0.55577576",
"0.5510184",
"0.5451579",
"0.5296543",
"0.52919173",
"0.5273207",
"... | 0.644264 | 0 |
Asserts that the Puppetfile satisfies the given specifications. | def assert_satisfies(specs)
unsatisfied_specs = specs.specs.reject do |spec|
@modules.any? do |mod|
spec.satisfied_by?(mod)
end
end
versionless_mods = @modules.select { |mod| mod.is_a?(ForgeModule) && mod.version.nil? }
command = Bolt::Util.windows? ? 'Install-BoltModule -Force' : 'bolt module install --force'
if unsatisfied_specs.any?
message = <<~MESSAGE.chomp
Puppetfile does not include modules that satisfy the following specifications:
#{unsatisfied_specs.map(&:to_hash).to_yaml.lines.drop(1).join.chomp}
This Puppetfile might not be managed by Bolt. To forcibly overwrite the
Puppetfile, run '#{command}'.
MESSAGE
raise Bolt::Error.new(message, 'bolt/missing-module-specs')
end
if versionless_mods.any?
message = <<~MESSAGE.chomp
Puppetfile includes Forge modules without a version requirement:
#{versionless_mods.map(&:to_spec).join.chomp}
This Puppetfile might not be managed by Bolt. To forcibly overwrite the
Puppetfile, run '#{command}'.
MESSAGE
raise Bolt::Error.new(message, 'bolt/missing-module-version-specs')
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_file_presence\n spec.icons.values.each do |path|\n fail_if_not_exist \"Icon\", path\n end\n\n if spec.browser_action\n fail_if_not_exist \"Browser action popup\", spec.browser_action.popup\n fail_if_not_exist \"Browser action icon\", spec.browser_action.icon\n end... | [
"0.58765095",
"0.57015646",
"0.56661254",
"0.5586466",
"0.5561006",
"0.5542875",
"0.54308707",
"0.5377907",
"0.5270812",
"0.5223945",
"0.52022547",
"0.52011627",
"0.51944715",
"0.51783633",
"0.5154872",
"0.5135916",
"0.51121175",
"0.5109653",
"0.5101004",
"0.5089794",
"0.5076... | 0.6458803 | 0 |
Split input on empty lines | def error_chunks(text)
text.split(/^$/).select(){ |block| block =~ /^(\d+)\t([^\t]+)\t([^\t]+)\t(.+)$/ }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_lines(input)\n return input.split(/[ ]*[\\.\\n]+[ ]*/)\n end",
"def split_paragraphs(input)\n return input.split(/\\n[ ]*\\n+/)\n end",
"def str_groups_separated_by_blank_lines(original_filename)\n groups = []\n curr_group = []\n\n get_input_str_arr(original_filename).each do |str|... | [
"0.72236997",
"0.67111963",
"0.668515",
"0.6652201",
"0.65309876",
"0.64228195",
"0.6372302",
"0.63663125",
"0.6331584",
"0.6320501",
"0.6319029",
"0.62600183",
"0.62105036",
"0.61466193",
"0.61130404",
"0.6091063",
"0.6074753",
"0.60559344",
"0.60424465",
"0.6013885",
"0.599... | 0.0 | -1 |
Parse a text chunk | def parse(text)
# match = text.scan(/^(\/[^:]+):\s([^:]+):\s(.+)$/)[0]
rows = text.split(/\n/)
rows.shift(rows.length-3) if rows.length > 3
match = rows[0].scan(/^(\d+)\t([^\t]+)\t([^\t]+)\t(.+)$/)[0]
result = {
:linenumber => match[0],
:file => match[1],
:filename => match[2],
:type => match[3] =~ /warning/i ? "warning" : "error",
:description => match[3],
:code => rows[1],
:position => rows[2].scan(/^(.*)\^$/)[0][0].length
}
return result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse(text); end",
"def parse_text(text)\n\n end",
"def parse_content(content); end",
"def parse_paragraph; end",
"def parse text\n # Extract our headers, if any.\n if text =~ /\\A.*:/\n if text =~ /\\A((?:.|\\n)*?)\\n\\n((?:.|\\n)*)\\z/\n # Headers and body.\n @he... | [
"0.76387006",
"0.7308275",
"0.70444554",
"0.698981",
"0.6772674",
"0.67336214",
"0.67336214",
"0.67336214",
"0.6590431",
"0.6544239",
"0.64541125",
"0.64406395",
"0.6438528",
"0.63759613",
"0.6352888",
"0.6336605",
"0.63172615",
"0.63149965",
"0.6291017",
"0.62696713",
"0.625... | 0.6098735 | 34 |
GET /admin/email or admin_email_path | def email
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def admin_email\n ContactMailer.admin_email\n end",
"def email(id)\n get(\"/user/emails/#{id}\")\n end",
"def email\n admin.try(:email)\n end",
"def api_get\n handler.get({email: email}, path)\n end",
"def admin_email(e=nil)\n return @admin_email unless e\n @admin_email = ... | [
"0.6668606",
"0.66480494",
"0.663049",
"0.6542402",
"0.64853954",
"0.63137704",
"0.62178886",
"0.61869144",
"0.61869144",
"0.6172627",
"0.60714924",
"0.5985296",
"0.5985296",
"0.5899344",
"0.5885849",
"0.58612657",
"0.5826722",
"0.5768623",
"0.5768623",
"0.57577866",
"0.57474... | 0.6165371 | 10 |
POST /admin/test_emails or admin_test_emails_path | def test_emails
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def admin_emails\n # Must run this against proper tenant database\n Apartment::Tenant.switch(tenant) do\n Site.instance.admin_emails\n end\n end",
"def admin_emails\n # Must run this against proper tenant database\n Apartment::Tenant.switch(tenant) do\n Site.instance.admin_emails\n e... | [
"0.61674833",
"0.61674833",
"0.6025231",
"0.5898635",
"0.5898635",
"0.5729893",
"0.5722603",
"0.5711962",
"0.56153333",
"0.5434638",
"0.542562",
"0.5412021",
"0.5370677",
"0.53562576",
"0.53158206",
"0.52987224",
"0.52895224",
"0.52435946",
"0.52435946",
"0.52268434",
"0.5224... | 0.67887825 | 0 |
GET /admin/clone_user or admin_cloning_tank_path | def cloning_tank
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_cloned_user(user)\n set_current_user(user)\n session[:cloned] = true\n end",
"def clone_url\n raise \"not implemented\"\n end",
"def git_clone\n\n Rugged::Repository.clone_at git_url, root_path.to_s if git_url\n end",
"def clone_url\n \"git://github.com/#{@account}/#{name}... | [
"0.59709865",
"0.5918871",
"0.56211334",
"0.5512551",
"0.54888743",
"0.5443419",
"0.5400115",
"0.5398953",
"0.5384527",
"0.53755444",
"0.53269583",
"0.5316194",
"0.530443",
"0.52929235",
"0.528547",
"0.526805",
"0.526683",
"0.52627254",
"0.52390134",
"0.52245235",
"0.5205282"... | 0.5316266 | 11 |
POST /admin/user_search or admin_user_search_path | def user_search
@users = User.admin_search(params[:query])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n authorize_action_for User, at: current_store\n query = saved_search_query('user', 'admin_user_search')\n @search = UserSearch.new(query.merge(search_constrains))\n @users = @search.results.page(params[:page])\n end",
"def user_search(search, options = {})\n options[:search] = search... | [
"0.6904633",
"0.6892098",
"0.6871711",
"0.68405217",
"0.68313456",
"0.67881584",
"0.67727834",
"0.66121995",
"0.6454574",
"0.6441365",
"0.63880974",
"0.6359633",
"0.6350827",
"0.6314141",
"0.63122773",
"0.628496",
"0.6250156",
"0.62340546",
"0.6211916",
"0.6202621",
"0.618933... | 0.7401135 | 0 |
POST /admin/clone_user or admin_clone_user_path | def clone_user
user = User.find params[:id]
cookies[:auth_token] = user.auth_token
redirect_to root_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_cloned_user(user)\n set_current_user(user)\n session[:cloned] = true\n end",
"def duplicate\n plan = Plan.find(params[:id])\n authorize plan\n @plan = Plan.deep_copy(plan)\n respond_to do |format|\n if @plan.save\n @plan.add_user!(current_user.id, :creator)\n format.... | [
"0.6351005",
"0.5872246",
"0.5778269",
"0.5687453",
"0.56080955",
"0.5562799",
"0.5547554",
"0.5467411",
"0.5373801",
"0.53212124",
"0.52928996",
"0.525695",
"0.5250147",
"0.52337724",
"0.522425",
"0.5196931",
"0.5191451",
"0.51554906",
"0.51218075",
"0.51147497",
"0.51135606... | 0.5702464 | 3 |
GET /admin/wine_comment or admin_wine_comment_path | def wine_comment
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def comment_path(comment)\n \"/#{comment.domain.class.name.underscore.pluralize}/#{comment.domain.id}#comments/#{comment.id}\"\n end",
"def commentable_path\n eval(\"%s(%s)\" % find_path_and_parts)\n end",
"def after_update_path\n if @comment.idea\n return idea_path(id: @comment.wyc_id)\n ... | [
"0.59681356",
"0.5943564",
"0.5847443",
"0.58427566",
"0.5774099",
"0.5753357",
"0.57361794",
"0.57192135",
"0.5702366",
"0.5629841",
"0.5622197",
"0.5616164",
"0.5577234",
"0.5530465",
"0.5526944",
"0.54859036",
"0.5462795",
"0.54263896",
"0.5409991",
"0.5379059",
"0.5351392... | 0.6386145 | 0 |
COMPARE ORIGINAL AND FORMATTED PHONE | def check_phone_status(hsh)
phone = hsh[:phone]
phone_f = hsh[:phone_f]
status = 'invalid'
status = phone != phone_f ? 'formatted' : 'unchanged' if phone && phone_f
hsh[:phone_status] = status if status.present?
hsh
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_phone\n if Phoner::Phone.valid? self.phone\n pn = Phoner::Phone.parse phone, :country_code => '1'\n self.phone = pn.format(\"(%a) %f-%l\")\n end\n end",
"def format_phone_numbers\n\t\tif self.phone_number_1.present? and self.phone_number_1.length > 9\n\t\t\told = self.phone_number_1.g... | [
"0.5891859",
"0.5674633",
"0.5586002",
"0.5585086",
"0.5476419",
"0.5476353",
"0.541156",
"0.5395598",
"0.5374729",
"0.5352627",
"0.5352627",
"0.5352627",
"0.53491217",
"0.5307323",
"0.5297832",
"0.52698374",
"0.5250822",
"0.52269274",
"0.52204883",
"0.5200437",
"0.51819056",... | 0.59754115 | 0 |
FORMATS PHONE AS: (000) 0000000 Assumes phone is legitimate, then formats. Not designed to detect Valid phone number. Call: Wrap.new.format_phone(phone) | def format_phone(phone)
regex = Regexp.new('[A-Z]+[a-z]+')
if !phone.blank? && (phone != 'N/A' || phone != '0') && !regex.match(phone)
phone_stripped = phone.gsub(/[^0-9]/, '')
phone_step2 = phone_stripped && phone_stripped[0] == '1' ? phone_stripped[1..-1] : phone_stripped
final_phone = !(phone_step2 && phone_step2.length < 10) ? "(#{phone_step2[0..2]}) #{(phone_step2[3..5])}-#{(phone_step2[6..9])}" : phone
else
final_phone = nil
end
final_phone
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_phone\n if @phone != nil\n @phone = self.phone.scan(/[0-9]/).join\n self.phone = @phone.length == 7 ? ActionController::Base.helpers.number_to_phone(@phone) : \n @phone.length == 10 ? ActionController::Base.helpers.number_to_phone(@phone, area_code: true) :\n @phone\n\n end\n ... | [
"0.85179865",
"0.8491006",
"0.83427703",
"0.82791495",
"0.82706046",
"0.81327736",
"0.81212807",
"0.81212807",
"0.7997928",
"0.7980441",
"0.7980441",
"0.7980441",
"0.79404956",
"0.79095054",
"0.7876361",
"0.7820334",
"0.7797076",
"0.77761674",
"0.77670234",
"0.77526426",
"0.7... | 0.8364903 | 2 |
Given a hash with numeric values, return the key for the smallest value | def key_for_min_value(name_hash)
if name_hash.empty?
nil
else
lowest_value = Array.new
name_hash.each do |key, value|
if !lowest_value.empty? && value < lowest_value[0]
lowest_value.replace([value])
elsif lowest_value.empty?
lowest_value = [value]
end
end
name_hash.each do |key, value|
if value == lowest_value[0]
return key
end
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n hash.each do |key, value|\n if value < lowest_value\n lowest_value = value\n lowest_key = key\n end\n end\n lowest_key\nend",
"def key_for_min_value(hash)\n lowest_key = nil\n lowest_value = Float::INFINITY\n... | [
"0.8821222",
"0.8777674",
"0.87769854",
"0.8745862",
"0.8689437",
"0.86553806",
"0.865241",
"0.86165065",
"0.8587693",
"0.8572328",
"0.85674095",
"0.8550907",
"0.8529734",
"0.8529734",
"0.85182345",
"0.84936565",
"0.8475531",
"0.8475531",
"0.8466132",
"0.8449126",
"0.84490585... | 0.0 | -1 |
GET /classrooms GET /classrooms.json | def index
@classrooms = Classroom.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @classrooms = Classroom.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @classrooms }\n end\n end",
"def index\n @classrooms = ClientApi.classroom_all\n end",
"def show\n @classroom = classroom.find(params[:id])\n\n render jso... | [
"0.8008243",
"0.77901953",
"0.7419338",
"0.7294799",
"0.6992918",
"0.69750464",
"0.689671",
"0.68321544",
"0.6719616",
"0.6710493",
"0.6621833",
"0.65460867",
"0.65109086",
"0.6463596",
"0.6432278",
"0.6424339",
"0.6398858",
"0.6386652",
"0.6372728",
"0.63432235",
"0.63301724... | 0.7382656 | 3 |
GET /classrooms/1 GET /classrooms/1.json | def show
# TODO: Add student's view
if initialize_stats(@classroom)
if params[:topics] == "active"
@assignments = @active = Assignment.where(classroom_id: @classroom.id).where("due_date > ?", Time.current)
@student_assignments = @assignments
@assignments = @assignments.uniq {|a| a.topic_id }
# Update stats
new_stats = JSON.parse(@classroom.stats)
new_avg = 0
@assignments.each do |assign|
new_avg += new_stats["#{assign.topic_id}"]["avg_resources_viewed"]
end
new_stats["active"]["avg_resources_viewed"] = new_avg
highest = nil
highest_rating = -Float::INFINITY
lowest = nil
lowest_rating = Float::INFINITY
@assignments.each do |a|
if new_stats["#{a.topic_id}"]["highest_rated_resource_rating"].nil? # In case topic doesn't have any feedback yet
next
end
if new_stats["#{a.topic_id}"]["highest_rated_resource_rating"] > highest_rating
highest_rating = new_stats["#{a.topic_id}"]["highest_rated_resource_rating"]
highest = new_stats["#{a.topic_id}"]["highest_rated_resource"]
end
if new_stats["#{a.topic_id}"]["lowest_rated_resource_rating"] < lowest_rating
lowest_rating = new_stats["#{a.topic_id}"]["lowest_rated_resource_rating"]
lowest = new_stats["#{a.topic_id}"]["lowest_rated_resource"]
end
end
new_stats["active"]["highest_rated_resource"] = highest || nil
new_stats["active"]["highest_rated_resource_rating"] = if highest_rating > -Float::INFINITY then highest_rating else nil end
new_stats["active"]["lowest_rated_resource"] = lowest || nil
new_stats["active"]["lowest_rated_resource_rating"] = if lowest_rating < Float::INFINITY then lowest_rating else nil end
@classroom.stats = new_stats.to_json
@classroom.save
elsif params[:topics] == "past"
@assignments = Assignment.where(classroom_id: @classroom.id).where("due_date < ?", Time.current)
@student_assignments = @assignments
@active = Assignment.where(classroom_id: @classroom.id).where("due_date > ?", Time.current)
@assignments = @assignments.uniq {|a| a.topic_id }
# Update stats
new_stats = JSON.parse(@classroom.stats)
new_avg = 0
@assignments.each do |assign|
new_avg += new_stats["#{assign.topic_id}"]["avg_resources_viewed"]
end
new_stats["past"]["avg_resources_viewed"] = new_avg
highest = nil
highest_rating = -Float::INFINITY
lowest = nil
lowest_rating = Float::INFINITY
@assignments.each do |a|
if new_stats["#{a.topic_id}"]["highest_rated_resource_rating"].nil? # In case resource hasn't been given any feedback yet
next
end
if new_stats["#{a.topic_id}"]["highest_rated_resource_rating"] > highest_rating
highest_rating = new_stats["#{a.topic_id}"]["highest_rated_resource_rating"]
highest = new_stats["#{a.topic_id}"]["highest_rated_resource"]
end
if new_stats["#{a.topic_id}"]["lowest_rated_resource_rating"] < lowest_rating
lowest_rating = new_stats["#{a.topic_id}"]["lowest_rated_resource_rating"]
lowest = new_stats["#{a.topic_id}"]["lowest_rated_resource"]
end
end
new_stats["active"]["highest_rated_resource"] = highest || nil
new_stats["active"]["highest_rated_resource_rating"] = if highest_rating > -Float::INFINITY then highest_rating else nil end
new_stats["active"]["lowest_rated_resource"] = lowest || nil
new_stats["active"]["lowest_rated_resource_rating"] = if lowest_rating < Float::INFINITY then lowest_rating else nil end
@classroom.stats = new_stats.to_json
@classroom.save
end
else
raise "Could not initialize this classroom's stats."
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @classroom = classroom.find(params[:id])\n\n render json: @classroom\n end",
"def index\n @classrooms = Classroom.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @classrooms }\n end\n end",
"def index\n @classrooms = ClientApi.... | [
"0.78510505",
"0.775566",
"0.74021953",
"0.74015397",
"0.713145",
"0.70221114",
"0.6785876",
"0.678109",
"0.6671423",
"0.6663336",
"0.66603005",
"0.66079086",
"0.65824693",
"0.65813327",
"0.65528905",
"0.6524695",
"0.65165",
"0.6388906",
"0.6367941",
"0.6343786",
"0.6343551",... | 0.0 | -1 |
POST /classrooms POST /classrooms.json | def create
@classroom = Classroom.new(classroom_params)
@classroom.enrolled<<(current_user)
@classroom.user_id = current_user.id
@classroom.join_code = SecureRandom.hex(4)
respond_to do |format|
if @classroom.save
format.html { redirect_to "/classrooms/#{@classroom.id}/show/active", notice: 'Classroom was successfully created.' }
format.json { render :show, status: :created, location: "/classrooms/#{@classroom.id}/active" }
else
format.html { render :new }
format.json { render json: @classroom.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @classroom = Classroom.new(classroom_params)\n respond_to do |format|\n if @classroom.save\n format.html { redirect_to classrooms_url, notice: t('.notice', name: @classroom.name) }\n format.json { render :show, status: :created, location: @classroom }\n else\n form... | [
"0.7005064",
"0.69444746",
"0.67413205",
"0.6707056",
"0.6701791",
"0.6641425",
"0.663151",
"0.65877414",
"0.64901394",
"0.64711696",
"0.6376137",
"0.6342278",
"0.62105525",
"0.6195001",
"0.6118909",
"0.61103565",
"0.60723364",
"0.6037975",
"0.60306823",
"0.60118365",
"0.5965... | 0.6661625 | 5 |
PATCH/PUT /classrooms/1 PATCH/PUT /classrooms/1.json | def update
respond_to do |format|
if @classroom.update(classroom_params)
format.html { redirect_to @classroom, notice: 'Classroom was successfully updated.' }
format.json { render :show, status: :ok, location: @classroom }
else
format.html { render :edit }
format.json { render json: @classroom.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @classroom = classroom.find(params[:id])\n\n if @classroom.update_attributes(params[:classroom])\n head :no_content\n else\n render json: @classroom.errors, status: :unprocessable_entity\n end\n end",
"def update\n @classroom = Classroom.find(params[:id])\n\n respond_to ... | [
"0.73850185",
"0.71434546",
"0.7090638",
"0.69019264",
"0.68219817",
"0.6790598",
"0.6777076",
"0.6614741",
"0.65600693",
"0.65059566",
"0.6460165",
"0.64074343",
"0.63155764",
"0.6254383",
"0.62097776",
"0.6133744",
"0.6102012",
"0.6102012",
"0.6053652",
"0.6014905",
"0.6014... | 0.69145095 | 4 |
DELETE /classrooms/1 DELETE /classrooms/1.json | def destroy
@classroom.destroy
respond_to do |format|
format.html { redirect_to classrooms_url, notice: 'Classroom was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @classroom = Classroom.find(params[:id])\n @classroom.destroy\n\n respond_to do |format|\n format.html { redirect_to classrooms_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @classroom = classroom.find(params[:id])\n @classroom.destroy\n\n hea... | [
"0.7699335",
"0.73992443",
"0.7308683",
"0.7247049",
"0.72242516",
"0.7197427",
"0.716772",
"0.7139636",
"0.71007943",
"0.7089076",
"0.6991675",
"0.69511276",
"0.69331956",
"0.69179493",
"0.69055104",
"0.6881181",
"0.687983",
"0.68790716",
"0.68789047",
"0.6854109",
"0.682563... | 0.72919005 | 3 |
Use callbacks to share common setup or constraints between actions. | def set_classroom
@classroom = Classroom.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163927",
"0.6046165",
"0.59465253",
"0.59167755",
"0.58904207",
"0.58346355",
"0.577713",
"0.5703502",
"0.5703502",
"0.56531286",
"0.56215113",
"0.54224145",
"0.5410795",
"0.5410795",
"0.5410795",
"0.53924775",
"0.5379919",
"0.53580743",
"0.53401667",
"0.53397506",
"0.533... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def classroom_params
params.require(:classroom).permit(:name)
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.6980957",
"0.6783065",
"0.6747844",
"0.6741468",
"0.67356336",
"0.6592548",
"0.65036845",
"0.64978707",
"0.64825076",
"0.64795035",
"0.64560914",
"0.64397955",
"0.6379666",
"0.6376688",
"0.6366702",
"0.6319728",
"0.6300833",
"0.6300629",
"0.6294277",
"0.6293905",
"0.629117... | 0.0 | -1 |
Initialize stats field if nil to a JSON array with all topics | def initialize_stats(classroom)
if classroom.stats.nil?
# TODO: quiz_avg initialized to nil b/c no quiz integration yet
# Resources are stored by ids
new_stats = {
active: { quiz_avg: nil, avg_resources_viewed: 0, highest_rated_resource: nil, highest_rated_resource_rating: nil, lowest_rated_resource: nil, lowest_rated_resource_rating: nil },
past: { quiz_avg: nil, avg_resources_viewed: 0, highest_rated_resource: nil, highest_rated_resource_rating: nil, lowest_rated_resource: nil, lowest_rated_resource_rating: nil }
}
new_stats = new_stats.to_json
classroom.stats = new_stats
classroom.save
else
true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def topics\n respond_to?(:topic) ? topic : []\n end",
"def all\n data = service.list_topics.to_h[:topics] || []\n load(data)\n end",
"def show\n\t\treferenced = @topic.tweets.count(:distinct)\n\t\tusers = @topic.tweets.user.count(:distinct)\n\t\trender json: show_json(@... | [
"0.60508996",
"0.59199107",
"0.58814096",
"0.5788902",
"0.5660047",
"0.565565",
"0.5618181",
"0.56122184",
"0.5603733",
"0.5603733",
"0.5583852",
"0.553468",
"0.55257046",
"0.5486205",
"0.5479462",
"0.5477043",
"0.54188925",
"0.53733",
"0.53704983",
"0.5362765",
"0.53519833",... | 0.55499357 | 11 |
Is the table a temporary table or not | def temporary?
schema.temporary?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def use_temp_table?\n !@limit.nil? && !@offset.nil? && @offset > 0\n end",
"def temporary_table_sql\n TEMPORARY\n end",
"def temporary_table_sql\n TEMPORARY\n end",
"def temporary_table_sql\n 'TEMPORARY '\n end",
"def create_temp_table\n RailsRedshiftReplicato... | [
"0.7425512",
"0.70780194",
"0.70780194",
"0.6818762",
"0.6410045",
"0.6329076",
"0.62820405",
"0.62619925",
"0.62295777",
"0.6212729",
"0.62044245",
"0.60376143",
"0.6026412",
"0.6017955",
"0.6013508",
"0.59843385",
"0.5965261",
"0.596024",
"0.5890547",
"0.58528274",
"0.58164... | 0.7205942 | 1 |
the Columns in original definition order | def columns_in_order
@columns.values.sort_by { |c| c.order }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def columns; end",
"def columns; @columns; end",
"def columns\n _columns || columns!\n end",
"def columns\n\t\t\t@columns ||= Txtboard::Column.columns.sort_by(&:order)\n\t\tend",
"def columns\n @columns ||= []\n end",
"def columns\n @columns ||= [];\n end",
"... | [
"0.78994954",
"0.7828204",
"0.782254",
"0.76722944",
"0.7631085",
"0.76223487",
"0.761473",
"0.7577862",
"0.75276774",
"0.7430823",
"0.7427482",
"0.74073905",
"0.73975337",
"0.73975337",
"0.73665786",
"0.7358449",
"0.7339714",
"0.7316946",
"0.7296269",
"0.7296269",
"0.7289927... | 0.70304257 | 44 |
the column names in original definition order | def column_names
columns_in_order.map { |c| c.name }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def column_names\n columns.map(&:name)\n end",
"def column_names\n @columns.keys\n end",
"def column_names\n @column_names ||= @columns.keys\n end",
"def column_names\n @column_names ||= columns.collect(&:name)\n end",
"def column_names(table_name)\n columns... | [
"0.8201744",
"0.7938683",
"0.7920868",
"0.7908965",
"0.7785883",
"0.7739997",
"0.7714316",
"0.7617322",
"0.7578363",
"0.75420356",
"0.7535253",
"0.7521838",
"0.7481324",
"0.74751383",
"0.7438091",
"0.7425295",
"0.7359442",
"0.7340629",
"0.7324111",
"0.7317851",
"0.73007905",
... | 0.8311155 | 0 |
the columns that make up the primary key | def primary_key_columns
@columns.values.find_all { |c| c.primary_key? }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key_columns\n @key_columns ||= [\"#{self.table_name}__id\".to_sym]\n end",
"def columns\n unless defined?(@columns) && @columns\n @columns = connection.columns(table_name, \"#{name} Columns\").select do |column| \n column.name =~ Regexp.new(\"^#{se... | [
"0.8006035",
"0.79476196",
"0.78944254",
"0.77287316",
"0.76391935",
"0.75898236",
"0.74707097",
"0.7285446",
"0.72474337",
"0.7237039",
"0.7190185",
"0.71730334",
"0.71672416",
"0.7162006",
"0.71519506",
"0.7117364",
"0.711734",
"0.70984787",
"0.7070163",
"0.70646614",
"0.70... | 0.8635547 | 0 |
the array of colmuns that make up the primary key of the table since a primary key has an index, we loop over all the indexes for the table and pick the first one that is unique, and all the columns in the index have primary_key? as true. we do this instead of just looking for the columns where primary key is true because we want the columns in primary key order | def primary_key
unless @primary_key
pk_column_names = Set.new( primary_key_columns.collect { |c| c.name } )
unique_indexes = indexes.values.find_all { |i| i.unique? }
pk_result = []
unique_indexes.each do |idx|
idx_column_names = Set.new( idx.columns.collect { |c| c.name } )
r = idx_column_names ^ pk_column_names
if r.size == 0 then
pk_result = idx.columns
break
end
end
# no joy, see about just using all the columns that say the are primary
# keys
if pk_result.empty? then
pk_result = self.primary_key_columns
end
@primary_key = pk_result
end
return @primary_key
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def primary_key_columns\n @columns.values.find_all { |c| c.primary_key? }\n end",
"def primary_keys(field)\n sql = \"SELECT #{field.primary_key_col} from #{field.table} \"\n sql += \"#{where_and(sql)} #{field.column} IS NOT NULL \" if field.leave_null\n field.where&.each_pair do |column, value|\n s... | [
"0.8102493",
"0.7097868",
"0.7064459",
"0.7007203",
"0.6913126",
"0.6912206",
"0.68672913",
"0.669321",
"0.667993",
"0.6676346",
"0.6541355",
"0.6535345",
"0.65180254",
"0.64925045",
"0.64799976",
"0.646325",
"0.6426712",
"0.6401427",
"0.63823336",
"0.6354877",
"0.6325923",
... | 0.82497185 | 0 |
def test_count_is_ten count = 10 assert false, "Count should be 10" end Called before every test method runs. Can be used to set up fixture information. | def setup
# Do nothing
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def before_test(test); end",
"def before_test(test); end",
"def test_should_be_setup\n assert false\n end",
"def test_contains_four_eachface\n assert true == false\n end",
"def _test_pages_available\n #execute this code x number of times\n @custom_number_of_users.times do |i|\n put... | [
"0.6907003",
"0.6907003",
"0.6755066",
"0.67336255",
"0.65376735",
"0.6436397",
"0.63884985",
"0.6362583",
"0.6327711",
"0.6309824",
"0.6300795",
"0.6295088",
"0.6273818",
"0.6273818",
"0.6266045",
"0.6266045",
"0.6256781",
"0.6256781",
"0.6256781",
"0.62477934",
"0.62477934"... | 0.0 | -1 |
Called after every test method runs. Can be used to tear down fixture information. | def teardown
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_teardown; end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def tear... | [
"0.80261725",
"0.7953777",
"0.7953777",
"0.7856355",
"0.784488",
"0.784488",
"0.784488",
"0.784488",
"0.784488",
"0.784488",
"0.784488",
"0.784488",
"0.78328496",
"0.78328496",
"0.77501464",
"0.77479887",
"0.77479887",
"0.7733529",
"0.771271",
"0.77113944",
"0.77113944",
"0... | 0.7556477 | 51 |
Run validation. Returns False if the given value is nil or empty, True otherwise. | def run_validator(value)
if value.nil?
set_error :missing
false
elsif value.respond_to?(:empty?) && value.empty?
set_error :empty
false
else
true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid?( value )\n ( required? && ( value.nil? || value.to_s.empty? ) ) ? false : true\n end",
"def valid?\n @value ? true : false\n end",
"def valid?\n value\n end",
"def valid?(value)\n # we also allow nil values, which do not have to be verified.\n return true if val... | [
"0.7432915",
"0.71249044",
"0.705155",
"0.69319844",
"0.6860305",
"0.6857427",
"0.68460125",
"0.681188",
"0.68012327",
"0.68012327",
"0.6799599",
"0.6790351",
"0.67649674",
"0.6705831",
"0.6705831",
"0.66883135",
"0.66883135",
"0.66883135",
"0.66883135",
"0.66883135",
"0.6688... | 0.85905415 | 0 |
GET /notices GET /notices.xml | def index
@menu = "board"
@board = "notice"
@section = "index"
@notices_news = Notice.only_news.search(params[:search], params[:page])
@notices_notices = Notice.only_notice.search(params[:search], params[:page])
@total_count = Notice.only_news.search(params[:search],"").count
render 'notice'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @notices = Notice.all\n end",
"def index\r\n @notices = Notice.all\r\n end",
"def index\n @notices = current_user.notices.page params[:page]\n end",
"def show\n @notices = Notice.order(created_at: :desc).where(finalised: false)\n end",
"def show\n @pharmacy_notices = Pharmacy... | [
"0.66531163",
"0.65893584",
"0.6432258",
"0.616246",
"0.61178434",
"0.6017407",
"0.5999476",
"0.59181225",
"0.591488",
"0.59115833",
"0.59081393",
"0.58735275",
"0.5865686",
"0.5858988",
"0.5851268",
"0.5850512",
"0.58026606",
"0.57874125",
"0.57701063",
"0.5689915",
"0.56866... | 0.0 | -1 |
GET /notices/1 GET /notices/1.xml | def show
@notice = Notice.get(params[:id])
if @notice
@menu = "board"
@board = "notice"
@section = "show"
@notice.hit_cnt += 1
@notice.save
render 'notice'
else
redirect_to '/notices'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @notices = Notice.all\n end",
"def index\r\n @notices = Notice.all\r\n end",
"def index\n @notices = current_user.notices.page params[:page]\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @notifier }\n end\n end... | [
"0.63647825",
"0.63091123",
"0.62240267",
"0.60661876",
"0.60159445",
"0.59795207",
"0.59425867",
"0.59199786",
"0.59188646",
"0.58635867",
"0.5848736",
"0.58163154",
"0.5814088",
"0.58124536",
"0.57995653",
"0.57889086",
"0.57793105",
"0.5772317",
"0.57243615",
"0.569481",
"... | 0.51587665 | 93 |
GET /notices/new GET /notices/new.xml | def new
@menu = "board"
@board = "notice"
@section = "new"
@notice = Notice.new
render 'notice'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @notifier }\n end\n end",
"def new\n @notice = @person.notices.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @notice }\n end\n end",
"def ... | [
"0.70967466",
"0.686593",
"0.6843608",
"0.68026596",
"0.6743433",
"0.6708605",
"0.6646194",
"0.6549437",
"0.65355176",
"0.6511833",
"0.65074176",
"0.6431483",
"0.64209145",
"0.64093673",
"0.63750416",
"0.6351674",
"0.6351674",
"0.6351674",
"0.63161665",
"0.63161665",
"0.63115... | 0.601811 | 95 |
POST /notices POST /notices.xml | def create
@menu = "board"
@board = "notice"
@notice = Notice.new(params[:notice])
if @notice.save
redirect_to admin_notices_url
else
@section = "new"
render 'notice'
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @notice = Notice.new(notice_params)\n @notice.client = current_client if current_client\n @notice.order_num = 0\n\n shuffle_notices(current_client.id) if current_client\n\n @notices = Notice.all.where(client_id: current_client.id) if current_client\n\n respond_to do |format|\n i... | [
"0.6023591",
"0.5817914",
"0.5774758",
"0.57629013",
"0.57181966",
"0.56686044",
"0.5529179",
"0.5518506",
"0.5495022",
"0.54454833",
"0.5414494",
"0.5410084",
"0.53981984",
"0.53858566",
"0.53840977",
"0.5370329",
"0.5366684",
"0.53607434",
"0.5331785",
"0.532445",
"0.532370... | 0.0 | -1 |
PUT /notices/1 PUT /notices/1.xml | def update
@notice = Notice.get(params[:id])
respond_to do |format|
if @notice.save(params[:notice])
format.html { redirect_to(@notice) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @notice.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update opts = {}\n opts[:headers] ||= {}\n opts[:headers]['Content-Type'] ||= 'text/xml'\n post 'update', opts\n end",
"def test_put_invoices_1_xml\n @parameters = {:invoice => {:number => 'NewNumber'}}\n \n Redmine::ApiTest::Base.should_allow_api_authentication(:put,\n ... | [
"0.6317148",
"0.60328764",
"0.5954462",
"0.59396523",
"0.59192175",
"0.58754724",
"0.5862353",
"0.5823528",
"0.58154184",
"0.58048445",
"0.5798715",
"0.5697773",
"0.56954634",
"0.56902266",
"0.56881994",
"0.56852996",
"0.56852996",
"0.56818235",
"0.5678948",
"0.5652184",
"0.5... | 0.6239323 | 1 |
DELETE /notices/1 DELETE /notices/1.xml | def destroy
@notice = Notice.get(params[:id])
@notice.destroy
respond_to do |format|
format.html { redirect_to(admin_notices_url) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @pharmacy_notices = PharmacyNotices.find(params[:id])\n @pharmacy_notices.destroy\n\n respond_to do |format|\n format.html { redirect_to(pharmacy_notices_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @notice.destroy\n\n reorder_notices(current_client.id... | [
"0.66738",
"0.6481168",
"0.64719886",
"0.64698493",
"0.6458221",
"0.6431499",
"0.64147353",
"0.63499355",
"0.63424295",
"0.6340936",
"0.6340936",
"0.6339415",
"0.6333574",
"0.6324451",
"0.63182884",
"0.6304207",
"0.630133",
"0.62997407",
"0.62884873",
"0.62808305",
"0.6256904... | 0.7246214 | 0 |
Required at least for testing; instructions are persisted between tags otherwise. | def clear_instructions
instructions.clear
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def instructions\n \n end",
"def instruction name, instruction\n end",
"def instructions; raise NotImplementedError\n end",
"def processing_instruction(name, content); end",
"def processing_instruction(name, content); end",
"def processing_instruction?; end",
"def processing_instruction?; end... | [
"0.668282",
"0.64637876",
"0.62288845",
"0.5876667",
"0.5876667",
"0.56349695",
"0.56349695",
"0.55951923",
"0.54677457",
"0.54677457",
"0.54425615",
"0.5425525",
"0.5423554",
"0.5416815",
"0.540846",
"0.53366923",
"0.5330022",
"0.5328616",
"0.5316253",
"0.5257162",
"0.524854... | 0.48559982 | 64 |
Class names can't contain question marks, so we strip them. | def instruction_class(method_name)
Object.const_get instruction_class_name(method_name)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sanitize_class_name(name)\n name.gsub(/[^_0-9A-Za-z:]/, '')\n end",
"def safe_class_name()\n self.class.name.downcase.gsub(/[^\\d\\w]/, '_')\n end",
"def stripped_class_name\n name.demodulize\n end",
"def check_class_name\n\t\tspecial = \"!?<>',?[]}{=-)(*&|... | [
"0.79565597",
"0.7339181",
"0.6887076",
"0.6705381",
"0.66707647",
"0.66436183",
"0.6516235",
"0.6482526",
"0.6482526",
"0.64575887",
"0.64556134",
"0.64142776",
"0.6340486",
"0.6285525",
"0.62645537",
"0.6251943",
"0.6229951",
"0.6225908",
"0.6213478",
"0.6181661",
"0.61713"... | 0.0 | -1 |
a quick dirty code formatter, TODO : parse it at least like a help file, with a content_type :code or :ruby TODO : provide key 'gf' to open other files under cursor | def code_browse path
dr = ruby_renderer
view(path, :close_key => 'q', :title => $0) do |t|
t.renderer dr
t.bind_key([?\\,?\\,?o],'choose file') {
str = choose_file "**/*"
if str and str != ""
t.add_content str
t.buffer_last
else
alert "nothing chosen"
end
}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bob_code(options={}, &block)\n # if the only string is give, it must be filename by default\n if options.is_a? String\n f = options\n options = {}\n options[:filename] = f \n end\n if block_given?\n code = capture(&block)\n options[:brush] ||= :plain\n else\n unless... | [
"0.67209065",
"0.66687053",
"0.66617787",
"0.6656897",
"0.66454667",
"0.6569746",
"0.65450567",
"0.65171087",
"0.64851105",
"0.64760035",
"0.6385224",
"0.63796324",
"0.635637",
"0.6343274",
"0.62623304",
"0.6241568",
"0.62404853",
"0.6227667",
"0.6222192",
"0.6222192",
"0.620... | 0.0 | -1 |
this should be available to view also. | def choose_file_and_view glob=nil, startdir="."
glob ||= "**/*.rb"
str = choose_file glob, :title => "Select a file",
:directory => startdir,
:help_text => "Enter pattern, use UP DOWN to traverse, Backspace to delete, ENTER to select. Esc-Esc to quit"
if str and str != ""
code_browse str
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _view; end",
"def private; end",
"def view_info\n super\n end",
"def view\n @_view\n end",
"def view; end",
"def rendered; end",
"def initialize\n super\n end",
"def initialize\n super\n end",
"def rendered_views=(_arg0); end",
"def view_ass... | [
"0.7073296",
"0.68427557",
"0.6695035",
"0.6517976",
"0.64995354",
"0.6406089",
"0.63709706",
"0.63709706",
"0.635243",
"0.63100725",
"0.63100725",
"0.6310039",
"0.62885314",
"0.6248693",
"0.6248693",
"0.6248693",
"0.6248693",
"0.6248693",
"0.62459826",
"0.6218396",
"0.621839... | 0.0 | -1 |
for the current field, display the instance variables and their values as well as the public methods. (We can do this in a tree format too) | def view_properties field=@form.get_current_field
alert "Nil field" unless field
return unless field
text = ["Instance Variables"]
text << "------------------"
#iv = field.instance_variables.map do |v| v.to_s; end
field.instance_variables.each do |v|
val = field.instance_variable_get(v)
klass = val.class
if val.is_a? Array
val = val.size
elsif val.is_a? Hash
val = val.keys
end
case val
when String, Integer, TrueClass, FalseClass, NilClass, Array, Hash, Symbol
;
else
val = "Not shown"
end
text << "%20s %10s %s" % [v, klass, val]
end
text << " "
text << "Public Methods"
text << "--------------"
pm = field.public_methods(false).map do |v| v.to_s; end
text += pm
text << " "
text << "Inherited Methods"
text << "-----------------"
pm = field.public_methods(true) - field.public_methods(false)
pm = pm.map do |v| v.to_s; end
text += pm
#$log.debug " view_properties #{s.size} , #{s} "
textdialog text, :title => "Properties"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inspect\n instance_variables.each_with_object([\n \"\\n#<#{self.class}:0x#{object_id.to_s(16)}>\",\n \"\\tInstance variables:\"\n ]) do |item, result|\n result << \"\\t\\t#{item} = #{instance_variable_get(item)}\"\n result\n end.join(\"\\n\")\n end",
"def inspect... | [
"0.6681427",
"0.66210157",
"0.66210157",
"0.6566131",
"0.65621835",
"0.6486566",
"0.6456121",
"0.63365465",
"0.63365465",
"0.6325427",
"0.6170013",
"0.6170013",
"0.6170013",
"0.6148033",
"0.6103148",
"0.609513",
"0.6077762",
"0.60707414",
"0.6069215",
"0.6061529",
"0.60567385... | 0.6718983 | 0 |
place instance_vars of current or given object into a hash and view in a treedialog. | def view_properties_as_tree field=@form.get_current_field
alert "Nil field" unless field
return unless field
text = []
tree = {}
#iv = field.instance_variables.map do |v| v.to_s; end
field.instance_variables.each do |v|
val = field.instance_variable_get(v)
klass = val.class
if val.is_a? Array
#tree[v.to_s] = val
text << { v.to_s => val }
val = val.size
elsif val.is_a? Hash
#tree[v.to_s] = val
text << { v.to_s => val }
if val.size <= 5
val = val.keys
else
val = val.keys.size.to_s + " [" + val.keys.first(5).join(", ") + " ...]"
end
end
case val
when String, Integer, TrueClass, FalseClass, NilClass, Array, Hash, Symbol
;
else
val = "Not shown"
end
text << "%-20s %10s %s" % [v, klass, val]
end
tree["Instance Variables"] = text
pm = field.public_methods(false).map do |v| v.to_s; end
tree["Public Methods"] = pm
pm = field.public_methods(true) - field.public_methods(false)
pm = pm.map do |v| v.to_s; end
tree["Inherited Methods"] = pm
#$log.debug " view_properties #{s.size} , #{s} "
treedialog tree, :title => "Properties"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_glade_variables(obj = self)\r\n obj.instance_variables.each do |name|\r\n name = name.to_s #ruby 1.9 passes symbol!\r\n v = obj.instance_variable_get(name)\n name = name.gsub('@', '')\r\n if v.is_a?(Array) \r\n v.each_index do |i|\r\n fill_control(\"#{name}[#{i.to_s}]... | [
"0.59859794",
"0.58868414",
"0.5798459",
"0.5515661",
"0.5497084",
"0.52927786",
"0.52924514",
"0.5268527",
"0.52530265",
"0.52455175",
"0.52412593",
"0.5234987",
"0.5214921",
"0.5168881",
"0.5165953",
"0.5163566",
"0.5163566",
"0.51604694",
"0.514506",
"0.5143935",
"0.514097... | 0.48349816 | 74 |
Set datetime format. +datetime_format+:: A string suitable for passing to +strftime+. | def datetime_format=(datetime_format)
@default_formatter.datetime_format = datetime_format
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def datetime_format=(format)\n add_datetime_formatter!(format)\n end",
"def datetime_format=(datetime_format)\n formatter.datetime_format = datetime_format if formatter.respond_to?(:datetime_format=)\n end",
"def datetime_format=(datetime_format)\n @default_formatter.datetime_format = datetime_f... | [
"0.8424987",
"0.83794785",
"0.8300264",
"0.8126997",
"0.75935125",
"0.73568064",
"0.7155124",
"0.7117314",
"0.6875376",
"0.68167543",
"0.66866356",
"0.66772956",
"0.66471344",
"0.6595629",
"0.65921634",
"0.6578348",
"0.6540522",
"0.6487698",
"0.6363807",
"0.6326973",
"0.63214... | 0.843665 | 0 |
Returns the date format being used. See datetime_format= | def datetime_format
@default_formatter.datetime_format
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def date_format\n return @date_format\n end",
"def datetime_format\n @default_formatter.datetime_format\n end",
"def datetime_format\n end",
"def set_date_format(format) \n unless format.nil?\n return format\n else\n return @@db_format\n end\n end",
"def... | [
"0.8482674",
"0.80629194",
"0.7870147",
"0.7720138",
"0.77118975",
"0.74758786",
"0.7436615",
"0.741742",
"0.74096006",
"0.7377887",
"0.73540306",
"0.7247036",
"0.71706444",
"0.7064184",
"0.70533293",
"0.7038547",
"0.7029291",
"0.70237607",
"0.7005066",
"0.7001785",
"0.692306... | 0.8166775 | 1 |
recieves the full path and returns a symbol for category | def get_category text
#text = File.join(@path, t)
if File.directory? text
return :dir
elsif File.executable? text
return :executable
elsif File.symlink? text
return :link
elsif File.exists? text
if text =~ /\.txt$/
return :text
elsif text =~ /\.zip$/ or text =~ /gz$/
return :zip
else
return :file
end
else
return :other
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def categories_from_path(special_dir); end",
"def category(rel_path)\n find_category based_on_root rel_path\n end",
"def category\n path = @path_remote.split('/')\n return path[3] # Could require changes depending on the structure of the maps repo\n end",
"def add_category(path, name)\n @list... | [
"0.66660875",
"0.66264933",
"0.6623153",
"0.65397346",
"0.63834655",
"0.6365718",
"0.6353815",
"0.6352989",
"0.6268777",
"0.6201033",
"0.61333984",
"0.6111277",
"0.60819906",
"0.6060928",
"0.60556287",
"0.59803486",
"0.59612495",
"0.5953593",
"0.5935044",
"0.58867437",
"0.584... | 0.66288483 | 1 |
long directory renderer text is only the file name without path | def render pad, lineno, text
fullname = File.join(@path, text)
klass = get_category fullname
$log.info "fullname is #{fullname}, #{klass} "
# some links throw up an error of no such file
_stat = File.stat(fullname) rescue File.lstat(fullname)
@fg = @hash[klass][0]
bg = @hash[klass][1]
@bg = bg #if bg
bg = @hash[klass][2]
@attr = bg # if bg
prefix = @prefix[klass] || " "
#@left_margin_text = prefix
ftext = format_message( text, _stat, prefix)
super pad, lineno, ftext
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_dir_name\n return @builder['dir_label'].text\n end",
"def file_listings_html_string(file_paths, folder_name)\n file_paths.map do |path|\n dist_file_name = file_name_from_path(sanitize_path(path))\n dist_final_path = public_path(folder_name, dist_file_name)\n next file_listin... | [
"0.6689698",
"0.64538646",
"0.62626445",
"0.62547964",
"0.6228867",
"0.620585",
"0.6205777",
"0.6188645",
"0.61595273",
"0.6155371",
"0.6135325",
"0.6099071",
"0.6051347",
"0.6047144",
"0.6045798",
"0.6028868",
"0.6028405",
"0.59927374",
"0.5980991",
"0.5968079",
"0.5953535",... | 0.5726348 | 40 |
read files files can be one filename, a pattern or an array of filenames and/or patterns | def read patterns
Dir[*patterns].uniq.map do |f|
filename = File.join(Dir.pwd, f)
@files ||= []; @files << filename
STDERR.puts filename
case File.extname(filename)
when '.erb'
Dir.chdir File.dirname(filename) do
ERB.new(File.read(File.basename(filename))).result(binding)
end
else
File.read filename
end
end.join("\n")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read(files); end",
"def read(files); end",
"def parse_files(*files); end",
"def parse_files(files, opts = {})\n opts = { :extension => nil, :directory => nil }.merge opts\n files = [files] unless files.is_a?(Array)\n search_text = files.join(\" \")\n parsed_files = []\n ... | [
"0.73474854",
"0.73474854",
"0.6795345",
"0.6407315",
"0.63469326",
"0.63382936",
"0.63059384",
"0.6297352",
"0.6263728",
"0.6252611",
"0.6246023",
"0.6199426",
"0.61886835",
"0.6144287",
"0.614405",
"0.61128956",
"0.6102357",
"0.6081472",
"0.60678136",
"0.6055396",
"0.604726... | 0.67608964 | 3 |
map directory structure to javascript objects | def map dirname, indent = 2
out = "{\n"
omit_comma = true
Dir.entries(dirname).each do |f|
next if f =~ /^\./
file = File.join(dirname, f)
f.sub!(/\.erb$/, '')
f.sub!(/#{Regexp.escape File.extname(f)}$/, '')
if omit_comma
omit_comma = false
else
out << ",\n"
end
out << ' '*indent + ' "%s": ' % f
if File.directory?(file)
out << map(file, indent + 2)
else
out << h(read(file))
end
end
out + "\n" + ' '*indent + '}'
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def directories; end",
"def directories; end",
"def directories\n directory_entries.map{ |f| FileObject[path, f] }\n end",
"def json_dir_names\n DIR.entries\n .map(&:basename)\n .map(&:to_s)\n .select { |dirname| dirname =~ /^[0-9]+\\.[0-9]/ }.sort\n end",
"def dirs; end",
"... | [
"0.6391133",
"0.6391133",
"0.6379577",
"0.6342453",
"0.6287408",
"0.6287408",
"0.62732416",
"0.6217411",
"0.6197997",
"0.6142358",
"0.602604",
"0.6009284",
"0.59698087",
"0.5961182",
"0.59152526",
"0.59109086",
"0.59011394",
"0.58745456",
"0.58729243",
"0.5868736",
"0.5833053... | 0.65250844 | 0 |
GET /solutions GET /solutions.json | def index
@assignment = Assignment.find(params[:assignment_id])
@solutions = @assignment.solutions
@hash_solutions = {}
@solutions.pluck(:language).uniq.each {|language| @hash_solutions[language] = @solutions.where('language = ?', language)}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @solutions = @idea.solutions.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @solutions }\n end\n end",
"def show\n @solution = @idea.solutions.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n f... | [
"0.77688867",
"0.7308382",
"0.6823754",
"0.6823754",
"0.6823754",
"0.67705363",
"0.6600122",
"0.6597075",
"0.6508489",
"0.64890707",
"0.64498717",
"0.63750976",
"0.6354698",
"0.6287679",
"0.623368",
"0.61995995",
"0.61232305",
"0.61224574",
"0.6097867",
"0.6092867",
"0.602930... | 0.5979331 | 23 |
GET /solutions/1 GET /solutions/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @solutions = @idea.solutions.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @solutions }\n end\n end",
"def show\n @solution = @idea.solutions.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n f... | [
"0.75871086",
"0.75095385",
"0.69770825",
"0.6890578",
"0.67686564",
"0.67686564",
"0.67686564",
"0.6619587",
"0.655043",
"0.65149266",
"0.64279115",
"0.63966733",
"0.6391543",
"0.6352886",
"0.628824",
"0.62604916",
"0.6244843",
"0.6210185",
"0.62029654",
"0.6200472",
"0.6198... | 0.0 | -1 |
POST /solutions POST /solutions.json | def create
@solution = Solution.new(solution_params)
@solution.user_id = current_user.id
@assignment = Assignment.find(params[:assignment_id])
respond_to do |format|
if @solution.save
format.html { redirect_to @solution, notice: 'Solution was successfully created.' }
format.json { render :show, status: :created, location: @solution }
else
format.html { render :new }
format.json { render json: @solution.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @solution = @idea.solutions.new(feature: params[:toSent]) #@idea.solutions.new(params[:solution])\n\n if @solution.save\n render json: { text: \"success\", id: \"#{@solution.id}\" }\n else\n render json: { text: \"fail\"}\n end\n end",
"def new\n @solution = @idea.solutions... | [
"0.68262124",
"0.6717463",
"0.6662279",
"0.6640301",
"0.66299975",
"0.66066796",
"0.64212006",
"0.63876235",
"0.63704526",
"0.61834604",
"0.61586016",
"0.61448663",
"0.6144085",
"0.6068623",
"0.6052766",
"0.6036344",
"0.60117763",
"0.59383637",
"0.59383637",
"0.59383637",
"0.... | 0.59603775 | 17 |
PATCH/PUT /solutions/1 PATCH/PUT /solutions/1.json | def update
@assignment = Assignment.find(params[:assignment_id])
respond_to do |format|
if @solution.update(solution_params)
format.html { redirect_to @solution, notice: 'Solution was successfully updated.' }
format.json { render :show, status: :ok, location: @solution }
else
format.html { render :edit }
format.json { render json: @solution.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @solution = @idea.solutions.find(params[:id])\n\n if @solution.update_attributes(params[:solution])\n render json: { text: \"success\" }\n else\n render json: { text: \"fail\"}\n end\n end",
"def update\n @solution = Solution.find(params[:id])\n\n respond_to do |format|\... | [
"0.7246333",
"0.66415024",
"0.64563525",
"0.6391965",
"0.63387203",
"0.6336246",
"0.62703794",
"0.6269332",
"0.62673825",
"0.6234307",
"0.61789775",
"0.6133806",
"0.60892016",
"0.6066992",
"0.598312",
"0.5979192",
"0.5954163",
"0.59250957",
"0.59240204",
"0.59214807",
"0.5906... | 0.57063466 | 44 |
DELETE /solutions/1 DELETE /solutions/1.json | def destroy
@solution.destroy
respond_to do |format|
format.html { redirect_to assignment_solutions_path(@solution.assignment_id), notice: 'Solution was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @solution.destroy\n render json: {solutions: @solution}, status: 200\n end",
"def destroy\n @solution.destroy\n respond_to do |format|\n format.html { redirect_to solutions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @solution = Solution.fin... | [
"0.7864415",
"0.75774145",
"0.7555733",
"0.75061536",
"0.7288376",
"0.7288376",
"0.72574353",
"0.7144156",
"0.7115537",
"0.69710326",
"0.69710326",
"0.69703645",
"0.6970164",
"0.68471247",
"0.68289363",
"0.68050957",
"0.6802883",
"0.6802161",
"0.6802161",
"0.6802161",
"0.6802... | 0.711246 | 9 |
Use callbacks to share common setup or constraints between actions. | def set_solution
@solution = Solution.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def solution_params
params.require(:solution).permit(:user_id, :body, :language, :assignment_id, :code_type)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
convert a string to a date (using Chronic, of course) | def convert_to_date(string)
return nil if (string.nil? || string.class != String)
tmp = Chronic.parse(string)
tmp ? tmp.to_date : nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_to_date(string)\n return nil if string.blank?\n Chronic.parse(string).to_date\n end",
"def convert_to_date(string)\n return nil if string.blank?\n Chronic.parse(string).to_date\n end",
"def date_from_string(date)\n\n#remove st rd nd and th\n\nfirstParse = Chronic.parse(date)\nr1 = /[a... | [
"0.8390564",
"0.8390564",
"0.78838104",
"0.75446165",
"0.74621123",
"0.7293652",
"0.7241278",
"0.70949775",
"0.70762724",
"0.6975335",
"0.68844914",
"0.6879644",
"0.6750106",
"0.6738062",
"0.66463464",
"0.66281503",
"0.662495",
"0.6624812",
"0.65937877",
"0.65862",
"0.6584451... | 0.8166301 | 2 |
convert a string to a datetime (Chronic's default) | def convert_to_datetime(string)
return nil if (string.nil? || string.class != String)
Chronic.parse(string)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_to_datetime(string)\n return nil if string.blank?\n Chronic.parse(string)\n end",
"def convert_to_date(string)\n return nil if string.blank?\n Chronic.parse(string).to_date\n end",
"def convert_to_date(string)\n return nil if string.blank?\n Chronic.parse(string).to_date\n end"... | [
"0.8730958",
"0.7691374",
"0.7691374",
"0.766451",
"0.7596385",
"0.7291732",
"0.7040065",
"0.68634987",
"0.68624246",
"0.6856555",
"0.6840499",
"0.6791504",
"0.6779921",
"0.67230445",
"0.671948",
"0.66973567",
"0.6671493",
"0.66088444",
"0.6602428",
"0.6571812",
"0.65577006",... | 0.8741711 | 0 |
pointer to start of PmValueSet | def vset
numpmid.times.collect do |n|
PmValueSet.new((start_of_vset + FFI::Pointer.size * n).get_pointer(0))
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first_value\r\n get(@first_index)\r\n end",
"def peek\n @first.val\n end",
"def next\r\n next_values[0]\r\n end",
"def start_point; get(start_param) end",
"def explain\n init_value_list \n @value_list[@current_value] \n end",
"def get_r... | [
"0.57193214",
"0.55723876",
"0.55306673",
"0.55303264",
"0.5460171",
"0.53776896",
"0.53692776",
"0.5351155",
"0.53217316",
"0.53210133",
"0.52786696",
"0.5277981",
"0.52255",
"0.520621",
"0.52028334",
"0.5200248",
"0.5199766",
"0.5199766",
"0.5199766",
"0.5199766",
"0.519976... | 0.6207112 | 0 |
fetch article regarding the id | def show
@article = Article.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def article(id:)\n Article.find(id)\n end",
"def article(cps_id)\n @client.request(:get, \"articles/#{cps_id}\")[\"article\"]\n end",
"def article(id, *args)\n options = args.last.is_a?(Hash) ? args.pop : {}\n response = get(\"articles/#{id}\",options)\n response.article\n ... | [
"0.8167026",
"0.7849825",
"0.7698102",
"0.75659394",
"0.7510568",
"0.73399884",
"0.7294814",
"0.7293967",
"0.72300637",
"0.7118161",
"0.7105801",
"0.7013201",
"0.69944984",
"0.6927694",
"0.69141877",
"0.6828723",
"0.68211985",
"0.67912114",
"0.6781864",
"0.6771606",
"0.674175... | 0.6795305 | 26 |
Returns true if video content is an episode | def episode?
content_type == "Episode"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def finished?\n @episodes.last.watched?\n end",
"def video?\n @streams.any? { |stream| stream.is_a? VideoStream }\n end",
"def video?\n !!( content_type =~ Transit.config.video_regexp )\n end",
"def video?\n attributes['_type'].split('::').last == 'Video'\n end",
"def video?\n se... | [
"0.7138559",
"0.7015842",
"0.6987692",
"0.6959381",
"0.68698",
"0.6810561",
"0.6753542",
"0.6748452",
"0.6746819",
"0.67315745",
"0.67262423",
"0.6689152",
"0.6653512",
"0.65196747",
"0.6504204",
"0.6461419",
"0.64389575",
"0.6437859",
"0.6399085",
"0.63948387",
"0.6389745",
... | 0.8572123 | 0 |
Returns true if video content is a movie | def movie?
content_type == "Movie"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def video?\n !!( content_type =~ Transit.config.video_regexp )\n end",
"def is_video_type?\n file_content_type =~ %r(video)\n end",
"def video?\n attributes['_type'].split('::').last == 'Video'\n end",
"def is_video_type?\n background_media.content_type =~ %r(video)\n end",
"def vid... | [
"0.81751806",
"0.79499906",
"0.77967423",
"0.7716721",
"0.7643054",
"0.76139987",
"0.7609431",
"0.7506507",
"0.7469072",
"0.7456127",
"0.7341145",
"0.7302153",
"0.7301916",
"0.7293641",
"0.7244949",
"0.7137275",
"0.7135879",
"0.7072998",
"0.7010379",
"0.68267965",
"0.680432",... | 0.82757044 | 0 |
Return list of genres for content | def get_content_genres
if episode?
return content.show.show_genres
else
return content.movie_genres
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def genres\n to_array search_by_itemprop 'genre'\n end",
"def genres\n document.search(\"h5[text()='Genre:'] ~ a[@href*=/Sections/Genres/']\").map { |link| link.innerHTML.strip.imdb_unescape_html } rescue []\n end",
"def genres\n details.css(\"div.subtext a[href^='/genre/']\").map { |genre... | [
"0.79443926",
"0.75103533",
"0.7485573",
"0.7465215",
"0.7429743",
"0.7343849",
"0.7336712",
"0.7313418",
"0.7250769",
"0.72030485",
"0.71876574",
"0.71617365",
"0.71580577",
"0.7143602",
"0.70856345",
"0.7029887",
"0.7029887",
"0.7029887",
"0.7029887",
"0.7029887",
"0.696141... | 0.81162053 | 0 |
Return either show or movie that video belongs to | def content_parent
if episode?
return content.show
else
return content
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_movie?\n self.type_of_show.downcase == \"movie\" ? true : false \n end",
"def next_video_or_show\n ep = next_video\n if ep.nil?\n return content.show\n else\n return ep\n end\n end",
"def show; @video.show; end",
"def video\n\t\tVideo.find(self.video_id)\n\tend",
"de... | [
"0.7160327",
"0.69813913",
"0.6838212",
"0.6687403",
"0.65743804",
"0.6559246",
"0.6517944",
"0.6504247",
"0.65014154",
"0.6470489",
"0.6469852",
"0.6467781",
"0.6417266",
"0.64115226",
"0.6394044",
"0.63842565",
"0.6378261",
"0.6350301",
"0.6346233",
"0.6335565",
"0.6326199"... | 0.0 | -1 |
Returns the next video in a playlist | def next_video
if episode?
episode = content.next_ep
unless episode.nil?
return episode.video
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_video(current_id)\n @video_ids = airings.map {|a| a.video_id }\n\n @current_index = @video_ids.index current_id.to_i\n\n if @current_index\n next_index = (@current_index + 1) % self.videos.count\n Video.find(@video_ids[next_index])\n else\n # give the next video or the first if cu... | [
"0.73518544",
"0.7097479",
"0.70873034",
"0.68476266",
"0.6299124",
"0.6255716",
"0.61375475",
"0.6079883",
"0.60471314",
"0.5993541",
"0.59920794",
"0.5963424",
"0.58872503",
"0.5872706",
"0.58417547",
"0.5821337",
"0.5807029",
"0.58052254",
"0.57922477",
"0.5790547",
"0.574... | 0.76897305 | 0 |
Returns the next episode or the show if not found | def next_video_or_show
ep = next_video
if ep.nil?
return content.show
else
return ep
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_episode\n # Not ep(@current_ep + 1) because episodes are not guaranteed to be in\n # sequence (i.e. we could have episodes 1, 2, 4, 5 etc.)\n idx = @episodes.map(&:number).index(@current_ep)\n if idx + 1 < @episodes.size\n @episodes[idx + 1]\n else\n ep(@current_ep)\... | [
"0.78785944",
"0.7780579",
"0.73600245",
"0.6834073",
"0.66040397",
"0.6459011",
"0.6455885",
"0.6379392",
"0.62951183",
"0.6276544",
"0.6195771",
"0.619475",
"0.6186945",
"0.61499995",
"0.613592",
"0.6059871",
"0.6047438",
"0.60450304",
"0.6001297",
"0.59973264",
"0.5996119"... | 0.7709584 | 2 |
Returns the previous video in a playlist | def prev_video
if episode?
episode = content.prev_ep
unless episode.nil?
episode.video
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prev_in_playlist\n self.new_record? ? nil : (self.in_playlist? ? VirtualClassroomLesson.where(:user_id => self.user_id, :position => (self.position - 1)).first : nil)\n end",
"def do_previous\n do_command('requests/status.json?command=pl_previous')\n return currently_playing\n end",
"def previou... | [
"0.76331955",
"0.73653996",
"0.729033",
"0.7030783",
"0.70207363",
"0.7014135",
"0.6913962",
"0.6896182",
"0.6890706",
"0.6879115",
"0.6875744",
"0.6827318",
"0.68202513",
"0.68202513",
"0.6703472",
"0.66802037",
"0.6676138",
"0.666423",
"0.66608125",
"0.6653655",
"0.6650649"... | 0.77256835 | 0 |
Returns true if producer has edit permission | def valid_producer?(producer)
content.valid_producer?(producer)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_edit\n producer.admin?(user) || group_admin?\n end",
"def can_edit?\n allows_current_user_access_to? :edit\n end",
"def has_edit_permission?\n persisted?\n end",
"def reseller_allow_edit(permission)\n return reseller_right(permission) == 2\n end",
"def can_edit?\n can_write... | [
"0.8448451",
"0.8228131",
"0.8153759",
"0.8133407",
"0.8113015",
"0.8013095",
"0.7975358",
"0.7974252",
"0.78429466",
"0.7802496",
"0.7802496",
"0.77815014",
"0.77650577",
"0.77635485",
"0.7728769",
"0.77209204",
"0.7684703",
"0.7676465",
"0.76564544",
"0.7631858",
"0.7617176... | 0.0 | -1 |
redefine the format to the y2log format | def format_message(severity, timestamp, progname, msg)
# remove the function name from the caller location
location = caller(3).first.gsub(/:in `.*'$/, "")
"#{timestamp.strftime(datetime_format)} #{severity} #{Socket.gethostname}(#{Process.pid}) #{progname} #{location} #{msg}\n"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_formatter; end",
"def log_formatter; end",
"def d2logL\n raise \"No implemented\"\n end",
"def log_formatter=(_arg0); end",
"def log_formatter=(_arg0); end",
"def to_log_format\n @log_format ||= begin\n attributes = []\n attributes << \"#{LOG_ATTR_ENV}=#{env}\" ... | [
"0.5762884",
"0.5762884",
"0.5740351",
"0.54915833",
"0.54915833",
"0.5443621",
"0.54123354",
"0.54123354",
"0.53662896",
"0.5355424",
"0.53240436",
"0.53240436",
"0.53240436",
"0.5321103",
"0.5281784",
"0.5281784",
"0.5281784",
"0.5239434",
"0.5239434",
"0.5239434",
"0.52394... | 0.0 | -1 |
allows :name parameter for user to go through on new user signup | def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:name])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sign_up(name:, user_name:)\n user_name = user_name.downcase\n return SYNTAX_ERROR if include_punctuation?(user_name)\n return TOO_LONG_ERROR if too_long?(user_name)\n return TOO_SHORT_ERROR if too_short?(user_name)\n\n @user_class.add(name: name, user_name: user_name)\n end",
"def signup_user... | [
"0.7726892",
"0.7263389",
"0.7132566",
"0.7034578",
"0.6986917",
"0.69436747",
"0.6841855",
"0.67708164",
"0.6737441",
"0.6703919",
"0.67015797",
"0.66715056",
"0.6610613",
"0.6594151",
"0.6586289",
"0.6551408",
"0.65415967",
"0.6516297",
"0.6502861",
"0.65013975",
"0.6501397... | 0.63149005 | 44 |
GET /transactions GET /transactions.json | def index
@transactions = Transaction.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transactions\n JSON.parse(response.body).fetch('transactions')\n end",
"def transactions\n JSON.parse(call_blockchain_api(\"transactions\"))\n end",
"def index\n @transactions = Transaction.all\n render json: @transactions\n end",
"def all_transactions\n json_respo... | [
"0.8164624",
"0.796332",
"0.77854896",
"0.7751081",
"0.7728147",
"0.7706774",
"0.7691088",
"0.7651612",
"0.7590682",
"0.7567767",
"0.7548055",
"0.751779",
"0.75108814",
"0.745996",
"0.745996",
"0.745996",
"0.73983127",
"0.7326831",
"0.7299761",
"0.7288485",
"0.7288485",
"0.... | 0.71780056 | 35 |
POST /transactions POST /transactions.json | def create
@transaction = Transaction.new(transaction_params)
respond_to do |format|
if @transaction.save
format.html { redirect_to @transaction, notice: 'Transaction was successfully created.' }
format.json { render :show, status: :created, location: @transaction }
else
format.html { render :new }
format.json { render json: @transaction.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def postTransaction(useridgiving, useridreceiving, amount)\n parameters={useridgiving: useridgiving.to_i, useridreceiving: useridreceiving.to_i, amount: amount.to_f, state: \"initial\"}\n options = {\n :body => parameters.to_json,\n :headers => {\n 'Content-Type' => 'application/js... | [
"0.7124941",
"0.71085167",
"0.7107366",
"0.70616746",
"0.6970805",
"0.69395524",
"0.6882131",
"0.6873944",
"0.6864678",
"0.68382066",
"0.682873",
"0.6797429",
"0.6790942",
"0.67898583",
"0.6742485",
"0.67210656",
"0.67054796",
"0.66835666",
"0.6677946",
"0.66753876",
"0.66521... | 0.6634216 | 29 |
PATCH/PUT /transactions/1 PATCH/PUT /transactions/1.json | def update
respond_to do |format|
if @transaction.update(transaction_params)
format.html { redirect_to @transaction, notice: 'Transaction was successfully updated.' }
format.json { render :show, status: :ok, location: @transaction }
else
format.html { render :edit }
format.json { render json: @transaction.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @transaction = Transaction.find(params[:id])\n\n respond_to do |format|\n if @transaction.update_attributes(params[:transaction])\n @transaction.account.update_transactions\n format.html { redirect_to transactions_path, notice: 'Transaction was successfully updated.' }\n ... | [
"0.6729087",
"0.64824617",
"0.6465789",
"0.6443912",
"0.6443912",
"0.6443912",
"0.6443912",
"0.6399401",
"0.6378991",
"0.63113767",
"0.6295922",
"0.6292649",
"0.6292649",
"0.6292649",
"0.62898886",
"0.62879014",
"0.6284101",
"0.6274408",
"0.62717205",
"0.6249161",
"0.62378335... | 0.6127156 | 43 |
DELETE /transactions/1 DELETE /transactions/1.json | def destroy
@transaction.destroy
respond_to do |format|
format.html { redirect_to transactions_url, notice: 'Transaction was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @transaction = Transaction.find(params[:id])\n @transaction.destroy\n\n respond_to do |format|\n format.html { redirect_to transactions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @transaction = Transaction.find(params[:id])\n @transaction.dest... | [
"0.74672043",
"0.74672043",
"0.74672043",
"0.74672043",
"0.74672043",
"0.74672043",
"0.74672043",
"0.74672043",
"0.7446662",
"0.7431593",
"0.7431593",
"0.7431593",
"0.7431593",
"0.7431593",
"0.7431593",
"0.7431593",
"0.73309535",
"0.724183",
"0.72055084",
"0.7149197",
"0.7149... | 0.71086586 | 42 |
Use callbacks to share common setup or constraints between actions. | def set_transaction
@transaction = Transaction.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_... | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def transaction_params
params.require(:transaction).permit(:get, :post)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
rubocop:enable Layout/HeredocIndentation(RuboCop) rubocop:disable Metrics/AbcSize(RuboCop) (RuboCop) rubocop:disable Metrics/MethodLength(RuboCop) | def gen_digest_byte_tests
FILES.each do |path, hashlen|
name = File.basename(path).split('.')[0]
f = File.new("sha3_digest_#{hashlen}_spec.rb", 'w')
f.puts(REQUIRED)
f.puts(
SPEC
.gsub(/HASH_LEN/, hashlen.to_s)
.gsub(/NAME/, name)
)
contents = File.read(path).split('Len = ')
contents.each do |test|
lines = test.split("\n")
next unless !lines.empty? && lines[0] !~ /^#/
length = lines[0].to_i
next unless (length % 8).zero? && length != 0
msg_raw = lines[1].split(' = ').last
digest = lines[2].split(' = ').last.downcase
f.puts(
EXPECT
.gsub(/HASHLEN/, hashlen.to_s)
.gsub(/MSG/, msg_raw)
.gsub(/DIGEST/, digest)
)
end
f.puts(ENDING)
f.close
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wrapped_by_paragraph; end",
"def as_you_like_it_quote; end",
"def test_heredoc_method\n desired_output = <<-EOS.unindent\n This should contain no indents.\n\n It should be 3 lines long.\n EOS\n test_output = \"This should contain no indents.\\n\\nIt should be 3 lines long.\\n\"\n asse... | [
"0.6007793",
"0.6005454",
"0.5912826",
"0.5819228",
"0.5815952",
"0.580401",
"0.57380533",
"0.57380533",
"0.5727617",
"0.5727617",
"0.57272977",
"0.5692961",
"0.568741",
"0.5671377",
"0.5671377",
"0.5641813",
"0.5613714",
"0.56031585",
"0.5595179",
"0.5554156",
"0.5516496",
... | 0.0 | -1 |
rubocop:enable Metrics/AbcSize(RuboCop) rubocop:enable Metrics/MethodLength(RuboCop) | def setup; end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def private; end",
"def probers; end",
"def implementation; end",
"def implementation; end",
"def schubert; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def suivre; end",
"def refutal()\n end",
"def custom; end",
"def custom; end",
"def intensifier... | [
"0.7476475",
"0.63192856",
"0.6167057",
"0.6167057",
"0.6103087",
"0.60707223",
"0.60707223",
"0.60707223",
"0.60707223",
"0.6001502",
"0.598691",
"0.598084",
"0.598084",
"0.59254736",
"0.5880717",
"0.5874546",
"0.5862551",
"0.5830262",
"0.5825877",
"0.57795614",
"0.57778895"... | 0.0 | -1 |
and returns true if the sum of the characters is prime. Remember that a number is prime if the only integers that can divide it with no remainder are 1 and itself. Examples of length three prime_chars? ['abc'] => true prime_chars? ['a', 'bc'] => true prime_chars? ['ab', 'c'] => true prime_chars? ['a', 'b', 'c'] => true Examples of length four prime_chars? ['abcd'] => false prime_chars? ['ab', 'cd'] => false prime_chars? ['a', 'bcd'] => false prime_chars? ['a', 'b', 'cd'] => false | def prime_chars?(strings_array)
sum = 0
new_array = []
strings_array.join.split("").each {|x| sum += 1}
if sum != 1 && (strings_array != [""] && strings_array != [])
(2..sum/2).map {|a| new_array << sum % a }
!(new_array.include? 0)
else
false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prime_chars?(x)\n require \"prime\"\n if x ==[]\n return false\n else\n Prime.prime?(x.map { |i| i.length }.inject(:+))\n end\nend",
"def prime_chars?(array_of_strings)\n\tif array_of_strings.length == 1 \n\t\tstring = array_of_strings[0]\n\t\tsum = 0 + string.length\n\telse\n\t\tsum = 0 + array_of... | [
"0.8334389",
"0.82992715",
"0.82931143",
"0.82873017",
"0.8210412",
"0.81576204",
"0.81355137",
"0.809702",
"0.8085591",
"0.80799",
"0.7944249",
"0.7935834",
"0.7842787",
"0.7810238",
"0.7627042",
"0.7522761",
"0.7301141",
"0.72730374",
"0.72413903",
"0.715781",
"0.7146766",
... | 0.7950291 | 10 |
GET /slideshows/1 GET /slideshows/1.json | def show
@slideshow = Slideshow.find(params[:id])
@slides = @slideshow.slides
respond_to do |format|
format.html # show.html.erb
format.json { render json: @slideshow }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @slideshow = Slideshow.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @slideshow }\n end\n end",
"def show\n @slideshow = Slideshow.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n ... | [
"0.8133371",
"0.8133371",
"0.7762472",
"0.77482057",
"0.77462846",
"0.7373935",
"0.7373935",
"0.71811527",
"0.71302176",
"0.71240145",
"0.71027374",
"0.7046371",
"0.7046371",
"0.7046371",
"0.6972977",
"0.6972977",
"0.69592965",
"0.6883599",
"0.68524235",
"0.6838921",
"0.67770... | 0.82744855 | 0 |
GET /slideshows/new GET /slideshows/new.json | def new
@slideshow = Slideshow.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @slideshow }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @slideshow_item = SlideshowItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @slideshow_item }\n end\n end",
"def new\n @slide = Slide.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json:... | [
"0.8089594",
"0.77394575",
"0.77394575",
"0.77394575",
"0.77230847",
"0.7667716",
"0.76496696",
"0.75205386",
"0.75205386",
"0.7458299",
"0.743807",
"0.743807",
"0.7352983",
"0.7352983",
"0.7352983",
"0.71078014",
"0.71070534",
"0.70939475",
"0.70752",
"0.7023398",
"0.6956382... | 0.8400315 | 1 |
POST /slideshows POST /slideshows.json | def create
@slideshow = Slideshow.new(params[:slideshow])
respond_to do |format|
if @slideshow.save
format.html { redirect_to @slideshow, notice: 'Slideshow was successfully created.' }
format.json { render json: @slideshow, status: :created, location: @slideshow }
else
format.html { render action: "new" }
format.json { render json: @slideshow.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @slideshow = Slideshow.new(slideshow_params)\n\n respond_to do |format|\n if @slideshow.save\n format.html { redirect_to @slideshow, notice: 'Slideshow was successfully created.' }\n format.json { render :show, status: :created, location: @slideshow }\n else\n form... | [
"0.74267346",
"0.74267346",
"0.74267346",
"0.7147942",
"0.7098196",
"0.7098196",
"0.7049254",
"0.6980505",
"0.689624",
"0.6893306",
"0.6858169",
"0.677515",
"0.6753637",
"0.6713457",
"0.6713457",
"0.6639847",
"0.6608018",
"0.65958506",
"0.65389365",
"0.64928275",
"0.64604634"... | 0.74475336 | 1 |
PUT /slideshows/1 PUT /slideshows/1.json | def update
@slideshow = Slideshow.find(params[:id])
@slideshow.slides += params[:add_slides].map{ |es| Slide.find(es) } if params[:add_slides]
@slideshow.slideshow_slides.where(:slide_id => params[:del_slides]).delete_all
respond_to do |format|
if @slideshow.update_attributes(params[:slideshow])
format.js { render :nothing => true }
format.html { redirect_to (params[:existing_slides] ? edit_slideshow_path(@slideshow) : @slideshow), notice: 'Slideshow was successfully updated.' }
format.json { head :no_content }
else
format.js { render :nothing => true }
format.html { render action: "edit" }
format.json { render json: @slideshow.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @slideshow = Slideshow.find(params[:id])\n\n respond_to do |format|\n if @slideshow.update_attributes(params[:slideshow])\n format.html { redirect_to @slideshow, notice: 'Slideshow was successfully updated.' }\n format.json { head :no_content }\n else\n format.html... | [
"0.75944984",
"0.75111306",
"0.74391097",
"0.74391097",
"0.71799284",
"0.71799284",
"0.6866891",
"0.6795044",
"0.678487",
"0.675374",
"0.675374",
"0.66529506",
"0.65569437",
"0.652209",
"0.6500816",
"0.6457901",
"0.6457901",
"0.64310133",
"0.64310133",
"0.64310133",
"0.642756... | 0.7068016 | 6 |
DELETE /slideshows/1 DELETE /slideshows/1.json | def destroy
@slideshow = Slideshow.find(params[:id])
@slideshow.destroy
respond_to do |format|
format.html { redirect_to slideshows_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n id = @slideshow.id\n @slideshow.delete\n render :json => {:id => id}\n end",
"def destroy\n @slideshow_item = SlideshowItem.find(params[:id])\n @slideshow_item.destroy\n\n respond_to do |format|\n format.html { redirect_to slideshow_items_url }\n format.json { head :ok ... | [
"0.8474956",
"0.7959318",
"0.7947231",
"0.7908333",
"0.7908333",
"0.78684115",
"0.7847883",
"0.7847883",
"0.74992585",
"0.74213576",
"0.74213576",
"0.74213576",
"0.73651767",
"0.73429066",
"0.72759145",
"0.7234686",
"0.714241",
"0.71375084",
"0.71106845",
"0.7081164",
"0.7074... | 0.81346536 | 2 |
before_transition from: any, to: :use do |token, transition| end | def validate_token
if self.transaction_token_created_at + 720.minutes > Time.now
true
else
false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_transition(*args, &block); end",
"def trans(from, to, name)\n StateMachineChecker::Transition.new(from, to, name)\nend",
"def transition(&block)\n @transition_function = block\n end",
"def start_transition\n nil\n end",
"def before\n all? {|transition| transition.before}\n en... | [
"0.66496724",
"0.6456332",
"0.642616",
"0.6422432",
"0.6082246",
"0.6055364",
"0.6034521",
"0.6004297",
"0.6004297",
"0.5960361",
"0.5960361",
"0.5920073",
"0.5881608",
"0.58583856",
"0.58527696",
"0.5808948",
"0.5742249",
"0.56624967",
"0.56437474",
"0.55957687",
"0.5434352"... | 0.0 | -1 |
Enter email address to recover password | def new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recover_password params\n user = find_with_email(params[:email])\n user.send_recover_password\n end",
"def recover_password\n begin\n @user = User.find_by_email(params[:user][:email])\n UserMailer.send_password_recovery_mail(@user,\n edit_... | [
"0.7556378",
"0.71617657",
"0.71390975",
"0.7034441",
"0.7003322",
"0.7001021",
"0.68538123",
"0.6814802",
"0.6673175",
"0.66175944",
"0.6526481",
"0.65205514",
"0.6517617",
"0.6516411",
"0.6460639",
"0.64300394",
"0.64277",
"0.6402415",
"0.6396358",
"0.635453",
"0.6348659",
... | 0.0 | -1 |
A user cliks a link from an email to get to this form used to reset their email GET /reset_password/:id | def edit
if request.get?
raise if params[:id].nil? || !(@user = User.find_by_password_reset_code(params[:id]))
flash.now[:notice] = "Welcome back <strong>#{@user.profile.email}</strong>! Please choose a new password."
else
update
end
rescue
logger.error "Invalid Reset Code entered."
flash[:error] = "Sorry, that is an invalid password reset code. Please check your code and try again. Perhaps the link was split over multiple lines and didn't come over correctly? You might want to try copy and pasting the link rather than clicking on it."
redirect_to signin_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_reset_link(url, token)\n \"#{url}/reset_password/#{token}/edit?email=#{self.email}\"\n end",
"def gen_reset_link(url, token)\n \"#{url}/reset_password/#{token}/edit?email=#{self.email}\"\n end",
"def gen_reset_link(url, token)\n \"#{url}/reset_password/#{token}/edit?email=#{self.email}\"\n... | [
"0.7693381",
"0.76067644",
"0.76067644",
"0.7504044",
"0.7417011",
"0.7402745",
"0.7395636",
"0.738232",
"0.73440415",
"0.73380244",
"0.73211676",
"0.7320249",
"0.7303696",
"0.7303509",
"0.72980654",
"0.72738343",
"0.7257044",
"0.7248337",
"0.72446364",
"0.72216254",
"0.72079... | 0.0 | -1 |
GET /reports GET /reports.json | def index
@reports = Report.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @reports }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_reports\n @reports ||= Report.user(current_user).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reports }\n end\n end",
"def reports\n collection(\"reports\")\n end",
"def list\n @reports_fetch = Report.all\n @reports = []\n\... | [
"0.78636414",
"0.77486503",
"0.7707248",
"0.7619338",
"0.7569814",
"0.75290066",
"0.74211705",
"0.73762834",
"0.73735154",
"0.73633385",
"0.7334833",
"0.733009",
"0.72732675",
"0.7264923",
"0.7264923",
"0.7264923",
"0.7264923",
"0.7264923",
"0.7264923",
"0.7264923",
"0.726492... | 0.7896447 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.