query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
PATCH/PUT /rationales/1 PATCH/PUT /rationales/1.json | def update
respond_to do |format|
if @rationale.update(rationale_params)
format.html { redirect_to position_rationale_path, notice: 'Rationale was successfully updated.' }
format.json { render :show, status: :ok, location: @rationale }
else
format.html { render :edit }
fo... | [
"def update\n respond_to do |format|\n if @rationale.update(rationale_params)\n format.html { redirect_to @rationale, notice: 'Rationale was successfully updated.' }\n format.json { render :show, status: :ok, location: @rationale }\n else\n format.html { render :edit }\n for... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
gets the property name from the +PropertyInfo+ when the property is an indexer it will return +[]+ | def property_name_from(property_info)
return property_info.name.underscore if property_info.get_index_parameters.empty?
"get_Item"
end | [
"def property_name(property)\n property.name.to_s\n end",
"def get_name_at_index(array,index)\n JavaScriptCore::Lib.JSPropertyNameArrayGetNameAtIndex(array,index)\n end",
"def name_property\n p = properties.find { |n, p| p.name_property? }\n p ? p.first : nil\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
the binding flags for instance members of a CLR type | def instance_flags
System::Reflection::BindingFlags.public | System::Reflection::BindingFlags.instance
end | [
"def class_flags\n System::Reflection::BindingFlags.public | System::Reflection::BindingFlags.static\n end",
"def initialize_instance_members_for(klass)\n clr_type = klass.to_clr_type\n\n context = {}\n context[:properties] = clr_type.collect_interface_properties\n context[:methods] = ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
the binding flags for class members of a CLR type | def class_flags
System::Reflection::BindingFlags.public | System::Reflection::BindingFlags.static
end | [
"def instance_flags\n System::Reflection::BindingFlags.public | System::Reflection::BindingFlags.instance\n end",
"def initialize_class_members_for(klass)\n clr_type = klass.to_clr_type\n\n context = {}\n context[:methods] = clr_type.get_methods(class_flags)\n context[:properties] = cl... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
collects instance members on this interface it will collect properties, methods and property setters | def initialize_instance_members_for(klass)
clr_type = klass.to_clr_type
context = {}
context[:properties] = clr_type.collect_interface_properties
context[:methods] = clr_type.collect_interface_methods
context[:events] = clr_type.collect_interface_events
@instance_members = build_me... | [
"def instance_variables() end",
"def add_attr_accessors_to_self\n instance_variables.each do |name|\n method_name = name[1..-1].to_sym\n MetricFu::Configuration.send(:attr_accessor, method_name)\n end\n end",
"def all_attributes\n super.each do |op|\n op.class_eval { i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
collects all the static members of the provided CLR class type | def initialize_class_members_for(klass)
clr_type = klass.to_clr_type
context = {}
context[:methods] = clr_type.get_methods(class_flags)
context[:properties] = clr_type.get_properties(class_flags)
context[:events] = clr_type.get_events(class_event_flags)
@class_members = build_membe... | [
"def initialize_instance_members_for(klass)\n clr_type = klass.to_clr_type\n\n context = {}\n context[:properties] = clr_type.collect_interface_properties\n context[:methods] = clr_type.collect_interface_methods\n context[:events] = clr_type.collect_interface_events\n\n @instance_membe... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /german_armors GET /german_armors.json | def index
@german_armors = GermanArmor.all
end | [
"def index\n @armors = Armor.all\n\n render json: @armors\n end",
"def index\n @armors = Armor.all\n end",
"def armors\r\r\n @battler_ref.armors \r\r\n end",
"def index\n @ladders = Ladder.all\n\n render json: @ladders\n end",
"def index\n @mentors = Mentor.all\n respond_to do |f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /german_armors POST /german_armors.json | def create
@german_armor = GermanArmor.new(german_armor_params)
respond_to do |format|
if @german_armor.save
format.html { redirect_to @german_armor, notice: 'German armor was successfully created.' }
format.json { render :show, status: :created, location: @german_armor }
else
... | [
"def create\n @galactic_arm = Galacticarm.new(galactic_arm_params)\n\n respond_to do |format|\n if @galactic_arm.save\n format.html { redirect_to @galactic_arm, notice: 'Galactic arm was successfully created.' }\n format.json { render :show, status: :created, location: @galactic_arm }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
not used, check if rank only in one taxonomy | def get_2tax_rank(res, rank_check, taxonomy_name)
return true if ((res["classification_path_ranks"].split('|')[-1] == rank_check) && (res["data_source_title"] == taxonomy_name))
end | [
"def is_in? taxon\n r = taxon.ranks.keys.first\n return false if self[ r ].nil?\n self[ r ].downcase == taxon[ r ].downcase\n end",
"def in?(taxon)\n r = taxon.ranks.keys.first\n return false if self[r].nil?\n\n self[r].casecmp(taxon[r]).zero?\n end",
"def navy_rank; end",
"def active_rank... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /hr/config/departments GET /hr/config/departments.json | def index
@hr_config_departments = Hr::Config::Department.all
end | [
"def departments()\n require_authentication!\n options = make_options(\"getDepartments\")\n response = self.class.post(\"/WebUntis/jsonrpc.do;jsessionid=#{@session_id}?school=#{@school}\", options)\n raise response[\"error\"][\"message\"] unless response[\"error\"].nil?\n response[\"result\"]\n end"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /hr/config/departments/1 DELETE /hr/config/departments/1.json | def destroy
@hr_config_department.destroy
respond_to do |format|
format.html { redirect_to hr_config_departments_url, notice: 'លុបទទួលបានជោគជ័យ' }
format.json { head :no_content }
end
end | [
"def destroy\n request = RestClient.delete File.join(API_SERVER,\"rest-api/departments\",params['id'])\n redirect_to :action => :index\t\n end",
"def destroy\n @department_entry.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_departm... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
methods for rendering spokes | def render_spokes(cx, cy, type, spoke_length, spoke_direction, color)
@app.stroke color
u_p1 = spoke_direction[0]
u_m1 = spoke_direction[1]
@app.stroke color
spoke_end_x_up1 = cx + spoke_length[0] * u_p1[0]
spoke_end_y_up1 = cy - spoke_length[0] * u_p1[1]
@app.line(cx, cy, spoke_end_x_up1, ... | [
"def render_spokes(cx, cy, type, spoke_length, spoke_direction, color)\n @app.stroke color\n u_p1 = spoke_direction[0]\n u_m1 = spoke_direction[1] \n @app.stroke color\n spoke_end_x_up1 = cx + spoke_length[0] * u_p1[0]\n spoke_end_y_up1 = cy - spoke_length[0] * u_p1[1]\n @app.line(cx, cy, spoke... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
method for rendering interpolated spokes | def render_interp_spokes(shiftx, shifty, color, ibegin, iend)
@app.stroke color
ibegin.each_with_index do |p, i|
@app.line(p[0]+shiftx, p[1]+shifty, iend[i][0]+shiftx, iend[i][1]+shifty)
end
end | [
"def render_interp_spokes(shiftx, shifty, color, ibegin, iend, srep_index)\n\n ibegin.each_with_index do |p, i|\n if ($colored_spoke_indices.include? i and srep_index == 0)\n @app.stroke Color.blue\n else\n @app.stroke color\n end\n @app.line(p[0]+shiftx, p[1]+shifty, ie... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
method for rendering atoms | def render_atom(x, y, color)
render_point_big(x, y, color)
end | [
"def render(options = {}, extra_options = {}, &block)\n if atom = options[:atom]\n response.content_type ||= Mime::ATOM\n render_for_text(atom.respond_to?(:to_atom) ? atom.to_atom.to_xml : atom.to_xml, options[:status])\n else\n super\n end\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
method for rendering linking structure | def render_linking_structure(shifts)
shift = shifts[0]
$linkingPts.each do |pt|
if pt != []
render_atom(pt[0]+shift, pt[1]+shift, Color.black)
end
end
end | [
"def render_linking_structure(shifts)\n shift = shifts[0]\n if not $refine_linking_structure\n $linkingPts.each do |pt|\n if pt != []\n render_atom(pt[0]+shift, pt[1]+shift, Color.black)\n end\n end\n else \n $refined_linkingPts.each do |pt|\n if pt !=... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
this method interates the sreps and let them check the spoke intersection | def checkSrepIntersection
(0..$sreps.length-1).each do |j|
(0..$sreps.length-1).each do |i|
if i != j
$sreps[j].checkIntersection($sreps[i])
end
end
end
end | [
"def checkSrepIntersection\n (0..$sreps.length-1).each do |j|\n (0..$sreps.length-1).each do |i|\n if i != j\n $sreps[j].checkIntersection($sreps[i])\n end\n end\n end\n end",
"def intersect(s1,s2)\n # no intersect if either segment doesn't existend\n return false if s1.nil? ||... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
name: a Symbol, String or an Array; nil means hook to the root cascade: true/false; for cascading hook of sub key hook: block which will be called with 2 args, name and value | def add_hook(name = nil, cascade = false, &hook)
if name == nil or name == true or name == false
cascade = name
assign_self_hook(cascade, &hook)
else
assign_hook(name_to_a(name), cascade, &hook)
end
end | [
"def trigger name, *args, &block\n if block\n trigger :before, name\n yield\n trigger :after, name\n else\n return unless hooks[name]\n hooks[name][args.shift].each do |proc|\n proc.call *args\n end\n end\n end",
"def hooks... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
replace [noreply]\r\n replace store this data, but only if the server does already hold data for this key. | def replace (key,value,exptime="0",flags="0")
msj = "replace #{key} #{flags} #{exptime} #{value.length}\r\n#{value}\r\n"
@socket.puts(msj)
respuesta = @socket.gets.chomp
return respuesta
end | [
"def replace(key, flags, expiration, length, data)\n if storage.keys? key\n set(key, flags, expiration, data)\n elsif\n 'NOT_STORED'\n end\n end",
"def replace(value, hash)\n hash[value[:key]] = { flags: value[:flags], exptime: value[:exptime], value: value[:value], cas_unique: value[:cas_u... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
prepend [noreply]\r\n prepend add this data to an existing key before existing data. | def prepend (key,value)
msj = "prepend #{key} 0 0 #{value.length}\r\n#{value}\r\n"
@socket.puts(msj)
respuesta = @socket.gets.chomp
return respuesta
end | [
"def prepend(key, length, data)\n end",
"def prepend(key, value)\n perform(:prepend, key, value.to_s)\n end",
"def prepend(key, value)\n value.then do |resolved_value|\n @client.perform(:prepend, key, resolved_value.to_s)\n end\n end",
"def prepend(*args)\n data = join_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
For an array sorted in ascending order, searches for 'value_to_find'. Returns true if found, false otherwise. Complexity assessment: Note: where n = length of the input array Time complexity: O(log n); logarithmic; half of array is eliminated with each search: doubling size of array only increases search count by 1 Spa... | def binary_search(array, length, value_to_find)
begin_ind = 0
end_ind = length - 1
while begin_ind <= end_ind
midpoint = (begin_ind + end_ind) / 2
if array[midpoint] == value_to_find
return true
elsif array[midpoint] > value_to_find
end_ind = midpoint - 1
else
begin_ind = midpoi... | [
"def linear_search_sorted(arr, value)\n size = arr.length\n i = 0\n while i < size\n if value == arr[i]\n return true\n elsif value < arr[i] # Stops loop from searching until end of array\n return false\n end\n\n i += 1\n end\n false\nend",
"def search_array(array, value)\n if array... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /event_questions/1 GET /event_questions/1.json | def show
@event_question = EventQuestion.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @event_question }
end
end | [
"def new\n @event_question = EventQuestion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event_question }\n end\n end",
"def questions\n self.class.get('/2.2/questions', @options)\n end",
"def getsurveyquestion_app\n response = getsurvey_que... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /event_questions/new GET /event_questions/new.json | def new
@event_question = EventQuestion.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @event_question }
end
end | [
"def new\n @question = Question.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end",
"def new\n @question = Question.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /event_questions POST /event_questions.json | def create
@event_question = EventQuestion.new(params[:event_question])
@event_question.event_id = params[:event_id]
@event = Event.find(@event_question.event_id)
respond_to do |format|
if @event_question.save
format.html { redirect_to @event, notice: 'Event question was successfully... | [
"def new\n @event_question = EventQuestion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event_question }\n end\n end",
"def create\n json = params[:survey]\n json[:questions] = JSON.parse(json[:questions])\n json[:questions].each_with_index... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /event_questions/1 DELETE /event_questions/1.json | def destroy
@event_question = EventQuestion.find(params[:id])
@event_question.destroy
respond_to do |format|
format.html { redirect_to event_questions_url }
format.json { head :no_content }
end
end | [
"def destroy\n if @v1_question.destroy\n render json: {'message': 'Deleted question successfully'}, status: :ok\n else\n render json: get_errors, status: :unprocessable_entity\n end\n\n end",
"def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns an image tag for an image exactly 75x75 djatoka_smallbox_image_tag('info:lanlrepo/ds/5aa182c2c0924596af6ee95d2e263de3') | def djatoka_smallbox_image_tag(rft_id, params={})
url = djatoka_smallbox_image_url(rft_id, params)
image_tag url, clean_square_image_tag_params(params)
end | [
"def thumbnail_in_box(image, width, height)\n image_tag(image.medium_url, ls_image_options(image, width, height))\n end",
"def smaller_img\n return self.step_image.variant(resize: '750X750')\n end",
"def image(size)\n\t\t\tsearch_xml(\"//artist/image[@size='#{size}']\").first.inner_html rescue \"\"\n\t\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Include djatoka_openlayers_script on any page you need pan and zoom to include the scripts OpenLayers, OpenURL and djatoka. Including those scripts is required for djatoka_init_openlayers to work. | def djatoka_openlayers_script
jquery = '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>'
jquery + javascript_include_tag('OpenLayers','OpenURL', 'djatoka')
end | [
"def djatoka_init_openlayers(rft_id, div_identifier, params={})\n resolver = determine_resolver(params)\n metadata_url = resolver.metadata_url(rft_id)\n %Q|<script type=\"text/javascript\">\n jQuery(document).ready(function() {openlayersInit('#{resolver.scheme}://#{resolver.host}',\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
View helper to include a bit of jQuery on the page which waits for document load and then initializes the Ajax, OpenLayers viewer. Since this works via Ajax, Djatoka will need to be running or proxied at the same domain as the application to avoid crossdomain restrictions. | def djatoka_init_openlayers(rft_id, div_identifier, params={})
resolver = determine_resolver(params)
metadata_url = resolver.metadata_url(rft_id)
%Q|<script type="text/javascript">
jQuery(document).ready(function() {openlayersInit('#{resolver.scheme}://#{resolver.host}',
'#{metadat... | [
"def djatoka_openlayers_script\n jquery = '<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js\"></script>'\n jquery + javascript_include_tag('OpenLayers','OpenURL', 'djatoka')\n end",
"def load_page\n mount\n end",
"def load_map_js\n @d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
calculate datetime when retrieval_status should be updated, adding random interval sources that are not queueable use a fixed date | def stale_at
unless source.queueable
cron_parser = CronParser.new(source.cron_line)
return cron_parser.next(Time.zone.now)
end
age_in_days = Time.zone.now.to_date - work.published_on
if (0..7).include?(age_in_days)
random_time(source.staleness[0])
elsif (8..31).include?(age_in_day... | [
"def refresh_interval\n x = self.entries.where('published > ?', 6.hours.ago).where('published < ?', 1.hour.ago).count / 5.0\n \n if x <= 0.001\n time = 120.minutes\n else\n time = ((-20 * x) + 120).to_i.minutes\n end\n \n time = [time, 30.minutes].max \n time\n end",
"def pun... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
'With this hack, files that require this file, will have access to configatron store by using: settings. | def settings()
configatron
end | [
"def script_settings_files_def\nend",
"def config_file\n CONFIG_FILE\n end",
"def settings\n load_settings unless @config_loaded\n @settings\n end",
"def remote_settings; end",
"def configuration_file_path; end",
"def require_config_file\n RGovData::Config.require_config_file\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.