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 |
|---|---|---|---|---|---|---|
GET /schedules GET /schedules.json | def index
#@schedules = Schedule.all
#ransack保持用コード
query = params[:q]
query ||= eval(cookies[:recent_search_history].to_s)
if params[:move_flag] == "1"
#工事一覧画面から遷移した場合
construction_id = params[:construction_id]
query = {"construction_datum_id_eq"=> construction_id }
end
#@q = ConstructionDailyReport.ransack(params[:q])
#ransack保持用--上記はこれに置き換える
@q = Schedule.ransack(query)
#ransack保持用コード
search_history = {
value: params[:q],
expires: 24.hours.from_now
}
cookies[:recent_search_history] = search_history if params[:q].present?
#
@schedules = @q.result(distinct: true)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def schedules\n params = init_params\n request_url = UrlGenerator.url_for(\"schedules\")\n asgn = SignatureGenerator.signature_for(http_verb: 'GET', url: request_url, params: params)\n\n res = self.get(request_url, query: params.merge!({asgn: asgn}))\n if res[\"status\"] == \"SUC... | [
"0.8661993",
"0.7932834",
"0.7721805",
"0.7581812",
"0.756851",
"0.74673015",
"0.74673015",
"0.74673015",
"0.74673015",
"0.74673015",
"0.74673015",
"0.74673015",
"0.74673015",
"0.74673015",
"0.74673015",
"0.74545866",
"0.74526054",
"0.7417857",
"0.738682",
"0.73845774",
"0.73... | 0.0 | -1 |
GET /schedules/1 GET /schedules/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def schedules\n params = init_params\n request_url = UrlGenerator.url_for(\"schedules\")\n asgn = SignatureGenerator.signature_for(http_verb: 'GET', url: request_url, params: params)\n\n res = self.get(request_url, query: params.merge!({asgn: asgn}))\n if res[\"status\"] == \"SUC... | [
"0.7881139",
"0.78478694",
"0.78178704",
"0.7655067",
"0.7655067",
"0.7655067",
"0.7655067",
"0.7502815",
"0.74651474",
"0.7440307",
"0.73753405",
"0.73640394",
"0.73032045",
"0.7294372",
"0.7294372",
"0.7294372",
"0.7294372",
"0.7294372",
"0.7294372",
"0.7294372",
"0.7294372... | 0.0 | -1 |
POST /schedules POST /schedules.json | def create
@schedule = Schedule.new(schedule_params)
respond_to do |format|
if @schedule.save
#format.html { redirect_to @schedule, notice: 'Schedule was successfully created.' }
#format.json { render :show, status: :created, location: @schedule }
format.html {redirect_to schedule_path(@schedule, :construction_id => params[:construction_id],
:move_flag => params[:move_flag])}
else
format.html { render :new }
format.json { render json: @schedule.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def schedule\n POST \"https://www.googleapis.com/calendar/v3/calendars/#{calendar_id}/events\"\n render \"schedule\"\n end",
"def create\n @schedule = Schedule.new(params[:schedule])\n\n if @schedule.save\n render json: @schedule, status: :created, location: @schedule\n else\n render js... | [
"0.75881946",
"0.7474024",
"0.7151664",
"0.7084306",
"0.70569384",
"0.7056925",
"0.7046065",
"0.7033174",
"0.70252305",
"0.70078295",
"0.69831187",
"0.69428563",
"0.6929221",
"0.6847984",
"0.68398225",
"0.683571",
"0.6806257",
"0.68006486",
"0.67971665",
"0.67918414",
"0.6775... | 0.0 | -1 |
PATCH/PUT /schedules/1 PATCH/PUT /schedules/1.json | def update
respond_to do |format|
if @schedule.update(schedule_params)
#format.html { redirect_to @schedule, notice: 'Schedule was successfully updated.' }
#format.json { render :show, status: :ok, location: @schedule }
format.html {redirect_to schedule_path(@schedule, :construction_id => params[:construction_id],
:move_flag => params[:move_flag])}
else
format.html { render :edit }
format.json { render json: @schedule.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @schedule = Schedule.find(params[:id])\n\n if @schedule.update(params[:schedule])\n head :no_content\n else\n render json: @schedule.errors, status: :unprocessable_entity\n end\n end",
"def update\n @schedule = Schedule.find(params[:id])\n\n respond_to do |format|\n ... | [
"0.75879264",
"0.74838686",
"0.74345046",
"0.74228406",
"0.7411354",
"0.7381991",
"0.7381991",
"0.7381991",
"0.7381991",
"0.7381991",
"0.7381991",
"0.7381991",
"0.7371768",
"0.735785",
"0.73518276",
"0.73262507",
"0.7256818",
"0.72330225",
"0.72296935",
"0.72224194",
"0.71900... | 0.6354576 | 78 |
DELETE /schedules/1 DELETE /schedules/1.json | def destroy
@schedule.destroy
respond_to do |format|
#format.html { redirect_to schedules_url, notice: 'Schedule was successfully destroyed.' }
#format.json { head :no_content }
format.html {redirect_to schedules_path( :construction_id => params[:construction_id],
:move_flag => params[:move_flag])}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @schedule = Schedule.find(params[:id])\n @schedule.destroy\n\n respond_to do |format|\n format.html { redirect_to schedules_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @schedule = Schedule.find(params[:id])\n @schedule.destroy\n\n respond_to do |for... | [
"0.7996615",
"0.7978626",
"0.7978626",
"0.7978626",
"0.7978626",
"0.7978626",
"0.7971123",
"0.79660136",
"0.79660136",
"0.79660136",
"0.79660136",
"0.79660136",
"0.79264027",
"0.7902196",
"0.78268224",
"0.77931434",
"0.779228",
"0.77445745",
"0.7744383",
"0.77290374",
"0.7721... | 0.6928068 | 85 |
Use callbacks to share common setup or constraints between actions. | def set_schedule
@schedule = Schedule.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 schedule_params
params.require(:schedule).permit(:construction_datum_id, :content_name, :estimated_start_date, :estimated_end_date, :work_start_date, :work_end_date)
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.69795185",
"0.6782116",
"0.6745877",
"0.6742722",
"0.67368543",
"0.65932566",
"0.65048057",
"0.6497429",
"0.6481512",
"0.6478456",
"0.6455591",
"0.64391",
"0.6379068",
"0.6376498",
"0.636542",
"0.632084",
"0.630046",
"0.62998945",
"0.62943697",
"0.6293775",
"0.629097",
"... | 0.0 | -1 |
Create a Resource from an args hash. The meaningful args are: :project:: Dixi::Project that this resource belongs to. :type:: The resource's type, e.g. "instance method". :resource:: An existing Resource. Used for transmuting class. :id:: The resource ID, e.g. "api/Rubygame/Surface/blitim" Partial (untyped) IDs are not supported. So "api/Rubygame/Surface/blit" is WRONG. Use Resource.find if you have a partial ID. You must provide :project, plus either :resource or :id. :type is optional, and may be ignored if the resource already has a defined type. | def initialize( args={} )
# Create from another instance. Used for transmuting class.
if args[:resource]
other = args[:resource]
@project = other.project
@type = other.type
@id = other.id
@content = other.content(:load => false)
@yaml = other.yaml_content(:load => false)
# Create from a project and id
else
@project = args[:project]
@type = args[:type]
@id = args[:id]
if SUFFIX_REGEXP =~ @id
suffix = $2
@id = $1 + suffix
@type = TYPE_SUFFIXES.invert[suffix]
end
@content = nil
@yaml = nil
end
if @project.nil? or @id.nil?
raise ArgumentError, "Insufficient resource args: #{args.inspect}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resource type, labels = {}\n Resource.new.tap do |r|\n r.type = type\n r.labels = labels\n end\n end",
"def create(name, type, options = {})\n Utils.stringify_keys!(options)\n path = \"/projects/#{project.name}/resources/\"\n\n headers = build_create_... | [
"0.669052",
"0.65326464",
"0.6268602",
"0.625199",
"0.6185074",
"0.61746633",
"0.60353845",
"0.60140824",
"0.59818965",
"0.59668046",
"0.5944942",
"0.5902627",
"0.5895642",
"0.5890019",
"0.5821315",
"0.581289",
"0.5791745",
"0.57607764",
"0.5739502",
"0.5709686",
"0.56289744"... | 0.8029933 | 0 |
Dump important resource data as a Hash for the index. | def index_dump
{ id => {
"name" => name,
"file" => filepath.relative_path_from(Dixi.contents_dir).to_s,
"type" => type,
}
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_hash\n index_hash = Hash.new\n index_hash[\"json_claz\"] = self.class.name\n index_hash[\"id\"] = id\n index_hash[\"node_id\"] = node_id\n index_hash[\"node_name\"] = node_name\n index_hash[\"appdefns\"] = appdefns\n index_hash[\"created_at\"] = created_at\n index_has... | [
"0.64070547",
"0.63710654",
"0.6308978",
"0.624469",
"0.62418324",
"0.62339413",
"0.6219523",
"0.61428535",
"0.61402017",
"0.6140162",
"0.61375284",
"0.61330086",
"0.6025524",
"0.59204227",
"0.5906019",
"0.5897803",
"0.5871136",
"0.5850145",
"0.58302975",
"0.58281916",
"0.579... | 0.66706085 | 0 |
Returns an Index::Entry for this resource. | def index_entry
@project.index[@id]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def entry\n Entry.new\n end",
"def machine_index_entry\n entry = machine_index.get(env[:machine].index_uuid)\n end",
"def entry\n @entry.object\n end",
"def entry\n return nil unless @item and self.type == :query\n @item['entry']\n end",
"def entry\n\t\t... | [
"0.7110794",
"0.6812855",
"0.67599404",
"0.6550413",
"0.65264124",
"0.6292286",
"0.6259506",
"0.62499213",
"0.61851686",
"0.6171196",
"0.61284614",
"0.60773826",
"0.60584027",
"0.58815503",
"0.58623505",
"0.5861137",
"0.578642",
"0.57799864",
"0.5735745",
"0.5729695",
"0.5729... | 0.65550566 | 3 |
Returns an array of all existing resources which are children of this resource, or [] if there are no children. A child is a resource contained within this resource. For example, "api/Rubygame/Surface" is a child of "api/Rubygame". | def children
ie = index_entry
ie.children.collect{ |child| child.resource } if ie
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def children\n @resource.children\n end",
"def list_child_resources(parent_res_path, recursive = false)\n path = parent_res_path.is_a?(CanonicalPath) ? parent_res_path : CanonicalPath.parse(parent_res_path)\n parent_resource_path = path.resource_ids.join('/')\n feed_id = path.feed_id\n ... | [
"0.7909825",
"0.73102427",
"0.71862644",
"0.71862644",
"0.71744627",
"0.71599114",
"0.7053759",
"0.7028729",
"0.70163804",
"0.7004623",
"0.6987494",
"0.6986678",
"0.69154626",
"0.6908932",
"0.6888049",
"0.6884456",
"0.6884456",
"0.6868736",
"0.68631154",
"0.68631154",
"0.6863... | 0.71039736 | 6 |
Call to require a bunch of files in a block and add the result to the list of watches | def watch_yield
current = currently_loaded_files
new_exceptions = Array.new
begin
result = yield
rescue Interrupt, SystemExit
raise
rescue Exception => e
new_exceptions << e
run_hook :on_exception, e
exceptions << e
# cross-drb exceptions are broken w.r.t. #backtrace_locations. It
# returns a string in their case. Since it happens only on
# exceptions that originate from the server (which means a broken
# Roby codepath), let's just ignore it
if !e.backtrace_locations.kind_of?(String)
backtrace = e.backtrace_locations.map { |l| Pathname.new(l.absolute_path) }
else
STDERR.puts "Caught what appears to be a cross-drb exception, which should not happen"
STDERR.puts e.message
STDERR.puts e.backtrace.join("\n ")
backtrace = Array.new
end
error_paths.merge(backtrace)
if e.kind_of?(LoadError) && e.path
error_paths << Pathname.new(e.path)
end
end
required_paths.merge(currently_loaded_files - current)
return result, new_exceptions
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_watch_files\n coffee_files.each do |file|\n @notifier.watch(file, :modify) do\n CoffeeCompiler.compile_file(file, true, true)\n end\n end\n end",
"def watch(&block)\n\n # Startup File Watcher\n script_changed = lambda { |modified, added, removed|\n\n @log.... | [
"0.6217772",
"0.62088746",
"0.61494565",
"0.6013197",
"0.60080224",
"0.5965024",
"0.5926499",
"0.58912766",
"0.5888557",
"0.5855768",
"0.5828631",
"0.5825047",
"0.58039457",
"0.57835525",
"0.57657677",
"0.57445014",
"0.5736413",
"0.57305235",
"0.5728018",
"0.57188183",
"0.571... | 0.5198468 | 98 |
Returns whether we have been spawned by a manager, or in standalone mode | def slave?
self.class.slave?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def running?\n !!managers\n end",
"def standalone?\n @standalone.nil? ? true : !!@standalone\n end",
"def running?\n !@manager_thread.nil? &&\n ['sleep', 'run'].include?(@manager_thread.status)\n end",
"def running?\n spawned? and !@status and alive?\n end",
"def curr... | [
"0.7868446",
"0.7461317",
"0.7405134",
"0.72087723",
"0.7160473",
"0.7091846",
"0.7011606",
"0.7001871",
"0.6966072",
"0.6895019",
"0.6865854",
"0.6861144",
"0.6836612",
"0.6827247",
"0.68222696",
"0.67635494",
"0.6751183",
"0.67298764",
"0.672022",
"0.66913164",
"0.6678264",... | 0.0 | -1 |
Request that the master spawns these subcommands | def add_slave(*cmdline, name: nil, **spawn_options)
subcommands << [name, cmdline, spawn_options]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subcommands(cmd); end",
"def subcommands(cmd); end",
"def subcommands() __subcommands__ end",
"def subcommands!() __subcommands__! end",
"def subcommand() __subcommand__ end",
"def subcommands\n @subcommands ||= []\n end",
"def subcommands\n @subcommands ||= []\n end",
"de... | [
"0.72690827",
"0.72690827",
"0.726041",
"0.7214944",
"0.68276525",
"0.660239",
"0.660239",
"0.65042394",
"0.6460359",
"0.6434559",
"0.64321256",
"0.6391371",
"0.6358438",
"0.6334969",
"0.63307697",
"0.6318437",
"0.6232918",
"0.622911",
"0.6183768",
"0.6183768",
"0.6183768",
... | 0.62487435 | 16 |
Create a pipe and dump the program ID state of the current program there | def dump_initial_state(files)
program_id = ProgramID.new
files = program_id.resolve_file_list(files)
program_id.register_files(files)
io = Tempfile.new "autorespawn_initial_state"
initial_info = Marshal.dump([name, program_id])
io.write([initial_info.size].pack("L<"))
io.write(initial_info)
io.flush
io.rewind
io
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_pipe\n IO.popen(@cmdline, 'r+')\n end",
"def status_pipe\n r_pipe, w_pipe = ::IO.pipe\n\n w_pipe.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)\n\n [r_pipe, w_pipe]\n end",
"def create_pipe \n params = [\n 'P', # pointer to read handle\n 'P', # pointer to write handle\n ... | [
"0.6667233",
"0.60883474",
"0.5905975",
"0.5733379",
"0.54899067",
"0.53856987",
"0.53437966",
"0.53258395",
"0.5314098",
"0.53139216",
"0.5159549",
"0.51531684",
"0.5077909",
"0.50630844",
"0.5045186",
"0.5037954",
"0.5033153",
"0.5005234",
"0.49885",
"0.4986702",
"0.4979738... | 0.48315468 | 39 |
Defines the exit code for this instance | def exit_code(value = nil)
if value
@exit_code = value
else
@exit_code
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exit_code=(value)\n end",
"def exit_code\n self.__options[:exit_code]\n end",
"def exitstatus; end",
"def exit_code(code)\n @exit_code = code\n end",
"def exitstatus(*) end",
"def exit_status=(value)\n @exit_status = value\n end",
"def exit_status_from_excepti... | [
"0.8586762",
"0.85458106",
"0.8144754",
"0.8079349",
"0.79343486",
"0.7836874",
"0.7714646",
"0.77128005",
"0.76138103",
"0.75839096",
"0.75353503",
"0.75281316",
"0.75027806",
"0.74561733",
"0.74528164",
"0.73703146",
"0.7325815",
"0.7280226",
"0.724273",
"0.7228174",
"0.719... | 0.82196766 | 2 |
Perform the program workd and reexec it when needed It is the last method you should be calling in your program, providing the program's actual work in the block. Once the block return, the method will watch for changes and reexec's it Exceptions raised by the block are displayed but do not cause the watch to stop This method does NOT return | def run(&block)
if slave? || subcommands.empty?
all_files = required_paths | error_paths
if block_given?
all_files = perform_work(all_files, &block)
end
if slave?
io = IO.for_fd(Autorespawn.slave_result_fd)
string = Marshal.dump([subcommands, all_files])
io.write string
io.flush
exit exit_code
else
io = dump_initial_state(all_files)
cmdline = process_command_line[0].dup
redirect = Hash[io.fileno => io.fileno].merge(process_command_line[1])
if cmdline.last.kind_of?(Hash)
redirect = redirect.merge(cmdline.pop)
end
Kernel.exec(Hash[SLAVE_INITIAL_STATE_ENV => "#{io.fileno}"], *cmdline, redirect)
end
else
if block_given?
raise ArgumentError, "cannot call #run with a block after using #add_slave"
end
manager = Manager.new
subcommands.each do |name, command, options|
manager.add_slave(*command, name: name, **options)
end
return manager.run
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def work(&block)\n Celluloid::Logger.info \"Preparing work...\"\n self.working_code = block if block_given?\n end",
"def run!\n run\n die\n end",
"def run(&block); end",
"def execute\n listen_for_changes\n @block.call\n end",
"def watch\n begin\n yield\n... | [
"0.6437811",
"0.63125473",
"0.6225823",
"0.6081704",
"0.60057825",
"0.59718126",
"0.59718126",
"0.59252894",
"0.5923397",
"0.5897216",
"0.5878182",
"0.5804613",
"0.5804613",
"0.579366",
"0.5791542",
"0.5783965",
"0.5774042",
"0.5754091",
"0.5749098",
"0.5747798",
"0.5718634",... | 0.0 | -1 |
Read notes, skipping serialization, callbacks, validation | def read_notes_without_serializing(obs)
Observation.connection.exec_query("
SELECT notes FROM observations WHERE id = #{obs.id}
").rows.first.first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_todo\n update\n end",
"def notes params=nil\n @nimble.get \"contact/#{self.id}/notes\", params\n end",
"def notes; end",
"def notes; end",
"def notes; end",
"def read\n \n end",
"def notes\n @data[:notes]\n end",
"def read_note(note)\n return false unless allow_fea... | [
"0.6541511",
"0.6465858",
"0.6385528",
"0.6385528",
"0.6385528",
"0.6379529",
"0.63667405",
"0.63651586",
"0.63321936",
"0.6289651",
"0.61796993",
"0.6155673",
"0.6155673",
"0.6155673",
"0.6155673",
"0.61309445",
"0.61244357",
"0.6107389",
"0.6033561",
"0.6033481",
"0.6033481... | 0.67646486 | 0 |
Write notes, skipping serialization, callbacks, validation | def write_notes_without_serializing(obs:, notes:)
Observation.connection.execute("
UPDATE observations
SET notes = #{Observation.connection.quote(notes)}
WHERE id = #{obs.id}
")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_notes\n end",
"def notes; end",
"def notes; end",
"def notes; end",
"def add_note(note)\n self.notes = notes.present? ? \"\\n\\n#{note}\" : note\n save\n end",
"def docs_to_write; end",
"def notes_generated(notes)\n puts green(\"Release notes generated: #{notes}\")\n end"... | [
"0.70107967",
"0.67187476",
"0.67187476",
"0.67187476",
"0.6542784",
"0.6533384",
"0.6501408",
"0.6280839",
"0.62450296",
"0.6240399",
"0.6209291",
"0.6164008",
"0.6164008",
"0.6164008",
"0.6164008",
"0.6145525",
"0.61314344",
"0.61005557",
"0.60971737",
"0.60787266",
"0.6078... | 0.67827165 | 2 |
Return desired upmigrated, serialized notes putting nonempty notes into the "other:" field | def to_up_notes(raw_notes)
raw_notes.present? ? { other: raw_notes } : Observation.no_notes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_up_notes(raw_notes)\n raw_notes.present? ? { Other: raw_notes } : {}\n end",
"def to_down_notes(notes)\n notes.empty? ? \"\" : notes[:other]\n end",
"def to_down_notes(notes)\n # notes.is_a?(Hash) ? (notes)[:Other] : \"\"\n notes.empty? ? \"\" : (notes)[:Other]\n end",
"def old_combine_... | [
"0.7298604",
"0.71867675",
"0.70875514",
"0.6262913",
"0.61152405",
"0.6102725",
"0.602353",
"0.5864332",
"0.57408744",
"0.5632308",
"0.56311244",
"0.5449311",
"0.5449311",
"0.53696716",
"0.5368698",
"0.5280701",
"0.52374005",
"0.52037364",
"0.51834863",
"0.51681244",
"0.5134... | 0.73754114 | 0 |
Return desired reverted notes Extract the "other:" field; otherwise return a blank string | def to_down_notes(notes)
notes.empty? ? "" : notes[:other]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_down_notes(notes)\n # notes.is_a?(Hash) ? (notes)[:Other] : \"\"\n notes.empty? ? \"\" : (notes)[:Other]\n end",
"def get_receipt_notes\n result = ''\n result << self.additional_notes unless self.additional_notes.blank?\n result << \"\\n\\n\" if self.additional_notes && self.is_payed?\n ... | [
"0.66748327",
"0.630465",
"0.5964522",
"0.5962075",
"0.5939171",
"0.5850005",
"0.5792832",
"0.573475",
"0.55259085",
"0.5522404",
"0.55112314",
"0.5458568",
"0.54188836",
"0.53898424",
"0.5353548",
"0.53401816",
"0.5309677",
"0.5249727",
"0.51963603",
"0.5189475",
"0.5184592"... | 0.70509183 | 0 |
start next processor cycle | def next_cycle
pre_cycle
user_cycle
after_cycle
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_processing\n @ran = true\n @start_time = Time.now\n end",
"def start\n unless @enabled\n @enabled = true\n\n begin\n next_item = self.get_next\n\n unless next_item.nil?\n @clock = next_item.due_time if next_item.due_time > @clock\n ... | [
"0.6638804",
"0.6612211",
"0.6539297",
"0.64723885",
"0.64123297",
"0.62736654",
"0.6250497",
"0.62105364",
"0.6178981",
"0.61690116",
"0.61183757",
"0.6068075",
"0.6046539",
"0.6032444",
"0.60250324",
"0.602102",
"0.59698397",
"0.5908288",
"0.586827",
"0.5860916",
"0.5860874... | 0.6492504 | 3 |
excute instruction, located in C0 | def execute_current_instruction
case read_register(REGISTER_C0)
when SUM
write_register(REGISTER_R0, read_register(read_register(REGISTER_D0)) + read_register(read_register(REGISTER_D1)))
when COPY
write_register(read_register(REGISTER_D1), read_register(read_register(REGISTER_D0)))
when WRITE
write_register(read_register(REGISTER_D1), read_register(REGISTER_D0))
when JUMP
write_register(REGISTER_M0, read_register(read_register(REGISTER_D0)))
when JUMPX
write_register(REGISTER_M0, read_register(read_register(REGISTER_D0))) if read_register(read_register(REGISTER_D1)) == 0
when READ_MEM
write_register(REGISTER_M4, Memory::READ)
write_register(REGISTER_M5, read_register(read_register(REGISTER_D0)))
write_register(REGISTER_M6, read_register(REGISTER_D1))
when WRITE_MEM
write_register(REGISTER_M4, Memory::WRITE)
write_register(REGISTER_M5, read_register(read_register(REGISTER_D0)))
write_register(REGISTER_M6, read_register(read_register(REGISTER_D1)))
else
raise UnknownInstruction.new("Instruction '#{read_register(REGISTER_C0)}' is undefined")
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def misty ci, &blk\n begin\n print 'stack: '; p ci.ctx.stack\n puts 'vars: '; p ci.ctx.vars\n print 'next instruction: '; p ci.peek\n gets\n ci.step\n rescue HaltState\n puts 'halted'\n rescue OpcodeError => err\n puts err.message\n end\nend",
"def xx\n raise InvalidInstruction\n end",... | [
"0.6160143",
"0.59810334",
"0.59793985",
"0.57630515",
"0.5682703",
"0.56545806",
"0.56378865",
"0.5627847",
"0.5627847",
"0.5627847",
"0.5627847",
"0.5627847",
"0.5625758",
"0.55730253",
"0.55626184",
"0.5559635",
"0.5538907",
"0.5506608",
"0.5459107",
"0.5456407",
"0.545409... | 0.0 | -1 |
System Pre Cycle. Executed before Users Cycle | def pre_cycle
copy_value_fetch_from_memory
initialize_memory_instruction_registers
move_instruction_pointer_to_a_next_address
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_init; end",
"def before_run; end",
"def initializer(user)\n rebuild_all_cache(user.id) #prevent inconsistences\n # rebuild_task_cache #prevent inconsistences\n user.log_trash = user.log_old\n user.log_old = nil\n user.tkn = rand(1000000)\n user.last_login = Time.now.utc\n user.sav... | [
"0.6227668",
"0.60449785",
"0.60255885",
"0.5939654",
"0.59046763",
"0.58870876",
"0.58263797",
"0.58257586",
"0.5780243",
"0.57417613",
"0.5695724",
"0.5634792",
"0.5628575",
"0.5615768",
"0.55807304",
"0.55706733",
"0.55355144",
"0.55275047",
"0.55116034",
"0.54970485",
"0.... | 0.0 | -1 |
System After Cycle. Executed after Users Cycle | def after_cycle
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def after_cycle; end",
"def after_remembered; end",
"def after_launched(force=false) \n end",
"def after_update user\n if user.entity_id_changed?\n user.user_kpi_items.update_all(:entity_id => user.entity_id)\n if entity=user.entity\n entity.increment!(:user_quantity)\n ... | [
"0.66312504",
"0.61727446",
"0.61663073",
"0.6142247",
"0.61336136",
"0.61336136",
"0.6128254",
"0.6093069",
"0.60489005",
"0.6048806",
"0.6033084",
"0.60234773",
"0.5926532",
"0.5905881",
"0.5797625",
"0.578727",
"0.578727",
"0.57320875",
"0.57192886",
"0.56941766",
"0.56822... | 0.6613692 | 1 |
this needs a method to take a stringedboard of codes that can create these cells and assign the row/col automatically hiddencell | def hc(row,col)
build :cell, row: row, col: col
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_board\n\n 8.times do |row|\n 8.times do |col|\n new_cell = Cell.new([col + 1, row + 1])\n @@cells.push(new_cell)\n end\n end\n\n end",
"def create_cells\n (\"A\"..@height).each do |rows|\n (1..@width.to_i).each do |column|\n k=\"#{rows}#{column}\"\n ... | [
"0.7199645",
"0.6980947",
"0.6727837",
"0.6725409",
"0.67216676",
"0.6686127",
"0.6652942",
"0.6571379",
"0.6518428",
"0.64964175",
"0.6473548",
"0.6431645",
"0.6422919",
"0.6399235",
"0.6379356",
"0.6370834",
"0.6330323",
"0.6330188",
"0.6318978",
"0.6282646",
"0.6238207",
... | 0.69162947 | 2 |
end properties for entry | def to_entry
Entry.new do |entry|
entry.date_on = self.fecha
entry.description = self.supplier.razonsocial.to_s
entry.exercise_id = self.supplier.company.exercises.where('started_on <= :fecha and finished_on >= :fecha',:fecha => self.fecha).first.try(:id)
# cada referencia es mapeada al asiento
ref = self.supplier.company.refenciacontables.where('referencename like "ventas_factura_%"')
ref.each do |referencia|
raise "falta metodo #{referencia.referencename}" unless self.respond_to?(referencia.referencename)
next if self.send(referencia.referencename,entry,referencia)
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def entry; end",
"def entry; end",
"def entry; end",
"def entry; end",
"def entry\n self['entry']||{}\n end",
"def properties; end",
"def properties; end",
"def properties; end",
"def properties; end",
"def properties; end",
"def properties; end",
"def properties; end",
"def properties;... | [
"0.6329258",
"0.6329258",
"0.6329258",
"0.6329258",
"0.6159638",
"0.6107968",
"0.6107968",
"0.6107968",
"0.6107968",
"0.6107968",
"0.6107968",
"0.6107968",
"0.6107968",
"0.60732484",
"0.5919562",
"0.58847344",
"0.586869",
"0.58551896",
"0.5757344",
"0.56651944",
"0.5647256",
... | 0.49667668 | 82 |
Session keys :cid id of logged in user; if absent, nobody logged in :return_to route params (for url_for) to return to after valid login :admin_disabled admin is logged in but wants to see regular patron view. Causes is_admin, etc to return nil :checkout_in_progress true if cart holds validlooking order, which should be displayed throughout checkout flow :cart ID of the order in progress (BUG: redundant with checkout_in_progress??) :new_session true when session is created, reset when checking if this is a new session (BUG: logic should be moved to the session create logic for interactive login) | def session_expired
render :template => 'components/session_expired', :layout => 'application', :status => 400
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def login_required\n if session[:customer]\n return true\n end\n\n # store current location so that we can \n # come back after the user logged in\n store_location\n \n redirect_to :action =>\"login\" and return false \n end",
"def cart_login\n unless @customer\n ... | [
"0.6627133",
"0.6597982",
"0.6533574",
"0.65006965",
"0.6414708",
"0.63917756",
"0.635157",
"0.63492453",
"0.62876016",
"0.6255175",
"0.62447786",
"0.61802924",
"0.6150279",
"0.6122826",
"0.6105216",
"0.60995847",
"0.6099415",
"0.6048407",
"0.6045983",
"0.6044435",
"0.603783"... | 0.0 | -1 |
Store the action to return to, or URI of the current request if no action given. We can return to this location by calling redirect_after_login. | def return_after_login(route_params)
session[:return_to] = route_params
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def store_location\n unless controller_name == \"sessions\" || action_name == \"activate\"\n session[:return_to] =\n if request.get?\n request.request_uri\n else\n request.referer\n end\n end\n end",
"def store_location!\n session[\"return_to\"] = ... | [
"0.68226606",
"0.6656928",
"0.6531517",
"0.64582026",
"0.6441107",
"0.6405471",
"0.63759494",
"0.63668734",
"0.63668734",
"0.63668734",
"0.63668734",
"0.6361976",
"0.6356382",
"0.63560796",
"0.63559186",
"0.6338682",
"0.63315743",
"0.63237935",
"0.63237935",
"0.63237935",
"0.... | 0.60059583 | 80 |
setup session etc. for an "external" login, eg by a daemon | def login_from_external(c)
session[:cid] = c.id
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_session_with_login\n $system_config ||= load_config(@@SERVER_CONFIG_PATH)\n url = \"#{$system_config.protocol}://#{$system_config.host}:#{$system_config.port}\"\n Util.open_session(url)\n Util.login($system_config.user, $system_config.password)\n end",
"def setup_credentials\n\n cmd ... | [
"0.73085165",
"0.7044009",
"0.6906991",
"0.67312455",
"0.6623717",
"0.6421679",
"0.6359819",
"0.63435304",
"0.63299036",
"0.631882",
"0.630243",
"0.6297178",
"0.627536",
"0.62576824",
"0.6241606",
"0.6235397",
"0.62279713",
"0.6209145",
"0.6172019",
"0.61689895",
"0.61513525"... | 0.63843066 | 6 |
filter that requires user to login before accessing account | def is_logged_in
redirect_to login_path unless logged_in?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def login_filter\n\t\tif not protect?( action_name )\n\t\t\treturn true \n\t\tend\n\n\t\tif not session[:user_id]\n\t\t\t# user isn't logged in\n\t\t\tstore_location\n\t\t\tredirect_to :controller=>\"account\", :action=>\"login\"\n\t\t\treturn false\n\t\tend\n\n\t\t# initialize the @user variable\n\t\t@user = Use... | [
"0.76397514",
"0.71257776",
"0.7110787",
"0.6999441",
"0.69850147",
"0.69682485",
"0.6914875",
"0.6904379",
"0.6889236",
"0.6889236",
"0.6889236",
"0.6884429",
"0.6881952",
"0.685686",
"0.6856578",
"0.6847049",
"0.682197",
"0.68150157",
"0.6804227",
"0.6788064",
"0.6788005",
... | 0.0 | -1 |
Last in, first out | def service
StockManagementService.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last\n out = nil\n\n each {|i| out = i }\n\n out\n end",
"def last() end",
"def last; end",
"def last; end",
"def last; end",
"def peek\n if @out.empty?\n @out << @in.pop until @in.empty?\n end\n\n @out.last\n end",
"def last\n return each\n end",
"def last\n ... | [
"0.6999296",
"0.68087715",
"0.6484346",
"0.6484346",
"0.6484346",
"0.6451529",
"0.63877416",
"0.6248895",
"0.6227901",
"0.6227901",
"0.6227901",
"0.6227901",
"0.62066025",
"0.6139675",
"0.60874426",
"0.60513484",
"0.6033704",
"0.6033704",
"0.6033704",
"0.6033704",
"0.6023387"... | 0.0 | -1 |
Returns a function that takes a list of stock items and quantity then deducts the quantity as per configured strategy (ie: FIFO or LIFO or FEFO). | def stock_update_strategy
case find_stock_update_strategy
when FEFO
method(:update_first_to_expire)
when FIFO
raise 'Not yet implemented: FIFO stock management'
when LIFO
raise 'Not yet implemeted: LIFO stock management'
else
raise "Invalid stock management strategy configured: #{configured_update_strategy}"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deduct_quantities_from_products\n line_items.each do |item|\n item.product_or_variant.deduct_quantity(item.quantity)\n end\n end",
"def deduct_quantity\n line_items.each do |i|\n i.product.current_stock -= i.quantity\n i.product.save\n end\n end",
"def consume_items(item_quanti... | [
"0.67048734",
"0.6652728",
"0.6402686",
"0.60832",
"0.5749579",
"0.57006335",
"0.56894076",
"0.56327355",
"0.5611262",
"0.5601547",
"0.55646014",
"0.5511754",
"0.5502636",
"0.5485637",
"0.5438029",
"0.54379696",
"0.54232967",
"0.54199696",
"0.5364249",
"0.5330506",
"0.5306175... | 0.50226563 | 66 |
The Clever Algorithms Project: (c) Copyright 2010 Jason Brownlee. Some Rights Reserved. This work is licensed under a Creative Commons AttributionNoncommercialShare Alike 2.5 Australia License. | def euc_2d(c1, c2)
Math.sqrt((c1[0] - c2[0])**2.0 + (c1[1] - c2[1])**2.0).round
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def alg; end",
"def ca; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def cops; end",
"def cops; end",
"def cops; end",
"def villian; end",
"def king_richard_iii; end",
"def celebrity; end",
"def celebrity; end",
... | [
"0.6706809",
"0.62739956",
"0.62480855",
"0.62480855",
"0.62480855",
"0.62480855",
"0.62480855",
"0.61692566",
"0.61692566",
"0.61692566",
"0.6068026",
"0.5925833",
"0.5914313",
"0.5914313",
"0.5866746",
"0.585631",
"0.583547",
"0.5832805",
"0.5789878",
"0.57778406",
"0.57778... | 0.0 | -1 |
Retrieve a single contact Get the contact object identified by this URL. A 'contact' is a person associated with a company who is designated to handle certain responsibilities of a tax collecting and filing entity. Security Policies This API requires one of the following user roles: AccountAdmin, AccountUser, BatchServiceAdmin, CompanyAdmin, CompanyUser, CSPAdmin, CSPTester, FirmAdmin, SiteAdmin, SSTAdmin, SystemAdmin, TechnicalSupportAdmin, TechnicalSupportUser, TreasuryAdmin, TreasuryUser. Swagger Name: AvaTaxClient | def get_contact(companyId, id) path = "/api/v2/companies/#{companyId}/contacts/#{id}"
get(path, {}, AvaTax::VERSION) end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def contact(contact, options = {})\n get(\"contacts/#{contact}\", options).pop\n end",
"def contact\n response[\"contact\"]\n end",
"def contact\n @contact ||= get_contact(@data_object.user_contact)\n end",
"def contact\n find('Contact', contact_id)\n end",
"def contact\... | [
"0.7007325",
"0.6800393",
"0.6698345",
"0.6601147",
"0.65647876",
"0.65334064",
"0.647679",
"0.6473304",
"0.6465133",
"0.64489466",
"0.63492364",
"0.63492364",
"0.63206375",
"0.6303082",
"0.62757474",
"0.6257894",
"0.62541014",
"0.61691034",
"0.61551726",
"0.6151276",
"0.6088... | 0.6904382 | 1 |
Retrieve contacts for this company List all contact objects assigned to this company. Search for specific objects using the criteria in the `$filter` parameter; full documentation is available on [Filtering in REST]( . Paginate your results using the `$top`, `$skip`, and `$orderby` parameters. Security Policies This API requires one of the following user roles: AccountAdmin, AccountUser, BatchServiceAdmin, CompanyAdmin, CompanyUser, CSPAdmin, CSPTester, FirmAdmin, SiteAdmin, SSTAdmin, SystemAdmin, TechnicalSupportAdmin, TechnicalSupportUser, TreasuryAdmin, TreasuryUser. Swagger Name: AvaTaxClient | def list_contacts_by_company(companyId, options={}) path = "/api/v2/companies/#{companyId}/contacts"
get(path, options, AvaTax::VERSION) end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_contacts(options={}) path = \"/api/v2/contacts\"\n get(path, options, AvaTax::VERSION) end",
"def get_contacts(params={})\n @obj.get('get-contacts', @auth.merge(params))\n end",
"def contacts\n @contacts = Employee.by_company_id(params[:company_id]).by_search(params[:sea... | [
"0.7355315",
"0.72307223",
"0.70423937",
"0.69668037",
"0.68441355",
"0.67285466",
"0.671055",
"0.66311365",
"0.6622163",
"0.66118634",
"0.6599579",
"0.6576376",
"0.6557251",
"0.65434057",
"0.65414894",
"0.65072966",
"0.6500982",
"0.65006196",
"0.6498676",
"0.64631265",
"0.64... | 0.78658986 | 0 |
Retrieve all contacts Get multiple contact objects across all companies. A 'contact' is a person associated with a company who is designated to handle certain responsibilities of a tax collecting and filing entity. Search for specific objects using the criteria in the `$filter` parameter; full documentation is available on [Filtering in REST]( . Paginate your results using the `$top`, `$skip`, and `$orderby` parameters. Security Policies This API requires one of the following user roles: AccountAdmin, AccountUser, BatchServiceAdmin, CompanyAdmin, CompanyUser, CSPAdmin, CSPTester, FirmAdmin, SiteAdmin, SSTAdmin, SystemAdmin, TechnicalSupportAdmin, TechnicalSupportUser, TreasuryAdmin, TreasuryUser. Swagger Name: AvaTaxClient | def query_contacts(options={}) path = "/api/v2/contacts"
get(path, options, AvaTax::VERSION) end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_contacts(params={})\n @obj.get('get-contacts', @auth.merge(params))\n end",
"def list_contacts_by_company(companyId, options={}) path = \"/api/v2/companies/#{companyId}/contacts\"\n get(path, options, AvaTax::VERSION) end",
"def contacts\n respond_with_entity(api.get('/api... | [
"0.74231416",
"0.720636",
"0.716505",
"0.70705295",
"0.70596826",
"0.7005011",
"0.69929606",
"0.697303",
"0.6966473",
"0.6871022",
"0.68682796",
"0.68251747",
"0.68171716",
"0.68070126",
"0.67985547",
"0.6786458",
"0.67682195",
"0.6764498",
"0.6753119",
"0.6716592",
"0.671510... | 0.7828451 | 0 |
Update a single contact Replace the existing contact object at this URL with an updated object. A 'contact' is a person associated with a company who is designated to handle certain responsibilities of a tax collecting and filing entity. All data from the existing object will be replaced with data in the object you PUT. To set a field's value to null, you may either set its value to null or omit that field from the object you post. Security Policies This API requires one of the following user roles: AccountAdmin, BatchServiceAdmin, CompanyAdmin, CSPTester, FirmAdmin, SSTAdmin, TechnicalSupportAdmin. Swagger Name: AvaTaxClient | def update_contact(companyId, id, model) path = "/api/v2/companies/#{companyId}/contacts/#{id}"
put(path, model, {}, AvaTax::VERSION) end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_contact(contact)\n raise \"contact_id or contact_number is required for updating contacts\" if contact.contact_id.nil? and contact.contact_number.nil?\n \n request_xml = contact.to_xml\n response_xml = http_post(\"#{@xero_url}/contact\", request_xml, {})\n\n parse_response(respo... | [
"0.79194516",
"0.7744628",
"0.7613756",
"0.7281753",
"0.72171676",
"0.71497893",
"0.7148424",
"0.713834",
"0.7048742",
"0.7043336",
"0.6977451",
"0.6977451",
"0.6977451",
"0.697727",
"0.6950752",
"0.69434196",
"0.69412583",
"0.69201016",
"0.6902136",
"0.69008297",
"0.6891857"... | 0.74974203 | 3 |
sorted by the length of the word. Time complexity: O(n^2) because I use bubble sort for sorting words by their length Space complexity: O(n) because I create array output which contains n number of words in input string | def sort_by_length(my_sentence)
raise ArgumentError if !my_sentence
# I'm not sure if I can use .split() here. I can write my own split method
# if .split() is not allowed here
output = my_sentence.split(" ")
length = output.length()
if length > 0
(0...length - 1).each do |i|
swapped = false
(0...length - i - 1).each do |j|
first = output[j]
second = output[j + 1]
if first.length() > second.length
output[j + 1] = first
output[j] = second
swapped = true
end
end
break if !swapped
end
end
return output
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_by_length(my_sentence)\n if my_sentence.nil? || my_sentence == \"\"\n return []\n end\n word_array = my_sentence.split(\" \")\n sorted = []\n sorted << word_array[0]\n \n \n word_array.each do |word|\n index = 0\n while index < word_array.length\n if word.length < sorted[index].lengt... | [
"0.85739714",
"0.8457791",
"0.8434317",
"0.83597374",
"0.83243775",
"0.8251071",
"0.82419974",
"0.8219587",
"0.8104973",
"0.80955386",
"0.8036381",
"0.8035996",
"0.7990923",
"0.79860103",
"0.7941196",
"0.79354006",
"0.7878929",
"0.7864247",
"0.78526986",
"0.78454566",
"0.7842... | 0.7736608 | 26 |
Ask user for input Return area | def get_triangle_base
print 'Please, enter triangle base:'
gets.chomp.to_i
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def area_prompt\n Rainbow (\"\\nPlease choose an area from the following options for event listings:\\n\\n\").bright.blue\n i = 1\n Neighborhood.all.each do |nbh|\n puts \"#{i}. #{nbh.name}\"\n i += 1\n end\n self.area_input = STDIN.gets.strip\n self.area_valid?\n end",
"def area_or_... | [
"0.69887835",
"0.6805162",
"0.6674863",
"0.6641659",
"0.66236013",
"0.65662754",
"0.65648055",
"0.6505463",
"0.65040284",
"0.6464855",
"0.6456317",
"0.64517355",
"0.6429062",
"0.64179903",
"0.6413937",
"0.6407725",
"0.6398645",
"0.6367678",
"0.63483924",
"0.6339668",
"0.63304... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_company
@company = Company.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.6165422",
"0.60457647",
"0.5946384",
"0.5916027",
"0.58905005",
"0.583495",
"0.5777223",
"0.56995213",
"0.56995213",
"0.56532377",
"0.5621348",
"0.5422839",
"0.54118705",
"0.54118705",
"0.54118705",
"0.53935355",
"0.5379617",
"0.53577393",
"0.53407264",
"0.53398263",
"0.53... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def company_params
params.require(:company).permit(:name, :logo, :address, :other_address, :email, :phone, :opening_times, :type, :company_id, :description, :links, :user_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
... | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.638045... | 0.0 | -1 |
Methods Ganky method to verify that we can parse ID3 tags from a file | def can_parse_id3?(filename)
begin
trash = Mp3Info.open(filename)
return true
rescue
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse\n # Flac file maybe contain ID3 header on the start, so skip it if exists\n id3_header = ID3::V2Header.new(@file_io)\n id3_header.valid? ? @file_io.seek(id3_header.size) : @file_io.rewind\n\n return if @file_io.read(4) != TAG_ID\n\n loop do\n block = Flac::Block.new(@file_... | [
"0.68090963",
"0.64340717",
"0.6419227",
"0.6322846",
"0.6260884",
"0.6244142",
"0.61025965",
"0.5977106",
"0.5963044",
"0.5780035",
"0.5734083",
"0.57061315",
"0.5685734",
"0.56820166",
"0.56771666",
"0.5627549",
"0.5611385",
"0.5601045",
"0.5596298",
"0.55377346",
"0.553116... | 0.78101474 | 0 |
Glob a filespec into an array. Keep only elements that are MP3 files. | def glob_mp3_files_from_filespec(filespec)
files = Dir[filespec]
files.reject! { |fn| File.directory?(fn) }
files.reject! { |fn| !(can_parse_id3?(fn)) }
return files
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def files #only wants mp3 files\n Dir.entries(path).select {|entry| entry.include?(\".mp3\")} #select returns an array itself\n end",
"def files\n @files_array ||= Dir.glob(\"#{@path}/*.mp3\").collect do |filename|\n filename.rpartition(\"... | [
"0.7455706",
"0.74132246",
"0.73870736",
"0.7343101",
"0.72986597",
"0.72884136",
"0.7234768",
"0.71966887",
"0.71597403",
"0.71549666",
"0.7147847",
"0.71309376",
"0.70988613",
"0.70716447",
"0.70560855",
"0.69704056",
"0.6968078",
"0.6945108",
"0.6929806",
"0.6909668",
"0.6... | 0.8526018 | 0 |
Dump all ID3 information prettyprinted to stdout | def dump(filename)
puts "Handling #{filename}"
if (File.directory?(filename))
puts "Skipping directory #{filename}."
end
begin
puts YAML::dump(Mp3Info.open(filename))
rescue Mp3InfoError
puts "Could not parse #{filename} for ID3 tags, skipping."
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n #nil\n require 'pp'\n pp directors_database\n puts directors_database\nend",
"def pretty_print_nds(nds)\n # Change the code below to pretty print the nds with pp\n pp directors_database\n nil\nend",
"def pretty_print_... | [
"0.6274295",
"0.621932",
"0.621932",
"0.61466414",
"0.6113787",
"0.607368",
"0.6062349",
"0.6056309",
"0.6056309",
"0.6056309",
"0.6056309",
"0.6056309",
"0.6056295",
"0.6055089",
"0.6054328",
"0.6017597",
"0.6002065",
"0.5990926",
"0.5976189",
"0.5976189",
"0.58993727",
"0... | 0.0 | -1 |
Retag files, setting iTunes' Album Artist field (ID3v2 TPE2). | def retag_album_artist(filename, album_artist_tag)
Mp3Info.open(filename) do |mp3file|
print "Retagging #{filename}..."
STDOUT.flush
if (mp3file.tag2.TPE2)
puts "oops!"
puts "Found existing Album Artist tag: #{mp3file.tag2.TPE2}. Skipping file."
return
end
mp3file.tag2.TPE2 = album_artist_tag
puts "done."
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_ID3(attributes)\n begin\n musicFile = TagLib::File.new(self.filePath())\n musicFile.title = attributes[:id3Title]\n musicFile.artist = attributes[:id3Artist]\n musicFile.save()\n rescue TagLib::BadFile => exc\n logger.error(\"Failed to id track: \\n #{exc}\")\n end \... | [
"0.6557229",
"0.63285017",
"0.624602",
"0.60190386",
"0.599681",
"0.58759683",
"0.58549124",
"0.5801045",
"0.5797781",
"0.57696027",
"0.57317865",
"0.5691395",
"0.56708074",
"0.56412303",
"0.56141573",
"0.5595953",
"0.5594207",
"0.5583716",
"0.5478074",
"0.5456357",
"0.545120... | 0.72005063 | 0 |
def email_required? false end | def email_changed?
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def email_required?; false end",
"def email_required?\r\n false\r\n end",
"def email_required?\n false\n end",
"def email_required?\n false\n end",
"def email_required? \n false \n end",
"def email_required?\n false\n end",
"def email_required?\n false\n end",
"def email_r... | [
"0.9845798",
"0.97756237",
"0.97513306",
"0.97512555",
"0.9744924",
"0.97424376",
"0.97424376",
"0.97424376",
"0.97424376",
"0.97424376",
"0.97424376",
"0.97424376",
"0.97424376",
"0.97424376",
"0.97424376",
"0.97424376",
"0.97424376",
"0.97424376",
"0.97424376",
"0.97424376",
... | 0.7424766 | 76 |
GET /receitas GET /receitas.xml | def index
debugger
@receitas = Receita.find(:all)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @receitas }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @receita = Receita.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @receita }\n end\n end",
"def show\n @receita = Receita.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.x... | [
"0.66862744",
"0.66862744",
"0.6636289",
"0.64751947",
"0.6473561",
"0.6457878",
"0.6455833",
"0.64369035",
"0.6431165",
"0.64297444",
"0.6416409",
"0.6415963",
"0.6368125",
"0.6350436",
"0.63320386",
"0.63026917",
"0.6277339",
"0.62762654",
"0.62719816",
"0.6239502",
"0.6225... | 0.6870639 | 0 |
GET /receitas/1 GET /receitas/1.xml | def show
@receita = Receita.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @receita }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n debugger\n @receitas = Receita.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @receitas }\n end\n end",
"def show\n @relatestagiario = Relatestagiario.find(params[:id])\n\n respond_to do |format|\n format.html # sh... | [
"0.67428404",
"0.66758746",
"0.6556506",
"0.6546369",
"0.6535406",
"0.6519192",
"0.65098506",
"0.6494149",
"0.6428493",
"0.6420139",
"0.64139885",
"0.6402394",
"0.63925314",
"0.63841105",
"0.63810366",
"0.6365567",
"0.63641864",
"0.6353992",
"0.6351161",
"0.63217795",
"0.6310... | 0.67537534 | 1 |
GET /receitas/new GET /receitas/new.xml | def new
@receita = Receita.new
#2.times { @receita.receitais.build }
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @receita }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @receita = Receita.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @receita }\n end\n end",
"def new\n @recurso = Recurso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @recurso }\... | [
"0.75796604",
"0.7449071",
"0.7381175",
"0.73644286",
"0.73403955",
"0.7319804",
"0.7307546",
"0.7302515",
"0.7286236",
"0.7243298",
"0.7220431",
"0.7209613",
"0.7201539",
"0.71962386",
"0.71909636",
"0.7190237",
"0.7165152",
"0.7159125",
"0.7150156",
"0.71491927",
"0.7129994... | 0.0 | -1 |
POST /receitas POST /receitas.xml | def create
debugger
@receita = Receita.new(params[:receita])
respond_to do |format|
if @receita.save
flash[:notice] = 'Receita was successfully created.'
format.html { redirect_to(@receita) }
format.xml { render :xml => @receita, :status => :created, :location => @receita }
else
format.html { render :action => "new" }
format.xml { render :xml => @receita.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n doc = Nokogiri::XML(request.body.read)\n cvNode = doc.xpath('elwak/checklisten_vorlage')\n cv = ChecklistenVorlage.new({\n objekt_id: cvNode.xpath('objekt_id').text.to_s, \n bezeichner: cvNode.xpath('bezeichner').text.to_s, \n version: cvNode.xpath('version').text.to_s.to_i, \n... | [
"0.6215831",
"0.61396146",
"0.6037671",
"0.5967602",
"0.5905336",
"0.5856489",
"0.5786618",
"0.5786074",
"0.5782296",
"0.5737521",
"0.5709026",
"0.57088",
"0.56902766",
"0.56767917",
"0.56745726",
"0.5627152",
"0.56088614",
"0.5606667",
"0.55797356",
"0.5571555",
"0.55671877"... | 0.61679095 | 1 |
PUT /receitas/1 PUT /receitas/1.xml | def update
debbuger
@receita = Receita.find(params[:id])
respond_to do |format|
if @receita.update_attributes(params[:receita])
flash[:notice] = 'Receita was successfully updated.'
format.html { redirect_to(@receita) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @receita.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 rest_update(uri, method: Net::HTTP::Put)\n request = Net::HTTP::Get.new uri\n request.add_field(\"Accept\",\"application/xml\")\n auth_admin(request)\n \n Net::HTTP.start... | [
"0.67230195",
"0.6609974",
"0.6347598",
"0.63146627",
"0.6238326",
"0.6172007",
"0.6167038",
"0.6160668",
"0.6100817",
"0.6083815",
"0.60616195",
"0.604735",
"0.59800506",
"0.5975231",
"0.5952496",
"0.59481996",
"0.59086245",
"0.58821386",
"0.58718216",
"0.5866564",
"0.584546... | 0.59537005 | 14 |
DELETE /receitas/1 DELETE /receitas/1.xml | def destroy
@receita = Receita.find(params[:id])
@receita.destroy
respond_to do |format|
format.html { redirect_to(@receita.paciente, :controller => :pacientes) }
format.xml { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n RestClient.delete \"#{REST_API_URI}/contents/#{id}.xml\" \n self\n end",
"def destroy\n @receita = Receita.find(params[:id])\n @receita.destroy\n\n respond_to do |format|\n format.html { redirect_to(receitas_url) }\n format.xml { head :ok }\n end\n end",
"def netdev... | [
"0.70992285",
"0.70320594",
"0.70188105",
"0.6925448",
"0.687526",
"0.6852916",
"0.67960423",
"0.6776617",
"0.67225987",
"0.67159766",
"0.67087764",
"0.67032015",
"0.66967577",
"0.66855294",
"0.66849405",
"0.6680877",
"0.66766036",
"0.66698164",
"0.6659388",
"0.66443735",
"0.... | 0.63726634 | 66 |
Output is one array with elements of both arrays Rule: No duplicate elements Select elements from array2 that array 1 doesnt include then add arrays I.e. return the union of two arrays (the set of elements that are either in arr1 or arr 2) | def merge(arr1, arr2)
to_add = arr2.select{|element| arr1.include?(element) == false}
arr1 + to_add
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def custom_union(arr1, arr2)\n final = []\n arr1.each { |item| final << item unless final.include?(item) }\n arr2.each { |item| final << item unless final.include?(item) }\n final\nend",
"def merge(ary1, ary2)\n results = ary1.uniq\n ary2.each {|el| results << el unless results.include?(el)}\n results\nen... | [
"0.8436955",
"0.8153297",
"0.8109773",
"0.80882615",
"0.8081647",
"0.8076852",
"0.8034219",
"0.80308264",
"0.79839796",
"0.79388577",
"0.7821601",
"0.78042656",
"0.77735734",
"0.7768387",
"0.7612303",
"0.75707",
"0.7561129",
"0.753924",
"0.753924",
"0.753529",
"0.7508143",
... | 0.7820095 | 11 |
GET /duty_nurses GET /duty_nurses.json | def index
@duty_nurses = DutyNurse.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @dutydeals = Dutydeal.all\n end",
"def index\n @duty_stations = DutyStation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @duty_stations }\n end\n end",
"def show\n @cleaning_duty = CleaningDuty.find(params[:id])\n\n respond... | [
"0.6331093",
"0.62689596",
"0.6238384",
"0.61536175",
"0.6149048",
"0.60732365",
"0.60681826",
"0.59231395",
"0.59230256",
"0.5919321",
"0.5798923",
"0.57702786",
"0.5767965",
"0.57631356",
"0.5762484",
"0.57501286",
"0.57405597",
"0.5727602",
"0.57041746",
"0.5696963",
"0.56... | 0.6794306 | 0 |
GET /duty_nurses/1 GET /duty_nurses/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @cleaning_duty = CleaningDuty.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cleaning_duty }\n end\n end",
"def index\n @duty_nurses = DutyNurse.all\n end",
"def show\n @duty_station = DutyStation.find(params[:id])\... | [
"0.68233114",
"0.6632095",
"0.6447411",
"0.6443991",
"0.63341576",
"0.6228078",
"0.6228078",
"0.6228078",
"0.61994267",
"0.61925983",
"0.6104631",
"0.6090656",
"0.6090656",
"0.60896796",
"0.6068971",
"0.60350263",
"0.5993829",
"0.58999455",
"0.58432007",
"0.58379793",
"0.5811... | 0.0 | -1 |
POST /duty_nurses POST /duty_nurses.json | def create
@duty_nurse = DutyNurse.new(duty_nurse_params)
respond_to do |format|
if @duty_nurse.save
format.html { redirect_to @duty_nurse, notice: 'Duty nurse was successfully created.' }
format.json { render :show, status: :created, location: @duty_nurse }
else
format.html { render :new }
format.json { render json: @duty_nurse.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n if !grant_access(\"alter_duties\", current_user)\n head(403)\n end\n @duty = Duty.new(duty_params)\n @duty.user_id = current_user.id\n respond_to do |format|\n if @duty.save\n format.html { redirect_to @duty, notice: 'Duty was successfully created.' }\n format.js... | [
"0.67292696",
"0.63869476",
"0.6369982",
"0.63038677",
"0.6118355",
"0.6060147",
"0.60513514",
"0.5962216",
"0.5945978",
"0.5882322",
"0.58305097",
"0.5705527",
"0.56926674",
"0.56926674",
"0.56926674",
"0.5660301",
"0.5613959",
"0.560877",
"0.55924916",
"0.55924916",
"0.5591... | 0.6665913 | 1 |
PATCH/PUT /duty_nurses/1 PATCH/PUT /duty_nurses/1.json | def update
respond_to do |format|
if @duty_nurse.update(duty_nurse_params)
format.html { redirect_to @duty_nurse, notice: 'Duty nurse was successfully updated.' }
format.json { render :show, status: :ok, location: @duty_nurse }
else
format.html { render :edit }
format.json { render json: @duty_nurse.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n if !grant_access(\"alter_duties\", current_user)\n head(403)\n end\n @duty.user_id = current_user.id\n respond_to do |format|\n if @duty.update(duty_params)\n format.html { redirect_to @duty, notice: 'Duty was successfully updated.' }\n format.json { render :show, s... | [
"0.71985334",
"0.6871559",
"0.63429207",
"0.6332714",
"0.6312464",
"0.625936",
"0.6194068",
"0.6190156",
"0.6166582",
"0.6166582",
"0.6166582",
"0.6129717",
"0.6106647",
"0.61050326",
"0.60778034",
"0.60778034",
"0.60742736",
"0.6050341",
"0.60480845",
"0.6043531",
"0.6033177... | 0.6786274 | 2 |
DELETE /duty_nurses/1 DELETE /duty_nurses/1.json | def destroy
@duty_nurse.destroy
respond_to do |format|
format.html { redirect_to duty_nurses_url, notice: 'Duty nurse was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @cleaning_duty = CleaningDuty.find(params[:id])\n @cleaning_duty.destroy\n\n respond_to do |format|\n format.html { redirect_to cleaning_duties_url }\n format.json { head :ok }\n end\n end",
"def incident_delete(statuspage_id, incident_id)\n data = {}\n data['statuspage... | [
"0.73456734",
"0.720335",
"0.7185273",
"0.71321565",
"0.692454",
"0.6914582",
"0.6866649",
"0.6854431",
"0.6837374",
"0.68044853",
"0.68044853",
"0.68011403",
"0.67889273",
"0.67769223",
"0.67703927",
"0.67611176",
"0.67417216",
"0.67319816",
"0.67292106",
"0.6706794",
"0.670... | 0.7343494 | 1 |
Use callbacks to share common setup or constraints between actions. | def set_duty_nurse
@duty_nurse = DutyNurse.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.6162554",
"0.60452986",
"0.5945278",
"0.59169763",
"0.58877826",
"0.5834763",
"0.5775349",
"0.5704972",
"0.5704972",
"0.56543803",
"0.5621491",
"0.5427202",
"0.54093206",
"0.54093206",
"0.54093206",
"0.53975695",
"0.53776276",
"0.53562194",
"0.5340594",
"0.5337824",
"0.532... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def duty_nurse_params
params.require(:duty_nurse).permit(:duty_id, :nurse_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69795185",
"0.6782116",
"0.6745877",
"0.6742722",
"0.67368543",
"0.65932566",
"0.65048057",
"0.6497429",
"0.6481512",
"0.6478456",
"0.6455591",
"0.64391",
"0.6379068",
"0.6376498",
"0.636542",
"0.632084",
"0.630046",
"0.62998945",
"0.62943697",
"0.6293775",
"0.629097",
"... | 0.0 | -1 |
returns a task accepted by wait_for method | def run_async(step)
# default implementation doesn't do any concurrence.
run(step)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def result\n wait_for\n # If the task threw an exception during execution we raise that here.\n @task_error ? raise(@task_error) : @task_result\n end",
"def wait_for\n @mutex.synchronize { @token.wait(@mutex) unless @task_complete }\n end",
"def wait\n @future.value\n end",
... | [
"0.6307025",
"0.6152342",
"0.6096742",
"0.60303783",
"0.5997641",
"0.5910166",
"0.58943385",
"0.5764262",
"0.57591826",
"0.572508",
"0.572107",
"0.5716171",
"0.5696181",
"0.56716436",
"0.5669529",
"0.56693006",
"0.562222",
"0.56104416",
"0.5594644",
"0.5591402",
"0.55459756",... | 0.0 | -1 |
wait for tasks to finish, returns the result of calling run for the step. | def wait_for(*tasks)
# default implementation returns the run results directly in the
# run_async output
return tasks
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_for\n raise TaskError, \"The group hasn't been started yet\" if @futures.nil?\n @futures.map do |future|\n future.value\n end\n end",
"def wait_final_result()\n @queue.pop\n @pipeline.stop\n return @result\n end",
"def result\n wait_for\n # If the t... | [
"0.6525414",
"0.63866353",
"0.62582594",
"0.6052893",
"0.5971692",
"0.59145457",
"0.5857932",
"0.58182645",
"0.5802015",
"0.5777033",
"0.5759779",
"0.57596487",
"0.5739218",
"0.5712336",
"0.5706643",
"0.56919634",
"0.5669548",
"0.5623573",
"0.56225294",
"0.56161183",
"0.55761... | 0.68601406 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_person
@person = Person.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.6162554",
"0.60452986",
"0.5945278",
"0.59169763",
"0.58877826",
"0.5834763",
"0.5775349",
"0.5704972",
"0.5704972",
"0.56543803",
"0.5621491",
"0.5427202",
"0.54093206",
"0.54093206",
"0.54093206",
"0.53975695",
"0.53776276",
"0.53562194",
"0.5340594",
"0.5337824",
"0.532... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def person_params
params.require(:person).permit(:name, :content, :avatar)
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.69795185",
"0.6782116",
"0.6745877",
"0.6742722",
"0.67368543",
"0.65932566",
"0.65048057",
"0.6497429",
"0.6481512",
"0.6478456",
"0.6455591",
"0.64391",
"0.6379068",
"0.6376498",
"0.636542",
"0.632084",
"0.630046",
"0.62998945",
"0.62943697",
"0.6293775",
"0.629097",
"... | 0.0 | -1 |
STARTDATE(Required) The earliest transaction date at which to start the search. ENDDATE(Optional) The latest transaction date to be included in the search. ...... | def initialize(service,startdate="",enddate="",country)
@service=service
post_day=BasicData.get_value("00A","001","paypal","").to_i
if(startdate.blank?)
@startdate=Time.zone.now.at_beginning_of_day-post_day.day
else
@startdate=startdate.to_time
end
if(enddate.blank?)
@enddate=Time.zone.now.at_beginning_of_day
else
@enddate=enddate.to_time
end
@paypal_reconciliation_hash=init_paypal_reconciliation_hash()
@reconciliation_date=current_time_format("%Y%m%d",0)
@batch_id=1 # 001
@country=country
Rails.logger.info("TRANSACTION SEARCH : [#{@country}] #{@startdate} -- #{@enddate}")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_by_modified_date( start_date, end_date )\r\n \r\n # Start Date Adjustment\r\n start_date -= @options[:time_adjustment]\r\n \r\n output_log \"Querying customer master records modified during #{parse_date(start_date)} and #{parse_date(end_date)} ...\"\r\n \r\n post_xml = ERP::Customer... | [
"0.61068594",
"0.5908131",
"0.5876566",
"0.5872002",
"0.58456135",
"0.5755044",
"0.5746341",
"0.5736119",
"0.5732394",
"0.57054484",
"0.56851125",
"0.56652445",
"0.5603098",
"0.55851513",
"0.55772436",
"0.5566321",
"0.555356",
"0.5548478",
"0.5513903",
"0.5509626",
"0.5509111... | 0.5102648 | 80 |
Your task is to sort an array of integer numbers by the product of the value and the index of the positions. For sorting the index starts at 1, NOT at 0! The sorting has to be ascending. The array will never be null and will always contain numbers. Example: Input: 23, 2, 3, 4, 5 Product of value and index: 23 => 23 1 = 23 > OutputPos 4 2 => 2 2 = 4 > OutputPos 1 3 => 3 3 = 9 > OutputPos 2 4 => 4 4 = 16 > OutputPos 3 5 => 5 5 = 25 > OutputPos 5 Output: 2, 3, 4, 23, 5 Have fun coding it and please don't forget to vote and rank this kata! :) I have also created other katas. Take a look if you enjoyed this kata! | def sort_by_value_and_index(arr)
return arr.each_with_index.map {|number, index| [number*(index+1), index]}.sort.map {|value| arr[value[1]]}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_product(arr)\n arr.sort_by.with_index(1) { |element, index| element * index }\nend",
"def get_products_of_all_ints_except_index(arr)\n products_array = []\n \n arr.each_with_index do |num, index|\n # new array with number at the current index removed\n \n removed_num = arr.delete_at(index)\... | [
"0.72267044",
"0.6278992",
"0.6258022",
"0.62045395",
"0.6172261",
"0.6132717",
"0.6122021",
"0.60962",
"0.6095077",
"0.60861164",
"0.60805404",
"0.60598546",
"0.6058578",
"0.6058578",
"0.6058578",
"0.6058578",
"0.6058578",
"0.6058578",
"0.6058578",
"0.60566646",
"0.6051003",... | 0.6716795 | 1 |
for each player on the received list it is going to calculate the complete salary | def process_data
@list_to_process.each do |player|
# if player team is not already on the list, it will be calculated and added
current_team = @teams.find { |team| team.name == player.equipo }
if current_team.nil?
current_team = Team.new(player.equipo, @list_to_process, @config)
current_team.calculate_percentage
@teams << current_team
end
# do calculations
meta = get_meta_from_config_list(@config, player.nivel)
player.calculate_salary(current_team.percentage, meta)
@players_to_return << player
end
@players_to_return.map do |player|
PlayerResponse.new(
nombre: player.nombre,
goles_minimos: player.goles_minimos,
goles: player.goles,
sueldo: player.sueldo,
bono: player.bono,
sueldo_completo: player.sueldo_completo,
equipo: player.equipo
)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def total_salary(employees)\n total = 0\n employees.each do |employee|\n # Don't know/care what kind of `Employee` (regular, Manager,\n # or CEO) this is. We can treat them all the same.\n total += employee.wage\n end\nend",
"def pays_players\n self.players.inject(0) {|sum, player| sum += player.p... | [
"0.66579664",
"0.6561209",
"0.62734044",
"0.62189466",
"0.618021",
"0.6088928",
"0.6086618",
"0.60108125",
"0.59877634",
"0.59194595",
"0.59005284",
"0.5860317",
"0.58555937",
"0.5825731",
"0.577349",
"0.5730107",
"0.57094723",
"0.57064855",
"0.5683785",
"0.56747264",
"0.5649... | 0.6591242 | 1 |
niceprint($wordArr) niceprint( scanFor( "b" )) | def go(dirString, location)
if canGo(dirString, location)
case dirString
when "n"
return [location[0]-1, location[1]]
when "s"
return [location[0]+1, location[1]]
when "w"
return [location[0], location[1]-1]
when "e"
return [location[0], location[1]+1]
when "ne"
return [location[0]-1, location[1]+1]
when "nw"
return [location[0]-1, location[1]-1]
when "se"
return [location[0]+1, location[1]+1]
when "sw"
return [location[0]+1, location[1]-1]
end
end
return [0,7]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_of_word(word,num)\n val =[]\n #scan sur le lettre est s'arrete au nobre demander\n for i in (0...num)\n val << word[i]\n end\n return val.join\nend",
"def array_word\n p @arrayed_word = @secret_word.split(\"\")\n end",
"def words\n scan(/\\S+/)\n end",
"def show_word(... | [
"0.6414557",
"0.6325913",
"0.621207",
"0.6075468",
"0.60424054",
"0.6036583",
"0.6008994",
"0.5929834",
"0.5917628",
"0.59077376",
"0.58996785",
"0.58471787",
"0.582862",
"0.5807257",
"0.57941455",
"0.578052",
"0.57727605",
"0.5763257",
"0.57599497",
"0.57573783",
"0.57522017... | 0.0 | -1 |
GET /pit_categories GET /pit_categories.json | def index
@pit_categories = PitCategory.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_categories\r\n categories = Taxonomy.get_categories\r\n render json: categories, root: 'categories', adapter: :json, status: :ok\r\n end",
"def GetCategories params = {}\n\n params = params.merge(path: 'categories.json')\n APICall(params)\n\n end",
"def categories\n\t\trender ... | [
"0.7493981",
"0.7489411",
"0.7297567",
"0.7244443",
"0.71693325",
"0.70602316",
"0.6923172",
"0.6846718",
"0.6832041",
"0.68205893",
"0.68199116",
"0.67807484",
"0.67610884",
"0.6756338",
"0.6701514",
"0.66988003",
"0.66968536",
"0.66733",
"0.6671509",
"0.66633534",
"0.666183... | 0.747125 | 2 |
GET /pit_categories/1 GET /pit_categories/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @pit_categories = PitCategory.all\n end",
"def get_categories\r\n categories = Taxonomy.get_categories\r\n render json: categories, root: 'categories', adapter: :json, status: :ok\r\n end",
"def GetCategories params = {}\n\n params = params.merge(path: 'categories.json')\n ... | [
"0.7374867",
"0.726812",
"0.72128755",
"0.71763605",
"0.7075331",
"0.6996908",
"0.6820896",
"0.6804443",
"0.6790288",
"0.67783254",
"0.66754705",
"0.66458684",
"0.65963465",
"0.6573807",
"0.6571419",
"0.65340745",
"0.6527828",
"0.6520521",
"0.6493832",
"0.6485674",
"0.6464073... | 0.0 | -1 |
POST /pit_categories POST /pit_categories.json | def create
@pit_category = PitCategory.new(pit_category_params)
respond_to do |format|
if @pit_category.save
format.html { redirect_to @pit_category, notice: 'Pit category was successfully created.' }
format.json { render :show, status: :created, location: @pit_category }
else
format.html { render :new }
format.json { render json: @pit_category.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CreateCategory params = {}\n \n APICall(path: 'categories.json',method: 'POST',payload: params.to_json)\n \n end",
"def create_category payload\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.post CATEGORIES, payload )\n\t\t\t\tend",
"def create\n json_create(cat... | [
"0.7173008",
"0.70253676",
"0.6670367",
"0.65091556",
"0.65018106",
"0.6489332",
"0.639165",
"0.63838565",
"0.6356915",
"0.6351262",
"0.63412553",
"0.6335678",
"0.6318037",
"0.6314266",
"0.63003796",
"0.62641275",
"0.6233873",
"0.61850125",
"0.616189",
"0.6158119",
"0.6131186... | 0.7089265 | 1 |
PATCH/PUT /pit_categories/1 PATCH/PUT /pit_categories/1.json | def update
respond_to do |format|
if @pit_category.update(pit_category_params)
format.html { redirect_to @pit_category, notice: 'Pit category was successfully updated.' }
format.json { render :show, status: :ok, location: @pit_category }
else
format.html { render :edit }
format.json { render json: @pit_category.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def UpdateCategory params = {}\n \n APICall(path: 'categories.json',method: 'PUT',payload: params.to_json)\n \n end",
"def update\n json_update(category,category_params, Category)\n end",
"def update\n @pcategory = Pcategory.find(params[:id])\n\n respond_to do |format|\n ... | [
"0.7288627",
"0.7106131",
"0.65720683",
"0.6565301",
"0.652174",
"0.64955765",
"0.64385664",
"0.6433496",
"0.6354468",
"0.63320005",
"0.6317733",
"0.6304992",
"0.6303336",
"0.6262758",
"0.62613994",
"0.62481153",
"0.6227553",
"0.62239116",
"0.620468",
"0.61816424",
"0.617418"... | 0.69510335 | 2 |
DELETE /pit_categories/1 DELETE /pit_categories/1.json | def destroy
@pit_category.destroy
respond_to do |format|
format.html { redirect_to pit_categories_url, notice: 'Pit category was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DeleteCategory id\n \n APICall(path: \"categories/#{id}.json\",method: 'DELETE')\n \n end",
"def destroy\n #@incidentcategory.destroy\n render json: {}, status: 200\n end",
"def destroy\n @category.destroy\n render json: @category, status: :ok\n end",
"def destroy\... | [
"0.73289615",
"0.73009086",
"0.7285853",
"0.72743267",
"0.7209776",
"0.71361023",
"0.7117667",
"0.7113508",
"0.70640874",
"0.7022726",
"0.7020255",
"0.6989797",
"0.69738996",
"0.69738996",
"0.69593734",
"0.6940887",
"0.6940745",
"0.69297034",
"0.69103235",
"0.69043",
"0.69015... | 0.7470722 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_pit_category
@pit_category = PitCategory.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.6165422",
"0.60457647",
"0.5946384",
"0.5916027",
"0.58905005",
"0.583495",
"0.5777223",
"0.56995213",
"0.56995213",
"0.56532377",
"0.5621348",
"0.5422839",
"0.54118705",
"0.54118705",
"0.54118705",
"0.53935355",
"0.5379617",
"0.53577393",
"0.53407264",
"0.53398263",
"0.53... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def pit_category_params
params.require(:pit_category).permit(:name, :pit_form_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n... | [
"0.69802505",
"0.6781974",
"0.67470175",
"0.67430073",
"0.67350477",
"0.6593221",
"0.6504263",
"0.64988977",
"0.6481794",
"0.64800006",
"0.64568025",
"0.64411247",
"0.6379476",
"0.63765615",
"0.6368045",
"0.6320141",
"0.6300363",
"0.6300057",
"0.62952244",
"0.6294712",
"0.629... | 0.0 | -1 |
Finds a selector field in a named +form+ in the given Mechanize +page+, selects the suggested +label+ | def select_and_submit(page, form_name, select_name, selection)
option = nil
form = page.form(form_name)
unless form.nil?
selector = form.field(select_name)
unless selector.nil?
option = select_option(selector, selection)
form.submit
end
end
return option
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_and_submit(page, form_name, select_name, selection)\r\n option = nil\r\n form = page.form(form_name)\r\n unless form.nil?\r\n selector = form.field(select_name)\r\n unless selector.nil?\r\n option = select_option(selector, selection)\r\n form.submit\r\n end\r\n ... | [
"0.61788553",
"0.6116043",
"0.60555726",
"0.5984972",
"0.5711259",
"0.57068366",
"0.5668102",
"0.5603845",
"0.55794114",
"0.54218334",
"0.541392",
"0.53893906",
"0.5364209",
"0.53626716",
"0.53484076",
"0.5293505",
"0.5293505",
"0.52399844",
"0.5237405",
"0.52113193",
"0.5211... | 0.61587715 | 1 |
Given a Mechanize::Form:SelectList +selector+ will attempt to select the option specified by +selection+. This algorithm is used: The first option with a label equal to the +selection+ is selected. if none is found then The first option with a value equal to the +selection+ is selected. if none is found then The first option with a label or value that equal to the +selection+ is selected after removing nonalphanumeric characters from the label or value if none is found then The first option with a lable or value that _contains_ the +selection+ If matching option is found, the select is called on it. If no option is found, nil is returned otherwise the option is returned | def select_option(selector, selection)
options = selector.options.select { |o| o.text == selection }
options = selector.options.select { |o| o.value == selection } if options.empty?
options = selector.options.select { |o| o.text.gsub(/[^a-zA-Z0-9]/,"") == selection } if options.empty?
options = selector.options.select { |o| o.value.gsub(/[^a-zA-Z0-9]/,"") == selection } if options.empty?
options = selector.options.select { |o| o.text.include?(selection) } if options.empty?
options = selector.options.select { |o| o.value.include?(selection) } if options.empty?
option = options.first
option.select() unless option.nil?
return option
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def select_option(selector, selection)\r\n options = selector.options.select { |o| o.text == selection }\r\n options = selector.options.select { |o| o.value == selection } if options.empty?\r\n options = selector.options.select { |o| o.text.gsub(/[^a-zA-Z0-9]/,\"\") == selection } if options.empty?\r\n ... | [
"0.7813909",
"0.6129942",
"0.6101055",
"0.60692185",
"0.5950425",
"0.5903314",
"0.5591723",
"0.552413",
"0.54537976",
"0.5453214",
"0.54009175",
"0.53515923",
"0.52680314",
"0.5254437",
"0.522444",
"0.5223021",
"0.5213418",
"0.5201068",
"0.5190482",
"0.51666206",
"0.5154867",... | 0.78068244 | 1 |
Allows accessing values in following ways foo[1] behaves like an integer foo[:bar] returns true if :bar is marked as true foo[:bar, "baz"] returns true if :bar and :baz are marked true | def [](*args)
if args.first.is_a?(Numeric)
get_model_attr[args.first]
else
args.all? { |key| key_true?(key) }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def [](key)\n ruby_get(key&&key.to_s)\n end",
"def [](k) data[k.to_sym] end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](key); end",
"def [](ke... | [
"0.66155154",
"0.64121574",
"0.6376709",
"0.6376709",
"0.6376709",
"0.6376709",
"0.6376709",
"0.6376709",
"0.6376709",
"0.6376709",
"0.6376709",
"0.6376709",
"0.6376709",
"0.6376709",
"0.6376709",
"0.6376709",
"0.6376709",
"0.6376709",
"0.6376709",
"0.62540036",
"0.6214226",
... | 0.5821509 | 54 |
Allows setting particular key to a boolean value (equivalent to adding/subtracting with these keys) foo[:bar] = false :bar is now false foo["baz"] = "string" :baz is set to true | def []=(arg, value)
arg = arg.to_sym
value = !!value
if @keys.include?(arg)
if value
add_keys!([arg])
else
remove_keys!([arg])
end
else
IntegerFu.raise_undefined_key_error(arg)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def boolean(key, options = {})\n before_all(key, options)\n match?(key, /(true)|(false)/) ? store(key, ->(item){to_boolean(item)}, options) : raise_type_error(key, \"Numeric\")\n end",
"def convert_boolean(key)\n @params[key] = _boolinze(@params[key]) if _is_bool?(get_default(key))\n end... | [
"0.69783074",
"0.6950658",
"0.6550382",
"0.6543301",
"0.6509397",
"0.6509397",
"0.6356276",
"0.6354748",
"0.6279232",
"0.613608",
"0.6091865",
"0.60833514",
"0.6040861",
"0.59938645",
"0.5971428",
"0.5951206",
"0.58897203",
"0.58783597",
"0.5866966",
"0.58617514",
"0.58544225... | 0.5405339 | 62 |
Delegates to + operator | def <<(*args)
self + args
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def +(x); end",
"def +(other)\n `return self + other;`\n end",
"def +(other)\n `return self + other;`\n end",
"def plus(number, other)\n\tnumber + other\nend",
"def +(other); end",
"def +(other); end",
"def +(other); end",
"def +(num)\n old_plus(old_plus(num))\n end",
"def +(other)\n ... | [
"0.8195565",
"0.7913047",
"0.7913047",
"0.78607786",
"0.7857777",
"0.7857777",
"0.7857777",
"0.77739877",
"0.7722048",
"0.7696503",
"0.7684861",
"0.76552546",
"0.75599843",
"0.75491685",
"0.75491685",
"0.74393886",
"0.74324226",
"0.7402248",
"0.7392047",
"0.7392047",
"0.73641... | 0.0 | -1 |
Adds multiple key identifiers (equivalent of setting them to true) foo += [:bar, "baz"] sets :bar and :baz to true unless they're already true | def +(*args)
if args.first.is_a?(Numeric)
get_model_attr + args.first
else
add_keys!(args)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_keys(*keys)\n @rye_opts[:keys] ||= []\n @rye_opts[:keys] += keys.flatten.compact\n @rye_opts[:keys].uniq!\n self # MUST RETURN self\n end",
"def add(*values)\n values.each do |e|\n @data[e] = true\n end\n self\n end",
"def sadd?(key, *members); end",
"d... | [
"0.70075166",
"0.6307468",
"0.6161991",
"0.6161991",
"0.61046195",
"0.60758847",
"0.60168284",
"0.60168284",
"0.6015675",
"0.59664786",
"0.59664786",
"0.5925732",
"0.58964664",
"0.5852222",
"0.56357706",
"0.5627153",
"0.5627153",
"0.56222415",
"0.56138504",
"0.56074613",
"0.5... | 0.0 | -1 |
Subtracts multiple key identifiers (equivalent of setting them to false) foo = :baz sets :baz to false unless they're already false | def -(*args)
if args.first.is_a?(Numeric)
get_model_attr - args.first
else
remove_keys!(args)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def srem?(key, *members); end",
"def srem?(key, *members); end",
"def rem_qs k,v,p={}; alter_qs :rem, k,v,p; end",
"def deny_keys(*keys)\r\n tmp = self.clone\r\n tmp.delete_if {|k,v| keys.include?(k) }\r\n tmp\r\n end",
"def attribute_set_subtract(a1, a2)\n a2_ids... | [
"0.60939413",
"0.60939413",
"0.60273117",
"0.5929489",
"0.5846456",
"0.58413863",
"0.58413863",
"0.57917625",
"0.5746912",
"0.5685828",
"0.5673875",
"0.5673875",
"0.5673793",
"0.5662932",
"0.5658529",
"0.5628494",
"0.5626806",
"0.56250954",
"0.5581588",
"0.55686754",
"0.55686... | 0.0 | -1 |
Collects all keys which are set to true, returns them as an array foo.to_a => [:bar, :baz] (assuming :bar and :baz are set to true) | def to_a
@keys.select{ |k| key_true?(k) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def as_selectable_array\n all.inject([]) { |h,t| h << [t.name, t.key] }\n end",
"def to_a\n @hash.keys\n end",
"def to_a\n @hash.keys\n end",
"def all_keys\n map(&:all_keys).flatten.uniq.sort\n end",
"def copy_boolean_options_to_attributes(keys)\n keys.each do |k|\n if @opts... | [
"0.6028804",
"0.5898612",
"0.5898612",
"0.5788183",
"0.57128423",
"0.57101333",
"0.56911224",
"0.56911224",
"0.56633294",
"0.56600636",
"0.5635634",
"0.5618339",
"0.55742615",
"0.55423945",
"0.55404294",
"0.5516784",
"0.5493157",
"0.54876626",
"0.54712546",
"0.5465756",
"0.54... | 0.81286013 | 0 |
Iterates over result of to_a | def each
self.to_a.each do |el|
yield(el)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def each\n to_a.each\n end",
"def each\n to_a.each\n end",
"def each\n to_a.each\n end",
"def to_a\n each.force\n end",
"def to_a\n each.to_a\n end",
"def to_a\n each.to_a\n end",
"def to_a\n Array(each)\n end",
"def to_a\n result = []\n s... | [
"0.75525457",
"0.75525457",
"0.75525457",
"0.7543442",
"0.7520516",
"0.7520516",
"0.73243034",
"0.6869569",
"0.6828296",
"0.6828296",
"0.6828229",
"0.6828229",
"0.6828229",
"0.6828229",
"0.68135375",
"0.6799883",
"0.6799883",
"0.67933154",
"0.67918843",
"0.6744275",
"0.674242... | 0.6405715 | 52 |
Returns all defined keys, no matter true or false | def all
@keys
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_a\n @keys.select{ |k| key_true?(k) }\n end",
"def list_keys\n @keydict.keys\n end",
"def get_keys()\n\t\t\treturn @config.keys\n\t\tend",
"def list_keys()\n # TODO\n end",
"def list_keys\n @keys.keys\n end",
"def keys\n DoesKeyValue::State.instance.keys[self.to_s]\... | [
"0.70376754",
"0.684412",
"0.67210233",
"0.6720357",
"0.67159235",
"0.659339",
"0.656552",
"0.65194386",
"0.64531136",
"0.6444567",
"0.6444567",
"0.6444567",
"0.6444567",
"0.6444567",
"0.6444567",
"0.6444567",
"0.6444567",
"0.6444567",
"0.64338106",
"0.642442",
"0.63608676",
... | 0.690091 | 1 |
Handles magic questionmark and setter methods. Delegates everything else to the integer. | def method_missing(meth, *args, &block)
meth = meth.to_s
if meth.ends_with?('=') && @keys.include?(meth[0, meth.size - 1].to_sym)
self[meth[0, meth.size - 1].to_sym] = args.first
elsif meth.ends_with?('?') && @keys.include?(meth[0, meth.size - 1].to_sym)
self[meth[0, meth.size - 1].to_sym]
else
get_model_attr.send(meth.to_sym, *args, &block)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_int(attr, val); end",
"def set_int(attr, val); end",
"def value; super.to_i; end",
"def attr_set_integer(attr_type, number)\n #This is a stub, used for indexing\n end",
"def edit\n if !@question.decimal\n @question.answer = @question.answer.to_i\n end\n end",
"def pos= integ... | [
"0.6269143",
"0.6269143",
"0.5681012",
"0.5662651",
"0.56617576",
"0.55470055",
"0.5441509",
"0.5421412",
"0.5390155",
"0.5341562",
"0.52746135",
"0.5264138",
"0.52344847",
"0.5204701",
"0.52045316",
"0.5147245",
"0.5142706",
"0.51219976",
"0.50852615",
"0.5071097",
"0.505369... | 0.0 | -1 |
Override url method to implement with "Image Space" | def url(version_name = "")
@url ||= super({})
version_name = version_name.to_s
return @url if version_name.blank?
# if not version_name.in?(IMAGE_UPLOADER_ALLOW_IMAGE_VERSION_NAMES)
# # To protected version name using, when it not defined, this will be give an error message in development environment
# raise "ImageUploader version_name:#{version_name} not allow."
# end
[@url,version_name].join("!") # thumb split with "!"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def image\n\n end",
"def images\n end",
"def image\n end",
"def image\n end",
"def image_content_return_url(url, width, height, alt = '')\n url = CGI::escape(url)\n width = CGI::escape(width.to_s)\n height = CGI::escape(height.to_s)\n alt = CGI::escape(alt)\n\n ... | [
"0.68276155",
"0.6798257",
"0.67573476",
"0.67573476",
"0.6534451",
"0.64983",
"0.6472371",
"0.64585644",
"0.6443435",
"0.6428251",
"0.6428251",
"0.6420293",
"0.64162093",
"0.64122665",
"0.63883954",
"0.6380832",
"0.63792115",
"0.6372745",
"0.63671196",
"0.6361875",
"0.635667... | 0.0 | -1 |
Two Admins: God 8123306777 Gesus E8D1e2d3EE GET /admins | def index
@admins = Admin.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def multiple_admins\n if !admin?\n num_admins = Member.where({\n band_id: params[:id],\n is_admin: true\n }).count\n\n if num_admins < 2\n flash[:danger] = \"There needs to be another admin before you step down.\"\n redirect_to band_url(params[:id])\n ... | [
"0.68583715",
"0.6743192",
"0.6711108",
"0.66693044",
"0.66650504",
"0.660384",
"0.659342",
"0.654651",
"0.6504704",
"0.6504704",
"0.63991183",
"0.63770753",
"0.6344192",
"0.6317446",
"0.6317446",
"0.6317446",
"0.6317446",
"0.63141733",
"0.6296615",
"0.629422",
"0.62816846",
... | 0.6255509 | 27 |
Use callbacks to share common setup or constraints between actions. | def set_admin
@admin = Admin.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 admin_params
# binding.pry
params.require(:admin).permit(:name, :password)
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.69795185",
"0.6782116",
"0.6745877",
"0.6742722",
"0.67368543",
"0.65932566",
"0.65048057",
"0.6497429",
"0.6481512",
"0.6478456",
"0.6455591",
"0.64391",
"0.6379068",
"0.6376498",
"0.636542",
"0.632084",
"0.630046",
"0.62998945",
"0.62943697",
"0.6293775",
"0.629097",
"... | 0.0 | -1 |
PUT /submissions/1 PUT /submissions/1.xml | def update
@submission = Submission.find(params[:id])
if @submission.update_attributes(params[:submission])
redirect_to(@submission, :notice => 'Submission was successfully updated.')
else
render :action => "edit"
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 update\n @submission = Submission.find(params[:id])\n\n respond_to do |format|\n if @submission.update_attributes(params[:submission])\n format.html { redire... | [
"0.6324332",
"0.6108188",
"0.6108188",
"0.60761786",
"0.5960084",
"0.5954857",
"0.580477",
"0.5725311",
"0.56365925",
"0.5629242",
"0.56238115",
"0.5591724",
"0.5587083",
"0.5554792",
"0.55325264",
"0.55211234",
"0.5514591",
"0.5510182",
"0.55014735",
"0.54943734",
"0.5460158... | 0.548045 | 20 |
DELETE /submissions/1 DELETE /submissions/1.xml | def destroy
@submission = Submission.find(params[:id])
@submission.destroy
redirect_to(submissions_url)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @submission = Submission.find(params[:id])\n @submission.destroy\n\n respond_to do |format|\n format.html { redirect_to(submissions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @submission = Submission.find(params[:id])\n @submission.destroy\n\n res... | [
"0.7187351",
"0.7187351",
"0.7187351",
"0.70988005",
"0.70670134",
"0.6692668",
"0.6636256",
"0.6602446",
"0.6602446",
"0.66023415",
"0.659241",
"0.6577398",
"0.6577398",
"0.6577398",
"0.6494246",
"0.6405225",
"0.6368198",
"0.6345369",
"0.6334303",
"0.6328775",
"0.6328365",
... | 0.66493356 | 6 |
Get the status code for a status symbol. | def status_code(status_symbol = :ok)
Rack::Utils::SYMBOL_TO_STATUS_CODE[status_symbol]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def status_code\n ActionController::StatusCodes::SYMBOL_TO_STATUS_CODE[@status]\n end",
"def symbol\n STATUS_CODE_TO_SYMBOL[status]\n end",
"def code_symbol\n HTTP_STATUS_CODES[status]\n end",
"def status_symbol(status_code = 200)\n Rack::Utils::SYMBOL_TO_STATUS_CODE.invert[status_co... | [
"0.7803918",
"0.77510536",
"0.76874804",
"0.76837116",
"0.7527758",
"0.7482126",
"0.73005044",
"0.72102445",
"0.6974091",
"0.6947958",
"0.68996537",
"0.6864096",
"0.67650896",
"0.66818786",
"0.6597427",
"0.6595027",
"0.6550374",
"0.6535673",
"0.6454608",
"0.64367986",
"0.6418... | 0.79401267 | 0 |
Get the status symbol for a status code. | def status_symbol(status_code = 200)
Rack::Utils::SYMBOL_TO_STATUS_CODE.invert[status_code]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def symbol\n STATUS_CODE_TO_SYMBOL[status]\n end",
"def code_symbol\n HTTP_STATUS_CODES[status]\n end",
"def status_code\n ActionController::StatusCodes::SYMBOL_TO_STATUS_CODE[@status]\n end",
"def get_status status_code\n status = STATUSES[status_code]\n if status\n status\n ... | [
"0.8634911",
"0.8144375",
"0.79853475",
"0.7641884",
"0.73583096",
"0.7182789",
"0.71612376",
"0.7144921",
"0.70778453",
"0.6986663",
"0.6985692",
"0.6957397",
"0.6769186",
"0.6723823",
"0.6641835",
"0.6585186",
"0.6542251",
"0.651085",
"0.64868057",
"0.64772725",
"0.64195204... | 0.84016377 | 1 |
Get the status phrase for a status symbol. | def status_phrase(status_symbol = :ok)
Rack::Utils::HTTP_STATUS_CODES[status_code(status_symbol)]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def symbol\n STATUS_CODE_TO_SYMBOL[status]\n end",
"def status_sym\n return nil if status.nil?\n Bike.what_status_is[status]\n end",
"def status_name\n STATUSES[status]\n end",
"def status_name\n STATUSE.key(@status)\n end",
"def pretty_status\r\n status.titleize\r\n en... | [
"0.7484087",
"0.7352005",
"0.719993",
"0.6941452",
"0.68987274",
"0.6834763",
"0.6808748",
"0.6803366",
"0.67659545",
"0.6713419",
"0.6668371",
"0.66519976",
"0.66110647",
"0.6577787",
"0.65641886",
"0.6563956",
"0.6551363",
"0.6519379",
"0.6491612",
"0.6447916",
"0.64451414"... | 0.7748644 | 0 |
Formats an item for a new response. | def prepare_new(item, user, _opts = {})
unless item.is_a?(ActiveRecord::Base)
raise CustomErrors::FilterArgumentError, "Item must be an ActiveRecord::Base, got #{item.class}"
end
filter_settings = item.class.filter_settings
item_new = item
# add new spec fields if filter_settings specifies a lambda for new_spec_fields
new_spec_fields = filter_settings[:new_spec_fields]
new_spec_fields_is_lambda = !new_spec_fields.blank? && new_spec_fields.lambda?
new_spec_fields_hash = {}
if new_spec_fields_is_lambda && (item_new.nil? || item_new.id.nil?)
new_spec_fields_hash = new_spec_fields.call(user)
end
new_spec_fields_hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format\n f = @item_attributes.first.format\n f.to_s unless f.nil?\n end",
"def item_into_standard_format(item)\n file = {}\n file[:id] = item.id\n file[:provider] = 'google'\n file[:title] = item.title\n file[:view_link] = item.alternateLink\n file[:owner_names] = i... | [
"0.6258121",
"0.6257043",
"0.61376494",
"0.61226195",
"0.6075508",
"0.6038171",
"0.5993201",
"0.5991267",
"0.5885846",
"0.5819619",
"0.5809988",
"0.57794577",
"0.572406",
"0.572406",
"0.5720921",
"0.561787",
"0.5613177",
"0.56084996",
"0.5598871",
"0.55908656",
"0.5586699",
... | 0.0 | -1 |
Add custom fields to an item. | def prepare(item, user, opts = {})
unless item.is_a?(ActiveRecord::Base)
raise CustomErrors::FilterArgumentError, "Item must be an ActiveRecord::Base, got #{item.class}"
end
filter_settings = item.class.filter_settings
item_new = item
# add custom fields if filter_settings specifies a lambda for custom_fields
custom_fields = filter_settings[:custom_fields]
custom_fields_is_lambda = !custom_fields.blank? && custom_fields.lambda?
custom_fields_hash = {}
if custom_fields_is_lambda && !item_new.nil? && !item_new.id.nil?
item_new, custom_fields_hash = custom_fields.call(item, user)
custom_fields_hash.transform_keys!(&:to_s)
end
custom_fields_keys = custom_fields_hash.keys
# get newer sort of custom fields, and keep only string keys and transforms
custom_fields_hash2 = filter_settings
.fetch(:custom_fields2, {})
# for calculated fields, they may not have a transform function, so skip those
# and just use the value returned from the database
.reject { |_key, value| value[:transform].nil? }
.transform_values { |value| value[:transform] }
.transform_keys(&:to_s)
hashed_item = {}.merge(
item_new&.as_json,
custom_fields_hash,
custom_fields_hash2
)
# project using filter projection or default fields
# Note: most queries with a projection already only return required fields
# but some don't... currently those using custom_filter_2
projection = opts[:projection]
if projection
if projection[:include]
# backwards compatible hack: custom fields always used to be included,
# no matter the projection
hashed_item.slice(*(projection[:include].map(&:to_s) + custom_fields_keys))
else
hashed_item.except(*projection[:exclude].map(&:to_s))
end => hashed_item
else
default_fields = filter_settings[:render_fields] + custom_fields_keys
hashed_item = hashed_item.slice(*default_fields.map(&:to_s))
end
# Now that the projection is applied, transform any remaining
# custom values.
# We don't want to do this earlier because calculating a custom field
# before the projection could result in unneeded custom fields being
# included which apart from being slow may also fail due to missing select
# data
hashed_item.transform_values { |value|
next value unless value.is_a?(Proc)
value.call(item)
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_custom_field(name, value)\n add_field name, value\n end",
"def init_custom_fields\n @item_types = [nil, '']\n @capacities_types = [nil, '']\n end",
"def item_fields(item, added = nil)\n item ||= default_to_self\n result = item.is_a?(ManifestItem) ? item.fields : item.symbol... | [
"0.68324035",
"0.65311974",
"0.64967686",
"0.63162553",
"0.6206523",
"0.61479527",
"0.6140996",
"0.61369556",
"0.60352105",
"0.594596",
"0.5942828",
"0.5936576",
"0.59264934",
"0.5918119",
"0.5885973",
"0.5868648",
"0.58654624",
"0.58560973",
"0.5816985",
"0.58117837",
"0.580... | 0.546287 | 43 |
Create and execute a query based on an index request. | def response_advanced(params, query, model, filter_settings)
response(params, query, model, filter_settings)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def AddQuery(query, index = '*', comment = '')\n # build request\n \n # mode and limits\n request = Request.new\n request.put_int @offset, @limit, @mode, @ranker\n # process the 'expr' ranker\n if @ranker == SPH_RANK_EXPR\n request.put_string @rankexpr\n end\n\n requ... | [
"0.7254738",
"0.6898698",
"0.66745734",
"0.6427395",
"0.6394695",
"0.6384594",
"0.638427",
"0.6368088",
"0.62521267",
"0.6243352",
"0.624212",
"0.6190889",
"0.61600196",
"0.61600196",
"0.6112741",
"0.60992956",
"0.6084172",
"0.60581344",
"0.6037699",
"0.60096556",
"0.59944874... | 0.0 | -1 |
Get error links hash. | def error_links_hash
{
sign_in: {
text: I18n.t('devise.sessions.new.sign_in'),
url: url_helpers.new_user_session_path
},
sign_up: {
text: I18n.t('devise.registrations.new.sign_up'),
url: url_helpers.new_user_registration_path
},
permissions: {
text: I18n.t('models.permissions.request_permissions'),
url: url_helpers.new_access_request_projects_path
},
confirm: {
text: I18n.t('devise.shared.links.confirm_account'),
url: url_helpers.new_user_confirmation_path
},
reset_password: {
text: I18n.t('devise.shared.links.reset_password'),
url: url_helpers.new_user_password_path
},
resend_unlock: {
text: I18n.t('devise.shared.links.unlock_account'),
url: url_helpers.new_user_unlock_path
}
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash\n [item_id, error_details].hash\n end",
"def uniqueness_hash\n return nil if (exception.backtrace.nil? || exception.backtrace.empty?)\n Digest::MD5.hexdigest(exception.backtrace.join)\n end",
"def hash\n [check_id, exceptions, key, links, port, proof, protocol, since, s... | [
"0.5966563",
"0.5941407",
"0.5888586",
"0.58598214",
"0.5822719",
"0.57597184",
"0.57597184",
"0.57032895",
"0.570126",
"0.56846154",
"0.56179583",
"0.5602457",
"0.55931467",
"0.54168767",
"0.53794867",
"0.53794044",
"0.53532314",
"0.5351928",
"0.5331575",
"0.5311044",
"0.531... | 0.6959302 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.