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 |
|---|---|---|---|---|---|---|
Triggers an event, moving record to associated state, if permitted Raises exception if event is not permitted | def trigger!(event, metadata={})
if !trigger(event, metadata)
raise StateTransitionException::TransitionNotPermitted
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trigger(event, metadata={})\n if (event_permitted(event) || User.is_admin?(metadata[:user_id])) &&\n required_metadata_present?(event, metadata)\n to_state = self.event_to_state(event)\n callback_metadata = metadata.clone\n transition_to(to_state, metadata)\n if respon... | [
"0.6229441",
"0.5922498",
"0.5919675",
"0.5870206",
"0.5862686",
"0.57361746",
"0.5734076",
"0.5732156",
"0.57278764",
"0.5684377",
"0.566975",
"0.5612304",
"0.5575925",
"0.55410093",
"0.55410093",
"0.542458",
"0.53809494",
"0.5369966",
"0.53378475",
"0.53007096",
"0.52587366... | 0.6480659 | 0 |
Return all prior state transitions for the record | def state_transitions
StateTransition.where(record_id: id, record_type: self.class.to_s).order(id: :desc)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transitions(curr_state = nil, **)\n curr_state = state_value(curr_state)\n next_states = state_table.dig(curr_state, :next)\n Array.wrap(next_states).compact_blank\n end",
"def transitions\n resource.state_paths.map(&:first).uniq\n end",
"def transitions\n @transitions ||=... | [
"0.68737185",
"0.6868081",
"0.6751057",
"0.6730548",
"0.6531023",
"0.6482059",
"0.6264212",
"0.6257882",
"0.6227596",
"0.6141549",
"0.61095476",
"0.60746163",
"0.6050716",
"0.6018203",
"0.5996663",
"0.5959529",
"0.59426916",
"0.59016854",
"0.58894616",
"0.5866294",
"0.5865126... | 0.689462 | 0 |
Returns the last (most recent) state transition for the record | def last_transition
StateTransition.where(record_id: id, record_type: self.class.to_s).order(id: :desc).limit(1).first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_transition_to(to_state)\n StateTransition.where(record_id: id, record_type: self.class.to_s, to_state: to_state.to_s).order(id: :desc).limit(1).first\n end",
"def state\n @state.last\n end",
"def state\n @state.last\n end",
"def current_state\n current = StateTransition.... | [
"0.76322365",
"0.72271574",
"0.72271574",
"0.67063844",
"0.6517754",
"0.6416929",
"0.6369829",
"0.6369829",
"0.63674843",
"0.63482183",
"0.62782526",
"0.6263277",
"0.62330526",
"0.62087923",
"0.6179601",
"0.61723965",
"0.61585957",
"0.6131995",
"0.6078243",
"0.60730934",
"0.6... | 0.8356173 | 0 |
Returns the last (most recent) state transition that moved the record to the given state | def last_transition_to(to_state)
StateTransition.where(record_id: id, record_type: self.class.to_s, to_state: to_state.to_s).order(id: :desc).limit(1).first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_transition\n StateTransition.where(record_id: id, record_type: self.class.to_s).order(id: :desc).limit(1).first\n end",
"def last_transition_before(*to_state)\n not_in_fragment = \"'#{to_state.map { |x| x.to_s }.join(\"','\")}'\"\n StateTransition.where(record_id: id, record_type: self... | [
"0.755925",
"0.6832542",
"0.6782237",
"0.6782237",
"0.65675104",
"0.6546778",
"0.64971745",
"0.6467904",
"0.63546413",
"0.634645",
"0.6280467",
"0.62629616",
"0.6201967",
"0.61261666",
"0.6107772",
"0.6034088",
"0.60317934",
"0.59852695",
"0.5975862",
"0.5904124",
"0.5781381"... | 0.78629667 | 0 |
Returns the last state transition prior to the record moving to the given state | def last_transition_before(*to_state)
not_in_fragment = "'#{to_state.map { |x| x.to_s }.join("','")}'"
StateTransition.where(record_id: id, record_type: self.class.to_s).where("to_state NOT IN (#{ not_in_fragment })").order(id: :desc).limit(1).first
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getPreviousState()\n\t\t\treturn @_previous_state\n\t\tend",
"def last_transition_to(to_state)\n StateTransition.where(record_id: id, record_type: self.class.to_s, to_state: to_state.to_s).order(id: :desc).limit(1).first\n end",
"def last_transition\n StateTransition.where(record_id: id, recor... | [
"0.7093016",
"0.6872691",
"0.67363065",
"0.6616219",
"0.64991057",
"0.63630867",
"0.63630867",
"0.63594055",
"0.63530886",
"0.6352977",
"0.6304752",
"0.6207049",
"0.6122179",
"0.60733604",
"0.59955645",
"0.59919864",
"0.59798914",
"0.59422284",
"0.59398556",
"0.5934959",
"0.5... | 0.736477 | 0 |
Returns the record's current state | def current_state
current = StateTransition.where(record_id: id, record_type: self.class.to_s, current: true).order(id: :desc).limit(1).first
if current
current.to_state.to_sym
else
self.initial_state.to_sym
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state\n @current_state\n end",
"def state\n return @state\n end",
"def state\n return @state\n end",
"def state\n return @state\n end",
"def state\n return @state\n end",
"def state\n ... | [
"0.78733504",
"0.773604",
"0.773604",
"0.773604",
"0.773604",
"0.773604",
"0.773604",
"0.773604",
"0.773604",
"0.773604",
"0.773604",
"0.76647264",
"0.76611406",
"0.76255757",
"0.76255757",
"0.75839853",
"0.7554649",
"0.7401205",
"0.7388965",
"0.7388965",
"0.7317087",
"0.72... | 0.78653955 | 1 |
Returns true if the current state is at or after the given state in the workflow | def state_reached?(state)
states = states_events.map { |se| se[0] }
if states.index(current_state) && states.index(state)
states.index(current_state) >= states.index(state)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def in_or_after_state?(test_state)\n return false if test_state.nil? || self.state.nil?\n test_state = test_state.to_sym\n my_state = self.state.to_sym\n\n # Get all the states that are in and after the state we want to check (test_state),\n # and then see if the vehicle's current state is in that l... | [
"0.74989223",
"0.6935901",
"0.6880012",
"0.67839164",
"0.6783049",
"0.67201126",
"0.667262",
"0.6622234",
"0.6569134",
"0.65045667",
"0.6503544",
"0.6502709",
"0.6491517",
"0.64779794",
"0.6460402",
"0.6451276",
"0.6443723",
"0.63995695",
"0.6388137",
"0.63499147",
"0.6313252... | 0.69461 | 1 |
Transition record to given state, creating a new StateTransition record | def transition_to(to_state, metadata={})
if last_transition
last_transition.update_attributes(current: false)
end
from_state = last_transition ? last_transition.to_state : nil
# remove request if included in metadata
if metadata && metadata[:request]
metadata.delete(:reques... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transition!(state:, parent: nil)\n Mua::State::Transition.new(state: state, parent: parent)\n end",
"def new_state\n newID = @@nextID\n @@nextID += 1\n @state[newID] = true\n @transition[newID] = {}\n newID \n end",
"def new_state\n newID = @@nextID\n ... | [
"0.71547484",
"0.7022737",
"0.7022737",
"0.7022737",
"0.6850803",
"0.68035316",
"0.6762736",
"0.66492397",
"0.66389924",
"0.66261494",
"0.6593114",
"0.6488374",
"0.64726883",
"0.63248134",
"0.62651026",
"0.6234825",
"0.6234825",
"0.6214949",
"0.62037313",
"0.61818093",
"0.617... | 0.7451565 | 0 |
TODO: rewrite with block? | def save_location
new_r = @location.new_record?
headers ={}
if @location.save
headers= ( new_r ? {status: :created, location: api_v1_location_url(id: @location.id, format: (params[:format] || :json) ) } : {status: :ok} )
end
respond_with(@location, headers)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end",
"def block; end"... | [
"0.7948326",
"0.7948326",
"0.7948326",
"0.7948326",
"0.7948326",
"0.7948326",
"0.7948326",
"0.7948326",
"0.7948326",
"0.7948326",
"0.7948326",
"0.7948326",
"0.7948326",
"0.7948326",
"0.7948326",
"0.7948326",
"0.7948326",
"0.7948326",
"0.7948326",
"0.7948326",
"0.7328322",
"... | 0.0 | -1 |
set sorting according to param "sort=name,+city" , "sort=+name", "sort=name" | def sort_locations
if params[:sort].present?
params[:sort].split(",").each {|sort_according_to| add_sorting_for(sort_according_to)}
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_params; end",
"def sort_params; end",
"def sort_params=(_arg0); end",
"def sort_params=(_arg0); end",
"def sort_param_with_url(sortable_name, *args)\n params.delete(:sortasc)\n params.delete(:sortdesc)\n params.merge(sort_param_without_url(sortable_name, *args))\n end",
"def set_listin... | [
"0.7363208",
"0.7363208",
"0.72075796",
"0.72075796",
"0.7155323",
"0.7117562",
"0.70686054",
"0.7038429",
"0.69951934",
"0.69249535",
"0.68984914",
"0.68962204",
"0.6876758",
"0.68648297",
"0.68562627",
"0.68520784",
"0.68272305",
"0.68005997",
"0.67932487",
"0.6771148",
"0.... | 0.72886384 | 2 |
filtering selected locations accordind to attributes values eg. "/locations?city=london&name=Eye" | def filter_locations
allowed_keys=["name", "city", "user_id", "area_tl", "area_br"]
filtering_keys=allowed_keys & params.keys
filtering_keys.each {|key| filter_by_key(key)}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filtering_params\n params.slice( :title, :location )\n end",
"def filtering_params(params)\n params.slice(:desired_location, :max_price_dollars, :tour_name, :earliest_start, :latest_end, :min_seats)\n end",
"def filtering_params(params)\n params.slice(:business_id, :location, :starts_with)... | [
"0.64562535",
"0.63139075",
"0.6283773",
"0.6136793",
"0.60109365",
"0.6010069",
"0.5859504",
"0.5857284",
"0.5842576",
"0.5692458",
"0.5671684",
"0.5658291",
"0.5655835",
"0.5653993",
"0.5641028",
"0.56142306",
"0.5600217",
"0.5582788",
"0.55661714",
"0.55595344",
"0.5558263... | 0.71998245 | 0 |
restrict returned locations according to "limit=5" and "offset=100" no default pagination implemented | def limit_locations
@locations=@locations.offset(params[:offset]) if params[:offset].present?
@locations=@locations.limit(params[:limit]) if params[:limit].present?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index \n @page = params.fetch(:page, 0).to_i - 1\n @locations = \n case params[:filter_by_region]\n when \"england\"\n Location.where(\"area_code LIKE 'E%' \")\n when \"scotland\"\n Location.where(\"area_code LIKE 'S%' \")\n when \"wales\"\n Location.where(\"are... | [
"0.68043894",
"0.6802948",
"0.66481966",
"0.6236128",
"0.6199374",
"0.61982775",
"0.6179837",
"0.6173554",
"0.6169362",
"0.6149517",
"0.6148165",
"0.6146034",
"0.6143953",
"0.60121",
"0.59736425",
"0.5968721",
"0.59542173",
"0.595252",
"0.5951218",
"0.591364",
"0.59052384",
... | 0.76903284 | 0 |
restrict returned attributes according to "fields=name,description" | def restrict_fields
allowed_fields=Location.new.attributes.keys+["top_left_coordinate_str", "bottom_right_coordinate_str"]-["top_left_coordinate_id", "bottom_right_coordinate_id"]
@fields=allowed_fields & (params[:fields] || "").split(",")
if @fields.present?
@locations=@locations.selec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_fields\n\t \n\t \tremove_attribute(:version)\n\t \tremove_attribute(:op_success)\n\t \tattributes\n\n\t \t\n\t end",
"def filter_fields\n\t \n\t \tremove_attribute(:version)\n\t \tremove_attribute(:op_success)\n\t \tattributes\n\n\t \t\n\t end",
"def filtered_attr... | [
"0.658014",
"0.658014",
"0.62035835",
"0.61637455",
"0.6110525",
"0.6055685",
"0.60435677",
"0.6004841",
"0.59830344",
"0.5975348",
"0.5960114",
"0.5948807",
"0.5944848",
"0.593336",
"0.59183306",
"0.59034926",
"0.5860897",
"0.5840949",
"0.5831644",
"0.57934326",
"0.57934326"... | 0.5555905 | 65 |
get all known coordinates which are in this area and scope locations to ones which use them | def filter_by_area
loc_ids=Area.new(params[:area_tl],params[:area_br]).locations.collect {|loc| loc.id}
@locations=@locations.where(id: loc_ids)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def locations\n unless defined?(@locations)\n @locations=[]\n for loc in Location.order(\"id ASC\").includes(:bottom_right_coordinate, :top_left_coordinate)\n @locations << loc if do_overlap_with?(loc.area)\n end \n end \n @locations\n end",
"def paint_coordinates\n result ... | [
"0.75211775",
"0.6671721",
"0.65559006",
"0.64323235",
"0.6374491",
"0.6374491",
"0.6356547",
"0.62963516",
"0.6292162",
"0.6282853",
"0.62170213",
"0.6210924",
"0.6176941",
"0.6154796",
"0.61505616",
"0.61460656",
"0.614366",
"0.61105996",
"0.6063449",
"0.6045944",
"0.602749... | 0.0 | -1 |
Connect to the server and execute the request | def execute(refresh=false)
return @response if @response && !refresh
validate
build_url
@done = true
DomainTools.counter!
require 'net/http'
begin
Net::HTTP.start(@host) do |http|
req = Net::HTTP::Get.new(@url)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run\n make_request(@path)\n end",
"def connect\n @connection = Net::HTTP.new(@params[:server], @params[:port])\n @connection.use_ssl = true if @params[:scheme] == 'https'\n @connection.start\n end",
"def run_request(hash)\n connection.run_request(hash[:verb], hash[:path], has... | [
"0.7094335",
"0.7086008",
"0.6986105",
"0.69535595",
"0.69326836",
"0.69056755",
"0.69041896",
"0.68762964",
"0.68762964",
"0.681176",
"0.67798245",
"0.6763191",
"0.6669012",
"0.6606677",
"0.6586112",
"0.6536989",
"0.6533942",
"0.65220463",
"0.64944005",
"0.6461239",
"0.64494... | 0.0 | -1 |
Check HTTP request status and raise an exception if needed | def validate_http_status
return true if @http.code.to_i == 200
DomainTools::Exceptions::raise_by_code(@http.code)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_request\n if @req.code.to_i.between?(400, 499)\n raise Exceptions::SlicingDiceHTTPError, \"Client Error \"\\\n \"#{@req.code} (#{@req.message}).\"\n elsif @req.code.to_i.between?(500, 600)\n raise Exceptions::SlicingDiceHTTPError, \"Server Error \"\\\n \"#{@req.c... | [
"0.7201969",
"0.70848364",
"0.7076407",
"0.70579445",
"0.6947345",
"0.6939352",
"0.6916729",
"0.6904823",
"0.68807936",
"0.68648785",
"0.67726105",
"0.6752844",
"0.6744162",
"0.66607004",
"0.6628896",
"0.6607424",
"0.6579199",
"0.653911",
"0.6523307",
"0.6515003",
"0.64933056... | 0.766848 | 0 |
Create tracklist files for every arguments | def run
@files.each do |file|
generate_tracklist(file)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_add\n file_paths = ARGV.dup\n\n file_paths.map! { |path| File.expand_path(path) }\n \n file_paths.each do |path|\n ensure_exists(path)\n end\n\n audiofiles = file_paths.map do |path|\n af = nil # SCOPE\n TagLib::FileRef.open(path) do |ref|\n if ref.null?\n warnx(\"#{path}: not an ... | [
"0.61979294",
"0.60090184",
"0.5938685",
"0.59232676",
"0.5852928",
"0.5827012",
"0.5758497",
"0.5654801",
"0.5643339",
"0.56404024",
"0.56303674",
"0.5620228",
"0.55967206",
"0.55612767",
"0.5545584",
"0.55431455",
"0.55284953",
"0.55196846",
"0.5499629",
"0.54539156",
"0.54... | 0.67386365 | 0 |
Write a method that takes an array of integers and an integer to search for. The method should return the index of the item, or nil if the integer is not present in the array. Don't use builtin array methods like .index. You are allowed to use .length and .each. Here's an example of how we might use your method (assumi... | def search_array(array, integer)
index = 0
while index < array.length
if array[index] == integer
return index
end
index += 1
end
puts "This integer is not included."
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def array_search(array, integer)\n count = 0\n stored_index_matches = []\n integer_index = nil\n while count < array.length\n if array[count] == integer\n integer_index = count\n stored_index_matches << integer_index\n count += 1\n else\n count += 1\n end\n end\n if integer_index... | [
"0.8767305",
"0.8630129",
"0.8515967",
"0.84132564",
"0.83563644",
"0.8350822",
"0.8306866",
"0.8270702",
"0.82659185",
"0.8241706",
"0.8218574",
"0.81912494",
"0.8177701",
"0.8116235",
"0.80885917",
"0.80707973",
"0.80228907",
"0.79947245",
"0.7979352",
"0.7972315",
"0.78890... | 0.79958445 | 17 |
get results from API | def results(path, params = {}, opts = {})
get(path, params, opts)['results']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def results\n response['data']\n end",
"def get_results\n\n # An internal counter to get the next\n # set of results from the API\n @result_count = 0\n\n # An array into which the API results can\n # be collected\n @results = []\n\n # Get the first set of results from the API\n json_r... | [
"0.767701",
"0.7573205",
"0.7234124",
"0.72020507",
"0.7159011",
"0.7145745",
"0.7023054",
"0.70038146",
"0.6994885",
"0.6979084",
"0.6947449",
"0.6907097",
"0.68875456",
"0.68720204",
"0.686931",
"0.6841",
"0.68353254",
"0.6811524",
"0.6790491",
"0.67601705",
"0.6740541",
... | 0.64474267 | 44 |
get cache version from CDN | def get_cache_version
data = get_from_cdn('version', {t: Time.now.to_i}, {public: true, uncompressed: true})
unless data
Tml.logger.debug('No releases have been published yet')
return '0'
end
data['version']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def version_for_cache\n \"download_url:#{source[:url]}|#{digest_type}:#{checksum}\"\n end",
"def fetch\n self.version = begin\n ver = cache.fetch(CACHE_VERSION_KEY) do\n {'version' => Tml.config.cache[:version] || 'undefined', 't' => cache_timestamp}\n end\n validate_ca... | [
"0.76647216",
"0.6983914",
"0.68580884",
"0.67800075",
"0.6721887",
"0.66773003",
"0.6515264",
"0.644718",
"0.6445817",
"0.6335401",
"0.6335401",
"0.6335401",
"0.6335401",
"0.6335401",
"0.6335401",
"0.6335401",
"0.6335401",
"0.6335401",
"0.6329364",
"0.6270976",
"0.62432224",... | 0.84086204 | 0 |
get from the CDN | def get_from_cdn(key, params = {}, opts = {})
if Tml.cache.version.invalid? and key != 'version'
return nil
end
response = nil
cdn_path = get_cdn_path(key, opts)
trace_api_call(cdn_path, params, opts.merge(:host => cdn_host)) do
begin
response = cdn_connection.get do |request|
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_from_cdn(slug, query = {}, id = nil)\n Request.new(self, \"/cdn/#{slug}\", query, id).get\n end",
"def index\n @cdn = 'https://avia.tickets.ru.default.staging.ttndev.com'\n end",
"def cdn_url\n unless defined?(@cdn_url)\n self.cdn_url = DEFAULT_CDN_URL\n end\n\n @cdn_ur... | [
"0.6787455",
"0.64344454",
"0.64078605",
"0.622766",
"0.62100583",
"0.6086183",
"0.6085073",
"0.6065835",
"0.60475683",
"0.6015261",
"0.5972909",
"0.5940724",
"0.5934942",
"0.592774",
"0.5914099",
"0.5909515",
"0.59045714",
"0.5898205",
"0.58774596",
"0.58692366",
"0.586811",... | 0.57279176 | 30 |
should the API go to live server | def live_api_request?
# if no access token, never use live mode
return false if access_token.nil?
# if block is specifically asking for it or inline mode is activated
Tml.session.inline_mode? or Tml.session.block_option(:live)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def go_live!\n self.api_endpoint = ENDPOINTS[:live][:api]\n self.pipeline_endpoint = ENDPOINTS[:live][:cbui]\n end",
"def is_api?\n false\n end",
"def api; end",
"def api; end",
"def from_api?; false end",
"def api_request?\n false\n end",
"def api_only; end",
"def api_only; ... | [
"0.70356965",
"0.6551053",
"0.6480305",
"0.6480305",
"0.64565474",
"0.6427468",
"0.6416886",
"0.6416886",
"0.6416886",
"0.6413284",
"0.6299056",
"0.624606",
"0.6242856",
"0.6231882",
"0.6173058",
"0.61349094",
"0.61331075",
"0.6062591",
"0.6046016",
"0.60105157",
"0.60093063"... | 0.6000638 | 28 |
checks if cache is enable | def cache_enabled?(opts)
# only gets ever get cached
return false unless opts[:method] == :get
return false if opts[:cache_key].nil?
return false unless Tml.cache.enabled?
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enabled?\n @cache_enabled\n end",
"def enabled?\n @cache_enabled\n end",
"def cache?\n caching && true\n end",
"def enabled?\n @config[:caching][:enabled]\n end",
"def cacheable?\n true\n end",
"def cache?\n false\n end",
"def cacheable?\n... | [
"0.81002283",
"0.81002283",
"0.7935995",
"0.7888146",
"0.78287065",
"0.77961874",
"0.76731455",
"0.76308584",
"0.7597265",
"0.7597265",
"0.75684845",
"0.75684845",
"0.75632626",
"0.75116867",
"0.7504043",
"0.7431417",
"0.7404764",
"0.7334416",
"0.7310652",
"0.7254841",
"0.723... | 0.76215714 | 8 |
checks mode and cache, and fetches data | def api(path, params = {}, opts = {})
# inline mode should always use API calls
if live_api_request?
params = params.merge(:access_token => access_token, :app_id => application.key)
return process_response(execute_request(path, params, opts), opts)
end
return unless cache_enabled?(opts)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _fetch\n cache_get(:_fetch) || @opts[:fetch]\n end",
"def cache_on?; end",
"def cache_on?; end",
"def cache\n DataCache\n end",
"def cache; end",
"def cache; end",
"def cache; end",
"def cache; end",
"def cache; end",
"def cache; end",
"def cache; end",
"def cached?; end",... | [
"0.69510424",
"0.6718811",
"0.6718811",
"0.66390353",
"0.656912",
"0.656912",
"0.656912",
"0.656912",
"0.656912",
"0.656912",
"0.656912",
"0.650384",
"0.6465237",
"0.6464358",
"0.6398518",
"0.6369102",
"0.63197696",
"0.63197696",
"0.63197696",
"0.63197696",
"0.6280398",
"0.... | 0.0 | -1 |
paginates through API results | def paginate(path, params = {}, opts = {})
data = get(path, params, opts.merge({'raw' => true}))
while data
if data['results'].is_a?(Array)
data['results'].each do |result|
yield(result)
end
else
yield(data['results'])
end
if data['pagination'] and dat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def paginate_all_data(url:, more_params: nil)\n query_params = \"since=#{@start_date}&until=#{@end_date}#{more_params ? \"&#{more_params}\" : ''}\"\n total_count = parse_json_from_api(\"#{url}?#{query_params}\")['page']['total_elements']\n puts \"[#{Time.new.strftime('%k:%M')}] total count for #{url}?#{query_pa... | [
"0.750995",
"0.70755816",
"0.70558906",
"0.70189464",
"0.686853",
"0.684405",
"0.68119764",
"0.6801764",
"0.6795103",
"0.67943615",
"0.6749409",
"0.6741508",
"0.67390716",
"0.67171884",
"0.6689035",
"0.66662496",
"0.66374516",
"0.6624825",
"0.6605624",
"0.660293",
"0.6599626"... | 0.6968677 | 4 |
get object class from options | def object_class(opts)
return unless opts[:class]
opts[:class].is_a?(String) ? opts[:class].constantize : opts[:class]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def class_name_from_options_object_or_class_name(class_name, options={})\n if options.has_key?(:object)\n options[:object].class\n else\n klass = class_name.to_s.classify.constantize\n end \n end",
"def model_from_options #nodoc\n @options[:class_name].ni... | [
"0.7809447",
"0.76796746",
"0.76707155",
"0.7632003",
"0.6883716",
"0.67408144",
"0.6690811",
"0.6497376",
"0.64721125",
"0.64673215",
"0.64125824",
"0.63948107",
"0.62916005",
"0.627215",
"0.6267384",
"0.6249081",
"0.6240605",
"0.6217699",
"0.6217609",
"0.6189834",
"0.618779... | 0.75881004 | 4 |
convert params to query | def to_query(hash)
query = []
hash.each do |key, value|
query << "#{key.to_s}=#{value.to_s}"
end
query.join('&')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_query(params)\n p = []\n params.each do |k,v|\n p << \"#{k}=#{v}\"\n end\n\n p.join \"&\"\n end",
"def to_query(params)\n params.map{|k,v| \"#{CGI::escape(k.to_s)}=#{CGI::escape(v.to_s)}\"}.join('&')\n end",
"def to_query(params)\n params.to_query.gsub(\"=\", \"%3D\").gsub... | [
"0.81687856",
"0.8043054",
"0.801108",
"0.77049375",
"0.7688457",
"0.7598513",
"0.7598513",
"0.7589697",
"0.7441789",
"0.7419318",
"0.7375283",
"0.7351151",
"0.7199683",
"0.7176989",
"0.70919853",
"0.70405746",
"0.70170766",
"0.69898117",
"0.69706964",
"0.6963376",
"0.6942878... | 0.6425024 | 86 |
trace api call for logging | def trace_api_call(path, params, opts = {})
if Tml.config.logger[:secure]
[:access_token].each do |param|
params = params.merge(param => "##filtered##") if params[param]
end
end
path = "#{path[0] == '/' ? '' : '/'}#{path}"
if opts[:method] == :post
Tml.logger.debug("post: #{o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_http_call(payload); end",
"def log_http_call(payload); end",
"def trace!\n request! :trace\n end",
"def __trace(method, path, params, body, url, response, json, took, duration)\n trace_url = \"http://localhost:9200/#{path}?pretty\" +\n ( params.empty? ? '' : \"&#{:... | [
"0.7530636",
"0.7530636",
"0.75142497",
"0.7345314",
"0.7259728",
"0.7184063",
"0.69135815",
"0.68136066",
"0.67793596",
"0.67383313",
"0.65950966",
"0.65950966",
"0.65950966",
"0.65950966",
"0.65950966",
"0.65950966",
"0.65950966",
"0.65950966",
"0.6588646",
"0.6527601",
"0.... | 0.76482236 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_user
@user = User.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 |
Only allow a trusted parameter "white list" through. | def user_params
params.require(:user).permit(:username, :password, :password_confirmation)
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 |
This method instructs the technician to image the given gel. | def image_gel gel, image_name
show do
title "Image gel #{gel}"
check "Clean the transilluminator with ethanol."
check "Put the gel #{gel} on the transilluminator."
check "Turn off the room lights before turning on the transilluminator."
check "Put the camera hood on, turn o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_gonullu\n @gonullu = Gonullu.find(params[:id])\n end",
"def saveReportAndGelImages(inputStr, num_samples)\n \n # number of rows in striwell plate\n rows = (num_samples/WELLS_PER_STRIPWELL.to_f).ceil\n \n show do \n title \"Save PDF and gel images\"\n ... | [
"0.564657",
"0.5533312",
"0.54516685",
"0.53099066",
"0.52793354",
"0.51666254",
"0.5099062",
"0.50289184",
"0.4975592",
"0.49450392",
"0.4899113",
"0.489393",
"0.48754197",
"0.48618728",
"0.4853254",
"0.48394895",
"0.48394895",
"0.48306644",
"0.48223236",
"0.48082736",
"0.47... | 0.70676124 | 0 |
This method tells the technician to verify fragment lengths for the given gel. | def check_frag_length gel, grouped_ops
show {
title "Verify Fragment Lengths for gel #{gel}"
table grouped_ops.start_table
.custom_column(heading: "Gel ID") { |op| op.input(FRAGMENT).item.id }
.custom_column(heading: "Row") { |op| op.input(FRAGMENT).row + 1 }
.custom_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def length(start_t, end_t, geores)\n return do_length(start_t, end_t, geores)\n end",
"def check_to_addr_length(block, transaction)\n if transaction.to_addr.length != 6\n puts \"Line #{block.block_number}: the to address #{transaction.to_addr} is too long.\"\n return false\... | [
"0.54140234",
"0.5281467",
"0.52686113",
"0.5206956",
"0.5177423",
"0.51546425",
"0.50913954",
"0.5026284",
"0.49581504",
"0.49581504",
"0.49248472",
"0.4888507",
"0.48702693",
"0.4868547",
"0.48620534",
"0.48336592",
"0.48283926",
"0.48100132",
"0.48047143",
"0.47987336",
"0... | 0.79853255 | 0 |
This method instructs the technician to cut out fragments associated to the given operations. | def cut_fragments grouped_ops
show {
title "Cut Out Fragments"
check "Take out #{grouped_ops.length} 1.5 mL tubes and label accordingly: #{grouped_ops.map { |op| "#{op.output("Fragment").item}" }.to_sentence}"
check "Now, cut out the bands and place them into the 1.5 mL tubes according t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleanup\n show do\n title \"Discard stripwells\"\n note \"Please discard all stripwells.\"\n operations.each do |op|\n op.input(\"PCR\").collection.mark_as_deleted\n end\n end\n \n show do\n title \"Make sure machine in parked position\"\n check \"Click \\\"Pr... | [
"0.60441583",
"0.58108044",
"0.5600317",
"0.5583106",
"0.5422177",
"0.5262113",
"0.5132756",
"0.5132756",
"0.51175237",
"0.5056944",
"0.50132215",
"0.50026506",
"0.4975581",
"0.49565533",
"0.49510932",
"0.49508694",
"0.4938602",
"0.4936642",
"0.4920512",
"0.49053377",
"0.4897... | 0.70585316 | 0 |
This method instructs the technician to weigh gel slices. | def weigh_fragments grouped_ops
show {
title "Weigh Gel Slices"
note "Perform this step using the scale inside the gel room."
check "Zero the scale with an empty 1.5 mL tube."
check "Weigh each slice and enter the weights in the following table:"
table grouped_ops.start_tab... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distribute_gels\n show do\n title \"Equally distribute melted gel slices between tubes\"\n note \"Please equally distribute the volume of the following tubes each between two 1.5 mL tubes:\"\n table operations.select{ |op| op.temporary[:is_divided]}.start_table\n .input_item(INPUT)\n ... | [
"0.56841254",
"0.5329414",
"0.5304679",
"0.5304679",
"0.51714206",
"0.50884223",
"0.5062749",
"0.505402",
"0.4926785",
"0.4901013",
"0.48083654",
"0.48083654",
"0.4799546",
"0.47229984",
"0.4699865",
"0.46893787",
"0.467285",
"0.46473932",
"0.46258768",
"0.46227458",
"0.45975... | 0.50667465 | 6 |
This method instructs the technician to clean up and dispose of gels. | def clean_up gel, gels
show {
title "Clean Up"
check "Turn off the transilluminator."
check "Dispose of the gel #{gel} and any gel parts by placing it in the waste container. Spray the surface of the transilluminator with ethanol and wipe until dry using a paper towel."
check "Clea... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dispose\n dispose_backgrounds\n dispose_sprites\n dispose_weather\n dispose_timer\n dispose_viewports\n end",
"def close\n @pool.dispose\n end",
"def dispose; end",
"def dispose\n return if @ptr.nil?\n do_finalization\n C.dispose_pass_manager(@ptr)\n @ptr = nil... | [
"0.57954496",
"0.5784859",
"0.5742562",
"0.5672827",
"0.56530416",
"0.56161165",
"0.5613865",
"0.5607113",
"0.55989486",
"0.55989486",
"0.55989486",
"0.55989486",
"0.5582154",
"0.55802697",
"0.55740327",
"0.5569289",
"0.5569289",
"0.5568204",
"0.5568204",
"0.55357915",
"0.553... | 0.59921557 | 0 |
=begin Updates the table cards if cards delt after a set result in no set being available. They are replaced. Written by: Sina =end | def updateTable(tableCards, deck)
while deck.deckSize!=0 && (tableCards.size<12 || findSets(tableCards).size==0)
tableCards.push(deck.dealCard!)
tableCards.push(deck.dealCard!)
tableCards.push(deck.dealCard!)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def noSetsBehavior (table, player,deck)\n player.increase_score\n if deck.cardCount == 0\n puts \"There is no set! We don't have cards left, Game Set!\"\n else\n table.changeCards(table.currentTable[0], table.currentTable[1], table.currentTable[2],deck)\n puts \"There is no set! Try again with updated ... | [
"0.71001416",
"0.69512504",
"0.65828496",
"0.65294504",
"0.64495856",
"0.6401883",
"0.63844",
"0.63314253",
"0.6261808",
"0.6198511",
"0.61926824",
"0.6189197",
"0.61262727",
"0.6123252",
"0.61217105",
"0.6095231",
"0.60856205",
"0.60846657",
"0.60725534",
"0.6068415",
"0.606... | 0.78803027 | 0 |
=begin This method prints the title. The ASCII art is from a website. Dr. Shareef approved the use of this. Written by: Roman =end | def printWelcome
system "clear"
puts '
__ ________ _ _____ ____ __ __ ______
\ \ / | ____| | / ____/ __ \| \/ | ____|
\ \ /\ / /| |__ | | | | | | | | \ / | |__
\ \/ \/ / | __| | | | | | | | | |\/| | __|
\ /\ / | |____| |___| |___| |__| | | | | |____... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def title(title)\n puts\n puts colorize(title, :bold, :white)\n line(:green)\n end",
"def print_title\n type(\"ZJCRUMPTON PRESENTS:\".green.to_s, 'mid')\n print \"\n #{\"______ _ _ ______ __ _\n | | | \\\\ | | | | | | | \\\\ \\\\ \\\\ | |\n | |__| | | | | | | |--... | [
"0.81673574",
"0.80841106",
"0.8040086",
"0.8025382",
"0.7894693",
"0.7878057",
"0.7878057",
"0.78696835",
"0.7861849",
"0.76628613",
"0.76326084",
"0.759979",
"0.75882477",
"0.7581833",
"0.7576905",
"0.7569385",
"0.7569385",
"0.7569385",
"0.7569385",
"0.7569385",
"0.7569385"... | 0.0 | -1 |
Delete Product By Id | def procurement_products_id_delete(id, opts = {})
procurement_products_id_delete_with_http_info(id, opts)
return nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_by_id(id)\n delete_product_by_id(id)\n end",
"def delete_product(id)\n @client.raw('delete', \"/ecommerce/products/#{id}\")\n end",
"def delete\n self.class.delete_product_by_id(self.id)\n end",
"def delete\n Product.destroy(params[:id])\n redirect_to dashboard_path\n... | [
"0.85897267",
"0.85084724",
"0.816126",
"0.79919326",
"0.796799",
"0.78782034",
"0.7771239",
"0.77210855",
"0.76672876",
"0.7607345",
"0.75022405",
"0.7493996",
"0.7475439",
"0.7475439",
"0.74684155",
"0.7453532",
"0.7422641",
"0.7420553",
"0.7408078",
"0.73851246",
"0.737923... | 0.0 | -1 |
Delete Product By Id | def procurement_products_id_delete_with_http_info(id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: ProductsItemApi.procurement_products_id_delete ..."
end
# verify the required parameter 'id' is set
fail ArgumentError, "Missing the required par... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_by_id(id)\n delete_product_by_id(id)\n end",
"def delete_product(id)\n @client.raw('delete', \"/ecommerce/products/#{id}\")\n end",
"def delete\n self.class.delete_product_by_id(self.id)\n end",
"def delete\n Product.destroy(params[:id])\n redirect_to dashboard_path\n... | [
"0.85897267",
"0.85084724",
"0.816126",
"0.79919326",
"0.796799",
"0.78782034",
"0.7771239",
"0.77210855",
"0.76672876",
"0.7607345",
"0.75022405",
"0.7493996",
"0.7475439",
"0.7475439",
"0.74684155",
"0.7453532",
"0.7422641",
"0.7420553",
"0.7408078",
"0.73851246",
"0.737923... | 0.0 | -1 |
Get Product By Id | def procurement_products_id_get(id, opts = {})
data, _status_code, _headers = procurement_products_id_get_with_http_info(id, opts)
return data
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getProduct(id)\n @products.find {|prod| prod.productId.to_i == id.to_i}\n end",
"def get_product_by_id(product_id)\n return Product.find(product_id)\n end",
"def find_by_id(id)\n get_product_by_id(id)\n end",
"def product(product_id)\n FarMar::Product.all.find { |product| product.i... | [
"0.8708508",
"0.85347825",
"0.843556",
"0.81763345",
"0.78564495",
"0.7848824",
"0.7838425",
"0.7784068",
"0.77791196",
"0.77619314",
"0.774326",
"0.75933135",
"0.74450564",
"0.74399054",
"0.7435381",
"0.7431306",
"0.7402735",
"0.7312172",
"0.7154256",
"0.7131732",
"0.7090488... | 0.0 | -1 |
Get Product By Id | def procurement_products_id_get_with_http_info(id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: ProductsItemApi.procurement_products_id_get ..."
end
# verify the required parameter 'id' is set
fail ArgumentError, "Missing the required parameter... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getProduct(id)\n @products.find {|prod| prod.productId.to_i == id.to_i}\n end",
"def get_product_by_id(product_id)\n return Product.find(product_id)\n end",
"def find_by_id(id)\n get_product_by_id(id)\n end",
"def product(product_id)\n FarMar::Product.all.find { |product| product.i... | [
"0.8708508",
"0.85347825",
"0.843556",
"0.81763345",
"0.78564495",
"0.7848824",
"0.7838425",
"0.7784068",
"0.77791196",
"0.77619314",
"0.774326",
"0.75933135",
"0.74450564",
"0.74399054",
"0.7435381",
"0.7431306",
"0.7402735",
"0.7312172",
"0.7154256",
"0.7131732",
"0.7090488... | 0.6689094 | 58 |
This method intentionally does not use SecureRandom, because it relies on urandom, which raises an exception in MRI when the interpreter runs out of allocated file descriptors. The guids generated by this method may not be _secure_, but they are random enough for our purposes. | def generate_guid(length = 16)
guid = case length
when 16
rand(MAX_RAND_16)
when 32
rand(MAX_RAND_32)
else
rand(16**length)
end.to_s(16)
guid.length < length ? guid.rjust(length, '0') : guid
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_random\n File.read(\"/dev/urandom\", 8).unpack(\"H*\")[0].hex\n rescue\n rand(9117854927)\n end",
"def create_guid\n self.guid = SecureRandom.uuid\n end",
"def random_uid\n SecureRandom.hex 5\n end",
"def generate_guid\n begin\n guid = SecureRandom.urlsafe_ba... | [
"0.6994666",
"0.67945087",
"0.6748681",
"0.6714791",
"0.6714791",
"0.6713919",
"0.6705493",
"0.66792315",
"0.6638163",
"0.6605697",
"0.6535889",
"0.6521189",
"0.6393062",
"0.631361",
"0.63075024",
"0.6272241",
"0.6247869",
"0.6243133",
"0.62186146",
"0.6213429",
"0.6190108",
... | 0.5835403 | 60 |
actions for logged in users | def show
@user = User.friendly.find(params[:id])
@posts = @user.posts.order(:created_at).page params[:page]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n redirect_to(:action => 'login') and return unless logged_in?\n \n @user = current_user\n end",
"def user_actions(user)\n can_act_as_logged_in_user(user) unless Revs::Application.config.restricted_beta # also have logged in privileges if we are not in beta\n end",
"def index\n # set... | [
"0.7306586",
"0.70516783",
"0.6977699",
"0.6977699",
"0.6976283",
"0.6931941",
"0.68858385",
"0.6853737",
"0.6841235",
"0.68352383",
"0.68192744",
"0.68176913",
"0.6791955",
"0.6791955",
"0.67882264",
"0.6775873",
"0.6735452",
"0.67246646",
"0.67070407",
"0.669417",
"0.667854... | 0.0 | -1 |
actions to register a account | def new
@user = User.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_account\n profile = Profile.new(params[:profile])\n profile = update_profile_for_register_account(profile)\n if save_objeck(profile)\n if Notifier.trigger_register_thank_you(profile.id)\n profile.histories.create(:message => \"Register Thank You email sent\")\n... | [
"0.73590285",
"0.73133105",
"0.7046741",
"0.70117575",
"0.6941932",
"0.6917717",
"0.68936026",
"0.68400544",
"0.68400544",
"0.68072224",
"0.67973465",
"0.6774164",
"0.67489594",
"0.674639",
"0.67354506",
"0.6730601",
"0.6716462",
"0.66687983",
"0.66687983",
"0.66687983",
"0.6... | 0.0 | -1 |
actions for owner of account | def edit
@user = User.friendly.find(params[:id])
if not_owner_check(@user)
redirect_to current_user
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def owner(account,id) \n if !account.owner(id) && !admin_signed_in?\n redirect_to root_url, notice: \"bad owner!\"\n end\n end",
"def owner(account,id) \n if !account.owner(id) && !admin_signed_in?\n redirect_to root_url, notice: \"bad owner!\"\n end\n end",
"def owner_o... | [
"0.71772766",
"0.71772766",
"0.7051747",
"0.6846193",
"0.682202",
"0.6798854",
"0.66654485",
"0.6551083",
"0.6544743",
"0.6503103",
"0.6480626",
"0.6397972",
"0.6374214",
"0.63663906",
"0.633275",
"0.62996477",
"0.6299214",
"0.62777627",
"0.627743",
"0.6270701",
"0.62572765",... | 0.60675466 | 35 |
the install location of ameem | def ameem_location
$ameem_location
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def install_dir\n Crate.project.install_dir\n end",
"def os_install_dir\n @os_install_dir\n end",
"def user_install_dir\n eval_path(find_val('user_install_dir') || home_dir)\n end",
"def install_directory\n \"C:\\\\opscode\\\\chef\"\n end",
"def installer_path\n %x[wh... | [
"0.6588749",
"0.64576817",
"0.6451305",
"0.6416124",
"0.6377108",
"0.6346813",
"0.6335459",
"0.6237625",
"0.62191045",
"0.62028366",
"0.61977464",
"0.6184897",
"0.6173553",
"0.5977952",
"0.59395975",
"0.59021944",
"0.59021944",
"0.590105",
"0.5889144",
"0.5867315",
"0.5853327... | 0.59729713 | 14 |
find the category name corresponding to the given file path e.g. if input is /home/me/devel/amee/transport/car/generic, output is tranport/car/generic | def find_category(file)
file.match(Regexp.new(Regexp.escape(csv_root))) or
raise AMEEM::Exceptions::Location.new("#{file} is not in CSV tree")
file.sub(Regexp.new(Regexp.escape(csv_root)),"");
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_category text\n #text = File.join(@path, t)\n if File.directory? text\n return :dir\n elsif File.executable? text\n return :executable\n elsif File.symlink? text\n return :link\n elsif File.exists? text\n if text =~ /\\.txt$/\n return :text\n ... | [
"0.68994355",
"0.6640812",
"0.62982243",
"0.62696946",
"0.62138146",
"0.61901",
"0.616347",
"0.6068479",
"0.6067369",
"0.60368085",
"0.5988359",
"0.59026015",
"0.5896371",
"0.58771884",
"0.5834808",
"0.5811244",
"0.58058065",
"0.58034545",
"0.5795773",
"0.5795009",
"0.5746728... | 0.67856354 | 1 |
create an absolute file path for a path given relative to the current root of ameem operations e.g. if root is set to current folder (.) , and are standing in ~/devel/amee/apicsvs/transport/car input: generic, output: /home/me/devel/amee/apicsvs/transport/car/generic | def based_on_root(rel_path)
File.expand_path(File.join(options.root,rel_path))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def root_path(path) File.join(root, path) end",
"def input_base_path(input_file,ext=nil)\n input_path=Pathname.new(input_file)\n throw \"Error: Input directory #{input_path.dirname} does not exist\" unless input_path.dirname.exist?\n dir=input_path.dirname.realpath.to_s\n ... | [
"0.66305244",
"0.6485387",
"0.6464295",
"0.64496946",
"0.63346124",
"0.6307481",
"0.62723047",
"0.62723047",
"0.6258136",
"0.62446564",
"0.6233995",
"0.61520624",
"0.6130217",
"0.61292624",
"0.6105278",
"0.609221",
"0.6064241",
"0.6058013",
"0.605482",
"0.6048996",
"0.6030531... | 0.58661 | 39 |
return api category path, based on path relative to current ameem root e.g. when standing in ~/devel/amee/apicsvs/transport/car, input: generic, output: transport/car/generic | def category(rel_path)
find_category based_on_root rel_path
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def api_path(path)\n \"#{options[:base_path]}/#{path}\" || \"/#{path}\"\n end",
"def category\n path = @path_remote.split('/')\n return path[3] # Could require changes depending on the structure of the maps repo\n end",
"def path\n # if an api_version is specified and the path does no... | [
"0.6738553",
"0.65938073",
"0.63345337",
"0.6318653",
"0.63063306",
"0.62864286",
"0.62597185",
"0.6236903",
"0.61943907",
"0.6184125",
"0.60027987",
"0.5998136",
"0.59849864",
"0.5951923",
"0.59411955",
"0.59063566",
"0.5880687",
"0.5850547",
"0.5827725",
"0.5819739",
"0.576... | 0.60103834 | 10 |
and tuple[1] represents its dependency, determine the order in which the packages should be installed. Only packages that have dependencies will be listed, but all packages from 1..max_id exist. N.B. this is how `npm` works. Import any files you need to | def install_order(arr)
hash = Hash.new
arr.each do |tup|
if hash[tup[0]].nil?
hash[tup[0]] = []
end
if hash[tup[1]]
hash[tup[1]].push(tup[0])
else
hash[tup[1]] = [tup[0]]
end
end
max = hash.keys.max
#insert missing nodes
(1..max).each do |i|
unless hash[i]
has... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def install_order(arr)\n vertices = []\n dependencies = Hash.new([])\n\n # find max_id\n max_id = 0\n arr.each do |package|\n max_id = package[0] if package[0] > max_id\n max_id = package[1] if package[1] > max_id\n\n # map dependencies\n dependencies[package[0]] += [package[1]]\n end\n\n # comp... | [
"0.675187",
"0.67132795",
"0.616176",
"0.61614823",
"0.6134685",
"0.6132012",
"0.61149544",
"0.60736763",
"0.6070665",
"0.6070665",
"0.6058421",
"0.5983973",
"0.5983897",
"0.5957476",
"0.59562457",
"0.59380054",
"0.5926231",
"0.58991534",
"0.5877549",
"0.58141583",
"0.5771654... | 0.0 | -1 |
test hack to in place change object type | def add_space_field(name,type)
class_type = Parfait.object_space.get_type_by_class_name(:Space)
class_type.send(:private_add_instance_variable, name , type)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def correct_type?(object)\n object.type == type\n end",
"def nonregular_type; end",
"def type(type); end",
"def type=(_); end",
"def type=(_); end",
"def type=(_); end",
"def type=(_); end",
"def type=(_); end",
"def vanilla_object(object)\n type = get_type(object)\n\n # I wanted to call ... | [
"0.6988366",
"0.6876899",
"0.6629268",
"0.6535772",
"0.6535772",
"0.6535772",
"0.6535772",
"0.6535772",
"0.6434367",
"0.6424378",
"0.63726616",
"0.63726616",
"0.63539726",
"0.6350381",
"0.6350235",
"0.6284709",
"0.6275142",
"0.61725754",
"0.61581826",
"0.6151854",
"0.61466795... | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_booking
@booking = Booking.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.6163443",
"0.604317",
"0.5943409",
"0.59143174",
"0.5887026",
"0.58335453",
"0.57738566",
"0.5701527",
"0.5701527",
"0.56534666",
"0.5618685",
"0.54237175",
"0.5407991",
"0.5407991",
"0.5407991",
"0.5394463",
"0.5376582",
"0.5355932",
"0.53376216",
"0.5337122",
"0.5329516"... | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def booking_params
params.permit(:date, :name, :description,
:beginning_hour, :ending_hour)
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 |
Initialize a new driver. | def initialize
@connection = nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize driver\n @driver = driver\n end",
"def initialize(driver)\n\t\tsuper\n\n\t\tself.driver = driver\n\tend",
"def initialize(driver)\r\n @@driver = driver\r\n end",
"def driver_initialize\n\t\t#Driver initialization happens here.\n\t\tdriver = Driver::new\n\t\tdriver.seed = rand(100)\n\t\t... | [
"0.8001311",
"0.7994479",
"0.7977173",
"0.7893135",
"0.76601356",
"0.7525705",
"0.70512545",
"0.70512545",
"0.70512545",
"0.70512545",
"0.70512545",
"0.70512545",
"0.6924099",
"0.6877463",
"0.6830599",
"0.6779003",
"0.67689615",
"0.6745393",
"0.67122304",
"0.66475046",
"0.662... | 0.0 | -1 |
Returns true if the driver is connected to the server. | def connected?
@connection && @connection.connected?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connected?\n unless @server.nil?\n true\n else\n false\n end\n end",
"def is_connected?\n if @connection == nil\n return false\n else \n return true\n end\n end",
"def is_connected?\n\t\tif @connection == nil\n\t\t\treturn false\n\t\telse\n\t\... | [
"0.84754837",
"0.8328109",
"0.8247889",
"0.8189558",
"0.8124868",
"0.8115551",
"0.8077176",
"0.7985147",
"0.7905992",
"0.7905992",
"0.7885996",
"0.7871468",
"0.7855547",
"0.7853854",
"0.7827114",
"0.78235495",
"0.78221434",
"0.7802144",
"0.77889735",
"0.77861124",
"0.77825177... | 0.79451555 | 8 |
Connects to the server on +host+ and +port+ with given connection timeout. | def connect(host, port, timeout)
conn = EventMachine.connect(host, port, ConnectionClient) do |c|
c.pending_connect_timeout = [Float(timeout), 0.1].max
end
setup_connect_callbacks(conn, Fiber.current)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connect_timeout(host, port, timeout = 5)\n # Convert the passed host into structures the non-blocking calls\n # can deal with\n addr = Socket.getaddrinfo(host, nil)\n sockaddr = Socket.pack_sockaddr_in(port, addr[0][3])\n\n Socket.new(Socket.const_get(addr[0][0]), Socket::SOC... | [
"0.79646575",
"0.7914061",
"0.74750346",
"0.7079682",
"0.70552707",
"0.70019627",
"0.6820901",
"0.68187314",
"0.6800003",
"0.6796902",
"0.67419016",
"0.6585408",
"0.65781575",
"0.65574074",
"0.65399015",
"0.6522282",
"0.64994764",
"0.6498691",
"0.64821273",
"0.6470601",
"0.64... | 0.82034135 | 0 |
Disconnects the driver from the server. | def disconnect
@connection.close_connection
@connection = nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def disconnect!\n @driver.close\n ensure\n close\n end",
"def disconnect\n @server = nil\n @status = :disconnected\n end",
"def disconnect\n @connection.logout\n end",
"def disconnect\n unless @server.nil?\n @server.cmd \"quit\"\n @server.cl... | [
"0.7978401",
"0.71691674",
"0.7080979",
"0.7070415",
"0.7016455",
"0.6992555",
"0.6986615",
"0.6967444",
"0.6943314",
"0.68936664",
"0.68570125",
"0.68570125",
"0.68570125",
"0.68570125",
"0.68521154",
"0.67908615",
"0.6789287",
"0.6776981",
"0.6769438",
"0.67622787",
"0.6726... | 0.69370955 | 9 |
Send a message to the server. | def write(rawmsg)
@connection.send(rawmsg)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send(message)\n\t\t\t@conn.send(message)\n\t\tend",
"def send_message(message)\n @networking.send_message(message)\n end",
"def send_message(message)\n check_parenthesis(message)\n puts \"Send: #{message}\" if @debug\n connection{|c| c.write(message)}\n end",
"def send(message)\... | [
"0.8247518",
"0.8029219",
"0.796251",
"0.79310066",
"0.77789456",
"0.77034175",
"0.7675094",
"0.7573248",
"0.74172884",
"0.7416329",
"0.7415942",
"0.7409815",
"0.73521805",
"0.7311471",
"0.73073924",
"0.7293615",
"0.7293615",
"0.7288523",
"0.7275053",
"0.7245676",
"0.7205875"... | 0.68620384 | 49 |
Read next message from the server. | def read
status, answer, msg = @connection.read
if status == :error
raise answer
else
return [status, answer, msg]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_message\n socket.get_packet\n end",
"def next_msg\n @socket.readline.chomp.split(\" \")\n end",
"def read_reply\n @socket.readline.chomp\n end",
"def read\n until message = @reader.read_message!(@unread, @state)\n bytes = @ios.read\n if ... | [
"0.8065984",
"0.78629297",
"0.71603477",
"0.71507305",
"0.7143136",
"0.70935756",
"0.6967429",
"0.6946744",
"0.684589",
"0.6842568",
"0.6831092",
"0.6802169",
"0.67867565",
"0.675373",
"0.6719226",
"0.6712558",
"0.6712558",
"0.6699505",
"0.66772723",
"0.66684675",
"0.66595393... | 0.63654363 | 33 |
Class initializer Can be initialized with WebdavApi's directory method or with Nextcloud::Webdav::Directory.new(...credentials...) | def initialize(args)
if args.class == Nextcloud::WebdavApi
@api = args
else
super
@api = self
end
@path = "/files/#{@api.username}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def webdav(args)\n WebdavApi.new(args)\n end",
"def initialize(request, response, options={})\n raise Forbidden if request.path_info.include?('..')\n @request = request\n @response = response\n @options = options\n\n\n\n @dav_extensions = options.delete(:dav_extensions) || []\n ... | [
"0.6819364",
"0.669579",
"0.6413268",
"0.6374371",
"0.6373152",
"0.6373152",
"0.63727975",
"0.6317148",
"0.62944925",
"0.6262393",
"0.61867625",
"0.61477697",
"0.6123523",
"0.6095767",
"0.6087591",
"0.60865515",
"0.60688764",
"0.6054441",
"0.6053894",
"0.6035126",
"0.5989182"... | 0.7431598 | 0 |
Query a file, find contents of directory (including information about directory) | def find(path = "/")
response = @api.request(:propfind, "#{@path}/#{path}", nil, RESOURCE)
(has_dav_errors(response)) ? has_dav_errors(response) : directory(response)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def directory_contents(path)\n\tputs ''\n\tfor i in get_dir_contents(path)\n\t\tputs i\n\tend\n\tputs ''\n\treturn nil\nend",
"def readdir(path, fileinfo)\n puts \"#readdir \" + path\n path == \"/\" or @root.directory?(path) and @root.contents(path)\n end",
"def search(command)\n resp = @client.files... | [
"0.6853171",
"0.6770077",
"0.66330147",
"0.6443253",
"0.6434418",
"0.6368033",
"0.63372016",
"0.63329685",
"0.62265474",
"0.6175437",
"0.6160522",
"0.6148498",
"0.607566",
"0.607201",
"0.6068166",
"0.6052199",
"0.6028159",
"0.6017478",
"0.60153824",
"0.60022587",
"0.59867173"... | 0.54991734 | 61 |
Make file/directory a favorite | def favorite(path)
response = @api.request(:proppatch, "#{@path}/#{path}", nil, MAKE_FAVORITE)
parse_dav_response(response)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fave(favable)\n favorite_folder.add_favable(favable)\n end",
"def create_favorite_folder\n favorite_folders.create(name: 'Favorites', is_permanent: true)\n end",
"def set_favorite\n file = session[:user].x_files.get(params[:id])\n file = session[:user].x_files_shared_to_me.get(params[:id]... | [
"0.69185406",
"0.60348624",
"0.5978639",
"0.5978292",
"0.57379955",
"0.5714852",
"0.5693282",
"0.564716",
"0.5641638",
"0.56409305",
"0.56065",
"0.5589795",
"0.551133",
"0.551133",
"0.53445303",
"0.53289044",
"0.5325703",
"0.53166234",
"0.5292484",
"0.52776474",
"0.52718914",... | 0.5222194 | 23 |
Shows favorite files/directories in given location | def favorites(path = "/")
response = @api.request(:REPORT, "#{@path}/#{path}", nil, FAVORITE)
(has_dav_errors(response)) ? has_dav_errors(response) : directory(response, false)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fave(favable)\n favorite_folder.add_favable(favable)\n end",
"def view_favorite_locations\n if get_favorite_locations_array.empty?\n puts \"You don't have any Favorites! Why don't you add one?\"\n puts \"\\n\"\n location_menu\n else\n prints_favorite_locations\n end\n puts... | [
"0.6294033",
"0.622565",
"0.621287",
"0.6162964",
"0.6057509",
"0.59888726",
"0.59616965",
"0.5944591",
"0.59359676",
"0.5923282",
"0.5918203",
"0.5909187",
"0.5899184",
"0.5837205",
"0.5800249",
"0.57679474",
"0.5765744",
"0.57591516",
"0.574215",
"0.5709443",
"0.5687275",
... | 0.59647626 | 6 |
Parses as turns file/directory response to model object | def directory(response, skip_first = true)
response = doc_to_hash(response).try(:[], "multistatus").try(:[], "response")
response = [response] if response.is_a? Hash
return [] if response.nil?
response.each_with_index do |h, index|
prop = h["propstat"].try(:[], 0).try(:[], "... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_list_response(xml)\n [ nodes_for(xml, 'files').collect{ |node| File.new(self, node) },\n nodes_for(xml, 'folders').collect{ |node| Folder.new(@rc, self, node) } ]\n end",
"def parse(response_body)\n Filepreviews::Response.new(JSON.parse(response_body))\n end",
"def parse(respon... | [
"0.6353439",
"0.6301339",
"0.6301339",
"0.62290645",
"0.61699736",
"0.5909282",
"0.5888182",
"0.58323216",
"0.5757707",
"0.5737787",
"0.5731527",
"0.56684726",
"0.56448567",
"0.56220275",
"0.555296",
"0.55306655",
"0.5515972",
"0.55120957",
"0.5501897",
"0.5500798",
"0.548509... | 0.55225784 | 16 |
Uses an adjacency matrix for the graph and a queue for storing the nodes to be searched | def bfs(g,s)
q = []
dists = Hash.new(Float::INFINITY)
curr = s
dists[curr] = 0
#q += g[curr].each_index.select {|v| v != s && !dists.include?(v) && g[curr][v] == 1 }.map {|v| [curr,v] }
g[curr].each.with_index {|e,v| q.push [curr,v] if v != s && e == 1 && !dists.include?(v)}
whi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_to_queue(graph, queue, node, visited)\n graph.vertices[node].each do |child|\n unless visited[child]\n queue.push(child)\n visited[child] = true\n end\n end\n end",
"def path_finder \n until queue.empty? \n current_node = queue.shift()\n g... | [
"0.66979474",
"0.65425086",
"0.6423386",
"0.6279115",
"0.62408596",
"0.6179269",
"0.61514246",
"0.6076913",
"0.6053881",
"0.604792",
"0.5992898",
"0.59727985",
"0.5956452",
"0.58941",
"0.58235925",
"0.58149385",
"0.5790372",
"0.57630706",
"0.5755442",
"0.57543784",
"0.5752193... | 0.0 | -1 |
Create a link to the details show page for the given model instance. | def model_link(item, **opt)
html_opt = remainder_hash!(opt, *MODEL_LINK_OPTIONS)
type = (model_type unless item)
item ||= object
label = opt[:label] || :label
label = item.send(label) if label.is_a?(Symbol)
if opt[:no_link]
html_span(label, html_opt)
else
# noinspecti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apphelp_protected_show_link( obj, name = nil )\n return apphelp_unknown_quantity_warning() if ( obj.nil? )\n\n name = obj.name if ( name.nil? )\n link = apphelp_protected_link_to(\n :show,\n {\n :model => obj.class,\n :method => :url_for\n },\n obj\n ) { h( name )... | [
"0.6659342",
"0.65367234",
"0.646787",
"0.6465886",
"0.63848275",
"0.6297857",
"0.61478627",
"0.6076724",
"0.6040701",
"0.60360205",
"0.6035531",
"0.60277396",
"0.6020516",
"0.6020059",
"0.60187155",
"0.59917134",
"0.5983429",
"0.59787685",
"0.5950355",
"0.5942537",
"0.591191... | 0.5678901 | 94 |
Create a link to the details show page for the given model instance. | def link(css: nil, **opt)
opt[:title] = opt.delete(:tooltip) || opt[:title] || show_tooltip
prepend_css!(opt, css) if css.present?
model_link(object, **opt)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apphelp_protected_show_link( obj, name = nil )\n return apphelp_unknown_quantity_warning() if ( obj.nil? )\n\n name = obj.name if ( name.nil? )\n link = apphelp_protected_link_to(\n :show,\n {\n :model => obj.class,\n :method => :url_for\n },\n obj\n ) { h( name )... | [
"0.6658588",
"0.65371037",
"0.6467537",
"0.64657265",
"0.6383913",
"0.6297965",
"0.61481917",
"0.6076509",
"0.604068",
"0.60354173",
"0.60348856",
"0.6026552",
"0.6020268",
"0.6019581",
"0.6019266",
"0.59910715",
"0.59837604",
"0.5977697",
"0.5949302",
"0.59438336",
"0.591168... | 0.0 | -1 |
Create a link to the details show page for the given model instance. | def button_link(css: '.button', **opt)
opt[:role] ||= 'button'
link(css: css, **opt)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apphelp_protected_show_link( obj, name = nil )\n return apphelp_unknown_quantity_warning() if ( obj.nil? )\n\n name = obj.name if ( name.nil? )\n link = apphelp_protected_link_to(\n :show,\n {\n :model => obj.class,\n :method => :url_for\n },\n obj\n ) { h( name )... | [
"0.66583836",
"0.653569",
"0.6467858",
"0.64657885",
"0.6383668",
"0.6295745",
"0.614617",
"0.60747504",
"0.60407233",
"0.6035303",
"0.6035301",
"0.6027276",
"0.6019732",
"0.6019726",
"0.6019275",
"0.5990701",
"0.59817404",
"0.5978305",
"0.5952173",
"0.5942154",
"0.59114254",... | 0.0 | -1 |
The URL link for an entry in a list of controller actions. | def action_link(
action = nil,
current: nil,
label: nil,
css: '.page-action',
**opt
)
action = opt.delete(:action) || action
entry = action_entry(action, current: current, **opt)
action, current = entry.values_at(:action, :current)
return if (action == current) && current&.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def action_links(action: nil, **opt)\n opt[:action] = action || :index\n config_lookup('action_links', **opt) || {}\n end",
"def url\n @current_controller.url_for :controller => @controller_name, :action => @action_name\n end",
"def link_action_index(path = nil, url_options = {:returning... | [
"0.65822756",
"0.6485831",
"0.64284986",
"0.64284986",
"0.63497007",
"0.6263884",
"0.6263884",
"0.6164033",
"0.61371547",
"0.61213714",
"0.60668266",
"0.6056753",
"0.60188144",
"0.60152704",
"0.60096186",
"0.5997904",
"0.59728557",
"0.5907535",
"0.58940506",
"0.58645827",
"0.... | 0.58488876 | 21 |
Action links configured for the controller. | def action_links(action: nil, **opt)
opt[:action] = action || :index
config_lookup('action_links', **opt) || {}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_action_link\n if controller_path == 'admin/articles'\n case action_name\n when 'index' then t('buttons/all_articles').html_safe\n when 'new' then t('buttons/new_article').html_safe\n when 'edit' then t('buttons/edit_article').html_safe\n when 'show' then t('buttons/p... | [
"0.65174127",
"0.6411384",
"0.6366774",
"0.62997794",
"0.6161196",
"0.61563647",
"0.6138954",
"0.60683745",
"0.5980663",
"0.5980663",
"0.5979443",
"0.5935151",
"0.59226686",
"0.5906998",
"0.5825662",
"0.57469416",
"0.5744176",
"0.5739048",
"0.56974304",
"0.56974304",
"0.56814... | 0.74452424 | 0 |
Returns GeoJSON representation of the polygon | def to_geojson
coordinates = @points.map { |point| [point.longitude, point.lattitude] }
{ 'type' => 'Polygon', 'coordinates' => [coordinates] }.to_json
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def geojson\n obj = factory.parse_wkt(geometry_as_wkt)\n RGeo::GeoJSON.encode(obj).to_json\n rescue\n Geoblacklight.logger.warn \"Geometry is not valid: #{geom}\"\n default_extent\n end",
"def as_polygon\n GeoRuby::SimpleFeatures::Polygon.from_points([@points[0] == @points[-1] ? ... | [
"0.7501355",
"0.7331852",
"0.723245",
"0.7198157",
"0.717839",
"0.7111076",
"0.7107858",
"0.7067264",
"0.6841457",
"0.68107307",
"0.67120314",
"0.66695666",
"0.6654405",
"0.6634142",
"0.6630575",
"0.6612628",
"0.6582748",
"0.65450287",
"0.65391296",
"0.6505882",
"0.64857846",... | 0.84297836 | 0 |
Returns a string representation of the polygon of the form points[0] points[1] points[2] ... where each point is formatted with Pointto_s | def to_s
@points.join(' ')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_s\n result = \"Polygon, Nr. of Points: #{@polygon_points.length}\"\n # @points.each { |point| result = result + point.to_s + ', '}\n\n return result\n end",
"def to_s\n result = \"Polygon, Nr. of Points: #{@polygon_points.length}\"\n # @points.each { |point| result = result + p... | [
"0.8570106",
"0.8570106",
"0.70963025",
"0.7079294",
"0.70779353",
"0.7076008",
"0.70419747",
"0.67857593",
"0.6776724",
"0.6727609",
"0.66826016",
"0.6665535",
"0.6620155",
"0.65611315",
"0.6501842",
"0.64980775",
"0.6465642",
"0.64612514",
"0.6458239",
"0.6423335",
"0.64166... | 0.72806144 | 2 |
Two polygons are equivalent if their collection of points is equivalent. | def ==(other)
@points == other.points
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ==(other)\n return false unless other.is_a?(Polygon)\n self.hashable_content == other.hashable_content\n end",
"def as_polygon\n GeoRuby::SimpleFeatures::Polygon.from_points([@points[0] == @points[-1] ? @points : (@points + [@points[0].clone])])\n end",
"def ==(other)\n ... | [
"0.67408794",
"0.61985296",
"0.6121195",
"0.6115726",
"0.60922",
"0.60922",
"0.6063004",
"0.60330284",
"0.5882249",
"0.5634391",
"0.56337386",
"0.5530372",
"0.5517326",
"0.55159116",
"0.5496973",
"0.5415212",
"0.539256",
"0.5330018",
"0.5329393",
"0.52881706",
"0.5279179",
... | 0.57509136 | 9 |
filename => path to filename, or filename. checks the extension only. | def is_supported? filename
a = filename.split('.')
$extensions.each do |e|
return true if e == a.last.downcase
end
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ext_of(filename)\n filename =~ /((\\.[a-z]+)*)$/ ? $1 : ''\n end",
"def get_filename filename, extension = 'png'\n unless filename.nil?\n file_extension = get_extension filename\n filename = (file_extension.empty?) ? filename + '.' + extension : filename\n else\n false\... | [
"0.7596053",
"0.7521567",
"0.74890685",
"0.73115736",
"0.72354275",
"0.7223823",
"0.7189833",
"0.7181934",
"0.7181934",
"0.7181934",
"0.7119237",
"0.7079729",
"0.70579165",
"0.70541936",
"0.70505905",
"0.70394564",
"0.7038963",
"0.7023008",
"0.7014547",
"0.6986528",
"0.696553... | 0.0 | -1 |
true if photoset named 'name' exists, false otherwise. | def photoset_exist? name
@flickr.photosets.getList.each do |x|
return true if x.title == name
end
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exists? name\r\n\t\t\tunless @data[name].nil?\r\n\t\t\t\ttrue\r\n\t\t\telse\r\n\t\t\t\tfalse\r\n\t\t\tend\r\n\t\tend",
"def exists?(name)\n return false if empty? || absent?(name)\n\n storage.include?(name)\n end",
"def exists?(name)\n get(name).exists?\n end",
"def exists?... | [
"0.68712693",
"0.679247",
"0.6771681",
"0.67317027",
"0.64887345",
"0.64887345",
"0.64887345",
"0.6460106",
"0.6442559",
"0.64361256",
"0.64348143",
"0.63864535",
"0.6326164",
"0.6317534",
"0.63171977",
"0.6285771",
"0.62802887",
"0.6275411",
"0.62701124",
"0.6259712",
"0.624... | 0.86085373 | 0 |
f => path to file to upload photoset => photoset name | def upload f, photoset
return if !is_supported?(f)
id = @flickr.photos.upload.upload_file(f, f, "", Array.new,
false, false, false)
if photoset_exist? photoset
set_id = get_photoset_id(photoset)
@flickr.photosets.addPhoto set_id, id
else
@f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upload_file( user, work, filename, title, visibility )\n\n print \"uploading #{filename}... \"\n\n fileset = ::FileSet.new\n fileset.title << title unless title.nil?\n file_actor = ::CurationConcerns::Actors::FileSetActor.new( fileset, user )\n file_actor.create_metadata( work )\n file_actor.... | [
"0.6269366",
"0.60555077",
"0.59584534",
"0.5934053",
"0.5918964",
"0.58980423",
"0.5874123",
"0.5846315",
"0.5824934",
"0.5823043",
"0.5791504",
"0.57905346",
"0.5788097",
"0.57767385",
"0.5726953",
"0.57080346",
"0.5681272",
"0.5667851",
"0.56657904",
"0.56566656",
"0.56549... | 0.809276 | 0 |
Syncs a dir. path is relative | def sync_dir dir
# TODO: think of a better name scheme
# maybe the title should include the relative path?
calculated_photoset_name = "[ruphy-backup] #{dir}"
Dir.chdir @root + '/' + dir
if photoset_exist? calculated_photoset_name
#sync
flickr_list = get_file_list calculated_photoset_nam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sync_dir(dir=Dir.getwd)\n @r.cmd \"setwd('#{dir}')\"\n end",
"def sync(srcDir, dstDir)\n end",
"def fdirsync(d)\n while d != \"/\"\n Dir.open(d) do |dh|\n io = IO.for_fd(dh.fileno)\n io.fsync\n end\n d = File.dirname(d)\n end\nend",
"def fdirsync(d)\n while d != '/'\n Dir.op... | [
"0.81647444",
"0.7351109",
"0.70661837",
"0.704548",
"0.6519953",
"0.6508771",
"0.6219932",
"0.6089021",
"0.603755",
"0.59839165",
"0.59768313",
"0.5975435",
"0.5937911",
"0.5859383",
"0.58451223",
"0.58375347",
"0.57903147",
"0.5748976",
"0.5731116",
"0.57295394",
"0.5712474... | 0.66261476 | 4 |
validates the position of the rover w.r.t the current plateau | def validate_position(current_x_pos, current_y_pos)
if (@bottom_left_X_pos..@top_right_X_pos).member?(current_x_pos) &&
(@bottom_left_Y_pos..@top_right_Y_pos).member?(current_y_pos)
return true
end
return false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_rover_position\n valid_rover_position = false\n\n while !valid_rover_position\n if valid_position\n valid_rover_position = plateau.rover_in_bounds?(input[0].to_i, input[1].to_i)\n unless valid_rover_position\n puts \"Rover position out of plateau bo... | [
"0.71685153",
"0.68923175",
"0.6537349",
"0.6467648",
"0.6445853",
"0.6445853",
"0.63836837",
"0.63658273",
"0.6316283",
"0.6305146",
"0.6268084",
"0.62586814",
"0.6252437",
"0.6211974",
"0.6200124",
"0.61948144",
"0.6192424",
"0.61849",
"0.6143998",
"0.61437243",
"0.6135378"... | 0.0 | -1 |
Create/get a pairtree node for 'id' | def payload_path id
self.pairtree.mk("trnsfrm:" + id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_node(id)\n get_object('node', id)\n end",
"def new_node\n id = @nodes.size\n node = Node.new(id: id)\n @nodes.push(node)\n id\n end",
"def get_node(id)\n @nodes[id.to_i]\n end",
"def get id\n @nodes[id]\n end",
"def add id\n return u... | [
"0.6901244",
"0.65056103",
"0.64461184",
"0.6330805",
"0.6279916",
"0.6257532",
"0.62239414",
"0.61310095",
"0.6110498",
"0.6108245",
"0.60911983",
"0.60484993",
"0.598205",
"0.59502316",
"0.5949664",
"0.59476006",
"0.59423906",
"0.5934872",
"0.59186053",
"0.59103054",
"0.590... | 0.0 | -1 |
Hash method to transform a file | def payload_id file
Digest::MD5.file(file)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash_file(filename)\n file = File.read(filename)\n tlsh_hash(file.bytes)\n end",
"def hash_file path, hash_store\r\n\thexdigest = HASH_DIGEST.hexdigest(open(path, 'rb') { |io| io.read })\r\n\thash_store[hexdigest] << path\r\nend",
"def hash\r\n # TODO what if file is empty?\r\n @hash... | [
"0.757647",
"0.7461397",
"0.7386476",
"0.7255277",
"0.7215535",
"0.7125543",
"0.7060736",
"0.702632",
"0.7015796",
"0.6947264",
"0.69299847",
"0.69052184",
"0.6892942",
"0.6892942",
"0.6892942",
"0.6892942",
"0.6892942",
"0.6892942",
"0.6892942",
"0.6861234",
"0.68212295",
... | 0.0 | -1 |
Stash the original file in a Pairtree node | def stash_payload location
io = Kernel.open(location)
case io
when File
file = io
else
bsiz = 4096
file = Tempfile.new('foo')
loop do
f.write(file.read(bsiz))
end rescue EOFError
end
hash = payload_id(file)
ppath = payload_path(hash.to_s)
return ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def store!\n unlink! @original_path\n return nil unless @tempfile_path\n\n new_path = path\n FileUtils.mkdir_p File.dirname(new_path)\n result = if @tempfile_path =~ /\\/te?mp\\//\n FileUtils.move @tempfile_path, new_path\n else\n FileUtils.copy @tempfil... | [
"0.56482947",
"0.55782616",
"0.55692655",
"0.53797114",
"0.5364469",
"0.5261016",
"0.52539253",
"0.52044845",
"0.52038014",
"0.5189296",
"0.5188417",
"0.5175911",
"0.5148761",
"0.5148761",
"0.5137612",
"0.5129384",
"0.5115545",
"0.50982744",
"0.5078473",
"0.50780016",
"0.5077... | 0.53346854 | 5 |
Retrieve a file out of the pairtree node | def find_payload id, fname = 'ORIGINAL'
ppath = payload_path(id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_node(path)\n file_info(path).first[0..19]\n end",
"def file\n file_id = @attributes[\"file\"]\n file_node = NodeCache.find(file_id)\n file_node ? file_node.name : nil\n end",
"def get\n file\n end",
"def path\n @file\n end",
"def getFile(tree, na... | [
"0.67622393",
"0.67022043",
"0.6256234",
"0.61928177",
"0.61802167",
"0.6177193",
"0.6160921",
"0.61239386",
"0.605004",
"0.6029571",
"0.6029571",
"0.6029571",
"0.6029571",
"0.6027228",
"0.6027228",
"0.5935631",
"0.59130913",
"0.584948",
"0.5803863",
"0.5782325",
"0.57777905"... | 0.0 | -1 |
GET /group_docs GET /group_docs.json | def index
@group_docs = GroupDoc.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def documents(params={})\n server.get(\"#{name}/_all_docs\", params)\n end",
"def solr_docs_for_group(group_field, group_value)\n group = @solr_response[\"grouped\"][group_field][\"groups\"]\n docs_for_value = group.find {|x| x[\"groupValue\"] == group_value }\n return [] if docs_for_value... | [
"0.71093196",
"0.68124276",
"0.670138",
"0.6696496",
"0.66532356",
"0.64987427",
"0.64666975",
"0.64545494",
"0.64265865",
"0.6410229",
"0.6389942",
"0.63838536",
"0.635386",
"0.6346937",
"0.6343858",
"0.6310047",
"0.6297177",
"0.6296526",
"0.6296526",
"0.6290847",
"0.6272291... | 0.81642085 | 0 |
GET /group_docs/1 GET /group_docs/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @group_docs = GroupDoc.all\n end",
"def new\n @document = Document.new\n # @document.format = 'markdown'\n if params[:group_id]\n @owner = Group.find(params[:group_id])\n end\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @do... | [
"0.79666066",
"0.6792125",
"0.67734706",
"0.65512514",
"0.65092224",
"0.6467944",
"0.64644486",
"0.6431504",
"0.6344501",
"0.63327116",
"0.6320053",
"0.6315727",
"0.6308028",
"0.63047945",
"0.62826496",
"0.6263004",
"0.62545294",
"0.62503135",
"0.6246496",
"0.6244987",
"0.623... | 0.0 | -1 |
POST /group_docs POST /group_docs.json | def create
@group_doc = GroupDoc.new(group_doc_params)
respond_to do |format|
if @group_doc.save
format.html { redirect_to @group_doc, notice: 'Group doc was successfully created.' }
format.json { render :show, status: :created, location: @group_doc }
else
format.html { rend... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @group_docs = GroupDoc.all\n end",
"def group_doc_params\n params.require(:group_doc).permit(:group_id, :document_id)\n end",
"def new\n @document = Document.new\n # @document.format = 'markdown'\n if params[:group_id]\n @owner = Group.find(params[:group_id])\n end\n ... | [
"0.70988244",
"0.70328194",
"0.6606842",
"0.65763026",
"0.64719576",
"0.63773775",
"0.6370058",
"0.635551",
"0.6264638",
"0.6164308",
"0.60435253",
"0.5937733",
"0.59360725",
"0.5868839",
"0.5866127",
"0.5866127",
"0.57760155",
"0.5765253",
"0.57515985",
"0.57509243",
"0.5639... | 0.7622513 | 0 |
PATCH/PUT /group_docs/1 PATCH/PUT /group_docs/1.json | def update
respond_to do |format|
if @group_doc.update(group_doc_params)
format.html { redirect_to @group_doc, notice: 'Group doc was successfully updated.' }
format.json { render :show, status: :ok, location: @group_doc }
else
format.html { render :edit }
format.json { r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_group_doc\n @group_doc = GroupDoc.find(params[:id])\n end",
"def UpdateGroup params = {}\n \n APICall(path: 'groups.json',method: 'PUT',payload: params.to_json)\n \n end",
"def update\n respond_to do |format|\n if @api_v1_group_update.update(api_v1_group_update... | [
"0.6719922",
"0.6373618",
"0.6350661",
"0.6350581",
"0.63352144",
"0.6302434",
"0.625627",
"0.62454313",
"0.62125254",
"0.6162001",
"0.6160491",
"0.6160303",
"0.6115097",
"0.6090327",
"0.60874194",
"0.6080907",
"0.60735255",
"0.60724926",
"0.6059244",
"0.6024253",
"0.5997554"... | 0.7490316 | 0 |
DELETE /group_docs/1 DELETE /group_docs/1.json | def destroy
@group_doc.destroy
respond_to do |format|
format.html { redirect_to group_docs_url, notice: 'Group doc was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @doc = Doc.find(params[:id])\n @doc.destroy\n\n respond_to do |format|\n format.html { redirect_to docs_url }\n format.json { head :ok }\n end\n end",
"def delete(group)\n url = build_url(group)\n response = rest_delete(url)\n response.return!\n end"... | [
"0.7053363",
"0.696886",
"0.6960989",
"0.6953194",
"0.69471085",
"0.6926768",
"0.69259506",
"0.69247806",
"0.68831545",
"0.6823861",
"0.6817456",
"0.6815852",
"0.6787941",
"0.67820895",
"0.6768344",
"0.67457914",
"0.6742257",
"0.67411953",
"0.67403173",
"0.672693",
"0.672693"... | 0.8032597 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_group_doc
@group_doc = GroupDoc.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.6163443",
"0.604317",
"0.5943409",
"0.59143174",
"0.5887026",
"0.58335453",
"0.57738566",
"0.5701527",
"0.5701527",
"0.56534666",
"0.5618685",
"0.54237175",
"0.5407991",
"0.5407991",
"0.5407991",
"0.5394463",
"0.5376582",
"0.5355932",
"0.53376216",
"0.5337122",
"0.5329516"... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def group_doc_params
params.require(:group_doc).permit(:group_id, :document_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.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",... | 0.0 | -1 |
GET /m_answers GET /m_answers.json | def index
@m_answers = MAnswer.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def answers\n request('answers')\n end",
"def index\n @answers = @question.answers\n respond_with( @answers )\n end",
"def answers(options={})\n parse_answers(request(singular(id) + \"answers\", options))\n end",
"def answers\n @celebrity = Celebrity.find(params[:id])\n @answ... | [
"0.7958627",
"0.73922455",
"0.73743117",
"0.7361327",
"0.73564565",
"0.7284723",
"0.7284723",
"0.7284723",
"0.7284723",
"0.72768563",
"0.7173971",
"0.70617706",
"0.7026541",
"0.70201564",
"0.69921947",
"0.6989048",
"0.69163334",
"0.6893332",
"0.6893332",
"0.6893332",
"0.68933... | 0.7545567 | 1 |
GET /m_answers/1 GET /m_answers/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @answers = Answer.where(url_params)\n if @answers.size == 1\n @answers.first!\n end\n render json: @answers\n end",
"def index\n\n @answers = Answer.current\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n ... | [
"0.7706",
"0.73487306",
"0.725264",
"0.7190017",
"0.7186499",
"0.7186499",
"0.7186499",
"0.7186499",
"0.71831095",
"0.7026468",
"0.70159864",
"0.6997433",
"0.6939656",
"0.6930342",
"0.6930342",
"0.6930342",
"0.6917548",
"0.6915092",
"0.6889885",
"0.6836144",
"0.6771261",
"0... | 0.0 | -1 |
POST /m_answers POST /m_answers.json | def create
@m_answer = @m_question.m_answers.build(m_answer_params)
respond_to do |format|
if @m_answer.save
format.html { redirect_to m_question_path(@m_question) }
format.json { render action: 'show', status: :created, location: @m_answer }
else
format.html { render action:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def answers\n request('answers')\n end",
"def submit_form\n answers_params = params.permit!\n\n render json: Answer.insert_answers(answers_params, current_user[\"id\"])\n end",
"def add_answer\n request('answers/add')\n end",
"def create\n @answer = @question.answe... | [
"0.72611064",
"0.7079285",
"0.70761657",
"0.70543355",
"0.7011699",
"0.6931337",
"0.6889049",
"0.6876192",
"0.6832556",
"0.68250567",
"0.6823368",
"0.6821457",
"0.67684335",
"0.67644167",
"0.6730672",
"0.67207867",
"0.6704139",
"0.6704139",
"0.66956955",
"0.6690075",
"0.66873... | 0.73787344 | 0 |
PATCH/PUT /m_answers/1 PATCH/PUT /m_answers/1.json | def update
@m_answer = MAnswer.find(params[:id])
respond_to do |format|
if @m_answer.update(m_answer_params)
format.html { redirect_to m_question_path(@m_question), notice: 'M answer was successfully updated.' }
format.json { head :no_content }
else
format.html { render actio... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @question = Question.update(params[:id], { \n :body => params[:body], \n :answer_type => params[:answer_type] }, \n params[:answers].values\n )\n\n respond_to do |format|\n format.json { render :json => @question.as_json({:include => :answers}) }\n\n # if @que... | [
"0.74612904",
"0.736709",
"0.7244587",
"0.710731",
"0.7012291",
"0.7007289",
"0.70067656",
"0.6979187",
"0.6969945",
"0.6969945",
"0.69555724",
"0.69221175",
"0.69199884",
"0.6896854",
"0.68938136",
"0.6886175",
"0.6869277",
"0.6862056",
"0.683952",
"0.683952",
"0.683952",
... | 0.70740813 | 4 |
DELETE /m_answers/1 DELETE /m_answers/1.json | def destroy
@m_answer.destroy
respond_to do |format|
format.html { redirect_to m_question_path(@m_question) }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n answer = Answer.find(params[:answer_id])\n answer.destroy\n \n render json: {success: true}\n end",
"def destroy\n @answer = Answer.find_by_key(params[:id])\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to answers_url }\n format.json { head :n... | [
"0.77226144",
"0.7650733",
"0.75997186",
"0.7563279",
"0.7563279",
"0.75065786",
"0.75065786",
"0.7491853",
"0.74542147",
"0.7445887",
"0.74139947",
"0.73820364",
"0.7351743",
"0.7295451",
"0.7292586",
"0.728119",
"0.72745967",
"0.7250745",
"0.7250745",
"0.7250745",
"0.725074... | 0.75353634 | 5 |
Use callbacks to share common setup or constraints between actions. | def set_m_answer
@m_answer = MAnswer.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.61637366",
"0.60446453",
"0.59452957",
"0.591511",
"0.58885515",
"0.5834122",
"0.57761765",
"0.5702554",
"0.5702554",
"0.5652102",
"0.5619581",
"0.5423898",
"0.5409782",
"0.5409782",
"0.5409782",
"0.5394745",
"0.53780794",
"0.5356209",
"0.5338898",
"0.53381324",
"0.5328622... | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def m_answer_params
params.require(:m_answer).permit(:check, :answer)
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.69811666",
"0.6782836",
"0.6747644",
"0.6742015",
"0.6735273",
"0.6593917",
"0.65037674",
"0.6498627",
"0.6482372",
"0.64795715",
"0.64566946",
"0.6439213",
"0.6380714",
"0.6378147",
"0.63657266",
"0.63206697",
"0.6300169",
"0.62992156",
"0.6295538",
"0.62943023",
"0.62915... | 0.0 | -1 |
GET /user_feedbacks GET /user_feedbacks.json | def index
@user_feedbacks = UserFeedback.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @feedbacks = Feedback.find(params[:id])\n render json: @feedbacks\n end",
"def getUsersFeedback *args\n options=fill_args [:username,:userid,:type],[],*args\n if options[:username]==nil && options[:userid]==nil\n raise \"Username or userid is required\"\n end\n if opt... | [
"0.7271491",
"0.71934885",
"0.7130322",
"0.7069723",
"0.6855934",
"0.6766139",
"0.67438674",
"0.6714783",
"0.6712246",
"0.67082965",
"0.67082965",
"0.67082965",
"0.67082965",
"0.67082965",
"0.67082965",
"0.67082965",
"0.67082965",
"0.66499925",
"0.66279215",
"0.65810037",
"0.... | 0.74874085 | 0 |
GET /user_feedbacks/1 GET /user_feedbacks/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @feedbacks = Feedback.find(params[:id])\n render json: @feedbacks\n end",
"def index\n @user_feedbacks = UserFeedback.all\n end",
"def index\n @feedbacks = Feedback.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @feedbacks }\n ... | [
"0.74584234",
"0.7357725",
"0.714274",
"0.70654684",
"0.6944926",
"0.69377625",
"0.693068",
"0.693068",
"0.693068",
"0.693068",
"0.693068",
"0.693068",
"0.6869734",
"0.68237484",
"0.67983633",
"0.66791856",
"0.66791856",
"0.66791856",
"0.66791856",
"0.66791856",
"0.66791856",... | 0.0 | -1 |
POST /user_feedbacks POST /user_feedbacks.json | def create
@user_feedback = UserFeedback.new(user_feedback_params)
respond_to do |format|
if @user_feedback.save
format.html { redirect_to @user_feedback, notice: 'User feedback was successfully created.' }
format.json { render :show, status: :created, location: @user_feedback }
els... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @feedback = Feedback.new(feedback_params)\n\n if @feedback.save\n render json: @feedback, status: :created\n else\n render json: @feedback.errors, status: :unprocessable_entity\n end\n end",
"def create\n @feedback = @entry.feedbacks.new(params[:feedback].merge(user: curren... | [
"0.7114799",
"0.7070192",
"0.6988508",
"0.697134",
"0.69531447",
"0.693223",
"0.6874204",
"0.6852683",
"0.68395895",
"0.6816681",
"0.6787715",
"0.6778278",
"0.6771812",
"0.67647934",
"0.6715473",
"0.66828126",
"0.6644261",
"0.6630272",
"0.6628235",
"0.6620317",
"0.66194546",
... | 0.73643553 | 0 |
PATCH/PUT /user_feedbacks/1 PATCH/PUT /user_feedbacks/1.json | def update
respond_to do |format|
if @user_feedback.update(user_feedback_params)
format.html { redirect_to @user_feedback, notice: 'User feedback was successfully updated.' }
format.json { render :show, status: :ok, location: @user_feedback }
else
format.html { render :edit }
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @feedback_user.update(feedback_user_params)\n format.html { redirect_to @feedback_user, notice: 'Feedback user was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.js... | [
"0.69681436",
"0.6943835",
"0.6915614",
"0.68690765",
"0.68642426",
"0.68478835",
"0.68478835",
"0.68478835",
"0.68330485",
"0.68330485",
"0.68330485",
"0.68330485",
"0.68205637",
"0.68205637",
"0.68205637",
"0.68205637",
"0.6671982",
"0.6652559",
"0.6616827",
"0.6592164",
"0... | 0.727767 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.