query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
Return true if the sequence is stable. | def stable?
(instability_index <= 40) ? true : false
end | [
"def increasing_sequence?(seq)\n\tseq.inject {|mem, x| return false if mem >= x; x}\n\ttrue\nend",
"def stable\n self[:draft] == false && self[:prerelease] == false\n end",
"def deterministic?\n @states.each{|s| return false if not s.deterministic_transitions? }\n return true\n end",
"def s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calculate aliphatic index of an AA sequence. _The aliphatic index of a protein is defined as the relative volume occupied by aliphatic side chains (alanine, valine, isoleucine, and leucine). It may be regarded as a positive factor for the increase of thermostability of globular proteins._ | def aliphatic_index
aa_map = aa_comp_map
@aliphatic_index ||= round(aa_map[:A] +
2.9 * aa_map[:V] +
(3.9 * (aa_map[:I] + aa_map[:L])), 2)
end | [
"def instability_index\n @instability_index ||=\n begin\n instability_sum = 0.0\n i = 0\n while @seq[i+1] != nil\n aa, next_aa = [@seq[i].chr.to_sym, @seq[i+1].chr.to_sym]\n if DIWV.key?(aa) && DIWV[aa].key?(next_aa)\n instability_sum += DIWV... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calculate GRAVY score of an AA sequence. _The GRAVY(Grand Average of Hydropathy) value for a peptide or protein is calculated as the sum of hydropathy values [9] of all the amino acids, divided by the number of residues in the sequence._ | def gravy
@gravy ||= begin
hydropathy_sum = 0.0
each_aa do |aa|
hydropathy_sum += HYDROPATHY[aa]
end
round(hydropathy_sum / @seq.length.to_f, 3)
end
end | [
"def raw_gpa\n tot_grade_points/tot_graded_attmp rescue 0.0/0.0\n end",
"def get_gpa\n total = registrations.where('grade is not null').inject(0){|sum, c| sum + c.grade}\n if total != 0\n # binding.pry\n final_gpa = total.to_f / (self.registrations.where('grade is not null').count).to_f\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calculate the percentage composition of an AA sequence as a Hash object. It return percentage of a given amino acid if aa_code is not nil. | def aa_comp(aa_code=nil)
if aa_code.nil?
aa_map = {}
IUPAC_CODE.keys.each do |k|
aa_map[k] = 0.0
end
aa_map.update(aa_comp_map){|k,_,v| round(v, 1) }
else
round(aa_comp_map[aa_code], 1)
end
end | [
"def calcPercentIdent(fasta)\n pos = nil\n idents = []\n len = nil\n counts = 0\n Bio::FlatFile.new(Bio::FastaFormat, File.new(fasta)).each do |seq1|\n len = seq1.length if len.nil?\n Bio::FlatFile.new(Bio::FastaFormat, File.new(fasta)).each do |seq2|\n next if seq2.full_id == seq1.full_id\n id... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return proc calculating charge of a residue. | def charge_proc positive, pK, num
if positive
lambda {|ph|
num.to_f / (1.0 + 10.0 ** (ph - pK))
}
else
lambda {|ph|
(-1.0 * num.to_f) / (1.0 + 10.0 ** (pK - ph))
}
end
end | [
"def charge\n return @charge\n end",
"def charge\n st = data['charge']\n # put the last char on the front and cast it\n (st[-1,1] + st[0...-1]).to_i\n end",
"def theoretical_pI\n charges = []\n residue_count().each do |residue|\n charges << charge_pro... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Transform AA sequence into residue count | def residue_count
counted = []
# N-terminal
n_term = @seq[0].chr
if PK[:nterm].key? n_term.to_sym
counted << {
:num => 1,
:residue => n_term.to_sym,
:pK => PK[:nterm][n_term.to_sym],
:positive => positive?(n_term)
}
elsif PK[:normal].... | [
"def acidic_count(amino_acid_sequence)\n count = 0\n comp = amino_acid_sequence.composition\n ACIDIC_AMINO_ACIDS.each do |acidic|\n if comp[acidic]\n count += comp[acidic]\n end\n end\n return count\n end",
"def basic_count(amino_acid_sequence)\n count = 0\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Solving pI value with bisect algorithm. | def solve_pI charges
state = {
:ph => 0.0,
:charges => charges,
:pI => nil,
:ph_prev => 0.0,
:ph_next => 14.0,
:net_charge => 0.0
}
error = false
# epsilon means precision [pI = pH +_ E]
epsilon = 0.001
loop do
# Reset net char... | [
"def interpolation_search_internal(value)\n return [false, 0] if @inner.size == 0\n left = 0\n right = @inner.size - 1\n return [false, 0] if value < @inner[left]\n return [false, right + 1] if value > @inner[right]\n while left <= right\n if left == right\n candidate = left\n els... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The load_game method is responsible for comparing the timestamp within the file to the time the filesystem has associated with the file. Write the load_game(file) method. | def load_game(file)
raise "I suspect you of cheating." if File.mtime(file) != Time.at(File.readlines(file).last.to_i)
end | [
"def load_game\n print_saves\n begin\n read_save\n rescue IOError, SystemCallError\n puts 'File not found'\n load_game\n end\n end",
"def load_game\n \t\t#Get information for game to load\n \t\tget_username\n \t\tfile_name = get_saved_games\n \t\treturn if file_name==\"menu\"\n \t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
find note and parent picture, destroy then redirect back to artwork | def destroy
@note = Note.find(params[:id])
@picture = @note.picture
@artwork = @picture.artwork
@note.destroy
redirect_to @artwork
end | [
"def destroy\n @picture = Picture.find(params[:id])\n @picture.destroy\n\n #need a redirect here\n redirect_back(fallback_location: root_path)\n #if artwork is no longer present fallback to the root\n end",
"def destroy\n @note_image = NoteImage.find(params[:id])\n @note_image.remove_image!\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
For a recurrent network, this resets hidden states back to zero | def reset
if config.isRecurrent
@nn.resetRecurrentStates
else
puts "Warning not a recurrent network. This does nothing"
end
end | [
"def reset_all_nodes\n NeuralNet.find(id).nodes.each do |node|\n unless node.bias\n node.output = 0.0\n node.total_input = 0.0\n node.save\n end\n end\n end",
"def deep_reset\n # reset memoization\n [:@layer_row_sizes, :@layer_col_sizes, :@nlayers, :@layer_shapes,\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Copies workflows to another scope. | def copy
workflows = Workflow.accessible_by(@context).where(id: params[:item_ids])
new_workflows = workflows.map { |wf| copy_service.copy(wf, params[:scope]).first }
# TODO: change old UI to handle json-response!
respond_to do |format|
format.html do
redirect_to pathify(workf... | [
"def copy_workflows(space, source_space)\n source_space.workflows.each { |workflow| copy_service.copy(workflow, space.uid) }\n end",
"def copy\n workflows = Workflow.accessible_by(@context).where(id: params[:item_ids])\n\n new_workflows = workflows.map { |wf| copy_service.copy(wf, params[:scope]... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This is the actual action that ships the reward ship_reward_now_user_payment_reward_receivers POST | def ship_reward_now
@reward_receiver = RewardReceiver.find(params[:reward_receiver_id])
@reward_receiver.update(reward_receiver_params)
if @reward_receiver.update(
status: "shipped"
)
#Send email
#Send notification
#Add xp
@user.add_score("ship_reward")
end
redirect_to show_user_studio_rewards_pa... | [
"def deliver_reward(reward, star_id)\n weight_adjustment = case\n when reward > 0 then 0.1\n when reward < 0 then -0.1\n else 0\n end\n @weighted_actions[@last_action] += weight_adjustment if @last_action\n end",
"def notify_owner_of_redeemed_reward\n reward_page.notify_owner_of_redeem... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Show the given thesis with the given tiss_id | def show
@thesis = Thesis.load params[:id]
end | [
"def show\n @thesis = Thesis.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @thesis }\n end\n end",
"def show\n @swit.sours.find(params[:id])\n end",
"def show\n @truites = Truite.find(params[:id])\n end",
"def index\n @... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns truthy if the given frame carries HTTP semantics (so has to be sent in order) | def semantic_frame? f
f.type == FrameTypes::DATA || f.type == FrameTypes::HEADERS || f.type == FrameTypes::CONTINUATION || f.type == FrameTypes::GZIPPED_DATA
end | [
"def control_frame?(frame_type); end",
"def head?\r\nHTTP_METHOD_LOOKUP[request_method] == :head\r\nend",
"def is? frame_type\n return true if frame_type == :all\n detection = \"is_#{frame_type.to_s.sub(/frames$/, 'frame')}?\"\n begin \n self.send detection\n rescue NoMethodError => e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Are we configured to accept GZIPPED_DATA frames from this peer? Takes into account peer's apparent ability to correctly send gzip. | def accept_gzip?
return if @ext__veto_gzip
@ext__recv_gzip
end | [
"def accept_gzip!\n return if @ext__veto_gzip\n if !@ext__recv_gzip\n send_frame Settings.frame_from({Settings::ACCEPT_GZIPPED_DATA => 1})\n @ext__recv_gzip = true\n end\n end",
"def send_gzip?\n return if !@ext__peer_gzip\n @ext__send_gzip\n end",
"def can_gzip?\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
tell the peer we'll accept GZIPPED_DATA frames | def accept_gzip!
return if @ext__veto_gzip
if !@ext__recv_gzip
send_frame Settings.frame_from({Settings::ACCEPT_GZIPPED_DATA => 1})
@ext__recv_gzip = true
end
end | [
"def accept_gzip?\n return if @ext__veto_gzip\n @ext__recv_gzip\n end",
"def no_accept_gzip!\n return if @ext__veto_gzip\n if @ext__recv_gzip\n send_frame Settings.frame_from({Settings::ACCEPT_GZIPPED_DATA => 0})\n @ext__recv_gzip = false\n end\n end",
"def send_gzip... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
tell the peer we don't accept GZIPPED_DATA frames | def no_accept_gzip!
return if @ext__veto_gzip
if @ext__recv_gzip
send_frame Settings.frame_from({Settings::ACCEPT_GZIPPED_DATA => 0})
@ext__recv_gzip = false
end
end | [
"def accept_gzip!\n return if @ext__veto_gzip\n if !@ext__recv_gzip\n send_frame Settings.frame_from({Settings::ACCEPT_GZIPPED_DATA => 1})\n @ext__recv_gzip = true\n end\n end",
"def skip_gzip?\n !gzip?\n end",
"def accept_gzip?\n return if @ext__veto_gzip\n @ex... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Are we configured to send GZIPPED_DATA frames to this peer? Takes into account peer's settings for receiving them. | def send_gzip?
return if !@ext__peer_gzip
@ext__send_gzip
end | [
"def accept_gzip?\n return if @ext__veto_gzip\n @ext__recv_gzip\n end",
"def accept_gzip!\n return if @ext__veto_gzip\n if !@ext__recv_gzip\n send_frame Settings.frame_from({Settings::ACCEPT_GZIPPED_DATA => 1})\n @ext__recv_gzip = true\n end\n end",
"def no_accept_gz... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
application lets us send GZIPPED_DATA frames to this peer | def send_gzip!
if !@ext__send_gzip
@ext__send_gzip = true
end
end | [
"def accept_gzip!\n return if @ext__veto_gzip\n if !@ext__recv_gzip\n send_frame Settings.frame_from({Settings::ACCEPT_GZIPPED_DATA => 1})\n @ext__recv_gzip = true\n end\n end",
"def send_data_with_http_tunnel(data)\n #msg_data = Base64::encode64(data)\n #@socket_srv.print \"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
does the questions table need an answer_id to make this connection work? generate question objects that are associated to quiz by question_id | def create_question
question_hash = Adapter.quiz_api(difficulty) #use adapter method, with difficulty passes into the url as a variable, to gnerate a new list of questions.
new_question = Question.new #make a new question instance
new_question.save #save now so we can store the question's id in the answer b... | [
"def setup_answers\n create :answer, question: @question1, response_id: @response.id, answer: 1, comments: 'True_1'\n create :answer, question: @question2, response_id: @response.id, answer: 0, comments: 'False_2'\n create :answer, question: @question3, response_id: @response.id, answer: 0, comments: 'Answer2_3'... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Centroid of an empty should return an empty collection rather than throw a weird exception out of ffigeos | def test_empty_centroid
assert_equal(@factory.collection([]), @factory.multi_polygon([]).centroid)
end | [
"def test_empty_centroid\n assert_equal(@factory.collection([]), @factory.multi_polygon([]).centroid)\n end",
"def centroid\n @centroid = @geometry.centroid unless @centroid\n @centroid\n end",
"def centroid\n return @centroid if defined?(@centroid)\n\n cx, cy = 0, 0\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
API to request a random speach of Robert with a direction to user | def random_roberto_speech
skip_authorization
respond_to do |format|
format.json do
render json: { roberto_speech: "#{RobertoBarros.in_ingrish} #{direction_for_active_cell(@play)}" }
end
end
end | [
"def greeting\n random_response :greeting\n end",
"def greeting\n\t\trandom_response(:greeting)\n\tend",
"def find_random_friend\r\n login\r\n doc = hpricot_get_url '/b.php?k=10010'\r\n friend_row = (doc/\"div.result//dd.result_name/a\").random\r\n parse_friend_row friend_row\r\n end",
"def r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the CollectionEventParameters for this Collectible. | def collection_event_parameters
event_parameters.detect { |ep| CaTissue::CollectionEventParameters === ep }
end | [
"def parameters\n params = []\n self.event_parameters.each do |param|\n params << OpenStruct.new( :param_id => param.id, :name => param.Description, :param_type => param.parameter_type.Description )\n end\n params\n end",
"def chargable_params\n chargable_events = Event.where(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns whether this Collectible has a received event. | def received?
received_event_parameters
end | [
"def has_event?\n return !@events.empty?\n end",
"def event?\n @events_mutex.synchronize do\n !@events.empty?\n end\n end",
"def raises_event?\n !!collected[:event_name]\n end",
"def has_pending_events?\n self.events.any?{|e| e.pending? }\n end",
"de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the ReceivedEventParameters for this Collectible. | def received_event_parameters
event_parameters.detect { |ep| CaTissue::ReceivedEventParameters === ep }
end | [
"def parameters\n params = []\n self.event_parameters.each do |param|\n params << OpenStruct.new( :param_id => param.id, :name => param.Description, :param_type => param.parameter_type.Description )\n end\n params\n end",
"def collection_event_parameters\n event_parameters.detec... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Overrides +Jinx::Resource.each_defaultable_reference+ to visit the +CaTissue::ReceivedEventParameters+. | def each_defaultable_reference
# visit ReceivedEventParameters first
rep = received_event_parameters
yield rep if rep
# add other dependent defaults
super { |dep| yield dep unless ReceivedEventParameters === dep }
end | [
"def add_default_event_parameters\n rep = received_event_parameters || create_default_received_event_parameters || return\n if collection_event_parameters.nil? then\n create_default_collection_event_parameters(rep)\n end\n end",
"def add_defaults_local\n super\n self.collection_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
methods copied from openstudiostandards Remove all air loops in model | def remove_air_loops(model)
model.getAirLoopHVACs.each(&:remove)
return model
end | [
"def remove_all_plant_loops(model)\n model.getPlantLoops.each(&:remove)\n return model\n end",
"def remove_plant_loops(model, runner)\n plant_loops = model.getPlantLoops\n plant_loops.each do |plant_loop|\n shw_use = false\n plant_loop.demandComponents.each do |component|\n if compon... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Remove plant loops in model except those used for service hot water | def remove_plant_loops(model, runner)
plant_loops = model.getPlantLoops
plant_loops.each do |plant_loop|
shw_use = false
plant_loop.demandComponents.each do |component|
if component.to_WaterUseConnections.is_initialized or component.to_CoilWaterHeatingDesuperheater.is_initialized
s... | [
"def remove_all_plant_loops(model)\n model.getPlantLoops.each(&:remove)\n return model\n end",
"def remove_all_HVAC(model)\n remove_air_loops(model)\n remove_all_plant_loops(model)\n remove_vrf(model)\n remove_all_zone_equipment(model, runner)\n remove_unused_curves(model)\n return model\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Remove all plant loops in model including those used for service hot water | def remove_all_plant_loops(model)
model.getPlantLoops.each(&:remove)
return model
end | [
"def remove_plant_loops(model, runner)\n plant_loops = model.getPlantLoops\n plant_loops.each do |plant_loop|\n shw_use = false\n plant_loop.demandComponents.each do |component|\n if component.to_WaterUseConnections.is_initialized or component.to_CoilWaterHeatingDesuperheater.is_initialized\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Remove zone equipment except for exhaust fans | def remove_zone_equipment(model, runner)
zone_equipment_removed_count = 0
model.getThermalZones.each do |zone|
zone.equipment.each do |equipment|
if equipment.to_FanZoneExhaust.is_initialized
runner.registerInfo("#{equipment.name} is a zone exhaust fan and will not be removed.")
... | [
"def remove_all_zone_equipment(model, runner)\n zone_equipment_removed_count = 0\n model.getThermalZones.each do |zone|\n zone.equipment.each do |equipment|\n equipment.remove\n zone_equipment_removed_count += 1\n end\n end\n runner.registerInfo(\"#{zone_equipment_removed_count} ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Remove all zone equipment including exhaust fans | def remove_all_zone_equipment(model, runner)
zone_equipment_removed_count = 0
model.getThermalZones.each do |zone|
zone.equipment.each do |equipment|
equipment.remove
zone_equipment_removed_count += 1
end
end
runner.registerInfo("#{zone_equipment_removed_count} zone equipment... | [
"def remove_zone_equipment(model, runner)\n zone_equipment_removed_count = 0\n model.getThermalZones.each do |zone|\n zone.equipment.each do |equipment|\n if equipment.to_FanZoneExhaust.is_initialized\n runner.registerInfo(\"#{equipment.name} is a zone exhaust fan and will not be removed.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Remove unused performance curves | def remove_unused_curves(model)
model.getCurves.each do |curve|
if curve.directUseCount == 0
model.removeObject(curve.handle)
end
end
return model
end | [
"def remove_all_cost_segments\n super\n end",
"def discard_trip_outliers\n @drivers.each do |driver|\n driver.discard_trip_outliers\n end\n end",
"def remove_useless_traces_data(params)\n convert_list_of_json_traces_to_objects(params[0])\n create_new_traces\n @traces_json_string = '... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Remove all HVAC equipment including service hot water loops and zone exhaust fans | def remove_all_HVAC(model)
remove_air_loops(model)
remove_all_plant_loops(model)
remove_vrf(model)
remove_all_zone_equipment(model, runner)
remove_unused_curves(model)
return model
end | [
"def remove_all_zone_equipment(model, runner)\n zone_equipment_removed_count = 0\n model.getThermalZones.each do |zone|\n zone.equipment.each do |equipment|\n equipment.remove\n zone_equipment_removed_count += 1\n end\n end\n runner.registerInfo(\"#{zone_equipment_removed_count} ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /android_profiles/new GET /android_profiles/new.json | def new
@android_profile = @user.build_android_profile
respond_to do |format|
format.html # new.html.erb
format.json { render json: @android_profile }
end
end | [
"def new\n @profile = current_user.profiles.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @profile }\n end\n end",
"def new\n @user = User.find(params[:user_id])\n @profile = @user.profile == nil ? Profile.new : @user.profile\n @from_profiles... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /android_profiles POST /android_profiles.json | def create
@android_profile = @user.build_android_profile(params[:android_profile])
respond_to do |format|
if @android_profile.save
format.html { redirect_to user_android_profile_url, :flash => { success: 'Successfully saved.' } }
format.json { render json: @android_profile, status: :crea... | [
"def new\n @android_profile = @user.build_android_profile\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @android_profile }\n end\n end",
"def newprofile\n result = {}\n result[:status] = \"failed\"\n if params[\"auth_key\"] != nil and params[\"de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /android_profiles/1 PUT /android_profiles/1.json | def update
@android_profile = @user.android_profile
respond_to do |format|
if @android_profile.update_attributes(params[:android_profile])
format.html { redirect_to user_android_profile_url, :flash => { success: 'Successfully updated.' } }
format.json { head :no_content }
else
... | [
"def assign_default_profile(args = {}) \n put(\"/profiles.json/#{args[:profileId]}/default\", args)\nend",
"def update_profile(options = {}) \n # query profile info\n response = HTTP.auth('Bearer ' + Asca::Tools::Token.new_token).get(URI_PROFILES, :params => { 'filter[name]' => options[:name... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /android_profiles/1 DELETE /android_profiles/1.json | def destroy
@android_profile = @user.android_profile
@android_profile.destroy
respond_to do |format|
format.html { redirect_to new_user_android_profile_url, :flash => { success: 'Successfully deleted.' } }
format.json { head :no_content }
end
end | [
"def destroy\n @profile.destroy\n respond_to do |format|\n format.html { redirect_to phone_profiles_url, notice: 'Profile was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def clear_default_profile \n put(\"/profiles.json/default/clear\")\nend",
"def destroy\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
We strip the segments before code analysis begins | def pre_code_analyze
# grab the section names we will strip
return if not options[ '/strip' ]
# split the string into an array of section names
names = options[ '/strip' ].split( ';' )
# don't bother to continue if we have no sections to strip
return if names.empty?
... | [
"def remove_segments()\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n Native.RunEditor_remove_segments(@handle.ptr)\n end",
"def strip_comments!\n\t\t@code = strip_comments\n\tend",
"def trim_code_prefix!\n substr!(4) if @line.length > 4\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /forum_comentarios POST /forum_comentarios.json | def create
@forum_comentario = ForumComentario.new(forum_comentario_params)
@forum_comentario.usuario_curso_id = @perfil.id
if @forum_comentario.save
ApplicationMailer.nova_postagem_forum(@forum_comentario).deliver
@forum_comentario = ForumComentario.where(forum_id: @forum_comentario.foru... | [
"def CreateForum params = {}\n \n APICall(path: 'forums.json',method: 'POST',payload: params.to_json)\n \n end",
"def create\n @comentarios_admin = ComentariosAdmin.new(params[:comentarios_admin])\n\n respond_to do |format|\n if @comentarios_admin.save\n format.html { r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /forum_comentarios/1 PATCH/PUT /forum_comentarios/1.json | def update
if @forum_comentario.update(forum_comentario_params)
@forum_comentario = ForumComentario.where(forum_id: @forum_comentario.forum_id)
else
respond_to do |format|
format.js { render :edit }
format.json { render json: @forum_comentario.errors, status: :unprocessable_entity }
... | [
"def UpdateForum id,params = {}\n \n APICall(path: \"forums/#{id}.json\",method: 'PUT',payload: params.to_json)\n \n end",
"def update\n @comentarios_admin = ComentariosAdmin.find(params[:id])\n\n respond_to do |format|\n if @comentarios_admin.update_attributes(params[:comenta... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /forum_comentarios/1 DELETE /forum_comentarios/1.json | def destroy
authorize! :destroy, ForumComentario
@forum = @forum_comentario.forum_id
@forum_comentario.destroy
if @forum_comentario.destroy
@forum_comentario = ForumComentario.where(forum_id: @forum)
end
end | [
"def DeleteForum id\n \n APICall(path: \"forums/#{id}.json\",method: 'DELETE')\n \n end",
"def destroy\n @forumm.destroy\n respond_to do |format|\n format.html { redirect_to forumms_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @forum.dest... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Get the number of lines of context padding. This may be overridden with the environment variable DEPRECATABLE_CALLER_CONTEXT_PADDING. Returns the Integer number of context padding lines. | def caller_context_padding
p = ENV['DEPRECATABLE_CALLER_CONTEXT_PADDING']
if p then
p = Float(p).to_i
raise ArgumentError, "DEPRECATABLE_CALLER_CONTEXT_APDDING must have a value > 0, it is currently #{p}" unless p > 0
return p
end
return @caller_context_padding
end | [
"def formatted_context_lines\n if @formatted_context_lines.empty? then\n number_width = (\"%d\" % @context_line_numbers.last).length\n @context_lines.each_with_index do |line, idx|\n prefix = (idx == @context_index) ? CallSiteContext.pointer : CallSiteContext.not_pointer\n numbe... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Set the maximum number of times an alert for a unqiue CallSite of a DeprecatedMethod will be emitted. (default: :once) That is, when a deprecated method is called from a particular CallSite, normally an 'alert' is sent. This setting controls the maximum number of times that the 'alert' for a particular CallSite... | def alert_frequency=( freq )
@alert_frequency = frequency_of( freq )
end | [
"def alert_frequency\n p = ENV['DEPRECATABLE_ALERT_FREQUENCY']\n return frequency_of(p) if p\n return @alert_frequency\n end",
"def freq=(freq_value)\n reset_errors\n @freq = freq_value\n end",
"def frequency\n Morrow.config.update_interval\n end",
"def alert( call_sit... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Get the current value of the alert_frequency. This may be overridden with the environment variable DEPRECATABLE_ALERT_FREQUENCY. Returns the Integer value representing the alert_frequency. | def alert_frequency
p = ENV['DEPRECATABLE_ALERT_FREQUENCY']
return frequency_of(p) if p
return @alert_frequency
end | [
"def alert_frequency=( freq )\n @alert_frequency = frequency_of( freq )\n end",
"def frequency\n temp = 0.chr * 4\n @fmod.invoke('Channel_GetFrequency', @handle, temp)\n return @fmod.unpackFloat(temp)\n end",
"def get_alert_frequency(hostname, service = nil, options = {})\n dura... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Public: Say whether or not the final at exit report shall be emitted. This may be overridden by the environment variable DEPRECATABLE_HAS_AT_EXIT_REPORT. Setting the environment variable to 'true' will override the existing setting. Returns the boolean of whether or not the exti report should be done. | def has_at_exit_report?
return true if ENV['DEPRECATABLE_HAS_AT_EXIT_REPORT'] == "true"
return @has_at_exit_report
end | [
"def should_run_on_exit?\n return false if ENV[\"KINTAMA_EXPLICITLY_DONT_RUN\"]\n return test_file_was_run? || run_via_rake?\n end",
"def is_entry_exit_announced\n return @is_entry_exit_announced\n end",
"def reporting?\n @reporting\n end",
"def exitable?\n @e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /customersessions GET /customersessions.json | def index
@customersessions = Customersession.all
end | [
"def show\n @session = @client.sessions.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json {render json: @session }\n end\n end",
"def show\n # /checkout_sessions/<id>\n checkout_session = Stripe::Checkout::Session.retrieve(params[:id])\n render j... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /customersessions POST /customersessions.json | def create
@customersession = Customersession.new(customersession_params)
respond_to do |format|
if @customersession.save
format.html { redirect_to @customersession, notice: 'Customersession was successfully created.' }
format.json { render :show, status: :created, location: @customersess... | [
"def create\n @user_session = UserSession.new(user_session_params)\n\n if @user_session.save\n render json: @user_session, status: :created, location: @user_session\n else\n render json: @user_session.errors, status: :unprocessable_entity\n end\n end",
"def create\n @session = Session.ne... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /customersessions/1 PATCH/PUT /customersessions/1.json | def update
respond_to do |format|
if @customersession.update(customersession_params)
format.html { redirect_to @customersession, notice: 'Customersession was successfully updated.' }
format.json { render :show, status: :ok, location: @customersession }
else
format.html { render :... | [
"def update\n #@session = @client.sessions.update!(session_params)\n\n respond_to do |format|\n if @session.update(session_params)\n format.html { redirect_to client_url(@client), notice: 'Session was successfully updated.' }\n format.json { render :show, status: :ok, location: @session }\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /customersessions/1 DELETE /customersessions/1.json | def destroy
@customersession.destroy
respond_to do |format|
format.html { redirect_to customersessions_url, notice: 'Customersession was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @session = @client.sessions.find(params[:id])\n @session.destroy\n respond_to do |format|\n format.html { redirect_to client_url(@client), notice: 'Session was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client_session = Clie... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
function to update the session and add in cart | def add_in_cart
product_id=params[:id].to_i
@product=Product.find(product_id)
total_request=1
update_through_cart=0
if params.has_key?(:quant)
total_request=params[:quant][:total_request].to_i
update_through_cart=1
end
if(check_availabilty(product_id,total_r... | [
"def add_to_cart\n \tif session[\"cart\"].nil?\n \t\tsession[\"cart\"] = []\n \tend\n \t#So luong cua san pham add vao gio hang\n \tquantity_ = 1\n \tsession[\"item\"] = {:id => params[:id].to_i, :name => params[:name], :quantity => quantity_.to_i, :price => params[:price].to_i, :total => quantity_.to_i * par... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
To view or fill out the form | def form
end | [
"def fill_form\n visit \"/\"\n fill_in 'first_name', with: 'Bob'\n fill_in 'last_name', with: 'Smith'\n fill_in 'street', with: '123 Anywhere St.'\n fill_in 'city', with: 'San Diego'\n fill_in 'state', with: 'CA'\n fill_in 'zip', with: '92101'\n fill_in 'country', with: 'USA'\n fill_in 'p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /code_samples POST /code_samples.json | def create
@code_sample = current_user.code_samples.new(code_sample_params)
respond_to do |format|
if @code_sample.save
format.html { redirect_to @code_sample, notice: 'Code sample was successfully created.' }
format.json { render :show, status: :created, location: @code_sample }
el... | [
"def create\n @api_v1_sample = Sample.new(sample_params)\n if @api_v1_sample.save\n render :show, status: :created, location: api_v1_sample_path(@api_v1_sample)\n else\n render json: @api_v1_sample.errors, status: :unprocessable_entity\n end\n end",
"def create\n @sampleapp = Sampleapp.n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /code_samples/1 DELETE /code_samples/1.json | def destroy
@code_sample.destroy
respond_to do |format|
format.html { redirect_to code_samples_url, notice: 'Code sample was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @api_v1_sample.destroy\n head :no_content\n end",
"def destroy\n @json_sample = JsonSample.find(params[:id])\n @json_sample.destroy\n\n respond_to do |format|\n format.html { redirect_to json_samples_url }\n format.json { render json: {msg: \"complete\", status: \"OK\"} }\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
I haven't written a test for it but the implemenation seems incorrect to me. It doesn't take into account the colour of the area you're filling. Your test passes only because you're limiting the area you're filling with the colour used to fill but if you change the colour, it fails. Also, it fails with a stack level to... | def floodfill(x, y, color)
if @pixels[y-1][x-1] != color
@pixels[y-1][x-1] = color
floodfill(x+1, y, color)
floodfill(x-1, y, color)
floodfill(x, y + 1, color)
floodfill(x, y - 1, color)
end
end | [
"def recursive_fill(x, y, colour, original_colour)\n # puts \"Setting #{x},#{y} to #{colour}\"\n @grid.set_value_at_point(x, y, colour)\n\n points = @grid.all_touching_points(x, y)\n points.each do |p|\n col = @grid.get_value_at_point(p[0], p[1])\n recursive_fill(p[0], p[1], colour, origina... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /contests/new GET /contests/new.json | def new
@contest = Contest.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @contest }
end
end | [
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contestant }\n end\n end",
"def new\n @contest_entry = ContestEntry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contest_entry }\n end\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /vanos/1 GET /vanos/1.json | def show
@vano = Vano.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @vano }
end
end | [
"def index\n @vinos = Vino.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @vinos }\n end\n end",
"def show\n @vocero = Vocero.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @voc... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /vanos/new GET /vanos/new.json | def new
@vano = Vano.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @vano }
end
end | [
"def new\n @nova = Nova.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @nova }\n end\n end",
"def new\n @volantino = Volantino.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @volantino }\n en... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /vanos POST /vanos.json | def create
@vano = Vano.new(params[:vano])
respond_to do |format|
if @vano.save
format.html { redirect_to @vano, notice: 'Vano was successfully created.' }
format.json { render json: @vano, status: :created, location: @vano }
else
format.html { render action: "new" }
... | [
"def create\n @vano = Vano.new(vano_params)\n\n respond_to do |format|\n if @vano.save\n format.html { redirect_to @vano, notice: 'Vano was successfully created.' }\n format.json { render :show, status: :created, location: @vano }\n else\n format.html { render :new }\n fo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /positioncoefficients GET /positioncoefficients.xml | def index
@positioncoefficients = Positioncoefficient.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @positioncoefficients }
end
end | [
"def show\n @positioncoefficient = Positioncoefficient.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @positioncoefficient }\n end\n end",
"def new\n @positioncoefficient = Positioncoefficient.new\n\n respond_to do |format|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /positioncoefficients/1 GET /positioncoefficients/1.xml | def show
@positioncoefficient = Positioncoefficient.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @positioncoefficient }
end
end | [
"def index\n @positioncoefficients = Positioncoefficient.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @positioncoefficients }\n end\n end",
"def new\n @positioncoefficient = Positioncoefficient.new\n\n respond_to do |format|\n format.h... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /positioncoefficients/new GET /positioncoefficients/new.xml | def new
@positioncoefficient = Positioncoefficient.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @positioncoefficient }
end
end | [
"def index\n @positioncoefficients = Positioncoefficient.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @positioncoefficients }\n end\n end",
"def create\n @positioncoefficient = Positioncoefficient.new(params[:positioncoefficient])\n\n respo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /positioncoefficients POST /positioncoefficients.xml | def create
@positioncoefficient = Positioncoefficient.new(params[:positioncoefficient])
respond_to do |format|
if @positioncoefficient.save
format.html { redirect_to(@positioncoefficient, :notice => 'Positioncoefficient was successfully created.') }
format.xml { render :xml => @positionc... | [
"def index\n @positioncoefficients = Positioncoefficient.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @positioncoefficients }\n end\n end",
"def new\n @positioncoefficient = Positioncoefficient.new\n\n respond_to do |format|\n format.h... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /positioncoefficients/1 PUT /positioncoefficients/1.xml | def update
@positioncoefficient = Positioncoefficient.find(params[:id])
respond_to do |format|
if @positioncoefficient.update_attributes(params[:positioncoefficient])
format.html { redirect_to(@positioncoefficient, :notice => 'Positioncoefficient was successfully updated.') }
format.xml ... | [
"def create\n @positioncoefficient = Positioncoefficient.new(params[:positioncoefficient])\n\n respond_to do |format|\n if @positioncoefficient.save\n format.html { redirect_to(@positioncoefficient, :notice => 'Positioncoefficient was successfully created.') }\n format.xml { render :xml =>... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /positioncoefficients/1 DELETE /positioncoefficients/1.xml | def destroy
@positioncoefficient = Positioncoefficient.find(params[:id])
@positioncoefficient.destroy
respond_to do |format|
format.html { redirect_to(positioncoefficients_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @position_dependant = PositionDependant.find(params[:id])\n @position_dependant.destroy\n\n respond_to do |format|\n format.html { redirect_to(position_dependants_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @position_threshold = PositionThreshold.find(pa... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
takes a code returned by wepay oauth2 authorization and makes an api call to generate oauth2 token for this farmer. | def request_wepay_access_token(code, redirect_uri)
response = GemsUsage::Application::WEPAY.oauth2_token(code, redirect_uri)
if response['error']
raise "Error - "+ response['error_description']
elsif !response['access_token']
raise "Error requesting access from WePay"
else
self.wepay_access_token = ... | [
"def request_wepay_access_token(code, redirect_uri)\n response = WEPAY.oauth2_token(code, redirect_uri)\n if response['error']\n raise \"Error - \"+ response['error_description']\n elsif !response['access_token']\n raise \"Error requesting access from WePay\"\n else\n self.wepay_access_token = response... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve all template information. Build an array of template ids here over which to iterate | def retrieve_all_template_info
puts "Retrieving all template ids and names for #{@primary_username} ..."
puts
uri = URI(@config['endpoint'])
# Retrieve templates
http = Net::HTTP.new( uri.host,uri.port )
http.use_ssl = true
request = Net::HTTP::Get.new( uri.request_uri )
... | [
"def child_templates\n\t\tif template_ids == \"all\" then\n\t\t\treturn Template.all\n\t\telse\n\t\t\tTemplate.where(:id => template_ids.split(\",\")).all\n\t\tend\n\tend",
"def find_many(options = {})\n client.find_many(Spire::Production::Template, \"/production/templates/\", options)\n end",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve single template. This method will be iterative over the result of retrieve_all_template_info | def retrieve_single_template( template_id )
puts "Retrieving template id #{template_id}."
uri = URI(@config['endpoint'] + '/' + template_id)
# Retrieve templates
http = Net::HTTP.new( uri.host,uri.port )
http.use_ssl = true
request = Net::HTTP::Get.new( uri.request_uri )
requ... | [
"def get(template_id)\n # TODO: Implement retrieve of a single template\n end",
"def details\n response = get \"/templates/#{template_id}.json\", {}\n Hashie::Mash.new(response)\n end",
"def details\n response = CreateSend.get \"/templates/#{template_id}.json\", {}\n Hashi... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Given a string or an IO object, this will attempt a parse of its contents and return a result. If the parse fails, a Parslet::ParseFailed exception will be thrown. | def parse(io)
if io.respond_to? :to_str
io = StringIO.new(io)
end
result = apply(io)
# If we haven't consumed the input, then the pattern doesn't match. Try
# to provide a good error message (even asking down below)
unless io.eof?
# Do we know why we stopped matching input?... | [
"def parse(io)\n source = Parslet::Source.new(io)\n context = Parslet::Atoms::Context.new\n \n result = nil\n value = apply(source, context)\n \n # If we didn't succeed the parse, raise an exception for the user. \n # Stack trace will be off, but the error tree should explain the reason\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Construct a new atom that repeats the current atom min times at least and at most max times. max can be nil to indicate that no maximum is present. Example: match any number of 'a's str('a').repeat match between 1 and 3 'a's str('a').repeat(1,3) | def repeat(min=0, max=nil)
Parslet::Atoms::Repetition.new(self, min, max)
end | [
"def repeat(min, max=nil)\n if min && max\n Rexp.new(parenthesized_encoding(POSTFIX) + apply_greedy(\"{#{min},#{max}}\"), POSTFIX, capture_keys)\n else\n Rexp.new(parenthesized_encoding(POSTFIX) + \"{#{min}}\", POSTFIX, capture_keys)\n end\n end",
"def rep(rule, min=1, max=Infinity... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a new parslet atom that is only maybe present in the input. This is synonymous to calling repeat(0,1). Generated tree value will be either nil (if atom is not present in the input) or the matched subtree. Example: str('foo').maybe | def maybe
Parslet::Atoms::Repetition.new(self, 0, 1, :maybe)
end | [
"def set_if_nil(word, value)\n current = @root\n current_prefix = word\n\n while current_prefix != \"\"\n current, current_prefix = find_canididate_insertion_node(current, current_prefix)\n end\n\n current[:value] ||= value\n return current[:value]\n end",
"def any?\n return Repetitio... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tests for absence of a parslet atom in the input stream without consuming it. Example: Only proceed the parse if 'a' is absent. str('a').absnt? | def absnt?
Parslet::Atoms::Lookahead.new(self, false)
end | [
"def absent?\n Parslet::Atoms::Lookahead.new(self, false)\n end",
"def assert_doesnt_parse(input, rule=nil, msg=nil)\n msg = \"not able to parse: #{input}\" if msg.nil?\n r = @parser.parse(input, rule)\n assert_nil r, msg\n nil\n rescue Anagram::Parsing::ParseError\n as... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Report/raise a parse error with the given message, printing the current position as well. Appends 'at line X char Y.' to the message you give. If +pos+ is given, it is used as the real position the error happened, correcting the io's current position. | def error(io, str, pos=nil)
pre = io.string[0..(pos||io.pos)]
lines = Array(pre.lines)
if lines.empty?
formatted_cause = str
else
pos = lines.last.length
formatted_cause = "#{str} at line #{lines.count} char #{pos}."
end
@last_cause = formatted_cause
raise Pars... | [
"def error(message, error_pos=nil)\n real_pos = (error_pos||self.pos) \n \n Cause.format(self, real_pos, message)\n end",
"def error(msg)\n raise \"#{msg} :#{@file}:#{@line}\"\n end",
"def parse_error(msg)\n crash \"PARSE\", msg\n end",
"def raise_error(message, line, col = ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true if a password reset has expired. | def password_reset_expired?
reset_sent_at < 2.hours.ago
end | [
"def password_reset_expired?\n reset_sent_at < Settings.timeout_reset_password.hours.ago\n end",
"def password_reset_expired?\n reset_sent_at < 2.hours.ago # The password reset was sent earlier than two hours ago.\n end",
"def password_reset_expired?\n reset_sent_at < PASSWORD_EXPIRATION.hours.ago\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /fnf_items GET /fnf_items.json | def index
@fnf_items = FnfItem.all
end | [
"def index\n @ft_items = FtItem.all\n end",
"def show\n @items = Item.find(params[:id])\n render json: @items\n end",
"def show\n require 'net/http'\n require 'json'\n\n response = Net::HTTP.get_response( URI.parse( \"http://freeshit.firebaseio.com/items/%s.json\" % [ params[:id] ] ) );\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /fnf_items POST /fnf_items.json | def create
@fnf_item = FnfItem.new(fnf_item_params)
respond_to do |format|
if @fnf_item.save
format.html { redirect_to @fnf_item, notice: 'Fnf item was successfully created.' }
format.json { render :show, status: :created, location: @fnf_item }
else
format.html { render :new... | [
"def create\n item = list.items.create!(item_params)\n render json: item, status: 201\n end",
"def create\n json_response(current_restaurant.restaurant_food_items.create!(food_item_params), :created)\n end",
"def create\n @ft_item = FtItem.new(ft_item_params)\n\n respond_to do |format|\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /fnf_items/1 PATCH/PUT /fnf_items/1.json | def update
respond_to do |format|
if @fnf_item.update(fnf_item_params)
format.html { redirect_to @fnf_item, notice: 'Fnf item was successfully updated.' }
format.json { render :show, status: :ok, location: @fnf_item }
else
format.html { render :edit }
format.json { render... | [
"def update_item token, item_id, name, description\n uri = URI.parse \"https://#{get_hostname(token)}/sf/v3/Items(#{item_id})\"\n puts uri\n \n http = Net::HTTP.new uri.host, uri.port\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n \n item = {\"Name\"=>name, \"Description\"=>descripti... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /fnf_items/1 DELETE /fnf_items/1.json | def destroy
@fnf_item.destroy
respond_to do |format|
format.html { redirect_to fnf_items_url, notice: 'Fnf item was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def delete_item(id)\n delete_request configure_payload(\"/items/#{id}\")\n end",
"def delete(items)\n item_ids = items.collect { |item| item.id }\n args = {ids: item_ids.to_json}\n return @client.api_helper.command(args, \"item_delete\")\n end",
"def destroy\n @fb_i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
breakpoint.hit_condition = symbol Sets the hit condition of the breakpoint which must be one of the following values: +nil+ if it is an unconditional breakpoint, or :greater_or_equal(:ge), :equal(:eq), :modulo(:mod) | def hit_condition= symbol
#This is a stub, used for indexing
end | [
"def condition=(expr)\n @condition = expr\n if @condition\n # Convert the breakpoint expression to a valid snippet of Ruby\n eval_str = expr.gsub('#hits', '__hits__')\n # - check if then...end is needed\n if eval_str =~ /^(?:if|unless).+^(?:end)$/\n eval_str << \" then true end\"\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
breakpoint.hit_count > int Returns the hit count of the breakpoint. | def hit_count()
#This is a stub, used for indexing
end | [
"def hit_count\n self[:hit_count] && self[:hit_count].to_i\n end",
"def hit_count=(hits)\n hits = hits.to_i\n return self[:hit_count] if hits < self[:hit_count]\n self[:hit_count] = (hits >= 0 ? hits : 0)\n end",
"def count\n hits.count\n end",
"def get_hits(handle)\n raise \"Must be impl... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
breakpoint.hit_value > int Returns the hit value of the breakpoint. | def hit_value()
#This is a stub, used for indexing
end | [
"def hit_value= int\n #This is a stub, used for indexing\n end",
"def hit_count\n self[:hit_count] && self[:hit_count].to_i\n end",
"def set_attack_hit_value(attacker)\n atk_hit = Damage_Algorithm_Type > 1 ? attacker.agi : attacker.dex\n eva = 8 * self.agi / atk_hit + self.eva\n h... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
breakpoint.hit_value = int Sets the hit value of the breakpoint. | def hit_value= int
#This is a stub, used for indexing
end | [
"def hit(hit_value)\r\n case hit_value\r\n when 1\r\n @bases.unshift(1)\r\n reset()\r\n when 2\r\n @bases.unshift(0,1)\r\n reset()\r\n when 3\r\n @bases.unshift(0,0,1)\r\n reset()\r\n when 4\r\n @bases.un... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
context.step(steps, force = false) Stops the current context after a number of +steps+ are made. +force+ parameter (if true) ensures that the cursor moves from the current line. | def step(steps, force = false)
#This is a stub, used for indexing
end | [
"def step_over(steps, frame = nil, force = false)\n #This is a stub, used for indexing\n end",
"def step(steps)\r\n\tdirection = (steps > 0) ? :brighten : :dim\r\n\tnsteps = steps.abs\r\n\twhile nsteps > 0\r\n\t n = (nsteps > 6) ? 6 : nsteps\r\n\t @controller.command(@house, @unit, direction, ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
context.step_over(steps, frame = nil, force = false) Steps over a +steps+ number of times. Make step over operation on +frame+, by default the current frame. +force+ parameter (if true) ensures that the cursor moves from the current line. | def step_over(steps, frame = nil, force = false)
#This is a stub, used for indexing
end | [
"def step_over(lines, frame = 0)\n #This is a stub, used for indexing\n end",
"def step_into(steps, frame = 0)\n #This is a stub, used for indexing\n end",
"def step(symbol = :over)\n raise RuntimeError, \"can only step top frame\" unless @index === 1\n case... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
context.thnum > int Returns the context's number. | def thnum()
#This is a stub, used for indexing
end | [
"def i_num\n return @i_num\n end",
"def context_for_variable_named(name)\n # Current temporary context?\n # (Shouldn't attempt to access contexts higher in the callstack)\n if current_element.temporary_variables.has_key?(name... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
context.stop_reason > sym Returns the reason for the stop. It maybe of the following values: :initial, :step, :breakpoint, :catchpoint, :postmortem | def stop_reason()
#This is a stub, used for indexing
end | [
"def stop_reason=(value)\n @stop_reason = value\n end",
"def stop_symbol\n STOP\n end",
"def stop_test(should_stop, str)\n return unless should_stop\n str ||= \"Test stopped for unknown reason\"\n abort str.color(:red).bright\nend",
"def stop(event, reason=\"\", bag={})\n step_errors << re... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
context.suspended? > bool Returns +true+ if the thread is suspended by debugger. | def suspended?()
#This is a stub, used for indexing
end | [
"def suspended?\n status.suspended?\n end",
"def is_suspended?\n current_teacher && current_teacher.suspended == true\n end",
"def async_suspended?\n synchronize do\n async_state == :suspended\n end\n end",
"def suspended\n return @suspended\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
context.tracing = bool Controls the tracing for this context. | def tracing= bool
#This is a stub, used for indexing
end | [
"def tracing_enabled?\n state.tracing_enabled?\n end",
"def tracing?\n # The non-nil value of this instance variable\n # indicates if we are currently tracing\n # in this thread or not.\n self.current_trace ? true : false\n end",
"def toggle_tracing!\n enabled? ? disabl... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
context.frame_args(frame_position=0) > list Returns frame's argument parameters | def frame_args(frame_position=0)
#This is a stub, used for indexing
end | [
"def frame_args_info(frame_position=0)\n #This is a stub, used for indexing\n end",
"def frame_locals(frame)\n #This is a stub, used for indexing\n end",
"def args\n @function.args\n end",
"def arguments\n return @arguments\n end",
"d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
context.frame_args_info(frame_position=0) > list if track_frame_args or nil otherwise Returns info saved about call arguments (if any saved). | def frame_args_info(frame_position=0)
#This is a stub, used for indexing
end | [
"def frame_args(frame_position=0)\n #This is a stub, used for indexing\n end",
"def frame_locals(frame)\n #This is a stub, used for indexing\n end",
"def track_args(args)\n case args\n when Hash\n timestamp, identity, values = args.values_at(:timestamp, :iden... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
context.frame_binding(frame_position=0) > binding Returns frame's binding. | def frame_binding(frame_position=0)
#This is a stub, used for indexing
end | [
"def frame_binding(frame_position = 0)\n #This is a stub, used for indexing\n end",
"def get_binding\n return binding\n end",
"def get_binding\n return binding\n end",
"def current_binding\n binding_stack.last\n end",
"def getBinding\r\n\t\treturn binding()\r\n\tend... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
context.frame_class(frame_position) > obj Returns the real class of the frame. It could be different than context.frame_self(frame).class | def frame_class(frame_position)
#This is a stub, used for indexing
end | [
"def frame_class(frame_position = 0)\n #This is a stub, used for indexing\n end",
"def frame_type\n if compiled_code.for_module_body?\n :class\n elsif compiled_code.for_eval?\n :eval\n elsif compiled_code.is_block?\n :block\n else\n :method\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
context.frame_file(frame_position) > string Returns the name of the file. | def frame_file(frame_position)
#This is a stub, used for indexing
end | [
"def frame_filename(frame)\n frame_exists?(frame) ? @frame_filename[frame] : nil\n end",
"def frame_file(frame_position = 0)\n #This is a stub, used for indexing\n end",
"def file_name\n return @file_name\n end",
"def name() @filename end",
"def file_name\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
context.frame_line(frame_position) > int Returns the line number in the file. | def frame_line(frame_position)
#This is a stub, used for indexing
end | [
"def frame_line(frame_position = 0)\n #This is a stub, used for indexing\n end",
"def line_number\n @current_line\n end",
"def file_position\n @line_count\n end",
"def line_number\n return unless backtrace and backtrace[0]\n\n backtrace[0].split(\":\")[1].to_i\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
context.frame_locals(frame) > hash Returns frame's local variables. | def frame_locals(frame)
#This is a stub, used for indexing
end | [
"def thread_variables\n _locals.keys\n end",
"def locals; end",
"def __locals__\n\t\t\treturn @locals\n\t\tend",
"def local_variables()\n eval( 'local_variables', self )\n end",
"def globals\n @context.globals\n end",
"def attributes\n\t\treturn self.scope.__locals__\n\tend",
"def ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
context.frame_self(frame_postion=0) > obj Returns self object of the frame. | def frame_self(frame_postion=0)
#This is a stub, used for indexing
end | [
"def frame_self(frame_postion = 0)\n #This is a stub, used for indexing\n end",
"def current_frame\n @current_frame\n end",
"def current_frame\n @callstack.top\n end",
"def framing\n previous, klass.current_frame = klass.current_frame, self unless @delegate_to_klass\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
context.breakpoint > breakpoint Returns a contextspecific temporary Breakpoint object. | def breakpoint()
#This is a stub, used for indexing
end | [
"def breakpoint?\n type == :breakpoint\n end",
"def break(breakpoint)\n if ::Thread.current[:breakpoints] &&\n ::Thread.current[:breakpoints].include?(breakpoint)\n ::Thread.current[:breakpoints_reached] << breakpoint\n puts \"breaking on #{breakpoint}\"\n self.m... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
context.set_breakpoint(source, pos, condition = nil) > breakpoint Sets a contextspecific temporary breakpoint, which can be used to implement 'Run to Cursor' debugger function. When this breakpoint is reached, it will be cleared out. source is a name of a file or a class. pos is a line number or a method name if source... | def set_breakpoint(source, pos, condition = nil)
#This is a stub, used for indexing
end | [
"def set_breakpoint(location:, condition: nil)\n {\n method: \"Debugger.setBreakpoint\",\n params: { location: location, condition: condition }.compact\n }\n end",
"def set_breakpoint(ip, obj)\n Rubinius.primitive :compiledmethod_set_breakpoint\n raise ArgumentError,... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
context.jump(line, file) > bool Returns +true+ if jump to +line+ in filename +file+ was successful. | def jump(line, file)
#This is a stub, used for indexing
end | [
"def jump?; @is_jump end",
"def jump_statement\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 66)\n jump_statement_start_index = @input.index\n\n success = false # flag used for memoization\n\n begin\n # rule memoization\n if @state.b... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /oeuvres POST /oeuvres.json | def create
@oeuvre = Oeuvre.new(oeuvre_params)
respond_to do |format|
if @oeuvre.save
format.html { redirect_to oeuvres_url, notice: 'Oeuvre was successfully created.' }
format.json { render :show, status: :created, location: @oeuvre }
else
format.html { render :new }
... | [
"def create\n @oeuvre = Oeuvre.new(oeuvre_params)\n\n respond_to do |format|\n if @oeuvre.save\n format.html { redirect_to @oeuvre, notice: \"Oeuvre was successfully created.\" }\n format.json { render :show, status: :created, location: @oeuvre }\n else\n format.html { render :n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /oeuvres/1 PATCH/PUT /oeuvres/1.json | def update
respond_to do |format|
if @oeuvre.update(oeuvre_params)
format.html { redirect_to oeuvres_url, notice: 'Oeuvre was successfully updated.' }
format.json { render :show, status: :ok, location: @oeuvre }
else
format.html { render :edit }
format.json { render json:... | [
"def rest_edit(path, options={}, &blk)\n callback = Proc.new { |*args|\n @object = yield(*args) or pass\n rest_params.each { |k, v| @object.send :\"#{k}=\", v unless k == 'id' }\n\n return 400, @object.errors.to_json unless @object.valid?\n\n @object.save\n rest_respond @object\n }\... | {
"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.